feat(berths): ship Waiting List + Maintenance Log tabs
Both berth-detail surfaces were stubbed/hidden behind a comment in berth-tabs.tsx. Their backing schema already existed; this wires the UI and fills the service gaps. Maintenance Log (was ~60% built: schema/migration/add+get service/route): - new edit + delete: updateMaintenanceLog / deleteMaintenanceLog service (port-scoped tenant guard), PATCH/DELETE at maintenance/[logId], plus updateMaintenanceLogSchema. add schema now accepts null for cost / responsibleParty so the shared add+edit dialog sends one body shape. - BerthMaintenanceTab: list (newest first) + add/edit dialog + delete confirm, realtime invalidation. New berth:maintenanceUpdated/Removed socket events. Waiting List (un-hide the orphaned manager + next-in-line notify): - getWaitingList now left-joins the client so the queue renders names, not raw ids. - WaitingListManager rewritten: ClientPicker instead of free-text id, client names, manage_waiting_list gating on add/reorder/remove, and a "Next in line" marker on position 1. - notifyWaitlistNextInLine: when a berth transitions to available, surface the #1 client to staff who hold berths.manage_waiting_list (mirrors the interest-based notifyNextInLine; dedupeKey-suppressed). Hooked into updateBerthStatus on any -> available transition. Tests: maintenance add/get/update/delete + cross-port guard; waitlist notify recipient-resolution / payload / empty + no-permission no-ops. Verified end-to-end in the browser (create/render/delete for both). Also adds scripts/dev-reset-admin-pw.ts (reset a synthetic user's password via the better-auth hasher after a dev reseed). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -158,15 +158,35 @@ export type BulkUpdateBerthPricesInput = z.infer<typeof bulkUpdateBerthPricesSch
|
||||
export const addMaintenanceLogSchema = z.object({
|
||||
category: z.enum(['routine', 'repair', 'inspection', 'upgrade']),
|
||||
description: z.string().min(1),
|
||||
cost: z.coerce.number().optional(),
|
||||
// `null` accepted (and treated as "no value") so the shared add/edit dialog
|
||||
// can send a single body shape — an empty optional field maps to null.
|
||||
cost: z.coerce.number().nullable().optional(),
|
||||
costCurrency: z.string().optional(),
|
||||
responsibleParty: z.string().optional(),
|
||||
responsibleParty: z.string().nullable().optional(),
|
||||
performedDate: z.string().min(1, 'Performed date is required'),
|
||||
photoFileIds: z.array(z.string()).optional(),
|
||||
});
|
||||
|
||||
export type AddMaintenanceLogInput = z.infer<typeof addMaintenanceLogSchema>;
|
||||
|
||||
// ─── Update Maintenance Log ───────────────────────────────────────────────────
|
||||
|
||||
// Partial of the add schema — every field optional so the edit dialog can
|
||||
// PATCH just the touched columns. `cost` and `responsibleParty` accept `null`
|
||||
// so the rep can clear a previously-recorded value (an empty edit field maps
|
||||
// to null in the UI, not to 0 / '').
|
||||
export const updateMaintenanceLogSchema = z.object({
|
||||
category: z.enum(['routine', 'repair', 'inspection', 'upgrade']).optional(),
|
||||
description: z.string().min(1).optional(),
|
||||
cost: z.coerce.number().nullable().optional(),
|
||||
costCurrency: z.string().optional(),
|
||||
responsibleParty: z.string().nullable().optional(),
|
||||
performedDate: z.string().min(1).optional(),
|
||||
photoFileIds: z.array(z.string()).optional(),
|
||||
});
|
||||
|
||||
export type UpdateMaintenanceLogInput = z.infer<typeof updateMaintenanceLogSchema>;
|
||||
|
||||
// ─── Update Waiting List ──────────────────────────────────────────────────────
|
||||
|
||||
export const updateWaitingListSchema = z.object({
|
||||
|
||||
Reference in New Issue
Block a user