Add Notes model, controller and database table. Implement it in Customer Dialog, #6
This commit is contained in:
Vendored
+28
-1
@@ -104,6 +104,32 @@ export function newContact(): Contact {
|
||||
}
|
||||
}
|
||||
|
||||
export interface Notable {
|
||||
id: number;
|
||||
notes?: Note[];
|
||||
}
|
||||
|
||||
export interface Note<T extends Notable = Notable> {
|
||||
id: number;
|
||||
user: User;
|
||||
text: string;
|
||||
notable_id: number;
|
||||
notable_type: string;
|
||||
notable?: T;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export function newNote<T extends Notable>(user: User, notable: T): Note<T> {
|
||||
return {
|
||||
id: 0,
|
||||
user: user,
|
||||
text: '',
|
||||
notable_id: notable.id,
|
||||
notable_type: notable.constructor.name,
|
||||
notable: notable
|
||||
};
|
||||
}
|
||||
|
||||
export interface Customer {
|
||||
id: number;
|
||||
type: string;
|
||||
@@ -118,7 +144,7 @@ export interface Customer {
|
||||
paymentTerms: PaymentTerms;
|
||||
status: string;
|
||||
avatar?: string | null;
|
||||
notes?: string;
|
||||
notes?: Note<Customer>[];
|
||||
logo: string | null;
|
||||
}
|
||||
|
||||
@@ -134,6 +160,7 @@ export function newCustomer(): Customer {
|
||||
billingAddress: newAddress(),
|
||||
paymentTerms: newPaymentTerms(),
|
||||
status: 'active',
|
||||
notes: [],
|
||||
logo: null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user