mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +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 StatusBadge from '@/components/helper/StatusBadge';
|
||||||
import CheckboxInput from '@/components/input/CheckboxInput';
|
import CheckboxInput from '@/components/input/CheckboxInput';
|
||||||
import { useUiStore } from '@/stores/ui/ui.store';
|
import { useUiStore } from '@/stores/ui/ui.store';
|
||||||
|
import { Color } from '@/types/theme';
|
||||||
|
|
||||||
// ===== STATUS BADGE UTILITIES =====
|
// ===== STATUS BADGE UTILITIES =====
|
||||||
const statusTextMap: Record<string, string> = {
|
const statusTextMap: Record<string, string> = {
|
||||||
@@ -48,10 +49,7 @@ const getStatusText = (status: string): string => {
|
|||||||
return statusTextMap[status] || status;
|
return statusTextMap[status] || status;
|
||||||
};
|
};
|
||||||
|
|
||||||
const statusBadgeColorMap: Record<
|
const statusBadgeColorMap: Record<string, Color> = {
|
||||||
string,
|
|
||||||
'success' | 'error' | 'neutral' | 'info' | 'warning'
|
|
||||||
> = {
|
|
||||||
APPROVED: 'success',
|
APPROVED: 'success',
|
||||||
Disetujui: 'success',
|
Disetujui: 'success',
|
||||||
approved: 'success',
|
approved: 'success',
|
||||||
@@ -70,9 +68,7 @@ const statusBadgeColorMap: Record<
|
|||||||
diperbarui: 'warning',
|
diperbarui: 'warning',
|
||||||
};
|
};
|
||||||
|
|
||||||
const getStatusBadgeColor = (
|
const getStatusBadgeColor = (status: string): Color => {
|
||||||
status: string
|
|
||||||
): 'success' | 'error' | 'neutral' | 'info' | 'warning' => {
|
|
||||||
return statusBadgeColorMap[status] || 'neutral';
|
return statusBadgeColorMap[status] || 'neutral';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import { useTableFilter } from '@/services/hooks/useTableFilter';
|
|||||||
import { ROWS_OPTIONS } from '@/config/constant';
|
import { ROWS_OPTIONS } from '@/config/constant';
|
||||||
import { Purchase } from '@/types/api/purchase/purchase';
|
import { Purchase } from '@/types/api/purchase/purchase';
|
||||||
import { PurchaseApi } from '@/services/api/purchase';
|
import { PurchaseApi } from '@/services/api/purchase';
|
||||||
|
import { Color } from '@/types/theme';
|
||||||
|
|
||||||
// ===== STATUS BADGE UTILITIES =====
|
// ===== STATUS BADGE UTILITIES =====
|
||||||
const statusTextMap: Record<string, string> = {
|
const statusTextMap: Record<string, string> = {
|
||||||
@@ -40,10 +41,7 @@ const getStatusText = (status: string): string => {
|
|||||||
return statusTextMap[status] || status;
|
return statusTextMap[status] || status;
|
||||||
};
|
};
|
||||||
|
|
||||||
const statusBadgeColorMap: Record<
|
const statusBadgeColorMap: Record<string, Color> = {
|
||||||
string,
|
|
||||||
'success' | 'error' | 'neutral' | 'info' | 'warning' | 'primary'
|
|
||||||
> = {
|
|
||||||
APPROVED: 'success',
|
APPROVED: 'success',
|
||||||
Disetujui: 'success',
|
Disetujui: 'success',
|
||||||
approved: 'success',
|
approved: 'success',
|
||||||
@@ -62,9 +60,7 @@ const statusBadgeColorMap: Record<
|
|||||||
diperbarui: 'warning',
|
diperbarui: 'warning',
|
||||||
};
|
};
|
||||||
|
|
||||||
const getStatusBadgeColor = (
|
const getStatusBadgeColor = (status: string): Color => {
|
||||||
status: string
|
|
||||||
): 'success' | 'error' | 'neutral' | 'info' | 'warning' | 'primary' => {
|
|
||||||
return statusBadgeColorMap[status] || 'neutral';
|
return statusBadgeColorMap[status] || 'neutral';
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -204,13 +200,7 @@ const PurchaseTable = () => {
|
|||||||
|
|
||||||
const status = approval.action;
|
const status = approval.action;
|
||||||
|
|
||||||
let statusColor:
|
let statusColor: Color = 'neutral';
|
||||||
| 'warning'
|
|
||||||
| 'success'
|
|
||||||
| 'neutral'
|
|
||||||
| 'error'
|
|
||||||
| 'info'
|
|
||||||
| 'primary' = 'neutral';
|
|
||||||
|
|
||||||
if (status === 'REJECTED') {
|
if (status === 'REJECTED') {
|
||||||
statusColor = getStatusBadgeColor(status);
|
statusColor = getStatusBadgeColor(status);
|
||||||
|
|||||||
Reference in New Issue
Block a user