| export function cx(...classes: Array<string | false | null | undefined>): string { | |
| return classes.filter(Boolean).join(" "); | |
| } | |
| export function formatDateTime(value?: string | null): string { | |
| if (!value) return "-"; | |
| const date = new Date(value); | |
| if (Number.isNaN(date.getTime())) return value; | |
| return date.toLocaleString(undefined, { | |
| month: "short", | |
| day: "numeric", | |
| hour: "2-digit", | |
| minute: "2-digit", | |
| }); | |
| } | |
| export function makeLocalId(prefix = "local"): string { | |
| return `${prefix}-${Date.now()}-${Math.random().toString(16).slice(2)}`; | |
| } | |
| export function uniqueById<T extends { id: string }>(items: T[]): T[] { | |
| const seen = new Set<string>(); | |
| return items.filter((item) => { | |
| if (seen.has(item.id)) return false; | |
| seen.add(item.id); | |
| return true; | |
| }); | |
| } | |
| export function compactQuestions(questions: string[]): string[] { | |
| return questions.map((q) => q.trim()).filter(Boolean); | |
| } | |