mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE): Use Color type for badge color typings
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user