- Added roles property to Employee type and a new column for displaying employee roles in the employee table. - Updated leave request columns to use formatted start and end dates instead of raw date strings. - Enhanced leave request index to accept filter options for status dynamically. - Refactored transaction index to support dynamic filter options for status, channel, and payment type. - Introduced AGENTS.md for session notes detailing model relationships, casting, scopes, reorganizations, and conventions.
38 lines
963 B
TypeScript
38 lines
963 B
TypeScript
export function formatNumber(
|
|
num: number,
|
|
options?: Intl.NumberFormatOptions,
|
|
): string {
|
|
return new Intl.NumberFormat('id-ID', options).format(num);
|
|
}
|
|
|
|
export type DateFormatStyle = 'full' | 'short' | 'datetime';
|
|
|
|
export function formatDate(dateString: string, style: DateFormatStyle = 'full'): string {
|
|
const date = new Date(dateString);
|
|
|
|
const datePart = date.toLocaleDateString('id-ID', {
|
|
day: '2-digit',
|
|
month: style === 'short' ? 'short' : 'long',
|
|
year: 'numeric',
|
|
});
|
|
|
|
if (style === 'short') {
|
|
return datePart;
|
|
}
|
|
|
|
const timePart = date.toLocaleTimeString('id-ID', {
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
});
|
|
|
|
return `${datePart} ${timePart}`;
|
|
}
|
|
|
|
export function formatShortDate(dateString: string): string {
|
|
return formatDate(dateString, 'short');
|
|
}
|
|
|
|
export function formatDateTime(dateString: string): string {
|
|
return formatDate(dateString, 'datetime');
|
|
}
|