(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/components/pages/production/uniformity/form/UniformityForm.tsx b/src/components/pages/production/uniformity/form/UniformityForm.tsx
index d7013520..e6b0657d 100644
--- a/src/components/pages/production/uniformity/form/UniformityForm.tsx
+++ b/src/components/pages/production/uniformity/form/UniformityForm.tsx
@@ -399,23 +399,58 @@ const UniformityForm = ({
// ===== SIDE EFFECTS =====
useEffect(() => {
if (
+ projectFlockKandangLookup?.chick_in_date &&
projectFlockKandangLookup?.project_flock_kandang_id &&
isResponseSuccess(recordingsData) &&
recordingsData.data
) {
- const matchingRecording = recordingsData.data.find(
+ const matchingRecordings = recordingsData.data.filter(
(recording: Recording) =>
recording.project_flock?.project_flock_kandang_id ===
projectFlockKandangLookup.project_flock_kandang_id
);
- if (matchingRecording?.project_flock?.production_standart?.week) {
- const weekValue =
- matchingRecording.project_flock.production_standart.week;
- formik.setFieldValue('week', weekValue);
+ matchingRecordings.sort(
+ (a: Recording, b: Recording) =>
+ new Date(a.record_datetime).getTime() -
+ new Date(b.record_datetime).getTime()
+ );
+
+ const earliestRecording = matchingRecordings[0];
+
+ if (earliestRecording) {
+ const chickInDate = new Date(projectFlockKandangLookup.chick_in_date);
+ chickInDate.setHours(0, 0, 0, 0);
+
+ const earliestRecordDate = new Date(earliestRecording.record_datetime);
+ earliestRecordDate.setHours(0, 0, 0, 0);
+
+ const initialWeek =
+ earliestRecording.project_flock?.production_standart?.week || 18;
+
+ if (formik.values.date) {
+ const selectedDate = new Date(formik.values.date);
+ selectedDate.setHours(0, 0, 0, 0);
+
+ const daysDiff = Math.floor(
+ (selectedDate.getTime() - chickInDate.getTime()) /
+ (1000 * 60 * 60 * 24)
+ );
+
+ const weeksDiff = Math.floor(daysDiff / 7);
+
+ formik.setFieldValue('week', initialWeek + weeksDiff);
+ } else {
+ formik.setFieldValue('week', initialWeek);
+ }
}
}
- }, [projectFlockKandangLookup?.project_flock_kandang_id, recordingsData]);
+ }, [
+ projectFlockKandangLookup?.chick_in_date,
+ projectFlockKandangLookup?.project_flock_kandang_id,
+ recordingsData,
+ formik.values.date,
+ ]);
useEffect(() => {
const unsub = subscribeValidate(() => {
diff --git a/src/config/constant.ts b/src/config/constant.ts
index eb271b9b..30af4b0a 100644
--- a/src/config/constant.ts
+++ b/src/config/constant.ts
@@ -389,6 +389,11 @@ export const FINANCE_INITIAL_BALANCE_TYPE_OPTIONS = [
{ label: 'Saldo Awal Negatif', value: 'NEGATIVE' },
];
+export const FINANCE_INJECTION_TYPE_OPTIONS = [
+ { label: 'Saldo Injection Positif', value: 'POSITIVE' },
+ { label: 'Saldo Injection Negatif', value: 'NEGATIVE' },
+];
+
export const FINANCE_TRANSACTION_TYPE_OPTIONS = [
{ label: 'Pembelian', value: 'PEMBELIAN' },
{ label: 'Penjualan', value: 'PENJUALAN' },
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)) {
diff --git a/src/services/api/production.ts b/src/services/api/production.ts
index 8e66d57e..d481081d 100644
--- a/src/services/api/production.ts
+++ b/src/services/api/production.ts
@@ -74,7 +74,8 @@ export class RecordingService extends BaseApiService<
}
async nextDayRecording(
- projectFlockId: number
+ projectFlockId: number,
+ recordDate?: string
): Promise | undefined> {
return await this.customRequest>(
`next-day`,
@@ -82,6 +83,7 @@ export class RecordingService extends BaseApiService<
method: 'GET',
params: {
project_flock_kandang_id: projectFlockId,
+ record_date: recordDate,
},
}
);
diff --git a/src/types/api/production/project-flock.d.ts b/src/types/api/production/project-flock.d.ts
index dcc1a348..d3a862d9 100644
--- a/src/types/api/production/project-flock.d.ts
+++ b/src/types/api/production/project-flock.d.ts
@@ -76,6 +76,7 @@ export type ProjectFlockKandangLookup = {
quantity: number;
available_quantity?: number;
population: number;
+ chick_in_date: string;
};
export type ProjectFlockAvailableQuantity = {