Add Notes model, controller and database table. Implement it in Customer Dialog, #6

This commit is contained in:
2025-11-21 13:23:13 +01:00
parent 739bf81bc9
commit b1a258f36d
11 changed files with 396 additions and 47 deletions
+28 -1
View File
@@ -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
}
}