mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE-316): Support localized uniformity statuses and fields
This commit is contained in:
@@ -46,7 +46,12 @@ import Menu from '@/components/menu/Menu';
|
||||
import MenuItem from '@/components/menu/MenuItem';
|
||||
|
||||
const isUniformityLocked = (uniformity: Uniformity): boolean => {
|
||||
return uniformity.status === 'APPROVED' || uniformity.status === 'REJECTED';
|
||||
return (
|
||||
uniformity.status === 'Disetujui' ||
|
||||
uniformity.status === 'Ditolak' ||
|
||||
uniformity.status === 'APPROVED' ||
|
||||
uniformity.status === 'REJECTED'
|
||||
);
|
||||
};
|
||||
|
||||
interface UniformityPreviewData {
|
||||
@@ -407,7 +412,9 @@ const UniformityTable = ({ refresh }: { refresh?: () => void }) => {
|
||||
const canApproveReject = useMemo(() => {
|
||||
return (
|
||||
selectedUniformities.length > 0 &&
|
||||
selectedUniformities.every((u) => u.status === 'CREATED')
|
||||
selectedUniformities.every(
|
||||
(u) => u.status === 'CREATED' || u.status === 'Pengajuan'
|
||||
)
|
||||
);
|
||||
}, [selectedUniformities]);
|
||||
|
||||
@@ -737,7 +744,7 @@ const UniformityTable = ({ refresh }: { refresh?: () => void }) => {
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: 'location.name',
|
||||
accessorKey: 'location_name',
|
||||
header: 'Lokasi',
|
||||
cell: (props) => props.row.original.location_name || '-',
|
||||
},
|
||||
|
||||
@@ -88,33 +88,18 @@ export type UniformityFormData = {
|
||||
};
|
||||
|
||||
export const getUniformityFormInitialValues = (
|
||||
initialValues?: Uniformity
|
||||
initialValues?: Partial<Uniformity>
|
||||
): UniformityFormValues => {
|
||||
return {
|
||||
date: initialValues?.week ? '' : '',
|
||||
week: initialValues?.week ?? 0,
|
||||
location: initialValues?.location
|
||||
? {
|
||||
value: initialValues.location.id,
|
||||
label: initialValues.location.name,
|
||||
}
|
||||
: null,
|
||||
location_id: initialValues?.location?.id ?? 0,
|
||||
project_flock: initialValues?.project_flock
|
||||
? {
|
||||
value: initialValues.project_flock.id,
|
||||
label: initialValues.project_flock.flock_name,
|
||||
}
|
||||
: null,
|
||||
project_flock_id: initialValues?.project_flock?.id ?? 0,
|
||||
project_flock_kandang_id: initialValues?.project_flock_kandang_id ?? 0,
|
||||
kandang: initialValues?.kandang
|
||||
? {
|
||||
value: initialValues.kandang.id,
|
||||
label: initialValues.kandang.name,
|
||||
}
|
||||
: null,
|
||||
kandang_id: initialValues?.kandang?.id ?? 0,
|
||||
location: null,
|
||||
location_id: 0,
|
||||
project_flock: null,
|
||||
project_flock_id: 0,
|
||||
project_flock_kandang_id: initialValues?.project_flock_kandang_id ?? null,
|
||||
kandang: null,
|
||||
kandang_id: 0,
|
||||
document: undefined,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -27,20 +27,29 @@ export const getWeightStatusText = (status: string): string => {
|
||||
|
||||
export const statusColorMap: Record<string, string> = {
|
||||
APPROVED: 'bg-[#00D39033]',
|
||||
Disetujui: 'bg-[#00D39033]',
|
||||
REJECTED: 'bg-error/10',
|
||||
Ditolak: 'bg-error/10',
|
||||
CREATED: 'bg-[#f3f3f4]',
|
||||
Pengajuan: 'bg-[#f3f3f4]',
|
||||
};
|
||||
|
||||
export const statusIndicatorColorMap: Record<string, string> = {
|
||||
APPROVED: 'bg-[#008000]',
|
||||
Disetujui: 'bg-[#008000]',
|
||||
REJECTED: 'bg-error',
|
||||
Ditolak: 'bg-error',
|
||||
CREATED: 'bg-[#D9D9D9]',
|
||||
Pengajuan: 'bg-[#D9D9D9]',
|
||||
};
|
||||
|
||||
export const statusTextMap: Record<string, string> = {
|
||||
APPROVED: 'Disetujui',
|
||||
Disetujui: 'Disetujui',
|
||||
REJECTED: 'Ditolak',
|
||||
Ditolak: 'Ditolak',
|
||||
CREATED: 'Pengajuan',
|
||||
Pengajuan: 'Pengajuan',
|
||||
};
|
||||
|
||||
export const getStatusColor = (status: string): string => {
|
||||
|
||||
+3
-4
@@ -8,21 +8,20 @@ import { BaseApproval } from '@/types/api/approval/approval';
|
||||
export type Uniformity = BaseMetadata & {
|
||||
id: number;
|
||||
project_flock_kandang_id: number;
|
||||
location: Location;
|
||||
project_flock: ProjectFlock;
|
||||
location_name: string;
|
||||
flock_name: string;
|
||||
kandang: Kandang;
|
||||
kandang_name: string;
|
||||
applied_at: string;
|
||||
week: number;
|
||||
status: 'CREATED' | 'APPROVED' | 'REJECTED';
|
||||
status: string;
|
||||
uniformity: number;
|
||||
cv: number;
|
||||
chick_qty_of_weight: number;
|
||||
uniform_qty: number;
|
||||
mean_up: number;
|
||||
mean_down: number;
|
||||
standard_mean_weight: number | null;
|
||||
standard_uniformity: number | null;
|
||||
created_at: string;
|
||||
created_by: number;
|
||||
latest_approval?: BaseApproval;
|
||||
|
||||
Reference in New Issue
Block a user