phase-0: scaffold backend and frontend shell
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { format, formatDistanceToNow } from "date-fns";
|
||||
import { toZonedTime } from "date-fns-tz";
|
||||
|
||||
// Kolkata offset: +05:30
|
||||
const KOLKATA_TZ = "Asia/Kolkata";
|
||||
|
||||
export function formatDateTime(isoString: string | null | undefined): string {
|
||||
if (!isoString) return "—";
|
||||
try {
|
||||
const d = toZonedTime(new Date(isoString), KOLKATA_TZ);
|
||||
return format(d, "dd-MMM-yyyy HH:mm");
|
||||
} catch {
|
||||
return "—";
|
||||
}
|
||||
}
|
||||
|
||||
export function formatDate(isoString: string | null | undefined): string {
|
||||
if (!isoString) return "—";
|
||||
try {
|
||||
const d = toZonedTime(new Date(isoString), KOLKATA_TZ);
|
||||
return format(d, "dd-MMM-yyyy");
|
||||
} catch {
|
||||
return "—";
|
||||
}
|
||||
}
|
||||
|
||||
export function formatDuration(minutes: number | null | undefined): string {
|
||||
if (minutes == null) return "—";
|
||||
const d = Math.floor(minutes / 1440);
|
||||
const h = Math.floor((minutes % 1440) / 60);
|
||||
const m = minutes % 60;
|
||||
const parts: string[] = [];
|
||||
if (d) parts.push(`${d}d`);
|
||||
if (h) parts.push(`${h}h`);
|
||||
if (m || !parts.length) parts.push(`${m}m`);
|
||||
return parts.join(" ");
|
||||
}
|
||||
|
||||
export function formatINR(amount: number | null | undefined): string {
|
||||
if (amount == null) return "—";
|
||||
return new Intl.NumberFormat("en-IN", {
|
||||
style: "currency",
|
||||
currency: "INR",
|
||||
maximumFractionDigits: 0,
|
||||
}).format(amount);
|
||||
}
|
||||
|
||||
export function formatRelative(isoString: string | null | undefined): string {
|
||||
if (!isoString) return "—";
|
||||
try {
|
||||
return formatDistanceToNow(new Date(isoString), { addSuffix: true });
|
||||
} catch {
|
||||
return "—";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
export type Role = "system_admin" | "biomedical" | "department_user" | "management" | "coordinator";
|
||||
|
||||
export const ROLE_LABELS: Record<Role, string> = {
|
||||
system_admin: "System Administrator",
|
||||
biomedical: "Biomedical / Maintenance",
|
||||
department_user: "Department User",
|
||||
management: "Management",
|
||||
coordinator: "Coordinator",
|
||||
};
|
||||
|
||||
// Full permission matrix will be added in Phase 1
|
||||
export function can(role: Role | undefined, _capability: string): boolean {
|
||||
if (!role) return false;
|
||||
if (role === "system_admin") return true;
|
||||
return false; // placeholder
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { type ClassValue, clsx } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
Reference in New Issue
Block a user