feat(09-01): add quote validators and service layer for Phase 9 quote builder
- Updated quotes table schema: added accepted_total, state, client_email, client_notes fields - Updated quote_items relations: changed service_id FK to unified services table - Created quote-validators.ts: Zod schemas for quote creation, acceptance, and step validation - Created quote-service.ts: public query layer (excludes line items) and admin queries - Added Phase 9 migration: additive columns for quotes state machine and client capture - Maintained backward compatibility: legacy quote_items tied to projects remain functional - TypeScript builds successfully with no errors Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { z } from "zod";
|
||||
|
||||
// Quote creation (admin builder)
|
||||
export const createQuoteSchema = z.object({
|
||||
client_id: z.string().min(1, "Cliente richiesto"),
|
||||
offer_micro_id: z.string().min(1, "Offerta richiesta"),
|
||||
accepted_total: z.string().regex(/^\d+(\.\d{1,2})?$/, "Formato prezzo invalido"),
|
||||
});
|
||||
|
||||
// Quote accept (public page, Step 3)
|
||||
export const acceptQuoteSchema = z.object({
|
||||
token: z.string().length(21, "Token invalido"),
|
||||
email: z.string().email("Email valida").optional().or(z.literal("")),
|
||||
notes: z.string().max(500, "Max 500 caratteri").optional().or(z.literal("")),
|
||||
});
|
||||
|
||||
// Quote step validation (public page Steps 1-2)
|
||||
export const quoteStep2Schema = z.object({
|
||||
tier: z.enum(["A", "B", "C"]).optional(),
|
||||
priceOverrides: z.record(z.string(), z.number().min(0)).optional(),
|
||||
});
|
||||
|
||||
export type CreateQuoteInput = z.infer<typeof createQuoteSchema>;
|
||||
export type AcceptQuoteInput = z.infer<typeof acceptQuoteSchema>;
|
||||
export type QuoteStep2Input = z.infer<typeof quoteStep2Schema>;
|
||||
Reference in New Issue
Block a user