mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE): Add utility for PDF badge styles and integrate into
reports
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
export type StatusColor = {
|
||||
bg: string;
|
||||
text: string;
|
||||
border: string;
|
||||
};
|
||||
|
||||
// Due status colors (for debt supplier reports)
|
||||
export const dueStatusColors: Record<string, StatusColor> = {
|
||||
'SUDAH JATUH TEMPO': {
|
||||
bg: '#FEE2E2',
|
||||
text: '#991B1B',
|
||||
border: '#F87171',
|
||||
}, // error/red
|
||||
'BELUM JATUH TEMPO': {
|
||||
bg: '#D1FAE5',
|
||||
text: '#065F46',
|
||||
border: '#34D399',
|
||||
}, // success/green
|
||||
'MENDEKATI JATUH TEMPO': {
|
||||
bg: '#FEF3C7',
|
||||
text: '#92400E',
|
||||
border: '#FBBF24',
|
||||
}, // warning/yellow
|
||||
};
|
||||
|
||||
// Payment status colors (for customer payment & debt supplier reports)
|
||||
export const paymentStatusColors: Record<string, StatusColor> = {
|
||||
'BELUM LUNAS': {
|
||||
bg: '#FEF3C7',
|
||||
text: '#92400E',
|
||||
border: '#FBBF24',
|
||||
}, // warning/yellow
|
||||
LUNAS: {
|
||||
bg: '#DBEAFE',
|
||||
text: '#1E40AF',
|
||||
border: '#60A5FA',
|
||||
}, // primary/blue
|
||||
'PEMBAYARAN SEBAGIAN': { bg: '#D1FAE5', text: '#065F46', border: '#34D399' }, // success/green
|
||||
PEMBAYARAN: {
|
||||
bg: '#D1FAE5',
|
||||
text: '#065F46',
|
||||
border: '#34D399',
|
||||
}, // success/green
|
||||
};
|
||||
|
||||
// Fallback color for unknown statuses
|
||||
export const fallbackStatusColor: StatusColor = {
|
||||
bg: '#F3F4F6',
|
||||
text: '#374151',
|
||||
border: '#D1D5DB',
|
||||
}; // neutral
|
||||
|
||||
export const getPDFBadgeStyle = (
|
||||
statusText: string,
|
||||
type: 'due' | 'payment' = 'payment'
|
||||
): StatusColor => {
|
||||
const normalizedStatus = statusText.toUpperCase().trim();
|
||||
|
||||
const colors =
|
||||
type === 'due'
|
||||
? dueStatusColors[normalizedStatus]
|
||||
: paymentStatusColors[normalizedStatus];
|
||||
|
||||
return colors || fallbackStatusColor;
|
||||
};
|
||||
Reference in New Issue
Block a user