import { defineField, defineType } from "sanity"; import { Inbox } from "lucide-react"; export default defineType({ name: "inquiry", title: "Client Inquiries / Leads", type: "document", icon: Inbox, readOnly: false, fields: [ defineField({ name: "status", title: "Lead Status", type: "string", initialValue: "new", options: { list: [ { title: "🟡 New (Chưa liên hệ)", value: "new" }, { title: "🔵 Contacted (Đã phản hồi)", value: "contacted" }, { title: "🟢 Booked (Đã chốt lịch tư vấn)", value: "booked" }, { title: "⚪ Archived (Lưu trữ)", value: "archived" }, ], layout: "radio", }, }), defineField({ name: "coupleNames", title: "Couple's Names", type: "string", validation: (Rule) => Rule.required(), }), defineField({ name: "email", title: "Email Address", type: "string", validation: (Rule) => Rule.required().email(), }), defineField({ name: "whatsapp", title: "WhatsApp / Phone", type: "string", }), defineField({ name: "weddingDate", title: "Target Wedding Date / Season", type: "string", }), defineField({ name: "destinationRegion", title: "Destination / Region of Interest", type: "string", }), defineField({ name: "guestCount", title: "Expected Guest Count", type: "string", }), defineField({ name: "budgetRange", title: "Budget Range (USD)", type: "string", }), defineField({ name: "serviceTrack", title: "Service of Interest", type: "string", }), defineField({ name: "message", title: "Message / Key Challenges", type: "text", rows: 4, }), defineField({ name: "internalNotes", title: "Internal Advisory Notes (Private)", type: "text", description: "Ghi chú nội bộ của Nhi Võ về tiến trình trao đổi với cặp đôi.", rows: 3, }), defineField({ name: "submittedAt", title: "Submitted At", type: "datetime", initialValue: () => new Date().toISOString(), }), ], orderings: [ { title: "Submission Date, Newest", name: "submittedAtDesc", by: [{ field: "submittedAt", direction: "desc" }], }, ], preview: { select: { title: "coupleNames", status: "status", date: "weddingDate", region: "destinationRegion", budget: "budgetRange", }, prepare({ title, status, date, region, budget }) { const statusIcons: Record = { new: "🟡 NEW", contacted: "🔵 CONTACTED", booked: "🟢 BOOKED", archived: "⚪ ARCHIVED", }; const label = statusIcons[status || "new"] || "🟡 NEW"; const subtitle = [region, budget, date].filter(Boolean).join(" • "); return { title: `${title || "Anonymous"} [${label}]`, subtitle: subtitle || "No details provided", }; }, }, });