mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-23 14:55:44 +00:00
refactor(FE-438): Extract uniformity status and weight helpers
This commit is contained in:
@@ -24,36 +24,11 @@ import UniformityTableSkeleton from './skeleton/UniformityTableSkeleton';
|
|||||||
import RequirePermission from '@/components/helper/RequirePermission';
|
import RequirePermission from '@/components/helper/RequirePermission';
|
||||||
import { useUniformityStore } from '@/stores/uniformity/uniformity.store';
|
import { useUniformityStore } from '@/stores/uniformity/uniformity.store';
|
||||||
import FloatingActionsButton from '@/components/FloatingActionsButton';
|
import FloatingActionsButton from '@/components/FloatingActionsButton';
|
||||||
|
import {
|
||||||
const statusColorMap: Record<string, string> = {
|
getStatusColor,
|
||||||
APPROVED: 'bg-[#00D39033]',
|
getStatusIndicatorColor,
|
||||||
REJECTED: 'bg-error/10',
|
getStatusText,
|
||||||
CREATED: 'bg-[#f3f3f4]',
|
} from '@/components/pages/uniformity/uniformity-utils';
|
||||||
};
|
|
||||||
|
|
||||||
const statusIndicatorColorMap: Record<string, string> = {
|
|
||||||
APPROVED: 'bg-[#008000]',
|
|
||||||
REJECTED: 'bg-error',
|
|
||||||
CREATED: 'bg-[#D9D9D9]',
|
|
||||||
};
|
|
||||||
|
|
||||||
const statusTextMap: Record<string, string> = {
|
|
||||||
APPROVED: 'Disetujui',
|
|
||||||
REJECTED: 'Ditolak',
|
|
||||||
CREATED: 'Pengajuan',
|
|
||||||
};
|
|
||||||
|
|
||||||
const getStatusColor = (status: string): string => {
|
|
||||||
return statusColorMap[status] || 'bg-info';
|
|
||||||
};
|
|
||||||
|
|
||||||
const getStatusIndicatorColor = (status: string): string => {
|
|
||||||
return statusIndicatorColorMap[status] || 'bg-info';
|
|
||||||
};
|
|
||||||
|
|
||||||
const getStatusText = (status: string): string => {
|
|
||||||
return statusTextMap[status] || status;
|
|
||||||
};
|
|
||||||
|
|
||||||
const isUniformityLocked = (uniformity: Uniformity): boolean => {
|
const isUniformityLocked = (uniformity: Uniformity): boolean => {
|
||||||
return uniformity.status === 'APPROVED' || uniformity.status === 'REJECTED';
|
return uniformity.status === 'APPROVED' || uniformity.status === 'REJECTED';
|
||||||
|
|||||||
@@ -15,36 +15,11 @@ import { UniformityDetail as UniformityDetailType } from '@/types/api/uniformity
|
|||||||
import { formatDate } from '@/lib/helper';
|
import { formatDate } from '@/lib/helper';
|
||||||
import { useUiStore } from '@/stores/ui/ui.store';
|
import { useUiStore } from '@/stores/ui/ui.store';
|
||||||
import UniformityDetailsPreview from './UniformityDetailsPreview';
|
import UniformityDetailsPreview from './UniformityDetailsPreview';
|
||||||
|
import {
|
||||||
const statusColorMap: Record<string, string> = {
|
getStatusColor,
|
||||||
APPROVED: 'bg-[#00D39033]',
|
getStatusIndicatorColor,
|
||||||
REJECTED: 'bg-error/10',
|
getStatusText,
|
||||||
CREATED: 'bg-[#f3f3f4]',
|
} from '@/components/pages/uniformity/uniformity-utils';
|
||||||
};
|
|
||||||
|
|
||||||
const statusIndicatorColorMap: Record<string, string> = {
|
|
||||||
APPROVED: 'bg-[#008000]',
|
|
||||||
REJECTED: 'bg-error',
|
|
||||||
CREATED: 'bg-[#D9D9D9]',
|
|
||||||
};
|
|
||||||
|
|
||||||
const statusTextMap: Record<string, string> = {
|
|
||||||
APPROVED: 'Disetujui',
|
|
||||||
REJECTED: 'Ditolak',
|
|
||||||
CREATED: 'Pengajuan',
|
|
||||||
};
|
|
||||||
|
|
||||||
const getStatusColor = (status: string): string => {
|
|
||||||
return statusColorMap[status] || 'bg-info';
|
|
||||||
};
|
|
||||||
|
|
||||||
const getStatusIndicatorColor = (status: string): string => {
|
|
||||||
return statusIndicatorColorMap[status] || 'bg-info';
|
|
||||||
};
|
|
||||||
|
|
||||||
const getStatusText = (status: string): string => {
|
|
||||||
return statusTextMap[status] || status;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type DetailOptionType = OptionType & {
|
export type DetailOptionType = OptionType & {
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
@@ -15,33 +15,11 @@ import Table from '@/components/Table';
|
|||||||
import Badge from '@/components/Badge';
|
import Badge from '@/components/Badge';
|
||||||
import { formatNumber } from '@/lib/helper';
|
import { formatNumber } from '@/lib/helper';
|
||||||
import { DetailOptionType } from '@/components/pages/uniformity/detail/UniformityDetail';
|
import { DetailOptionType } from '@/components/pages/uniformity/detail/UniformityDetail';
|
||||||
|
import {
|
||||||
const weightStatusColorMap: Record<string, string> = {
|
getWeightStatusColor,
|
||||||
ideal: 'bg-[#00D39033]',
|
getWeightStatusIndicatorColor,
|
||||||
outside: 'bg-error/10',
|
getWeightStatusText,
|
||||||
};
|
} from '@/components/pages/uniformity/uniformity-utils';
|
||||||
|
|
||||||
const weightStatusIndicatorColorMap: Record<string, string> = {
|
|
||||||
ideal: 'bg-[#008000]',
|
|
||||||
outside: 'bg-error',
|
|
||||||
};
|
|
||||||
|
|
||||||
const weightStatusTextMap: Record<string, string> = {
|
|
||||||
ideal: 'Ideal',
|
|
||||||
outside: 'Outside',
|
|
||||||
};
|
|
||||||
|
|
||||||
const getWeightStatusColor = (status: string): string => {
|
|
||||||
return weightStatusColorMap[status] || 'bg-info';
|
|
||||||
};
|
|
||||||
|
|
||||||
const getWeightStatusIndicatorColor = (status: string): string => {
|
|
||||||
return weightStatusIndicatorColorMap[status] || 'bg-info';
|
|
||||||
};
|
|
||||||
|
|
||||||
const getWeightStatusText = (status: string): string => {
|
|
||||||
return weightStatusTextMap[status] || status;
|
|
||||||
};
|
|
||||||
|
|
||||||
type BodyWeightData = {
|
type BodyWeightData = {
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
@@ -16,33 +16,11 @@ import { UniformityApi } from '@/services/api/uniformity';
|
|||||||
import { isResponseError } from '@/lib/api-helper';
|
import { isResponseError } from '@/lib/api-helper';
|
||||||
import Badge from '@/components/Badge';
|
import Badge from '@/components/Badge';
|
||||||
import { formatNumber } from '@/lib/helper';
|
import { formatNumber } from '@/lib/helper';
|
||||||
|
import {
|
||||||
const weightStatusColorMap: Record<string, string> = {
|
getWeightStatusColor,
|
||||||
ideal: 'bg-[#00D39033]',
|
getWeightStatusIndicatorColor,
|
||||||
outside: 'bg-error/10',
|
getWeightStatusText,
|
||||||
};
|
} from '@/components/pages/uniformity/uniformity-utils';
|
||||||
|
|
||||||
const weightStatusIndicatorColorMap: Record<string, string> = {
|
|
||||||
ideal: 'bg-[#008000]',
|
|
||||||
outside: 'bg-error',
|
|
||||||
};
|
|
||||||
|
|
||||||
const weightStatusTextMap: Record<string, string> = {
|
|
||||||
ideal: 'Ideal',
|
|
||||||
outside: 'Outside',
|
|
||||||
};
|
|
||||||
|
|
||||||
const getWeightStatusColor = (status: string): string => {
|
|
||||||
return weightStatusColorMap[status] || 'bg-info';
|
|
||||||
};
|
|
||||||
|
|
||||||
const getWeightStatusIndicatorColor = (status: string): string => {
|
|
||||||
return weightStatusIndicatorColorMap[status] || 'bg-info';
|
|
||||||
};
|
|
||||||
|
|
||||||
const getWeightStatusText = (status: string): string => {
|
|
||||||
return weightStatusTextMap[status] || status;
|
|
||||||
};
|
|
||||||
|
|
||||||
type BodyWeightData = {
|
type BodyWeightData = {
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
export const weightStatusColorMap: Record<string, string> = {
|
||||||
|
ideal: 'bg-[#00D39033]',
|
||||||
|
outside: 'bg-error/10',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const weightStatusIndicatorColorMap: Record<string, string> = {
|
||||||
|
ideal: 'bg-[#008000]',
|
||||||
|
outside: 'bg-error',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const weightStatusTextMap: Record<string, string> = {
|
||||||
|
ideal: 'Ideal',
|
||||||
|
outside: 'Outside',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getWeightStatusColor = (status: string): string => {
|
||||||
|
return weightStatusColorMap[status] || 'bg-info';
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getWeightStatusIndicatorColor = (status: string): string => {
|
||||||
|
return weightStatusIndicatorColorMap[status] || 'bg-info';
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getWeightStatusText = (status: string): string => {
|
||||||
|
return weightStatusTextMap[status] || status;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const statusColorMap: Record<string, string> = {
|
||||||
|
APPROVED: 'bg-[#00D39033]',
|
||||||
|
REJECTED: 'bg-error/10',
|
||||||
|
CREATED: 'bg-[#f3f3f4]',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const statusIndicatorColorMap: Record<string, string> = {
|
||||||
|
APPROVED: 'bg-[#008000]',
|
||||||
|
REJECTED: 'bg-error',
|
||||||
|
CREATED: 'bg-[#D9D9D9]',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const statusTextMap: Record<string, string> = {
|
||||||
|
APPROVED: 'Disetujui',
|
||||||
|
REJECTED: 'Ditolak',
|
||||||
|
CREATED: 'Pengajuan',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getStatusColor = (status: string): string => {
|
||||||
|
return statusColorMap[status] || 'bg-info';
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getStatusIndicatorColor = (status: string): string => {
|
||||||
|
return statusIndicatorColorMap[status] || 'bg-info';
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getStatusText = (status: string): string => {
|
||||||
|
return statusTextMap[status] || status;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user