14c880123c
Expo app with dashboard, time clock, invoices, and settings — native tabs, glass UI, theme-aware components, and iOS Live Activities. Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
export type InvoiceStatus = "draft" | "sent" | "paid" | "overdue";
|
|
|
|
export function getInvoiceStatus(invoice: {
|
|
status: string;
|
|
dueDate: Date | string;
|
|
}): InvoiceStatus {
|
|
if (invoice.status === "paid") return "paid";
|
|
if (invoice.status === "draft") return "draft";
|
|
if (new Date(invoice.dueDate) < new Date()) return "overdue";
|
|
return "sent";
|
|
}
|
|
|
|
export const statusLabels: Record<InvoiceStatus, string> = {
|
|
draft: "Draft",
|
|
sent: "Sent",
|
|
paid: "Paid",
|
|
overdue: "Overdue",
|
|
};
|
|
|
|
const lightStatusColors: Record<InvoiceStatus, string> = {
|
|
draft: "#6b7280",
|
|
sent: "#2563eb",
|
|
paid: "#16a34a",
|
|
overdue: "#dc2626",
|
|
};
|
|
|
|
const darkStatusColors: Record<InvoiceStatus, string> = {
|
|
draft: "#A1A1AA",
|
|
sent: "#60A5FA",
|
|
paid: "#4ADE80",
|
|
overdue: "#F87171",
|
|
};
|
|
|
|
/** @deprecated Use `getStatusColor` for theme-aware colors. */
|
|
export const statusColors = lightStatusColors;
|
|
|
|
export function getStatusColor(status: InvoiceStatus, isDark: boolean): string {
|
|
return (isDark ? darkStatusColors : lightStatusColors)[status];
|
|
}
|