Added Condo to client types
X-Lovable-Edit-ID: edt-b8e89016-fbc9-442e-9556-6cf454c43d57 Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
@@ -21,7 +21,7 @@ const boardMember = z.object({
|
||||
});
|
||||
|
||||
const schema = z.object({
|
||||
client_type: z.enum(["hoa", "individual", "business"]),
|
||||
client_type: z.enum(["hoa", "condo"]),
|
||||
name: z.string().trim().min(1, "Required").max(200),
|
||||
primary_contact_name: z.string().trim().max(120).optional().or(z.literal("")),
|
||||
primary_contact_email: z.string().trim().email("Invalid email").max(255).optional().or(z.literal("")),
|
||||
@@ -95,6 +95,7 @@ export function ClientFormDialog({
|
||||
}, [open, client, form]);
|
||||
|
||||
const clientType = form.watch("client_type");
|
||||
const isAssociation = clientType === "hoa" || clientType === "condo";
|
||||
const board = form.watch("board_members");
|
||||
|
||||
const addBoardMember = () => {
|
||||
@@ -163,8 +164,7 @@ export function ClientFormDialog({
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
<SelectItem value="hoa">HOA / Association</SelectItem>
|
||||
<SelectItem value="business">Business</SelectItem>
|
||||
<SelectItem value="individual">Individual</SelectItem>
|
||||
<SelectItem value="condo">Condominium</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage />
|
||||
@@ -176,7 +176,7 @@ export function ClientFormDialog({
|
||||
name="name"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>{clientType === "hoa" ? "Association name" : "Name"}</FormLabel>
|
||||
<FormLabel>{isAssociation ? "Association name" : "Name"}</FormLabel>
|
||||
<FormControl><Input {...field} /></FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@@ -184,7 +184,7 @@ export function ClientFormDialog({
|
||||
/>
|
||||
</div>
|
||||
|
||||
{clientType === "hoa" && (
|
||||
{isAssociation && (
|
||||
<div className="grid grid-cols-3 gap-3">
|
||||
<FormField
|
||||
control={form.control}
|
||||
@@ -293,7 +293,7 @@ export function ClientFormDialog({
|
||||
)} />
|
||||
</div>
|
||||
|
||||
{clientType === "hoa" && (
|
||||
{isAssociation && (
|
||||
<div>
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<label className="text-sm font-medium">Board members</label>
|
||||
|
||||
@@ -808,7 +808,7 @@ export type Database = {
|
||||
| "closed_won"
|
||||
| "closed_lost"
|
||||
| "closed"
|
||||
client_type: "hoa" | "individual" | "business"
|
||||
client_type: "hoa" | "individual" | "business" | "condo"
|
||||
invoice_status: "draft" | "sent" | "paid" | "overdue" | "void"
|
||||
}
|
||||
CompositeTypes: {
|
||||
@@ -946,7 +946,7 @@ export const Constants = {
|
||||
"closed_lost",
|
||||
"closed",
|
||||
],
|
||||
client_type: ["hoa", "individual", "business"],
|
||||
client_type: ["hoa", "individual", "business", "condo"],
|
||||
invoice_status: ["draft", "sent", "paid", "overdue", "void"],
|
||||
},
|
||||
},
|
||||
|
||||
@@ -145,7 +145,7 @@ function CaseDetail() {
|
||||
<TabsTrigger value="time"><Clock className="h-3.5 w-3.5 mr-1.5" />Time</TabsTrigger>
|
||||
<TabsTrigger value="expenses"><DollarSign className="h-3.5 w-3.5 mr-1.5" />Expenses</TabsTrigger>
|
||||
<TabsTrigger value="invoices"><Receipt className="h-3.5 w-3.5 mr-1.5" />Invoices</TabsTrigger>
|
||||
{data.client?.client_type === "hoa" && (
|
||||
{(data.client?.client_type === "hoa" || data.client?.client_type === "condo") && (
|
||||
<TabsTrigger value="collections"><Users className="h-3.5 w-3.5 mr-1.5" />Collections</TabsTrigger>
|
||||
)}
|
||||
</TabsList>
|
||||
@@ -155,7 +155,7 @@ function CaseDetail() {
|
||||
<TabsContent value="time"><CaseTimeTab caseRecord={data} /></TabsContent>
|
||||
<TabsContent value="expenses"><CaseExpensesTab caseId={caseId} /></TabsContent>
|
||||
<TabsContent value="invoices"><CaseInvoicesTab caseRecord={data} /></TabsContent>
|
||||
{data.client?.client_type === "hoa" && (
|
||||
{(data.client?.client_type === "hoa" || data.client?.client_type === "condo") && (
|
||||
<TabsContent value="collections"><CaseCollectionsTab caseRecord={data} /></TabsContent>
|
||||
)}
|
||||
</Tabs>
|
||||
|
||||
@@ -81,7 +81,7 @@ function ClientDetail() {
|
||||
}
|
||||
|
||||
const Icon =
|
||||
client.client_type === "hoa" ? Building2 : client.client_type === "business" ? Building : User;
|
||||
client.client_type === "hoa" || client.client_type === "condo" ? Building2 : User;
|
||||
const canEdit = isAdmin || client.created_by === user?.id;
|
||||
|
||||
return (
|
||||
@@ -117,7 +117,7 @@ function ClientDetail() {
|
||||
</div>
|
||||
<dl className="grid grid-cols-2 gap-y-3 gap-x-6 text-sm">
|
||||
<DetailRow label="Type" value={client.client_type} />
|
||||
{client.client_type === "hoa" && (
|
||||
{(client.client_type === "hoa" || client.client_type === "condo") && (
|
||||
<>
|
||||
<DetailRow label="Units" value={client.num_units} />
|
||||
<DetailRow label="Management Co." value={client.management_company} />
|
||||
@@ -153,7 +153,7 @@ function ClientDetail() {
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{client.client_type === "hoa" && client.board_members?.length > 0 && (
|
||||
{(client.client_type === "hoa" || client.client_type === "condo") && client.board_members?.length > 0 && (
|
||||
<Card className="border-border/60">
|
||||
<CardContent className="p-5">
|
||||
<div className="flex items-center gap-2 mb-3">
|
||||
|
||||
@@ -45,7 +45,7 @@ function ClientsList() {
|
||||
);
|
||||
|
||||
const typeIcon = (t: string) =>
|
||||
t === "hoa" ? Building2 : t === "business" ? Building : User;
|
||||
t === "hoa" || t === "condo" ? Building2 : User;
|
||||
|
||||
return (
|
||||
<PageContainer>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TYPE public.client_type ADD VALUE IF NOT EXISTS 'condo';
|
||||
Reference in New Issue
Block a user