@@ -0,0 +1,57 @@
|
||||
import type {
|
||||
ConsultationStatus,
|
||||
ProjectProgram,
|
||||
ProjectSector,
|
||||
UserRole,
|
||||
} from '@/types';
|
||||
|
||||
export const sectorLabels: Record<ProjectSector, string> = {
|
||||
government: 'Pemerintahan',
|
||||
private: 'Swasta',
|
||||
soe: 'BUMN',
|
||||
};
|
||||
|
||||
export const programLabels: Record<ProjectProgram, string> = {
|
||||
'price-monitoring': 'Pemantauan Harga',
|
||||
investment: 'Investasi',
|
||||
erp: 'ERP',
|
||||
};
|
||||
|
||||
export const statusLabels: Record<ConsultationStatus, string> = {
|
||||
new: 'Baru',
|
||||
contacted: 'Dihubungi',
|
||||
closed: 'Selesai',
|
||||
};
|
||||
|
||||
export const statusBadgeClasses: Record<ConsultationStatus, string> = {
|
||||
new: 'bg-primary text-primary-foreground border-transparent',
|
||||
contacted:
|
||||
'border-transparent bg-amber-100 text-amber-800 dark:bg-amber-500/20 dark:text-amber-300',
|
||||
closed: 'border-transparent bg-emerald-100 text-emerald-800 dark:bg-emerald-500/20 dark:text-emerald-300',
|
||||
};
|
||||
|
||||
export const sourceLabels = {
|
||||
home: 'Beranda',
|
||||
services: 'Jasa',
|
||||
contact: 'Kontak',
|
||||
} as const;
|
||||
|
||||
export const roleLabels: Record<UserRole, string> = {
|
||||
admin: 'Admin',
|
||||
editor: 'Editor',
|
||||
};
|
||||
|
||||
/** `{ value, label }` pairs for a select, in declaration order. */
|
||||
export function optionsOf<T extends string>(labels: Record<T, string>) {
|
||||
return (Object.keys(labels) as T[]).map((value) => ({
|
||||
value,
|
||||
label: labels[value],
|
||||
}));
|
||||
}
|
||||
|
||||
export function formatDate(value: string, withTime = false): string {
|
||||
return new Intl.DateTimeFormat('id-ID', {
|
||||
dateStyle: 'medium',
|
||||
...(withTime ? { timeStyle: 'short' } : {}),
|
||||
}).format(new Date(value));
|
||||
}
|
||||
Reference in New Issue
Block a user