Notification updates
This commit is contained in:
@@ -7,18 +7,19 @@ export class DocumentsService {
|
||||
private readonly repo = new DocumentsRepository(pool);
|
||||
|
||||
async createDocument(userId: string, body: CreateDocumentBody): Promise<DocumentRecord> {
|
||||
await this.assertVehicleOwnership(userId, body.vehicle_id);
|
||||
await this.assertVehicleOwnership(userId, body.vehicleId);
|
||||
const id = randomUUID();
|
||||
return this.repo.insert({
|
||||
id,
|
||||
user_id: userId,
|
||||
vehicle_id: body.vehicle_id,
|
||||
document_type: body.document_type as DocumentType,
|
||||
userId,
|
||||
vehicleId: body.vehicleId,
|
||||
documentType: body.documentType as DocumentType,
|
||||
title: body.title,
|
||||
notes: body.notes ?? null,
|
||||
details: body.details ?? null,
|
||||
issued_date: body.issued_date ?? null,
|
||||
expiration_date: body.expiration_date ?? null,
|
||||
issuedDate: body.issuedDate ?? null,
|
||||
expirationDate: body.expirationDate ?? null,
|
||||
emailNotifications: body.emailNotifications ?? false,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -3,35 +3,39 @@ import { z } from 'zod';
|
||||
export const DocumentTypeSchema = z.enum(['insurance', 'registration']);
|
||||
export type DocumentType = z.infer<typeof DocumentTypeSchema>;
|
||||
|
||||
// API response type (camelCase for frontend)
|
||||
export interface DocumentRecord {
|
||||
id: string;
|
||||
user_id: string;
|
||||
vehicle_id: string;
|
||||
document_type: DocumentType;
|
||||
userId: string;
|
||||
vehicleId: string;
|
||||
documentType: DocumentType;
|
||||
title: string;
|
||||
notes?: string | null;
|
||||
details?: Record<string, any> | null;
|
||||
storage_bucket?: string | null;
|
||||
storage_key?: string | null;
|
||||
file_name?: string | null;
|
||||
content_type?: string | null;
|
||||
file_size?: number | null;
|
||||
file_hash?: string | null;
|
||||
issued_date?: string | null;
|
||||
expiration_date?: string | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
deleted_at?: string | null;
|
||||
storageBucket?: string | null;
|
||||
storageKey?: string | null;
|
||||
fileName?: string | null;
|
||||
contentType?: string | null;
|
||||
fileSize?: number | null;
|
||||
fileHash?: string | null;
|
||||
issuedDate?: string | null;
|
||||
expirationDate?: string | null;
|
||||
emailNotifications?: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
deletedAt?: string | null;
|
||||
}
|
||||
|
||||
// API request schemas (camelCase for frontend)
|
||||
export const CreateDocumentBodySchema = z.object({
|
||||
vehicle_id: z.string().uuid(),
|
||||
document_type: DocumentTypeSchema,
|
||||
vehicleId: z.string().uuid(),
|
||||
documentType: DocumentTypeSchema,
|
||||
title: z.string().min(1).max(200),
|
||||
notes: z.string().max(10000).optional(),
|
||||
details: z.record(z.any()).optional(),
|
||||
issued_date: z.string().optional(),
|
||||
expiration_date: z.string().optional(),
|
||||
issuedDate: z.string().optional(),
|
||||
expirationDate: z.string().optional(),
|
||||
emailNotifications: z.boolean().optional(),
|
||||
});
|
||||
export type CreateDocumentBody = z.infer<typeof CreateDocumentBodySchema>;
|
||||
|
||||
@@ -39,8 +43,9 @@ export const UpdateDocumentBodySchema = z.object({
|
||||
title: z.string().min(1).max(200).optional(),
|
||||
notes: z.string().max(10000).nullable().optional(),
|
||||
details: z.record(z.any()).optional(),
|
||||
issued_date: z.string().nullable().optional(),
|
||||
expiration_date: z.string().nullable().optional(),
|
||||
issuedDate: z.string().nullable().optional(),
|
||||
expirationDate: z.string().nullable().optional(),
|
||||
emailNotifications: z.boolean().optional(),
|
||||
});
|
||||
export type UpdateDocumentBody = z.infer<typeof UpdateDocumentBodySchema>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user