mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 15:25:46 +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',
|
accessorKey: 'location.name',
|
||||||
header: 'Lokasi',
|
header: 'Lokasi',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
accessorKey: 'fcr.name',
|
|
||||||
header: 'FCR',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
accessorKey: 'category',
|
accessorKey: 'category',
|
||||||
header: 'Kategori',
|
header: 'Kategori',
|
||||||
|
|||||||
@@ -16,11 +16,6 @@ type ProjectFlockFormSchemaType = {
|
|||||||
label: string;
|
label: string;
|
||||||
} | null;
|
} | null;
|
||||||
category: string;
|
category: string;
|
||||||
fcr: {
|
|
||||||
value: number | string;
|
|
||||||
label: string;
|
|
||||||
} | null;
|
|
||||||
fcr_id: number;
|
|
||||||
production_standard: {
|
production_standard: {
|
||||||
value: number | string;
|
value: number | string;
|
||||||
label: string;
|
label: string;
|
||||||
@@ -96,15 +91,6 @@ export const ProjectFlockFormSchema: Yup.ObjectSchema<ProjectFlockFormSchemaType
|
|||||||
.oneOf(['GROWING', 'LAYING'], 'Kategori wajib diisi!')
|
.oneOf(['GROWING', 'LAYING'], 'Kategori wajib diisi!')
|
||||||
.required('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
|
||||||
production_standard: Yup.object({
|
production_standard: Yup.object({
|
||||||
value: Yup.number().required('ID Standar Produksi wajib diisi!'),
|
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 AlertErrorList from '@/components/helper/form/FormErrors';
|
||||||
import {
|
import {
|
||||||
AreaApi,
|
AreaApi,
|
||||||
FcrApi,
|
|
||||||
FlockApi,
|
FlockApi,
|
||||||
KandangApi,
|
KandangApi,
|
||||||
LocationApi,
|
LocationApi,
|
||||||
@@ -284,13 +283,6 @@ const ProjectFlockForm = ({
|
|||||||
: ((initialValues?.area?.id ?? '') as string),
|
: ((initialValues?.area?.id ?? '') as string),
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
|
||||||
options: optionsFcr,
|
|
||||||
isLoadingOptions: isLoadingFcrs,
|
|
||||||
setInputValue: setInputValueFcr,
|
|
||||||
loadMore: loadMoreFcr,
|
|
||||||
} = useSelect(FcrApi.basePath, 'id', 'name');
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
options: optionsProductionStandards,
|
options: optionsProductionStandards,
|
||||||
isLoadingOptions: isLoadingProductionStandards,
|
isLoadingOptions: isLoadingProductionStandards,
|
||||||
@@ -505,12 +497,6 @@ const ProjectFlockForm = ({
|
|||||||
label: initialValues.category,
|
label: initialValues.category,
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
fcr: initialValues?.fcr
|
|
||||||
? {
|
|
||||||
value: initialValues.fcr?.id,
|
|
||||||
label: initialValues.fcr.name,
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
production_standard: initialValues?.production_standard
|
production_standard: initialValues?.production_standard
|
||||||
? {
|
? {
|
||||||
value: initialValues.production_standard?.id,
|
value: initialValues.production_standard?.id,
|
||||||
@@ -531,7 +517,6 @@ const ProjectFlockForm = ({
|
|||||||
category: initialValues?.category as NonNullable<
|
category: initialValues?.category as NonNullable<
|
||||||
'GROWING' | 'LAYING' | undefined
|
'GROWING' | 'LAYING' | undefined
|
||||||
>,
|
>,
|
||||||
fcr_id: initialValues?.fcr?.id ?? 0,
|
|
||||||
production_standard_id: initialValues?.production_standard?.id ?? 0,
|
production_standard_id: initialValues?.production_standard?.id ?? 0,
|
||||||
location_id: initialValues?.location?.id ?? 0,
|
location_id: initialValues?.location?.id ?? 0,
|
||||||
kandang_ids: initialValues?.kandangs?.map(
|
kandang_ids: initialValues?.kandangs?.map(
|
||||||
@@ -574,7 +559,6 @@ const ProjectFlockForm = ({
|
|||||||
flock_name: values.flock_name as string,
|
flock_name: values.flock_name as string,
|
||||||
area_id: values.area_id as number,
|
area_id: values.area_id as number,
|
||||||
category: values.category as string,
|
category: values.category as string,
|
||||||
fcr_id: values.fcr_id as number,
|
|
||||||
production_standard_id: values.production_standard_id as number,
|
production_standard_id: values.production_standard_id as number,
|
||||||
location_id: values.location_id as number,
|
location_id: values.location_id as number,
|
||||||
kandang_ids: values.kandang_ids as number[],
|
kandang_ids: values.kandang_ids as number[],
|
||||||
@@ -996,25 +980,6 @@ const ProjectFlockForm = ({
|
|||||||
isClearable
|
isClearable
|
||||||
isDisabled={formType != 'add'}
|
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
|
<SelectInput
|
||||||
required
|
required
|
||||||
label='Kategori'
|
label='Kategori'
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ import {
|
|||||||
RecordingApi,
|
RecordingApi,
|
||||||
ProjectFlockApi,
|
ProjectFlockApi,
|
||||||
} from '@/services/api/production';
|
} from '@/services/api/production';
|
||||||
import { FcrApi, ProductionStandardApi } from '@/services/api/master-data';
|
import { ProductionStandardApi } from '@/services/api/master-data';
|
||||||
import { FcrWithStandards, FcrStandard } from '@/types/api/master-data/fcr';
|
|
||||||
import {
|
import {
|
||||||
ProductionStandard,
|
ProductionStandard,
|
||||||
StandardDetails,
|
StandardDetails,
|
||||||
@@ -87,24 +86,6 @@ interface RecordingFormProps {
|
|||||||
initialValues?: Recording;
|
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>[] = [
|
const productionStandardColumns: ColumnDef<StandardDetails>[] = [
|
||||||
{
|
{
|
||||||
accessorKey: 'week',
|
accessorKey: 'week',
|
||||||
@@ -253,36 +234,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
const approveModal = useModal();
|
const approveModal = useModal();
|
||||||
const rejectModal = useModal();
|
const rejectModal = useModal();
|
||||||
const deleteModal = useModal();
|
const deleteModal = useModal();
|
||||||
const fcrStandardModal = useModal();
|
|
||||||
const productionStandardModal = useModal();
|
const productionStandardModal = useModal();
|
||||||
|
|
||||||
const [fcrStandards, setFcrStandards] = useState<FcrStandard[]>([]);
|
|
||||||
const [productionStandards, setProductionStandards] =
|
const [productionStandards, setProductionStandards] =
|
||||||
useState<ProductionStandard | null>(null);
|
useState<ProductionStandard | null>(null);
|
||||||
|
|
||||||
const [isFcrModalOpen, setIsFcrModalOpen] = useState(false);
|
|
||||||
const [isProductionStandardModalOpen, setIsProductionStandardModalOpen] =
|
const [isProductionStandardModalOpen, setIsProductionStandardModalOpen] =
|
||||||
useState(false);
|
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(() => {
|
useEffect(() => {
|
||||||
const checkProductionStandardModalOpen = () => {
|
const checkProductionStandardModalOpen = () => {
|
||||||
const isOpen = productionStandardModal.ref.current?.open || false;
|
const isOpen = productionStandardModal.ref.current?.open || false;
|
||||||
@@ -460,24 +419,6 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
? projectFlockKandangLookupData.data
|
? projectFlockKandangLookupData.data
|
||||||
: undefined;
|
: 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(() => {
|
const productionStandardId = useMemo(() => {
|
||||||
if (type === 'add') {
|
if (type === 'add') {
|
||||||
return projectFlockKandangLookup?.project_flock?.production_standard_id;
|
return projectFlockKandangLookup?.project_flock?.production_standard_id;
|
||||||
@@ -1942,24 +1883,6 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
: '-'}
|
: '-'}
|
||||||
</p>
|
</p>
|
||||||
</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()}
|
|
||||||
>
|
|
||||||
{projectFlockKandangLookup?.project_flock?.fcr?.name ||
|
|
||||||
initialValues?.project_flock?.fcr?.name ||
|
|
||||||
'-'}
|
|
||||||
</Badge>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
<span className='text-sm text-gray-600'>
|
<span className='text-sm text-gray-600'>
|
||||||
Standard Produksi
|
Standard Produksi
|
||||||
@@ -2150,22 +2073,6 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
</div>
|
</div>
|
||||||
</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>
|
<div>
|
||||||
<span className='text-sm text-gray-600'>
|
<span className='text-sm text-gray-600'>
|
||||||
Standard Produksi
|
Standard Produksi
|
||||||
@@ -2217,21 +2124,6 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<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>
|
<tr>
|
||||||
<td className='py-3 font-medium'>Feed Intake (g)</td>
|
<td className='py-3 font-medium'>Feed Intake (g)</td>
|
||||||
<td className='text-center py-3'>
|
<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 */}
|
{/* Production Standard Modal */}
|
||||||
<Modal
|
<Modal
|
||||||
closeOnBackdrop={true}
|
closeOnBackdrop={true}
|
||||||
|
|||||||
-4
@@ -1,5 +1,4 @@
|
|||||||
import { Area } from '@/types/api/master-data/area';
|
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 { Flock } from '@/types/api/master-data/flock';
|
||||||
import { Kandang } from '@/types/api/master-data/kandang';
|
import { Kandang } from '@/types/api/master-data/kandang';
|
||||||
import { Location } from '@/types/api/master-data/location';
|
import { Location } from '@/types/api/master-data/location';
|
||||||
@@ -16,8 +15,6 @@ export type BaseProjectFlock = {
|
|||||||
area: Area;
|
area: Area;
|
||||||
area_id: number;
|
area_id: number;
|
||||||
category: string;
|
category: string;
|
||||||
fcr: Fcr;
|
|
||||||
fcr_id: number;
|
|
||||||
production_standard: ProductionStandard;
|
production_standard: ProductionStandard;
|
||||||
production_standard_id: number;
|
production_standard_id: number;
|
||||||
location: Location;
|
location: Location;
|
||||||
@@ -51,7 +48,6 @@ export type CreateProjectFlockPayload = {
|
|||||||
flock_name: string;
|
flock_name: string;
|
||||||
area_id: number;
|
area_id: number;
|
||||||
category: string;
|
category: string;
|
||||||
fcr_id: number;
|
|
||||||
production_standard_id: number;
|
production_standard_id: number;
|
||||||
location_id: number;
|
location_id: number;
|
||||||
kandang_ids: number[];
|
kandang_ids: number[];
|
||||||
|
|||||||
Reference in New Issue
Block a user