mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE): Remove FCR-related fields and functionality
This commit is contained in:
@@ -363,10 +363,6 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
||||
accessorKey: 'location.name',
|
||||
header: 'Lokasi',
|
||||
},
|
||||
{
|
||||
accessorKey: 'fcr.name',
|
||||
header: 'FCR',
|
||||
},
|
||||
{
|
||||
accessorKey: 'category',
|
||||
header: 'Kategori',
|
||||
|
||||
@@ -16,11 +16,6 @@ type ProjectFlockFormSchemaType = {
|
||||
label: string;
|
||||
} | null;
|
||||
category: string;
|
||||
fcr: {
|
||||
value: number | string;
|
||||
label: string;
|
||||
} | null;
|
||||
fcr_id: number;
|
||||
production_standard: {
|
||||
value: number | string;
|
||||
label: string;
|
||||
@@ -96,15 +91,6 @@ export const ProjectFlockFormSchema: Yup.ObjectSchema<ProjectFlockFormSchemaType
|
||||
.oneOf(['GROWING', 'LAYING'], 'Kategori wajib diisi!')
|
||||
.required('Kategori wajib diisi!'),
|
||||
|
||||
// FCR
|
||||
fcr: Yup.object({
|
||||
value: Yup.number().required('ID FCR wajib diisi!'),
|
||||
label: Yup.string().required('Nama FCR wajib diisi!'),
|
||||
}).nullable(),
|
||||
fcr_id: Yup.number()
|
||||
.min(1, 'FCR wajib diisi!')
|
||||
.required('FCR wajib diisi!'),
|
||||
|
||||
// Production Standard
|
||||
production_standard: Yup.object({
|
||||
value: Yup.number().required('ID Standar Produksi wajib diisi!'),
|
||||
|
||||
@@ -9,7 +9,6 @@ import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||
import AlertErrorList from '@/components/helper/form/FormErrors';
|
||||
import {
|
||||
AreaApi,
|
||||
FcrApi,
|
||||
FlockApi,
|
||||
KandangApi,
|
||||
LocationApi,
|
||||
@@ -284,13 +283,6 @@ const ProjectFlockForm = ({
|
||||
: ((initialValues?.area?.id ?? '') as string),
|
||||
});
|
||||
|
||||
const {
|
||||
options: optionsFcr,
|
||||
isLoadingOptions: isLoadingFcrs,
|
||||
setInputValue: setInputValueFcr,
|
||||
loadMore: loadMoreFcr,
|
||||
} = useSelect(FcrApi.basePath, 'id', 'name');
|
||||
|
||||
const {
|
||||
options: optionsProductionStandards,
|
||||
isLoadingOptions: isLoadingProductionStandards,
|
||||
@@ -505,12 +497,6 @@ const ProjectFlockForm = ({
|
||||
label: initialValues.category,
|
||||
}
|
||||
: null,
|
||||
fcr: initialValues?.fcr
|
||||
? {
|
||||
value: initialValues.fcr?.id,
|
||||
label: initialValues.fcr.name,
|
||||
}
|
||||
: null,
|
||||
production_standard: initialValues?.production_standard
|
||||
? {
|
||||
value: initialValues.production_standard?.id,
|
||||
@@ -531,7 +517,6 @@ const ProjectFlockForm = ({
|
||||
category: initialValues?.category as NonNullable<
|
||||
'GROWING' | 'LAYING' | undefined
|
||||
>,
|
||||
fcr_id: initialValues?.fcr?.id ?? 0,
|
||||
production_standard_id: initialValues?.production_standard?.id ?? 0,
|
||||
location_id: initialValues?.location?.id ?? 0,
|
||||
kandang_ids: initialValues?.kandangs?.map(
|
||||
@@ -574,7 +559,6 @@ const ProjectFlockForm = ({
|
||||
flock_name: values.flock_name as string,
|
||||
area_id: values.area_id as number,
|
||||
category: values.category as string,
|
||||
fcr_id: values.fcr_id as number,
|
||||
production_standard_id: values.production_standard_id as number,
|
||||
location_id: values.location_id as number,
|
||||
kandang_ids: values.kandang_ids as number[],
|
||||
@@ -996,25 +980,6 @@ const ProjectFlockForm = ({
|
||||
isClearable
|
||||
isDisabled={formType != 'add'}
|
||||
/>
|
||||
<SelectInput
|
||||
required
|
||||
label='FCR'
|
||||
placeholder='Pilih FCR'
|
||||
value={formik.values.fcr as OptionType}
|
||||
onChange={(val) => {
|
||||
optionChangeHandler(val, 'fcr');
|
||||
}}
|
||||
onInputChange={setInputValueFcr}
|
||||
onMenuScrollToBottom={loadMoreFcr}
|
||||
options={optionsFcr}
|
||||
isLoading={isLoadingFcrs}
|
||||
isError={
|
||||
formik.touched.fcr_id && Boolean(formik.errors.fcr_id)
|
||||
}
|
||||
errorMessage={formik.errors.fcr_id as string}
|
||||
isClearable
|
||||
isDisabled={formType != 'add'}
|
||||
/>
|
||||
<SelectInput
|
||||
required
|
||||
label='Kategori'
|
||||
|
||||
@@ -31,8 +31,7 @@ import {
|
||||
RecordingApi,
|
||||
ProjectFlockApi,
|
||||
} from '@/services/api/production';
|
||||
import { FcrApi, ProductionStandardApi } from '@/services/api/master-data';
|
||||
import { FcrWithStandards, FcrStandard } from '@/types/api/master-data/fcr';
|
||||
import { ProductionStandardApi } from '@/services/api/master-data';
|
||||
import {
|
||||
ProductionStandard,
|
||||
StandardDetails,
|
||||
@@ -87,24 +86,6 @@ interface RecordingFormProps {
|
||||
initialValues?: Recording;
|
||||
}
|
||||
|
||||
const fcrStandardColumns: ColumnDef<FcrStandard>[] = [
|
||||
{
|
||||
accessorKey: 'weight',
|
||||
header: 'Weight',
|
||||
cell: (props) => formatNumber(props.getValue() as number),
|
||||
},
|
||||
{
|
||||
accessorKey: 'fcr_number',
|
||||
header: 'FCR Number',
|
||||
cell: (props) => formatNumber(props.getValue() as number),
|
||||
},
|
||||
{
|
||||
accessorKey: 'mortality',
|
||||
header: 'Mortality',
|
||||
cell: (props) => formatNumber(props.getValue() as number),
|
||||
},
|
||||
];
|
||||
|
||||
const productionStandardColumns: ColumnDef<StandardDetails>[] = [
|
||||
{
|
||||
accessorKey: 'week',
|
||||
@@ -253,36 +234,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
const approveModal = useModal();
|
||||
const rejectModal = useModal();
|
||||
const deleteModal = useModal();
|
||||
const fcrStandardModal = useModal();
|
||||
const productionStandardModal = useModal();
|
||||
|
||||
const [fcrStandards, setFcrStandards] = useState<FcrStandard[]>([]);
|
||||
const [productionStandards, setProductionStandards] =
|
||||
useState<ProductionStandard | null>(null);
|
||||
|
||||
const [isFcrModalOpen, setIsFcrModalOpen] = useState(false);
|
||||
const [isProductionStandardModalOpen, setIsProductionStandardModalOpen] =
|
||||
useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const checkFcrModalOpen = () => {
|
||||
const isOpen = fcrStandardModal.ref.current?.open || false;
|
||||
setIsFcrModalOpen(isOpen);
|
||||
};
|
||||
|
||||
checkFcrModalOpen();
|
||||
|
||||
const observer = new MutationObserver(checkFcrModalOpen);
|
||||
if (fcrStandardModal.ref.current) {
|
||||
observer.observe(fcrStandardModal.ref.current, {
|
||||
attributes: true,
|
||||
attributeFilter: ['open'],
|
||||
});
|
||||
}
|
||||
|
||||
return () => observer.disconnect();
|
||||
}, [fcrStandardModal.ref]);
|
||||
|
||||
useEffect(() => {
|
||||
const checkProductionStandardModalOpen = () => {
|
||||
const isOpen = productionStandardModal.ref.current?.open || false;
|
||||
@@ -460,24 +419,6 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
? projectFlockKandangLookupData.data
|
||||
: undefined;
|
||||
|
||||
const fcrId = useMemo(() => {
|
||||
if (type === 'add') {
|
||||
return projectFlockKandangLookup?.project_flock?.fcr?.id;
|
||||
}
|
||||
return initialValues?.project_flock?.fcr?.id;
|
||||
}, [type, projectFlockKandangLookup, initialValues]);
|
||||
|
||||
const { data: fcr, isLoading: isLoadingFcrStandards } = useSWR(
|
||||
isFcrModalOpen && fcrId ? `fcr-detail-${fcrId}` : null,
|
||||
() => FcrApi.getSingle(fcrId!)
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (fcr?.status === 'success') {
|
||||
setFcrStandards((fcr.data as FcrWithStandards).fcr_standards || []);
|
||||
}
|
||||
}, [fcr]);
|
||||
|
||||
const productionStandardId = useMemo(() => {
|
||||
if (type === 'add') {
|
||||
return projectFlockKandangLookup?.project_flock?.production_standard_id;
|
||||
@@ -1942,24 +1883,6 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
: '-'}
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<span className='text-sm text-gray-600'>Standard FCR</span>
|
||||
<div className='mt-1'>
|
||||
<Badge
|
||||
variant='soft'
|
||||
color='primary'
|
||||
className={{
|
||||
badge:
|
||||
'cursor-pointer hover:opacity-80 transition-opacity whitespace-nowrap',
|
||||
}}
|
||||
onClick={() => fcrStandardModal.openModal()}
|
||||
>
|
||||
{projectFlockKandangLookup?.project_flock?.fcr?.name ||
|
||||
initialValues?.project_flock?.fcr?.name ||
|
||||
'-'}
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<span className='text-sm text-gray-600'>
|
||||
Standard Produksi
|
||||
@@ -2150,22 +2073,6 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div>
|
||||
<span className='text-sm text-gray-600'>Standard FCR</span>
|
||||
<div className='mt-1'>
|
||||
<Badge
|
||||
variant='soft'
|
||||
color='primary'
|
||||
className={{
|
||||
badge:
|
||||
'cursor-pointer hover:opacity-80 transition-opacity whitespace-nowrap',
|
||||
}}
|
||||
onClick={() => fcrStandardModal.openModal()}
|
||||
>
|
||||
{initialValues.project_flock?.fcr?.name || '-'}
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<span className='text-sm text-gray-600'>
|
||||
Standard Produksi
|
||||
@@ -2217,21 +2124,6 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td className='py-3 font-medium'>FCR (g)</td>
|
||||
<td className='text-center py-3'>
|
||||
<span className='font-semibold'>
|
||||
{initialValues.fcr_value != null
|
||||
? `${formatNumber(initialValues.fcr_value)} g`
|
||||
: '-'}
|
||||
</span>
|
||||
</td>
|
||||
<td className='text-center py-3 text-gray-600'>
|
||||
{initialValues.project_flock?.fcr?.fcr_std != null
|
||||
? `${formatNumber(initialValues.project_flock?.fcr?.fcr_std)} g`
|
||||
: '-'}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td className='py-3 font-medium'>Feed Intake (g)</td>
|
||||
<td className='text-center py-3'>
|
||||
@@ -3273,62 +3165,6 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* FCR Standard Modal */}
|
||||
<Modal
|
||||
ref={fcrStandardModal.ref}
|
||||
closeOnBackdrop={true}
|
||||
className={{
|
||||
modal: 'p-0',
|
||||
modalBox: 'p-0 rounded-2xl xl:max-w-4/12 max-w-sm',
|
||||
}}
|
||||
>
|
||||
<div className='space-y-6'>
|
||||
{/* Modal Header */}
|
||||
<div className='flex items-center justify-between gap-2 py-3 border-b border-gray-300 px-4'>
|
||||
<div className='flex items-center gap-2 text-primary'>
|
||||
<Icon icon='mdi:chart-line' width={20} height={20} />
|
||||
<h3 className='font-semibold'>Detail Standard FCR</h3>
|
||||
</div>
|
||||
<Button
|
||||
variant='link'
|
||||
onClick={fcrStandardModal.closeModal}
|
||||
className='text-gray-500 hover:text-gray-700 transition-colors cursor-pointer'
|
||||
>
|
||||
<Icon icon='heroicons:x-mark' width={20} height={20} />
|
||||
</Button>
|
||||
</div>
|
||||
<div className='px-4'>
|
||||
{isLoadingFcrStandards ? (
|
||||
<div className='flex justify-center py-8'>
|
||||
<span className='loading loading-spinner loading-lg'></span>
|
||||
</div>
|
||||
) : fcrStandards.length > 0 ? (
|
||||
<Table<FcrStandard>
|
||||
data={fcrStandards}
|
||||
columns={fcrStandardColumns}
|
||||
pageSize={100}
|
||||
className={{
|
||||
tableWrapperClassName: 'overflow-x-auto',
|
||||
tableClassName: 'w-full table-auto text-sm',
|
||||
headerRowClassName: 'border-b border-b-gray-200',
|
||||
headerColumnClassName:
|
||||
'px-4 py-3 text-xs font-semibold text-gray-500 whitespace-nowrap border-l border-l-gray-200 border-r border-r-gray-200 border-t border-t-gray-200 border-gray-200 border-b-0',
|
||||
bodyRowClassName:
|
||||
'hover:bg-gray-50 transition-colors border-b border-gray-200 first:border-t first:border-t-gray-200 border-l border-l-gray-200 border-r border-r-gray-200',
|
||||
bodyColumnClassName:
|
||||
'px-4 py-3 text-xs text-gray-900 whitespace-nowrap',
|
||||
paginationClassName: 'hidden',
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<p className='text-sm text-gray-500'>
|
||||
Tidak ada data FCR standards
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
{/* Production Standard Modal */}
|
||||
<Modal
|
||||
closeOnBackdrop={true}
|
||||
|
||||
-4
@@ -1,5 +1,4 @@
|
||||
import { Area } from '@/types/api/master-data/area';
|
||||
import { Fcr } from '@/types/api/master-data/fcr';
|
||||
import { Flock } from '@/types/api/master-data/flock';
|
||||
import { Kandang } from '@/types/api/master-data/kandang';
|
||||
import { Location } from '@/types/api/master-data/location';
|
||||
@@ -16,8 +15,6 @@ export type BaseProjectFlock = {
|
||||
area: Area;
|
||||
area_id: number;
|
||||
category: string;
|
||||
fcr: Fcr;
|
||||
fcr_id: number;
|
||||
production_standard: ProductionStandard;
|
||||
production_standard_id: number;
|
||||
location: Location;
|
||||
@@ -51,7 +48,6 @@ export type CreateProjectFlockPayload = {
|
||||
flock_name: string;
|
||||
area_id: number;
|
||||
category: string;
|
||||
fcr_id: number;
|
||||
production_standard_id: number;
|
||||
location_id: number;
|
||||
kandang_ids: number[];
|
||||
|
||||
Reference in New Issue
Block a user