+
+ Informasi Kandang
+
{/* Badge Row */}
-
- {' '}
- Aktif
-
+
-
-
- {` Kapasitas ${formatNumber(initialValues.kandang.capacity)} Ekor`}
-
+ text={` Kapasitas ${formatNumber(initialValues.kandang.capacity)} Ekor`}
+ className={{ badge: 'w-fit text-nowrap' }}
+ />
- {/* Information Grid */}
-
- {/* Area */}
-
-
Area
+ {/* Information Card */}
+
+
+
+
+ {' '}
+ Area
+
+
+ {initialValues.project_flock.area.name}
+
+
+
+
+ {' '}
+ Lokasi
+
+
+ {initialValues.project_flock?.location.name}
+
+
+
+
+ {' '}
+ Kandang
+
+
+ {initialValues.kandang.name}
+
+
+
+
+ {' '}
+ Jumlah DOC
+
+
+ {formatNumber(
+ initialValues.chickins?.reduce(
+ (total, chickin) => total + chickin.usage_qty,
+ 0
+ ) ?? 0
+ )}{' '}
+ Ekor
+
+
-
- {initialValues.project_flock.area.name}
-
-
- {/* Lokasi */}
-
- Lokasi
-
-
- {initialValues.project_flock?.location.name}
-
-
- {/* Kandang */}
-
- Kandang
-
- {initialValues.kandang.name}
-
- {/* Jumlah DOC */}
-
- Jumlah DOC
-
-
- {formatNumber(
- initialValues.chickins?.reduce(
- (total, chickin) => total + chickin.usage_qty,
- 0
- ) ?? 0
- )}{' '}
- Ekor
-
-
+
-
-
-
Informasi Chick In
+ {/* Informasi Chick In */}
+
+
+ Informasi Chick In
+
{/* Badge Row */}
-
- {' '}
- Perlu Chick In ({initialValues.available_qtys?.length ?? 0})
-
+
-
setOpenChickin(!openChickin)}
- >
- {`Riwayat Chick In ${formatNumber(initialValues.chickins?.length ?? 0)}`}
-
-
+ text={
+ <>
+ {`Riwayat Chick In ${formatNumber(initialValues.chickins?.length ?? 0)}`}
+
+ >
+ }
+ className={{ badge: 'w-fit text-nowrap cursor-pointer' }}
+ />
{openChickin && (
@@ -198,7 +190,7 @@ const ChickinFormKandang = ({
afterSubmit={afterSubmitFormChickin}
/>
-
+
);
};
diff --git a/src/components/pages/production/project-flock/closing/ProjectFlockClosingForm.tsx b/src/components/pages/production/project-flock/closing/ProjectFlockClosingForm.tsx
index aab21172..f963a793 100644
--- a/src/components/pages/production/project-flock/closing/ProjectFlockClosingForm.tsx
+++ b/src/components/pages/production/project-flock/closing/ProjectFlockClosingForm.tsx
@@ -1,10 +1,12 @@
'use client';
import Button from '@/components/Button';
+import Card from '@/components/Card';
import DrawerHeader from '@/components/helper/drawer/DrawerHeader';
import Table from '@/components/Table';
import Badge from '@/components/Badge';
-import { cn, formatDate, formatNumber, formatTitleCase } from '@/lib/helper';
+import StatusBadge from '@/components/helper/StatusBadge';
+import { formatDate, formatNumber, formatTitleCase } from '@/lib/helper';
import { ProjectFlock } from '@/types/api/production/project-flock';
import {
ClosingExpense,
@@ -20,9 +22,28 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal';
import { useMemo, useState } from 'react';
import toast from 'react-hot-toast';
import { useRouter } from 'next/navigation';
-import { ProductWarehouse } from '@/types/api/inventory/product-warehouse';
import { ApprovalApi } from '@/services/api/approval';
import RequirePermission from '@/components/helper/RequirePermission';
+import { Color } from '@/types/theme';
+
+const getExpenseStatusBadgeColor = (step: number): Color => {
+ switch (step) {
+ case 1:
+ return 'neutral';
+ case 2:
+ return 'info';
+ case 3:
+ return 'warning';
+ case 4:
+ return 'error';
+ case 5:
+ return 'warning';
+ case 6:
+ return 'success';
+ default:
+ return 'neutral';
+ }
+};
const ProjectFlockClosingForm = ({
projectFlock,
@@ -49,6 +70,10 @@ const ProjectFlockClosingForm = ({
)
);
+ const isKandangClosed = useMemo(() => {
+ return projectFlockKandang.kandang?.status === 'NON_ACTIVE';
+ }, [projectFlockKandang]);
+
const isCanClose = useMemo(() => {
return isResponseSuccess(projectFlockKandangApprovals)
? projectFlockKandangApprovals?.data?.[0]?.step_number <= 2
@@ -60,8 +85,10 @@ const ProjectFlockClosingForm = ({
const deleteProjectFlockRes = await ProjectFlockKandangApi.closing(
projectFlockKandang?.id as number,
{
- closed_date: isCanClose ? formatDate(new Date(), 'YYYY-MM-DD') : '',
- action: isCanClose ? 'close' : 'unclose',
+ closed_date: !isKandangClosed
+ ? formatDate(new Date(), 'YYYY-MM-DD')
+ : '',
+ action: !isKandangClosed ? 'close' : 'unclose',
}
);
@@ -78,160 +105,167 @@ const ProjectFlockClosingForm = ({
closeModal.closeModal();
};
- const errorStock = useMemo(() => {
- return isResponseSuccess(closingData)
- ? closingData?.data?.stock_remaining.every((stock) => stock.quantity > 0)
- : true;
- }, [closingData]);
+ // const errorStock = useMemo(() => {
+ // return isResponseSuccess(closingData)
+ // ? closingData?.data?.stock_remaining.every((stock) => stock.quantity > 0)
+ // : true;
+ // }, [closingData]);
- const errorExpense = useMemo(() => {
- return isResponseSuccess(closingData)
- ? closingData?.data?.expenses.every((expense) => expense.step < 5)
- : true;
- }, [closingData]);
+ // const errorExpense = useMemo(() => {
+ // return isResponseSuccess(closingData)
+ // ? closingData?.data?.expenses.every((expense) => expense.step < 5)
+ // : true;
+ // }, [closingData]);
const isCanCloseValid = true;
return (
<>
-
+
+ {/* Header */}
+ leftIconClassName='hover:text-gray-400'
+ subtitle={isKandangClosed ? 'Unclose Flock' : 'Close Flock'}
+ className='sticky top-0 z-10 bg-base-100'
+ />
{/* Informasi Kandang */}
-
-
-
Informasi Kandang
+
+
+ Informasi Kandang
+
{/* Badge Row */}
-
- {' '}
- Aktif
-
+
-
-
- {` Kapasitas ${formatNumber(projectFlockKandang.kandang?.capacity)} Ekor`}
-
+ text={` Kapasitas ${formatNumber(projectFlockKandang.kandang?.capacity)} Ekor`}
+ className={{ badge: 'w-fit text-nowrap' }}
+ />
- {/* Information Grid */}
-
- {/* Area */}
-
-
Area
+ {/* Information Card */}
+
+
+
+
+ {' '}
+ Area
+
+
+ {projectFlock.area?.name}
+
+
+
+
+ {' '}
+ Lokasi
+
+
+ {projectFlock.location?.name}
+
+
+
+
+ {' '}
+ Kandang
+
+
+ {projectFlockKandang.kandang?.name}
+
+
+
+
+ {' '}
+ Jumlah DOC
+
+
+ {formatNumber(
+ projectFlockKandang.chickins?.reduce(
+ (total, chickin) => total + chickin.usage_qty,
+ 0
+ ) ?? 0
+ )}{' '}
+ Ekor
+
+
- {projectFlock.area?.name}
-
- {/* Lokasi */}
-
- Lokasi
-
- {projectFlock.location?.name}
-
- {/* Kandang */}
-
- Kandang
-
-
- {projectFlockKandang.kandang?.name}
-
-
- {/* Jumlah DOC */}
-
- Jumlah
- DOC
-
-
- {formatNumber(
- projectFlockKandang.chickins?.reduce(
- (total, chickin) => total + chickin.usage_qty,
- 0
- ) ?? 0
- )}{' '}
- Ekor
-
-
+
{/* Table Biaya */}
-
-
-
Biaya
+
+
+ Biaya
+
data={
isResponseSuccess(closingData) ? closingData.data?.expenses : []
}
columns={[
+ {
+ header: 'Ref Number',
+ accessorKey: 'reference_number',
+ cell(props) {
+ return props.row.original.reference_number || '-';
+ },
+ },
{
header: 'PO Number',
accessorKey: 'po_number',
+ cell(props) {
+ return props.row.original.po_number || '-';
+ },
},
{
header: 'Total',
accessorKey: 'total',
+ cell(props) {
+ return formatNumber(props.row.original.total);
+ },
},
{
header: 'Status',
accessorKey: 'status',
cell(props) {
return (
-
- {formatTitleCase(props.row.original.step_name)}
-
+ />
);
},
},
]}
className={{
- containerClassName: cn('my-4'),
- tableWrapperClassName: 'overflow-x-auto min-h-full! max-w-120',
- tableClassName: 'font-inter w-full table-sm min-h-full!',
- headerRowClassName: 'border-b border-b-gray-200',
+ containerClassName: 'mb-0',
+ tableWrapperClassName: 'overflow-x-auto max-w-120',
+ tableClassName: 'font-inter w-full table-sm',
+ headerRowClassName: 'border-b border-base-content/10',
headerColumnClassName:
'px-3 py-3 text-xs font-semibold text-gray-500 last:flex last:flex-row last:justify-end',
- bodyRowClassName: 'border-b border-b-gray-200',
+ bodyRowClassName: 'border-b border-base-content/10',
bodyColumnClassName:
'px-3 py-3 last:flex last:flex-row last:justify-end',
- paginationClassName: 'hidden',
}}
/>
{/* {errorExpense && (
@@ -242,9 +276,10 @@ const ProjectFlockClosingForm = ({
{/* Table Persediaan Gudang */}
-
-
-
Persediaan Gudang
+
+
+ Persediaan Gudang
+
data={
isResponseSuccess(closingData)
@@ -263,6 +298,9 @@ const ProjectFlockClosingForm = ({
{
header: 'Quantity',
accessorKey: 'quantity',
+ cell(props) {
+ return formatNumber(props.row.original.quantity);
+ },
},
{
header: 'UOM',
@@ -270,16 +308,15 @@ const ProjectFlockClosingForm = ({
},
]}
className={{
- containerClassName: cn('my-4'),
- tableWrapperClassName: 'overflow-x-auto min-h-full! max-w-120',
- tableClassName: 'font-inter w-full table-sm min-h-full!',
- headerRowClassName: 'border-b border-b-gray-200',
+ containerClassName: 'mb-0',
+ tableWrapperClassName: 'overflow-x-auto max-w-120',
+ tableClassName: 'font-inter w-full table-sm',
+ headerRowClassName: 'border-b border-base-content/10',
headerColumnClassName:
'px-3 py-3 text-xs font-semibold text-gray-500 last:flex last:flex-row last:justify-end',
- bodyRowClassName: 'border-b border-b-gray-200',
+ bodyRowClassName: 'border-b border-base-content/10',
bodyColumnClassName:
'px-3 py-3 last:flex last:flex-row last:justify-end',
- paginationClassName: 'hidden',
}}
/>
{/* {errorStock && (
@@ -289,17 +326,24 @@ const ProjectFlockClosingForm = ({
)} */}
-
+
closeModal.openModal()}
>
- {' '}
- {isCanClose ? 'Close' : 'Unclose'}
+ {' '}
+ {isKandangClosed ? 'Unclose' : 'Close'}
@@ -308,7 +352,7 @@ const ProjectFlockClosingForm = ({
ref={closeModal.ref}
type='error'
text={
- isCanClose
+ !isKandangClosed
? 'Apakah kamu yakin ingin mengakhiri project ini ? *Pastikan persediaan produk di gudang terkait sudah kosong, dan BOP sudah selesai'
: 'Apakah kamu yakin ingin membuka kembali project ini ? *Project ini akan kembali ke status aktif'
}
@@ -322,7 +366,7 @@ const ProjectFlockClosingForm = ({
onClick: confirmationModalCloseClickHandler,
}}
/>
-
+
>
);
};
diff --git a/src/components/pages/production/project-flock/detail/ProjectFlockDetail.tsx b/src/components/pages/production/project-flock/detail/ProjectFlockDetail.tsx
index 47491dfa..db3d45aa 100644
--- a/src/components/pages/production/project-flock/detail/ProjectFlockDetail.tsx
+++ b/src/components/pages/production/project-flock/detail/ProjectFlockDetail.tsx
@@ -226,15 +226,37 @@ const ProjectFlockDetail = ({
- Kandang Aktif
+ Kandang
-
-
+
+ {projectFlock.kandangs?.filter(
+ (kandang) => kandang.status !== 'NON_ACTIVE'
+ ).length > 0 && (
+ kandang.status !== 'NON_ACTIVE'
+ ).length ?? 0
+ })`}
+ className={{ badge: 'w-fit' }}
+ />
+ )}
+
+ {projectFlock.kandangs?.filter(
+ (kandang) => kandang.status === 'NON_ACTIVE'
+ ).length > 0 && (
+ kandang.status === 'NON_ACTIVE'
+ ).length ?? 0
+ })`}
+ className={{ badge: 'w-fit' }}
+ />
+ )}
>
}
- className={{ badge: 'w-fit text-nowrap cursor-pointer' }}
+ className={{ badge: 'w-fit cursor-pointer' }}
/>
@@ -355,43 +377,53 @@ const ProjectFlockDetail = ({
disabled={projectFlock?.approval?.step_number == 1}
/>
-
- Kapasitas {kandang?.capacity} Ekor
-
+ Kapasitas {kandang?.capacity} Ekor>}
+ className={{ badge: 'w-fit text-nowrap' }}
+ />
))}
-
+
-
-
-
-
+ {selectedKandang?.status !== 'NON_ACTIVE' && (
+
+
- Chickin
-
-
-
+
+ Chickin
+
+
+
+ )}
- Close
+ {selectedKandang?.status === 'NON_ACTIVE' ? (
+ <>
+ Unclose
+ >
+ ) : (
+ <>
+ Close
+ >
+ )}