Backend: - Extract shared hard-delete authorization utility (#9) - Extract Prisma include constants per entity (#11) - Fix N+1 query pattern in events findAll (#12) - Extract shared date utility functions (#13) - Move vehicle utilization filtering to DB query (#15) - Add ParseBooleanPipe for query params - Add CurrentDriver decorator + ResolveDriverInterceptor (#20) Frontend: - Extract shared form utilities (toDatetimeLocal) and enum labels (#17) - Replace browser confirm() with styled ConfirmModal (#18) - Add centralized query-keys.ts constants (#19) - Clean up unused imports, add useMemo where needed (#19) - Standardize filter button styling across list pages Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
import { type ClassValue, clsx } from 'clsx';
|
|
import { twMerge } from 'tailwind-merge';
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
return twMerge(clsx(inputs));
|
|
}
|
|
|
|
export function formatDate(date: string | Date, timeZone?: string): string {
|
|
const d = typeof date === 'string' ? new Date(date) : date;
|
|
return d.toLocaleDateString('en-US', {
|
|
year: 'numeric',
|
|
month: 'short',
|
|
day: 'numeric',
|
|
...(timeZone && { timeZone }),
|
|
});
|
|
}
|
|
|
|
export function formatDateTime(date: string | Date, timeZone?: string): string {
|
|
const d = typeof date === 'string' ? new Date(date) : date;
|
|
return d.toLocaleString('en-US', {
|
|
year: 'numeric',
|
|
month: 'short',
|
|
day: 'numeric',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
...(timeZone && { timeZone }),
|
|
});
|
|
}
|
|
|
|
export function formatTime(date: string | Date, timeZone?: string): string {
|
|
const d = typeof date === 'string' ? new Date(date) : date;
|
|
return d.toLocaleTimeString('en-US', {
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
...(timeZone && { timeZone }),
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Convert ISO datetime string to datetime-local input format (YYYY-MM-DDTHH:mm)
|
|
* Used for populating datetime-local inputs in forms
|
|
*/
|
|
export function toDatetimeLocal(isoString: string | null | undefined): string {
|
|
if (!isoString) return '';
|
|
const date = new Date(isoString);
|
|
const year = date.getFullYear();
|
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
const day = String(date.getDate()).padStart(2, '0');
|
|
const hours = String(date.getHours()).padStart(2, '0');
|
|
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
return `${year}-${month}-${day}T${hours}:${minutes}`;
|
|
}
|