feat(reservations): detail page with agreement flow + contract mirror
Adds /berth-reservations/[id] with state-aware agreement card (none / in-flight / completed) and the Generate-agreement entry point that opens the wizard prefilled. handleDocumentCompleted now mirrors a signed reservation_agreement onto berth_reservations.contractFileId so the portal can resolve contracts without joining through documents. Reservation merge tokens (startDate/endDate/tenureType/termSummary/ signedDate) added to the catalog. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -725,6 +725,17 @@ export async function handleDocumentCompleted(eventData: { documentId: string })
|
||||
.update(documents)
|
||||
.set({ status: 'completed', signedFileId: fileRecord!.id, updatedAt: new Date() })
|
||||
.where(eq(documents.id, doc.id));
|
||||
|
||||
// Reservation agreements mirror their signed PDF onto
|
||||
// berth_reservations.contractFileId so the portal "My Reservations" view
|
||||
// can resolve the contract without joining through documents.
|
||||
if (doc.documentType === 'reservation_agreement' && doc.reservationId) {
|
||||
const { berthReservations } = await import('@/lib/db/schema/reservations');
|
||||
await db
|
||||
.update(berthReservations)
|
||||
.set({ contractFileId: fileRecord!.id, updatedAt: new Date() })
|
||||
.where(eq(berthReservations.id, doc.reservationId));
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error({ err, documentId: doc.id }, 'Failed to download/store signed PDF');
|
||||
await db
|
||||
|
||||
Reference in New Issue
Block a user