import * as React from "react"; import { addDays, startOfDay, format } from "date-fns"; import { cn } from "@/lib/utils"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogFooter, } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"; import { DatePicker } from "@/components/ui/date-picker"; /** * Pipeline Dialogs — WealthX DS (L4) * * Small, focused dialogs for Pipeline / Loan CRM actions: * - DeleteOpportunityDialog — confirm card deletion * - ChangePriorityDialog — select priority (Auto / Low / Medium / High) * - PutOnHoldDialog — choose a hold-until date (preset or custom) * * All dialogs are fully controlled (`open` + `onOpenChange`). * The `loading` prop disables actions and prevents accidental close. */ // --------------------------------------------------------------------------- // DeleteOpportunityDialog // --------------------------------------------------------------------------- export interface DeleteOpportunityDialogProps { open: boolean; /** Disables buttons and prevents close while an async op is in-flight. */ loading?: boolean; onOpenChange: (open: boolean) => void; onConfirm: () => void; className?: string; } export function DeleteOpportunityDialog({ open, loading = false, onOpenChange, onConfirm, className, }: DeleteOpportunityDialogProps) { return ( Want to delete this card? Doing so will also remove all associated loan applications and tasks. This action cannot be undone. ); } // --------------------------------------------------------------------------- // ChangePriorityDialog // --------------------------------------------------------------------------- export type PrioritySelection = "auto" | "low" | "medium" | "high"; const PRIORITY_OPTIONS: { value: PrioritySelection; label: string; color: string; }[] = [ { value: "auto", label: "Auto", color: "var(--color-muted-foreground)" }, { value: "low", label: "Low", color: "var(--color-success)" }, { value: "medium", label: "Medium", color: "var(--color-warning)" }, { value: "high", label: "High", color: "var(--color-destructive)" }, ]; export interface ChangePriorityDialogProps { open: boolean; value: PrioritySelection; loading?: boolean; onOpenChange: (open: boolean) => void; onSave: () => void; onSelectionChange: (value: PrioritySelection) => void; className?: string; } export function ChangePriorityDialog({ open, value, loading = false, onOpenChange, onSave, onSelectionChange, className, }: ChangePriorityDialogProps) { return ( Change priority ); } // --------------------------------------------------------------------------- // PutOnHoldDialog // --------------------------------------------------------------------------- export type HoldDuration = "90" | "180" | "360" | "custom"; const HOLD_OPTIONS: { value: HoldDuration; label: string }[] = [ { value: "90", label: "90 Days" }, { value: "180", label: "180 Days" }, { value: "360", label: "360 Days" }, { value: "custom", label: "Custom" }, ]; export interface PutOnHoldDialogProps { open: boolean; loading?: boolean; onOpenChange: (open: boolean) => void; /** Called with an ISO date string (yyyy-MM-dd) when the user saves. */ onSave: (isoDate: string) => void; className?: string; } export function PutOnHoldDialog({ open, loading = false, onOpenChange, onSave, className, }: PutOnHoldDialogProps) { const [duration, setDuration] = React.useState("90"); const [customDate, setCustomDate] = React.useState(); const today = React.useMemo(() => startOfDay(new Date()), []); const resolvedDate = React.useMemo(() => { if (duration === "custom") return customDate; return addDays(today, parseInt(duration, 10)); }, [duration, customDate, today]); const isValid = resolvedDate !== undefined && resolvedDate >= today; function handleSave() { if (!resolvedDate) return; onSave(format(resolvedDate, "yyyy-MM-dd")); } // Reset when dialog opens React.useEffect(() => { if (open) { setDuration("90"); setCustomDate(undefined); } }, [open]); return ( Hold and Hide Until Later Date
{ if (v.length) setDuration(v[0] as HoldDuration); }} className="w-full" > {HOLD_OPTIONS.map((opt) => ( {opt.label} ))} {/* Fixed-height row — same h-9 in all tab states to prevent layout jump */} {duration === "custom" ? ( ) : ( resolvedDate && (
Hold until:{" "} {format(resolvedDate, "dd MMM yyyy")}
) )} {/* For custom: show resolved date below the picker once selected */} {duration === "custom" && customDate && (

Hold until:{" "} {format(customDate, "dd MMM yyyy")}

)}
); }