feat(crm): event-type dropdown on quotes; quote→event uses it (no more hardcoded 'wedding')
Quotes now carry an event type (migration 146: quotes.event_type, the
event_types.slug_prefix), chosen from the active event-types catalog in the
quote editor's Event section. convertToEvent reads it instead of the
unconditional hardcoded 'wedding': quote.event_type → crm_default_event_type
setting → 'wedding' as last-resort seeded fallback. When the booking flow's
prepare_event is wired, it reads the same field.
Backend: createQuote/updateQuote persist event_type (hasColumn-guarded);
adminQuotes route accepts + returns eventType. Frontend: FormState + payload +
load + a catalog-sourced dropdown ("— Use default —"); EN/DE strings.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Migration 146: carry an event type on the quote.
|
||||
*
|
||||
* Quotes already snapshot event_name + event_date, but not the TYPE. Without it
|
||||
* the quote→event conversion (convertToEvent) had to hardcode 'wedding'. This
|
||||
* column lets the admin pick the type on the quote (from the event_types
|
||||
* catalog, stored as its slug_prefix — same shape as events.event_type), so the
|
||||
* conversion / booking flow's prepare_event can carry it through. Nullable: old
|
||||
* quotes and the "didn't pick one" case fall back to a configurable default.
|
||||
*/
|
||||
exports.up = async function (knex) {
|
||||
if (!(await knex.schema.hasTable('quotes'))) return;
|
||||
if (!(await knex.schema.hasColumn('quotes', 'event_type'))) {
|
||||
await knex.schema.alterTable('quotes', (t) => {
|
||||
t.string('event_type', 64);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.down = async function (knex) {
|
||||
if (!(await knex.schema.hasTable('quotes'))) return;
|
||||
if (await knex.schema.hasColumn('quotes', 'event_type')) {
|
||||
await knex.schema.alterTable('quotes', (t) => t.dropColumn('event_type'));
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user