Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-18 02:14:06 +00:00
co-authored by renee-png
parent bcf614baa9
commit 53adf807c9
+39
View File
@@ -26,6 +26,45 @@ export interface HomeownerLite {
opening_balance: number;
}
export interface ContactLite {
id: string;
name: string;
contact_type: string;
company: string | null;
title: string | null;
address_line1: string | null;
address_line2: string | null;
city: string | null;
state: string | null;
postal_code: string | null;
email: string | null;
phone: string | null;
}
export async function fetchContacts(): Promise<ContactLite[]> {
const { data } = await supabase
.from("contacts")
.select(
"id,name,contact_type,company,title,address_line1,address_line2,city,state,postal_code,email,phone",
)
.is("archived_at", null)
.order("name");
return (data ?? []) as ContactLite[];
}
export function contactMailingLines(c: ContactLite | null | undefined): string[] {
if (!c) return [];
const lines: string[] = [];
if (c.name) lines.push(c.name);
if (c.title) lines.push(c.title);
if (c.company) lines.push(c.company);
if (c.address_line1) lines.push(c.address_line1);
if (c.address_line2) lines.push(c.address_line2);
const cityLine = [c.city, c.state, c.postal_code].filter(Boolean).join(", ");
if (cityLine) lines.push(cityLine);
return lines;
}
export async function fetchClients(): Promise<ClientLite[]> {
const { data } = await supabase
.from("clients")