feat(contacts): add contacts page with per-store management and supplier email field

- New contacts table (group_id, name, role, phone, email, notes) per store
- Suppliers table: add email field with form and card display
- Page /contacts: two-column layout (suppliers read-only / free contacts CRUD)
- Permissions: read all roles, create/edit/delete admin + directeur + manager
- Admin can filter contacts by store; other roles see their own stores only
- Migration SQL: 20260515_add_contacts_and_supplier_email.sql

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Sonnet 4.6 committed 2026-05-15 10:44:39 +02:00
1 parent 40cf456a64
commit 805664dc32
8 files changed
+736 -6

No files matched your search

+22
View File
@@ -80,6 +80,7 @@ export const suppliers = pgTable("suppliers", {
name: varchar("name").notNull(),
contact: varchar("contact"),
phone: varchar("phone"),
email: varchar("email"),
hasDlc: boolean("has_dlc").default(false), // Coche DLC pour la gestion DLC
paymentMethod: varchar("payment_method"), // Mode de paiement: Virement, Traite, Traite Magnétique, Chèque
createdAt: timestamp("created_at").defaultNow(),
@@ -88,6 +89,19 @@ export const suppliers = pgTable("suppliers", {
requiresControl: boolean("requires_control").default(false), // Fournisseur nécessite un contrôle à la livraison
});
// Contacts libres (hors fournisseurs), rattachés à un magasin
export const contacts = pgTable("contacts", {
id: serial("id").primaryKey(),
groupId: integer("group_id").notNull(),
name: varchar("name").notNull(),
role: varchar("role"),
phone: varchar("phone"),
email: varchar("email"),
notes: text("notes"),
createdAt: timestamp("created_at").defaultNow(),
updatedAt: timestamp("updated_at").defaultNow(),
});
// Orders
export const orders = pgTable("orders", {
id: serial("id").primaryKey(),
@@ -544,6 +558,12 @@ export const insertSupplierSchema = createInsertSchema(suppliers).omit({
updatedAt: true,
});
export const insertContactSchema = createInsertSchema(contacts).omit({
id: true,
createdAt: true,
updatedAt: true,
});
export const insertOrderSchema = createInsertSchema(orders).omit({
id: true,
createdAt: true,
@@ -706,6 +726,8 @@ export type Group = typeof groups.$inferSelect;
export type InsertGroup = z.infer<typeof insertGroupSchema>;
export type Supplier = typeof suppliers.$inferSelect;
export type InsertSupplier = z.infer<typeof insertSupplierSchema>;
export type Contact = typeof contacts.$inferSelect;
export type InsertContact = z.infer<typeof insertContactSchema>;
export type Order = typeof orders.$inferSelect;
export type InsertOrder = z.infer<typeof insertOrderSchema>;
export type Delivery = typeof deliveries.$inferSelect;