mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
Merge branch 'hotfix/adjustment-fifo-stock-ttl' into 'development'
[HOTFIX/FE] FIFO Stock Adjustment for TTL, Recording and Project Flock (Chickin) See merge request mbugroup/lti-web-client!342
This commit is contained in:
@@ -23,7 +23,7 @@ const ChickinLogsView = ({
|
|||||||
rawDataApprovals: BaseApproval[];
|
rawDataApprovals: BaseApproval[];
|
||||||
}) => {
|
}) => {
|
||||||
const [chickinErrorMessage, setChickinErrorMessage] = useState('');
|
const [chickinErrorMessage, setChickinErrorMessage] = useState('');
|
||||||
const { openChickinApproveModal } = useChickinStore();
|
const { openChickinApproveModal, openChickinDeleteModal } = useChickinStore();
|
||||||
|
|
||||||
const handleClickApprove = () => {
|
const handleClickApprove = () => {
|
||||||
openChickinApproveModal(initialValues, async (notes?: string) => {
|
openChickinApproveModal(initialValues, async (notes?: string) => {
|
||||||
@@ -44,6 +44,21 @@ const ChickinLogsView = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleDeleteChickin = (chickinId: number) => {
|
||||||
|
openChickinDeleteModal(chickinId, async () => {
|
||||||
|
const deleteRes = await ChickinApi.delete(chickinId);
|
||||||
|
|
||||||
|
if (isResponseSuccess(deleteRes)) {
|
||||||
|
toast.success(deleteRes?.message || 'Chickin berhasil dihapus');
|
||||||
|
afterSubmit && afterSubmit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isResponseError(deleteRes)) {
|
||||||
|
toast.error(deleteRes?.message || 'Gagal menghapus chickin');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className='px-4 pb-4 flex flex-col gap-4'>
|
<div className='px-4 pb-4 flex flex-col gap-4'>
|
||||||
@@ -86,14 +101,30 @@ const ChickinLogsView = ({
|
|||||||
<div className='text-lg font-semibold'>
|
<div className='text-lg font-semibold'>
|
||||||
Chick In #{index + 1} - {latestApproval?.step_number}
|
Chick In #{index + 1} - {latestApproval?.step_number}
|
||||||
</div>
|
</div>
|
||||||
<PillBadge
|
<div className='flex flex-row gap-2 items-center'>
|
||||||
content={
|
<PillBadge
|
||||||
isApproved ? 'Disetujui' : isPending ? 'Pending' : '-'
|
content={
|
||||||
}
|
isApproved ? 'Disetujui' : isPending ? 'Pending' : '-'
|
||||||
color={
|
}
|
||||||
isApproved ? 'green' : isPending ? 'yellow' : 'gray'
|
color={
|
||||||
}
|
isApproved ? 'green' : isPending ? 'yellow' : 'gray'
|
||||||
/>
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{isApproved && (
|
||||||
|
<Button
|
||||||
|
color='error'
|
||||||
|
className='w-fit text-sm text-base-100 rounded-lg shadow-sm btn-xs!'
|
||||||
|
onClick={() => handleDeleteChickin(chickin.id)}
|
||||||
|
>
|
||||||
|
<Icon
|
||||||
|
icon='heroicons:trash-solid'
|
||||||
|
width={10}
|
||||||
|
height={10}
|
||||||
|
/>
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Tanggal Chick In */}
|
{/* Tanggal Chick In */}
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
|||||||
const confirmModal = useModal();
|
const confirmModal = useModal();
|
||||||
const successModal = useModal();
|
const successModal = useModal();
|
||||||
const chickinApproveModal = useModal();
|
const chickinApproveModal = useModal();
|
||||||
|
const chickinDeleteModal = useModal();
|
||||||
const closingModal = useModal();
|
const closingModal = useModal();
|
||||||
const [approvalAction, setApprovalAction] = useState<'APPROVED' | 'REJECTED'>(
|
const [approvalAction, setApprovalAction] = useState<'APPROVED' | 'REJECTED'>(
|
||||||
'APPROVED'
|
'APPROVED'
|
||||||
@@ -214,6 +215,11 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
|||||||
chickinApproveCallback,
|
chickinApproveCallback,
|
||||||
closeChickinApproveModal,
|
closeChickinApproveModal,
|
||||||
setChickinApproveLoading,
|
setChickinApproveLoading,
|
||||||
|
isChickinDeleteModalOpen,
|
||||||
|
isChickinDeleteLoading,
|
||||||
|
chickinDeleteCallback,
|
||||||
|
closeChickinDeleteModal,
|
||||||
|
setChickinDeleteLoading,
|
||||||
} = useChickinStore();
|
} = useChickinStore();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -478,6 +484,14 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
|||||||
}
|
}
|
||||||
}, [isChickinApproveModalOpen, chickinApproveModal]);
|
}, [isChickinApproveModalOpen, chickinApproveModal]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isChickinDeleteModalOpen) {
|
||||||
|
chickinDeleteModal.openModal();
|
||||||
|
} else {
|
||||||
|
chickinDeleteModal.closeModal();
|
||||||
|
}
|
||||||
|
}, [isChickinDeleteModalOpen, chickinDeleteModal]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isClosingModalOpen) {
|
if (isClosingModalOpen) {
|
||||||
closingModal.openModal();
|
closingModal.openModal();
|
||||||
@@ -1208,6 +1222,38 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{/* Chickin Delete Modal */}
|
||||||
|
<ConfirmationModal
|
||||||
|
ref={chickinDeleteModal.ref}
|
||||||
|
type='error'
|
||||||
|
text='Apakah anda yakin ingin menghapus data chick in ini?'
|
||||||
|
secondaryButton={{
|
||||||
|
text: 'Tidak',
|
||||||
|
onClick: () => {
|
||||||
|
closeChickinDeleteModal();
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
className={{
|
||||||
|
modal: 'z-9999',
|
||||||
|
}}
|
||||||
|
primaryButton={{
|
||||||
|
text: 'Ya',
|
||||||
|
color: 'error',
|
||||||
|
isLoading: isChickinDeleteLoading,
|
||||||
|
onClick: async () => {
|
||||||
|
if (chickinDeleteCallback) {
|
||||||
|
setChickinDeleteLoading(true);
|
||||||
|
try {
|
||||||
|
await chickinDeleteCallback();
|
||||||
|
} finally {
|
||||||
|
setChickinDeleteLoading(false);
|
||||||
|
closeChickinDeleteModal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* Filter Modal */}
|
{/* Filter Modal */}
|
||||||
<Modal
|
<Modal
|
||||||
ref={filterModal.ref}
|
ref={filterModal.ref}
|
||||||
|
|||||||
@@ -104,8 +104,19 @@ const RowOptionsMenu = ({
|
|||||||
return recording.approval?.action === 'REJECTED';
|
return recording.approval?.action === 'REJECTED';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isRecordingEditable = (recording: Recording) => {
|
||||||
|
if (
|
||||||
|
recording.executed_at &&
|
||||||
|
recording.project_flock?.project_flock_category === 'GROWING'
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
const isApproved = isRecordingApproved(props.row.original);
|
const isApproved = isRecordingApproved(props.row.original);
|
||||||
const isRejected = isRecordingRejected(props.row.original);
|
const isRejected = isRecordingRejected(props.row.original);
|
||||||
|
const isEditable = isRecordingEditable(props.row.original);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='relative'>
|
<div className='relative'>
|
||||||
@@ -138,18 +149,20 @@ const RowOptionsMenu = ({
|
|||||||
View Details
|
View Details
|
||||||
</Button>
|
</Button>
|
||||||
</RequirePermission>
|
</RequirePermission>
|
||||||
<RequirePermission permissions='lti.production.recording.update'>
|
{isEditable && (
|
||||||
<Button
|
<RequirePermission permissions='lti.production.recording.update'>
|
||||||
href={`/production/recording/detail/edit/?recordingId=${props.row.original.id}`}
|
<Button
|
||||||
variant='ghost'
|
href={`/production/recording/detail/edit/?recordingId=${props.row.original.id}`}
|
||||||
color='none'
|
variant='ghost'
|
||||||
className='p-3 justify-start text-sm font-semibold w-full'
|
color='none'
|
||||||
onClick={closePopover}
|
className='p-3 justify-start text-sm font-semibold w-full'
|
||||||
>
|
onClick={closePopover}
|
||||||
<Icon icon='mdi:pencil-outline' width={20} height={20} />
|
>
|
||||||
Edit
|
<Icon icon='mdi:pencil-outline' width={20} height={20} />
|
||||||
</Button>
|
Edit
|
||||||
</RequirePermission>
|
</Button>
|
||||||
|
</RequirePermission>
|
||||||
|
)}
|
||||||
{!isApproved && !isRejected && (
|
{!isApproved && !isRejected && (
|
||||||
<RequirePermission permissions='lti.production.recording.approve'>
|
<RequirePermission permissions='lti.production.recording.approve'>
|
||||||
<Button
|
<Button
|
||||||
@@ -182,20 +195,22 @@ const RowOptionsMenu = ({
|
|||||||
</Button>
|
</Button>
|
||||||
</RequirePermission>
|
</RequirePermission>
|
||||||
)}
|
)}
|
||||||
<RequirePermission permissions='lti.production.recording.delete'>
|
{isEditable && (
|
||||||
<Button
|
<RequirePermission permissions='lti.production.recording.delete'>
|
||||||
onClick={() => {
|
<Button
|
||||||
deleteClickHandler();
|
onClick={() => {
|
||||||
closePopover();
|
deleteClickHandler();
|
||||||
}}
|
closePopover();
|
||||||
variant='ghost'
|
}}
|
||||||
color='error'
|
variant='ghost'
|
||||||
className='p-3 justify-start text-sm font-semibold w-full focus-visible:text-error-content hover:text-error-content'
|
color='error'
|
||||||
>
|
className='p-3 justify-start text-sm font-semibold w-full focus-visible:text-error-content hover:text-error-content'
|
||||||
<Icon icon='mdi:delete-outline' width={20} height={20} />
|
>
|
||||||
Delete
|
<Icon icon='mdi:delete-outline' width={20} height={20} />
|
||||||
</Button>
|
Delete
|
||||||
</RequirePermission>
|
</Button>
|
||||||
|
</RequirePermission>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -272,6 +272,16 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
return recording?.approval?.action === 'REJECTED';
|
return recording?.approval?.action === 'REJECTED';
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const isRecordingEditable = useCallback((recording?: Recording) => {
|
||||||
|
if (
|
||||||
|
recording?.executed_at &&
|
||||||
|
recording?.project_flock?.project_flock_category === 'GROWING'
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}, []);
|
||||||
|
|
||||||
// ===== PAYLOAD CREATION HELPERS =====
|
// ===== PAYLOAD CREATION HELPERS =====
|
||||||
const createGrowingPayload = useCallback(
|
const createGrowingPayload = useCallback(
|
||||||
(values: RecordingGrowingFormValues) => {
|
(values: RecordingGrowingFormValues) => {
|
||||||
@@ -2990,42 +3000,46 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
<div className='flex flex-col sm:flex-row sm:justify-between gap-2'>
|
<div className='flex flex-col sm:flex-row sm:justify-between gap-2'>
|
||||||
{/* Left side - Detail & Edit actions */}
|
{/* Left side - Detail & Edit actions */}
|
||||||
<div className='flex flex-col sm:flex-row justify-start gap-2 w-full sm:w-auto'>
|
<div className='flex flex-col sm:flex-row justify-start gap-2 w-full sm:w-auto'>
|
||||||
{type === 'detail' && deleteRecordingClickHandler && (
|
{type === 'detail' &&
|
||||||
<RequirePermission permissions='lti.production.recording.delete'>
|
deleteRecordingClickHandler &&
|
||||||
<Button
|
isRecordingEditable(initialValues) && (
|
||||||
type='button'
|
<RequirePermission permissions='lti.production.recording.delete'>
|
||||||
color='error'
|
<Button
|
||||||
onClick={deleteRecordingClickHandler}
|
type='button'
|
||||||
className='px-4'
|
color='error'
|
||||||
>
|
onClick={deleteRecordingClickHandler}
|
||||||
<Icon
|
className='px-4'
|
||||||
icon='material-symbols:delete-outline-rounded'
|
>
|
||||||
width={24}
|
<Icon
|
||||||
height={24}
|
icon='material-symbols:delete-outline-rounded'
|
||||||
className='justify-start text-sm'
|
width={24}
|
||||||
/>
|
height={24}
|
||||||
Delete
|
className='justify-start text-sm'
|
||||||
</Button>
|
/>
|
||||||
</RequirePermission>
|
Delete
|
||||||
)}
|
</Button>
|
||||||
{type === 'detail' && initialValues && (
|
</RequirePermission>
|
||||||
<RequirePermission permissions='lti.production.recording.update'>
|
)}
|
||||||
<Button
|
{type === 'detail' &&
|
||||||
type='button'
|
initialValues &&
|
||||||
color='warning'
|
isRecordingEditable(initialValues) && (
|
||||||
href={`/production/recording/detail/edit/?recordingId=${initialValues.id}`}
|
<RequirePermission permissions='lti.production.recording.update'>
|
||||||
className='px-4'
|
<Button
|
||||||
>
|
type='button'
|
||||||
<Icon
|
color='warning'
|
||||||
icon='material-symbols:edit-outline'
|
href={`/production/recording/detail/edit/?recordingId=${initialValues.id}`}
|
||||||
width={24}
|
className='px-4'
|
||||||
height={24}
|
>
|
||||||
className='justify-start text-sm'
|
<Icon
|
||||||
/>
|
icon='material-symbols:edit-outline'
|
||||||
Edit
|
width={24}
|
||||||
</Button>
|
height={24}
|
||||||
</RequirePermission>
|
className='justify-start text-sm'
|
||||||
)}
|
/>
|
||||||
|
Edit
|
||||||
|
</Button>
|
||||||
|
</RequirePermission>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{/* Right side actions */}
|
{/* Right side actions */}
|
||||||
<div className='flex flex-col sm:flex-row sm:justify-end gap-2 w-full sm:w-auto'>
|
<div className='flex flex-col sm:flex-row sm:justify-end gap-2 w-full sm:w-auto'>
|
||||||
|
|||||||
+18
-8
@@ -50,12 +50,18 @@ const TransferToLayingConfirmationModalTable = ({
|
|||||||
transferToLayingForm?: TransferToLayingFormValues;
|
transferToLayingForm?: TransferToLayingFormValues;
|
||||||
transferToLayingId?: number;
|
transferToLayingId?: number;
|
||||||
}) => {
|
}) => {
|
||||||
|
const isValidId =
|
||||||
|
transferToLayingId !== undefined &&
|
||||||
|
transferToLayingId !== null &&
|
||||||
|
!isNaN(transferToLayingId) &&
|
||||||
|
transferToLayingId > 0;
|
||||||
|
|
||||||
const { data: transferToLaying, isLoading: isLoadingTransferToLaying } =
|
const { data: transferToLaying, isLoading: isLoadingTransferToLaying } =
|
||||||
useSWR(
|
useSWR(
|
||||||
transferToLayingId
|
isValidId
|
||||||
? ['detail-transfer-to-laying', String(transferToLayingId)]
|
? ['detail-transfer-to-laying', String(transferToLayingId)]
|
||||||
: undefined,
|
: undefined,
|
||||||
([id]) => TransferToLayingApi.getSingle(Number(id))
|
([, id]) => TransferToLayingApi.getSingle(Number(id))
|
||||||
);
|
);
|
||||||
|
|
||||||
const confirmationTableColumns: ColumnDef<TransferToLayingConfirmationTableDataType>[] =
|
const confirmationTableColumns: ColumnDef<TransferToLayingConfirmationTableDataType>[] =
|
||||||
@@ -273,12 +279,16 @@ const TransferToLayingConfirmationModal = ({
|
|||||||
|
|
||||||
{transferToLayingIds &&
|
{transferToLayingIds &&
|
||||||
!transferToLayingForm &&
|
!transferToLayingForm &&
|
||||||
transferToLayingIds.map((transferToLayingId, idx) => (
|
transferToLayingIds
|
||||||
<TransferToLayingConfirmationModalTable
|
.filter(
|
||||||
key={idx}
|
(id) => id !== undefined && id !== null && !isNaN(id) && id > 0
|
||||||
transferToLayingId={transferToLayingId}
|
)
|
||||||
/>
|
.map((transferToLayingId, idx) => (
|
||||||
))}
|
<TransferToLayingConfirmationModalTable
|
||||||
|
key={idx}
|
||||||
|
transferToLayingId={transferToLayingId}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
|
||||||
{withNote && (
|
{withNote && (
|
||||||
<TextArea
|
<TextArea
|
||||||
|
|||||||
@@ -229,6 +229,8 @@ const TransferToLayingFormModal = () => {
|
|||||||
ProjectFlock | undefined
|
ProjectFlock | undefined
|
||||||
>(undefined);
|
>(undefined);
|
||||||
|
|
||||||
|
const [maxSourceQuantity, setMaxSourceQuantity] = useState<number>(0);
|
||||||
|
|
||||||
const selectedFlockDestinationRawData = isResponseSuccess(
|
const selectedFlockDestinationRawData = isResponseSuccess(
|
||||||
flockDestinationRawData
|
flockDestinationRawData
|
||||||
)
|
)
|
||||||
@@ -353,19 +355,14 @@ const TransferToLayingFormModal = () => {
|
|||||||
return { available: countAvailable, unavailable: countUnavailable };
|
return { available: countAvailable, unavailable: countUnavailable };
|
||||||
}, [mappedFlockDestinationKandangsMaxTargetQty]);
|
}, [mappedFlockDestinationKandangsMaxTargetQty]);
|
||||||
|
|
||||||
const totalEnteredChickenForTransfer =
|
|
||||||
formik.values.flockSourceKandangs.reduce(
|
|
||||||
(acc, item) => acc + Number(item.quantity),
|
|
||||||
0
|
|
||||||
);
|
|
||||||
|
|
||||||
const totalTransferedChicken = formik.values.flockDestinationKandangs.reduce(
|
const totalTransferedChicken = formik.values.flockDestinationKandangs.reduce(
|
||||||
(acc, item) => acc + Number(item.quantity),
|
(acc, item) => acc + Number(item.quantity),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Sisa transfer = Max available dari kandang asal - Total yang sudah diisi di kandang tujuan
|
||||||
const totalAvailableChickenForTransfer =
|
const totalAvailableChickenForTransfer =
|
||||||
totalEnteredChickenForTransfer - totalTransferedChicken;
|
maxSourceQuantity - totalTransferedChicken;
|
||||||
|
|
||||||
const isNextButtonDisabled = useMemo(() => {
|
const isNextButtonDisabled = useMemo(() => {
|
||||||
if (step === 1) {
|
if (step === 1) {
|
||||||
@@ -397,6 +394,7 @@ const TransferToLayingFormModal = () => {
|
|||||||
formik.setFieldValue('maxTotalQuantity', '');
|
formik.setFieldValue('maxTotalQuantity', '');
|
||||||
formik.setFieldValue('reason', '');
|
formik.setFieldValue('reason', '');
|
||||||
formik.setFieldTouched('reason', false);
|
formik.setFieldTouched('reason', false);
|
||||||
|
setMaxSourceQuantity(0);
|
||||||
|
|
||||||
setStep(2);
|
setStep(2);
|
||||||
};
|
};
|
||||||
@@ -404,6 +402,7 @@ const TransferToLayingFormModal = () => {
|
|||||||
const flockSourceChangeHandler = (val: OptionType | OptionType[] | null) => {
|
const flockSourceChangeHandler = (val: OptionType | OptionType[] | null) => {
|
||||||
formik.setFieldValue('flockSource', val);
|
formik.setFieldValue('flockSource', val);
|
||||||
formik.setFieldValue('flockSourceKandangs', []);
|
formik.setFieldValue('flockSourceKandangs', []);
|
||||||
|
setMaxSourceQuantity(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
const flockDestinationChangeHandler = (
|
const flockDestinationChangeHandler = (
|
||||||
@@ -469,6 +468,26 @@ const TransferToLayingFormModal = () => {
|
|||||||
formik.setFieldValue('maxTotalQuantity', totalTransferedChicken);
|
formik.setFieldValue('maxTotalQuantity', totalTransferedChicken);
|
||||||
}, [totalTransferedChicken, formik.values.flockDestinationKandangs]);
|
}, [totalTransferedChicken, formik.values.flockDestinationKandangs]);
|
||||||
|
|
||||||
|
// Auto-fill source kandang quantity from total destination quantity
|
||||||
|
useEffect(() => {
|
||||||
|
if (formik.values.flockSourceKandangs.length > 0) {
|
||||||
|
formik.setFieldValue(
|
||||||
|
'flockSourceKandangs.0.quantity',
|
||||||
|
totalTransferedChicken
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, [totalTransferedChicken]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (
|
||||||
|
formik.values.flockSourceKandangs.length > 0 &&
|
||||||
|
formik.values.flockSourceKandangs[0].maxQuantity &&
|
||||||
|
maxSourceQuantity === 0
|
||||||
|
) {
|
||||||
|
setMaxSourceQuantity(formik.values.flockSourceKandangs[0].maxQuantity);
|
||||||
|
}
|
||||||
|
}, [formik.values.flockSourceKandangs, maxSourceQuantity]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Modal
|
<Modal
|
||||||
@@ -583,14 +602,9 @@ const TransferToLayingFormModal = () => {
|
|||||||
k.kandang.value === item.project_flock_kandang_id
|
k.kandang.value === item.project_flock_kandang_id
|
||||||
);
|
);
|
||||||
|
|
||||||
const flockSourceKandangCheckboxChangeHandler: FormEventHandler<
|
const flockSourceKandangRadioChangeHandler = () => {
|
||||||
HTMLInputElement
|
if (isAvailable) {
|
||||||
> = (e) => {
|
|
||||||
const checked = (e.target as HTMLInputElement)
|
|
||||||
.checked;
|
|
||||||
if (checked) {
|
|
||||||
formik.setFieldValue('flockSourceKandangs', [
|
formik.setFieldValue('flockSourceKandangs', [
|
||||||
...formik.values.flockSourceKandangs,
|
|
||||||
{
|
{
|
||||||
kandang: {
|
kandang: {
|
||||||
value: item.project_flock_kandang_id,
|
value: item.project_flock_kandang_id,
|
||||||
@@ -600,15 +614,7 @@ const TransferToLayingFormModal = () => {
|
|||||||
maxQuantity: item.available_qty,
|
maxQuantity: item.available_qty,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
} else {
|
setMaxSourceQuantity(item.available_qty);
|
||||||
formik.setFieldValue(
|
|
||||||
'flockSourceKandangs',
|
|
||||||
formik.values.flockSourceKandangs.filter(
|
|
||||||
(k) =>
|
|
||||||
k.kandang.value !==
|
|
||||||
item.project_flock_kandang_id
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -618,28 +624,22 @@ const TransferToLayingFormModal = () => {
|
|||||||
className='w-full p-3 flex flex-row items-center justify-between'
|
className='w-full p-3 flex flex-row items-center justify-between'
|
||||||
>
|
>
|
||||||
<div className='flex flex-row items-center gap-3'>
|
<div className='flex flex-row items-center gap-3'>
|
||||||
<CheckboxInput
|
<input
|
||||||
name={`flockSourceKandang.${itemIdx}.value`}
|
type='radio'
|
||||||
|
name='flockSourceKandang'
|
||||||
value={item.project_flock_kandang_id}
|
value={item.project_flock_kandang_id}
|
||||||
checked={isChecked}
|
checked={isChecked}
|
||||||
onChange={
|
onChange={flockSourceKandangRadioChangeHandler}
|
||||||
flockSourceKandangCheckboxChangeHandler
|
|
||||||
}
|
|
||||||
size='md'
|
|
||||||
disabled={!isAvailable}
|
disabled={!isAvailable}
|
||||||
classNames={{
|
className={cn('radio radio-md radio-primary', {
|
||||||
checkbox: cn({
|
'opacity-50 cursor-not-allowed': !isAvailable,
|
||||||
'bg-base-200 border border-base-content/10 opacity-100':
|
})}
|
||||||
!isAvailable,
|
|
||||||
}),
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<label
|
<label
|
||||||
htmlFor={`flockSourceKandang.${itemIdx}.value`}
|
|
||||||
className={cn('text-sm text-base-content/50', {
|
className={cn('text-sm text-base-content/50', {
|
||||||
'cursor-pointer': isAvailable,
|
'cursor-pointer': isAvailable,
|
||||||
'cursor-not-allowed': !isAvailable,
|
'cursor-not-allowed opacity-50': !isAvailable,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{item.kandang_name}{' '}
|
{item.kandang_name}{' '}
|
||||||
@@ -858,7 +858,7 @@ const TransferToLayingFormModal = () => {
|
|||||||
<NumberInput
|
<NumberInput
|
||||||
key={`flockSourceKandangs-${item.kandang.value}-${index}`}
|
key={`flockSourceKandangs-${item.kandang.value}-${index}`}
|
||||||
name={`flockSourceKandangs.${index}.quantity`}
|
name={`flockSourceKandangs.${index}.quantity`}
|
||||||
placeholder='Masukkan Kuantitas'
|
placeholder='Masukkan Kuantitas pada Kandang Tujuan'
|
||||||
value={item.quantity}
|
value={item.quantity}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
isError={isInvalid}
|
isError={isInvalid}
|
||||||
@@ -875,6 +875,8 @@ const TransferToLayingFormModal = () => {
|
|||||||
<div className='w-px bg-base-content/10' />
|
<div className='w-px bg-base-content/10' />
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
readOnly
|
||||||
|
disabled
|
||||||
className={{
|
className={{
|
||||||
inputPrefix:
|
inputPrefix:
|
||||||
'py-0 px-0 pl-3 text-base-content/50 bg-transparent border-r-0',
|
'py-0 px-0 pl-3 text-base-content/50 bg-transparent border-r-0',
|
||||||
@@ -1000,7 +1002,7 @@ const TransferToLayingFormModal = () => {
|
|||||||
isError={totalAvailableChickenForTransfer < 0}
|
isError={totalAvailableChickenForTransfer < 0}
|
||||||
errorMessage={
|
errorMessage={
|
||||||
totalAvailableChickenForTransfer < 0
|
totalAvailableChickenForTransfer < 0
|
||||||
? `Jumlah transfer melebihi ketersediaan (${formatNumber(totalEnteredChickenForTransfer, 'en-US')} ayam)`
|
? `Jumlah transfer melebihi ketersediaan (${formatNumber(maxSourceQuantity, 'en-US')} ayam)`
|
||||||
: ''
|
: ''
|
||||||
}
|
}
|
||||||
disabled
|
disabled
|
||||||
|
|||||||
@@ -48,11 +48,11 @@ const RowOptionsMenu = ({
|
|||||||
popoverPosition: 'bottom' | 'top';
|
popoverPosition: 'bottom' | 'top';
|
||||||
deleteClickHandler: () => void;
|
deleteClickHandler: () => void;
|
||||||
}) => {
|
}) => {
|
||||||
const showEditButton =
|
const showEditButton = props.row.original.approval.action !== 'APPROVED';
|
||||||
props.row.original.approval.action !== 'APPROVED' &&
|
|
||||||
props.row.original.approval.action !== 'REJECTED';
|
|
||||||
|
|
||||||
const showDeleteButton = showEditButton;
|
const showDeleteButton =
|
||||||
|
props.row.original.approval.action === 'APPROVED' ||
|
||||||
|
props.row.original.approval.step_name.toLowerCase() === 'pengajuan';
|
||||||
|
|
||||||
const popoverId = `transferToLaying#${props.row.original.id}`;
|
const popoverId = `transferToLaying#${props.row.original.id}`;
|
||||||
const popoverAnchorName = `--anchor-transferToLaying#${props.row.original.id}`;
|
const popoverAnchorName = `--anchor-transferToLaying#${props.row.original.id}`;
|
||||||
|
|||||||
@@ -4,13 +4,16 @@ import { create } from 'zustand';
|
|||||||
import { devtools } from 'zustand/middleware';
|
import { devtools } from 'zustand/middleware';
|
||||||
import { createChickinApprovalSlice } from '@/stores/production/chickin/slices/chickin-approval.slice';
|
import { createChickinApprovalSlice } from '@/stores/production/chickin/slices/chickin-approval.slice';
|
||||||
import { ChickinApprovalSlice } from '@/stores/production/chickin/slices/chickin-approval.slice';
|
import { ChickinApprovalSlice } from '@/stores/production/chickin/slices/chickin-approval.slice';
|
||||||
|
import { createChickinDeleteSlice } from '@/stores/production/chickin/slices/chickin-delete.slice';
|
||||||
|
import { ChickinDeleteSlice } from '@/stores/production/chickin/slices/chickin-delete.slice';
|
||||||
|
|
||||||
export type ChickinStore = ChickinApprovalSlice;
|
export type ChickinStore = ChickinApprovalSlice & ChickinDeleteSlice;
|
||||||
|
|
||||||
export const useChickinStore = create<ChickinStore>()(
|
export const useChickinStore = create<ChickinStore>()(
|
||||||
devtools(
|
devtools(
|
||||||
(...args) => ({
|
(...args) => ({
|
||||||
...createChickinApprovalSlice(...args),
|
...createChickinApprovalSlice(...args),
|
||||||
|
...createChickinDeleteSlice(...args),
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
name: 'ChickinStore',
|
name: 'ChickinStore',
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import { StateCreator } from 'zustand';
|
||||||
|
|
||||||
|
export type ChickinDeleteSlice = {
|
||||||
|
// State
|
||||||
|
isChickinDeleteModalOpen: boolean;
|
||||||
|
selectedChickinIdForDelete: number | null;
|
||||||
|
isChickinDeleteLoading: boolean;
|
||||||
|
chickinDeleteCallback: (() => Promise<void>) | null;
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
openChickinDeleteModal: (
|
||||||
|
chickinId: number,
|
||||||
|
callback: () => Promise<void>
|
||||||
|
) => void;
|
||||||
|
closeChickinDeleteModal: () => void;
|
||||||
|
setChickinDeleteLoading: (loading: boolean) => void;
|
||||||
|
resetChickinDelete: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const createChickinDeleteSlice: StateCreator<
|
||||||
|
ChickinDeleteSlice,
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
ChickinDeleteSlice
|
||||||
|
> = (set) => ({
|
||||||
|
// Initial state
|
||||||
|
isChickinDeleteModalOpen: false,
|
||||||
|
selectedChickinIdForDelete: null,
|
||||||
|
isChickinDeleteLoading: false,
|
||||||
|
chickinDeleteCallback: null,
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
openChickinDeleteModal: (chickinId, callback) =>
|
||||||
|
set({
|
||||||
|
isChickinDeleteModalOpen: true,
|
||||||
|
selectedChickinIdForDelete: chickinId,
|
||||||
|
chickinDeleteCallback: callback,
|
||||||
|
}),
|
||||||
|
|
||||||
|
closeChickinDeleteModal: () =>
|
||||||
|
set({
|
||||||
|
isChickinDeleteModalOpen: false,
|
||||||
|
selectedChickinIdForDelete: null,
|
||||||
|
chickinDeleteCallback: null,
|
||||||
|
}),
|
||||||
|
|
||||||
|
setChickinDeleteLoading: (loading) =>
|
||||||
|
set({ isChickinDeleteLoading: loading }),
|
||||||
|
|
||||||
|
resetChickinDelete: () =>
|
||||||
|
set({
|
||||||
|
isChickinDeleteModalOpen: false,
|
||||||
|
selectedChickinIdForDelete: null,
|
||||||
|
isChickinDeleteLoading: false,
|
||||||
|
chickinDeleteCallback: null,
|
||||||
|
}),
|
||||||
|
});
|
||||||
+1
@@ -49,6 +49,7 @@ export type BaseRecording = {
|
|||||||
project_flock: ProjectFlock;
|
project_flock: ProjectFlock;
|
||||||
record_datetime: string;
|
record_datetime: string;
|
||||||
day: number;
|
day: number;
|
||||||
|
executed_at: string;
|
||||||
} & ProductionMetrics;
|
} & ProductionMetrics;
|
||||||
|
|
||||||
export type RecordingDepletion = {
|
export type RecordingDepletion = {
|
||||||
|
|||||||
Reference in New Issue
Block a user