refactor(FE): Use Color type for badge color typings

This commit is contained in:
rstubryan
2026-02-02 11:10:58 +07:00
parent 3ca4b324d3
commit 85556c0db0
2 changed files with 7 additions and 21 deletions
@@ -33,6 +33,7 @@ import Badge from '@/components/Badge';
import StatusBadge from '@/components/helper/StatusBadge';
import CheckboxInput from '@/components/input/CheckboxInput';
import { useUiStore } from '@/stores/ui/ui.store';
import { Color } from '@/types/theme';
// ===== STATUS BADGE UTILITIES =====
const statusTextMap: Record<string, string> = {
@@ -48,10 +49,7 @@ const getStatusText = (status: string): string => {
return statusTextMap[status] || status;
};
const statusBadgeColorMap: Record<
string,
'success' | 'error' | 'neutral' | 'info' | 'warning'
> = {
const statusBadgeColorMap: Record<string, Color> = {
APPROVED: 'success',
Disetujui: 'success',
approved: 'success',
@@ -70,9 +68,7 @@ const statusBadgeColorMap: Record<
diperbarui: 'warning',
};
const getStatusBadgeColor = (
status: string
): 'success' | 'error' | 'neutral' | 'info' | 'warning' => {
const getStatusBadgeColor = (status: string): Color => {
return statusBadgeColorMap[status] || 'neutral';
};
@@ -25,6 +25,7 @@ import { useTableFilter } from '@/services/hooks/useTableFilter';
import { ROWS_OPTIONS } from '@/config/constant';
import { Purchase } from '@/types/api/purchase/purchase';
import { PurchaseApi } from '@/services/api/purchase';
import { Color } from '@/types/theme';
// ===== STATUS BADGE UTILITIES =====
const statusTextMap: Record<string, string> = {
@@ -40,10 +41,7 @@ const getStatusText = (status: string): string => {
return statusTextMap[status] || status;
};
const statusBadgeColorMap: Record<
string,
'success' | 'error' | 'neutral' | 'info' | 'warning' | 'primary'
> = {
const statusBadgeColorMap: Record<string, Color> = {
APPROVED: 'success',
Disetujui: 'success',
approved: 'success',
@@ -62,9 +60,7 @@ const statusBadgeColorMap: Record<
diperbarui: 'warning',
};
const getStatusBadgeColor = (
status: string
): 'success' | 'error' | 'neutral' | 'info' | 'warning' | 'primary' => {
const getStatusBadgeColor = (status: string): Color => {
return statusBadgeColorMap[status] || 'neutral';
};
@@ -204,13 +200,7 @@ const PurchaseTable = () => {
const status = approval.action;
let statusColor:
| 'warning'
| 'success'
| 'neutral'
| 'error'
| 'info'
| 'primary' = 'neutral';
let statusColor: Color = 'neutral';
if (status === 'REJECTED') {
statusColor = getStatusBadgeColor(status);