diff --git a/src/components/pages/uniformity/UniformityTable.tsx b/src/components/pages/uniformity/UniformityTable.tsx index d7c8d83a..78611730 100644 --- a/src/components/pages/uniformity/UniformityTable.tsx +++ b/src/components/pages/uniformity/UniformityTable.tsx @@ -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 || '-', }, diff --git a/src/components/pages/uniformity/form/UniformityForm.schema.ts b/src/components/pages/uniformity/form/UniformityForm.schema.ts index 0ff88188..050d2a3e 100644 --- a/src/components/pages/uniformity/form/UniformityForm.schema.ts +++ b/src/components/pages/uniformity/form/UniformityForm.schema.ts @@ -88,33 +88,18 @@ export type UniformityFormData = { }; export const getUniformityFormInitialValues = ( - initialValues?: Uniformity + initialValues?: Partial ): 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, }; }; diff --git a/src/components/pages/uniformity/uniformity-utils.ts b/src/components/pages/uniformity/uniformity-utils.ts index 1c5ee0b5..340bb555 100644 --- a/src/components/pages/uniformity/uniformity-utils.ts +++ b/src/components/pages/uniformity/uniformity-utils.ts @@ -27,20 +27,29 @@ export const getWeightStatusText = (status: string): string => { export const statusColorMap: Record = { APPROVED: 'bg-[#00D39033]', + Disetujui: 'bg-[#00D39033]', REJECTED: 'bg-error/10', + Ditolak: 'bg-error/10', CREATED: 'bg-[#f3f3f4]', + Pengajuan: 'bg-[#f3f3f4]', }; export const statusIndicatorColorMap: Record = { APPROVED: 'bg-[#008000]', + Disetujui: 'bg-[#008000]', REJECTED: 'bg-error', + Ditolak: 'bg-error', CREATED: 'bg-[#D9D9D9]', + Pengajuan: 'bg-[#D9D9D9]', }; export const statusTextMap: Record = { APPROVED: 'Disetujui', + Disetujui: 'Disetujui', REJECTED: 'Ditolak', + Ditolak: 'Ditolak', CREATED: 'Pengajuan', + Pengajuan: 'Pengajuan', }; export const getStatusColor = (status: string): string => { diff --git a/src/types/api/uniformity/uniformity.d.ts b/src/types/api/uniformity/uniformity.d.ts index c63e90ff..4d63f5ef 100644 --- a/src/types/api/uniformity/uniformity.d.ts +++ b/src/types/api/uniformity/uniformity.d.ts @@ -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;