Adds complete initial codebase for the RJ Bulk Supplies fuel delivery backoffice: - Authentication pages and protected route layouts - Customer, supplier, fuel purchase, and delivery note management - Custom reporting and customer statement sending tools - Full UI component library and Tailwind styling - Server actions, API routes, and PocketBase integration - Development scripts and project configuration updates - Updated README and package metadata
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { clsx, type ClassValue } from "clsx";
|
|
import { twMerge } from "tailwind-merge";
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
return twMerge(clsx(inputs));
|
|
}
|
|
|
|
export function formatCurrency(value: number | null | undefined): string {
|
|
if (value == null) return "R0.00";
|
|
return new Intl.NumberFormat("en-ZA", {
|
|
style: "currency",
|
|
currency: "ZAR",
|
|
minimumFractionDigits: 2,
|
|
}).format(value);
|
|
}
|
|
|
|
export function formatNumber(value: number | null | undefined, decimals = 2): string {
|
|
if (value == null) return "0";
|
|
return new Intl.NumberFormat("en-ZA", {
|
|
minimumFractionDigits: decimals,
|
|
maximumFractionDigits: decimals,
|
|
}).format(value);
|
|
}
|
|
|
|
export function formatDate(value: string | Date | null | undefined): string {
|
|
if (!value) return "";
|
|
const d = typeof value === "string" ? new Date(value) : value;
|
|
if (isNaN(d.getTime())) return "";
|
|
return new Intl.DateTimeFormat("en-ZA", {
|
|
year: "numeric",
|
|
month: "short",
|
|
day: "2-digit",
|
|
}).format(d);
|
|
}
|
|
|
|
export function formatDateInput(value: string | Date | null | undefined): string {
|
|
if (!value) return "";
|
|
const d = typeof value === "string" ? new Date(value) : value;
|
|
if (isNaN(d.getTime())) return "";
|
|
// YYYY-MM-DD for <input type="date">
|
|
const yyyy = d.getFullYear();
|
|
const mm = String(d.getMonth() + 1).padStart(2, "0");
|
|
const dd = String(d.getDate()).padStart(2, "0");
|
|
return `${yyyy}-${mm}-${dd}`;
|
|
}
|