(null);
// Flock Source
@@ -133,6 +141,7 @@ const TransferToLayingFormModal = () => {
toast.success(createTransferToLayingRes?.message as string);
router.push('/production/transfer-to-laying');
closeModalHandler(false);
+ successModal.openModal();
},
[router]
);
@@ -156,6 +165,7 @@ const TransferToLayingFormModal = () => {
toast.success(updateKandangRes?.message as string);
router.push('/production/transfer-to-laying');
closeModalHandler(false);
+ successModal.openModal();
},
[router]
);
@@ -187,6 +197,8 @@ const TransferToLayingFormModal = () => {
reason: values.reason as string,
};
+ setFormikLastValues(values);
+
switch (modalAction) {
case 'add':
await createTransferToLayingHandler(transferToLayingPayload);
@@ -244,7 +256,7 @@ const TransferToLayingFormModal = () => {
? selectedFlockSourceRawData.kandangs.map((kandang) => {
const availability =
flockSourceKandangsAvailability[kandang.project_flock_kandang_id]
- .available_qty;
+ ?.available_qty;
return {
kandang_name: kandang.name,
@@ -375,6 +387,12 @@ const TransferToLayingFormModal = () => {
formik.setValues(filledInitialValues);
setStep(3);
}
+
+ if (isResponseError(transferToLaying)) {
+ router.push('/production/transfer-to-laying');
+ closeModalHandler();
+ toast.error(transferToLaying.message);
+ }
};
const getFlockSourceData = async () => {
@@ -437,7 +455,7 @@ const TransferToLayingFormModal = () => {
- Add Transfer to Laying
+ {modalAction === 'add' ? 'Add' : 'Edit'} Transfer to Laying
@@ -771,7 +789,12 @@ const TransferToLayingFormModal = () => {
{formik.values.flockSourceKandangs.map((item, index) => {
const isInvalid =
- item.quantity === ''
+ !Boolean(
+ getIn(
+ formik.touched,
+ `flockSourceKandangs[${index}].quantity`
+ )
+ ) && item.quantity === ''
? false
: Boolean(
getIn(
@@ -833,7 +856,8 @@ const TransferToLayingFormModal = () => {
: 'neutral'
}
text={`Sisa transfer: ${formatNumber(
- totalAvailableChickenForTransfer
+ totalAvailableChickenForTransfer,
+ 'en-US'
)} ekor`}
className={{
badge: 'text-nowrap',
@@ -852,7 +876,12 @@ const TransferToLayingFormModal = () => {
{formik.values.flockDestinationKandangs.map(
(item, index) => {
const isInvalid =
- item.quantity === ''
+ !Boolean(
+ getIn(
+ formik.touched,
+ `flockDestinationKandangs.${index}.quantity`
+ )
+ ) && item.quantity === ''
? false
: Boolean(
getIn(
@@ -968,6 +997,16 @@ const TransferToLayingFormModal = () => {
)}
+
+ setFormikLastValues(undefined)}
+ secondaryButton={undefined}
+ />
>
);
};
diff --git a/src/components/pages/production/transfer-to-laying/TransferToLayingsTable.tsx b/src/components/pages/production/transfer-to-laying/TransferToLayingsTable.tsx
index 63f30109..4cdb4a60 100644
--- a/src/components/pages/production/transfer-to-laying/TransferToLayingsTable.tsx
+++ b/src/components/pages/production/transfer-to-laying/TransferToLayingsTable.tsx
@@ -14,9 +14,7 @@ import { Icon } from '@iconify/react';
import Table from '@/components/Table';
import Button from '@/components/Button';
import { useModal } from '@/components/Modal';
-import ConfirmationModal from '@/components/modal/ConfirmationModal';
import CheckboxInput from '@/components/input/CheckboxInput';
-import ConfirmationModalWithNotes from '@/components/modal/ConfirmationModalWithNotes';
import RequirePermission from '@/components/helper/RequirePermission';
import PopoverButton from '@/components/popover/PopoverButton';
import Badge from '@/components/Badge';
@@ -24,13 +22,14 @@ import PopoverContent from '@/components/popover/PopoverContent';
import Dropdown from '@/components/Dropdown';
import StatusBadge from '@/components/helper/StatusBadge';
import TransferToLayingFilterModal from '@/components/pages/production/transfer-to-laying/TransferToLayingFilterModal';
+import TransferToLayingConfirmationModal from '@/components/pages/production/transfer-to-laying/TransferToLayingConfirmationModal';
import {
TransferToLaying,
TransferToLayingFilter,
} from '@/types/api/production/transfer-to-laying';
import { TransferToLayingApi } from '@/services/api/production/transfer-to-laying';
-import { cn, formatDate } from '@/lib/helper';
+import { cn, formatDate, formatNumber } from '@/lib/helper';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { useTableFilter } from '@/services/hooks/useTableFilter';
import { Color } from '@/types/theme';
@@ -38,14 +37,11 @@ import { Color } from '@/types/theme';
const RowOptionsMenu = ({
props,
popoverPosition = 'bottom',
- approveClickHandler,
- rejectClickHandler,
+
deleteClickHandler,
}: {
props: CellContext;
popoverPosition: 'bottom' | 'top';
- approveClickHandler: () => void;
- rejectClickHandler: () => void;
deleteClickHandler: () => void;
}) => {
const showEditButton =
@@ -54,9 +50,6 @@ const RowOptionsMenu = ({
const showDeleteButton = showEditButton;
- // const showApproveButton = showEditButton;
- // const showRejectButton = showEditButton;
-
const popoverId = `transferToLaying#${props.row.original.id}`;
const popoverAnchorName = `--anchor-transferToLaying#${props.row.original.id}`;
@@ -260,7 +253,14 @@ const TransferToLayingsTable = () => {
{
accessorKey: 'usage_qty',
header: 'Kuantitas',
- cell: (props) => props.getValue() ?? props.row.original.pending_usage_qty,
+ cell: (props) => {
+ const totalQuantity = props.row.original.targets.reduce(
+ (total, target) => total + target.qty,
+ 0
+ );
+
+ return formatNumber(totalQuantity, 'en-US');
+ },
},
{
accessorKey: 'notes',
@@ -304,38 +304,20 @@ const TransferToLayingsTable = () => {
const isLast2Rows = currentRowRelativeIndex > currentPageSize - 2;
- const approveClickHandler = () => {
- setSelectedTransferToLaying(props.row.original);
-
- // Set row selection
- setRowSelection({
- [String(props.row.original.id)]: true,
- });
-
- approveModal.openModal();
- };
-
- const rejectClickHandler = () => {
- setSelectedTransferToLaying(props.row.original);
-
- // Set row selection
- setRowSelection({
- [String(props.row.original.id)]: true,
- });
-
- rejectModal.openModal();
- };
-
const deleteClickHandler = () => {
setSelectedTransferToLaying(props.row.original);
+
+ // Set row selection
+ setRowSelection({
+ [String(props.row.original.id)]: true,
+ });
+
deleteModal.openModal();
};
return (
@@ -377,6 +359,8 @@ const TransferToLayingsTable = () => {
refreshTransferToLayings();
+ setRowSelection({});
+ setSelectedTransferToLaying(undefined);
deleteModal.closeModal();
toast.success('Berhasil menghapus data transfer ke laying!');
setIsDeleteLoading(false);
@@ -646,53 +630,70 @@ const TransferToLayingsTable = () => {
onReset={filterResetHandler}
/>
- {
+ setRowSelection({});
+ deleteModal.closeModal();
+ },
}}
/>
-
-
- {
+ setRowSelection({});
+ approveModal.closeModal();
+ },
+ }}
+ />
+
+ {/* Reject Modal */}
+ {
+ setRowSelection({});
+ rejectModal.closeModal();
+ },
}}
primaryButton={{
- text: 'Reject',
- color: 'error',
isLoading: isRejectLoading,
+ color: 'error',
onClick: confirmationModalRejectClickHandler,
}}
/>
diff --git a/src/figma-make/components/pages/daily-checklist/DailyChecklistContent.tsx b/src/figma-make/components/pages/daily-checklist/DailyChecklistContent.tsx
index 9b2b6bf2..43a913ed 100644
--- a/src/figma-make/components/pages/daily-checklist/DailyChecklistContent.tsx
+++ b/src/figma-make/components/pages/daily-checklist/DailyChecklistContent.tsx
@@ -312,6 +312,7 @@ export function DailyChecklistContent() {
try {
const activitiesRes = await PhaseActivityApi.getAll({
phase_ids: selectedPhaseIds.join(','),
+ limit: '100',
});
if (isResponseError(activitiesRes)) {