-
- {' '}
- Perlu Chick In ({initialValues.available_qtys?.length ?? 0})
-
-
+
+
+ {' '}
+ Perlu Chick In ({initialValues.available_qtys?.length ?? 0})
+
+
+
)}
-
+
+
+
>
);
};
diff --git a/src/components/pages/production/chickin/form/tabs/ChickLogsView.tsx b/src/components/pages/production/chickin/form/tabs/ChickLogsView.tsx
index 99eb1cb3..17c76822 100644
--- a/src/components/pages/production/chickin/form/tabs/ChickLogsView.tsx
+++ b/src/components/pages/production/chickin/form/tabs/ChickLogsView.tsx
@@ -1,6 +1,7 @@
import Alert from '@/components/Alert';
import Button from '@/components/Button';
import Card from '@/components/Card';
+import RequirePermission from '@/components/helper/RequirePermission';
import { useModal } from '@/components/Modal';
import ConfirmationModalWithNotes from '@/components/modal/ConfirmationModalWithNotes';
import PillBadge from '@/components/PillBadge';
@@ -146,14 +147,16 @@ const ChickinLogsView = ({
)}
{initialValues?.approval?.step_number <= 2 && (
-
+
+
+
)}
{chickinErrorMessage && (
diff --git a/src/components/pages/production/project-flock/ProjectFlockTable.tsx b/src/components/pages/production/project-flock/ProjectFlockTable.tsx
index b3aa69a0..233c43d7 100644
--- a/src/components/pages/production/project-flock/ProjectFlockTable.tsx
+++ b/src/components/pages/production/project-flock/ProjectFlockTable.tsx
@@ -307,32 +307,6 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
Tambah
- {/*
-
*/}
void }) => {
cell: (props) =>
formatDate(props.row.original.created_at, 'MMM DD, YYYY'),
},
- // {
- // header: 'Aksi',
- // cell: (props) => {
- // const currentPageSize =
- // props.table.getPaginationRowModel().rows.length;
- // const currentPageRows =
- // props.table.getPaginationRowModel().flatRows;
- // const currentRowRelativeIndex =
- // currentPageRows.findIndex((r) => r.id === props.row.id) + 1;
-
- // const isLast2Rows =
- // currentRowRelativeIndex > currentPageSize - 2;
-
- // const deleteClickHandler = () => {
- // setSelectedProjectFlock(props.row.original);
- // deleteModal.openModal();
- // };
-
- // return (
- // <>
- // {currentPageSize > 2 && (
- //
- //
- //
- // )}
-
- // {currentPageSize <= 2 && (
- //
- //
- //
- // )}
- // >
- // );
- // },
- // },
]}
pageSize={tableFilterState.pageSize}
page={
diff --git a/src/components/pages/production/project-flock/chickin/ProjectFlockChickinDetail.tsx b/src/components/pages/production/project-flock/chickin/ProjectFlockChickinDetail.tsx
deleted file mode 100644
index 087f0848..00000000
--- a/src/components/pages/production/project-flock/chickin/ProjectFlockChickinDetail.tsx
+++ /dev/null
@@ -1,643 +0,0 @@
-'use client';
-
-import Badge from '@/components/Badge';
-import Button from '@/components/Button';
-import Card from '@/components/Card';
-import SelectInput, {
- OptionType,
- useSelect,
-} from '@/components/input/SelectInput';
-import PillBadge from '@/components/PillBadge';
-import Table from '@/components/Table';
-import { isResponseSuccess } from '@/lib/api-helper';
-import { cn, formatDate, formatTitleCase } from '@/lib/helper';
-import { ProjectFlockApi } from '@/services/api/production/project-flock';
-import { ProjectFlockKandangApi } from '@/services/api/production';
-import { useTableFilter } from '@/services/hooks/useTableFilter';
-import { ProjectFlock } from '@/types/api/production/project-flock';
-import { ProjectFlockKandang } from '@/types/api/production/project-flock-kandang';
-import { Icon } from '@iconify/react';
-import { useRouter } from 'next/navigation';
-import { useEffect, useState } from 'react';
-import useSWR from 'swr';
-import { FormHeader } from '@/components/helper/form/FormHeader';
-import Link from 'next/link';
-import RequirePermission from '@/components/helper/RequirePermission';
-
-const ProjectFlockChickinDetail = ({
- projectFlockId,
-}: {
- projectFlockId: number | undefined;
-}) => {
- const router = useRouter();
-
- // Tables Props
- const { state: tableFilterState } = useTableFilter({
- initial: { search: '' },
- paramMap: { page: 'page', pageSize: 'limit' },
- });
-
- // States
- const [searchProjectFlock, setSearchProjectFlock] = useState('');
- const [selectedProjectFlock, setSelectedProjectFlock] =
- useState(null);
- const [projectFlock, setProjectFlock] = useState();
-
- // Fetch Data
- const { data: listProjectFlockKandang } = useSWR(
- `${ProjectFlockKandangApi.basePath}?${new URLSearchParams({
- search: searchProjectFlock,
- project_flock_id:
- projectFlock?.id?.toString() ?? projectFlockId?.toString() ?? '',
- }).toString()}`,
- ProjectFlockKandangApi.getAllFetcher
- );
-
- const {
- options: options,
- isLoadingOptions: isLoadingListProjectFlock,
- rawData: listProjectFlock,
- } = useSelect(
- ProjectFlockApi.basePath,
- 'id',
- 'flock_name',
- '',
- {
- search: searchProjectFlock,
- }
- );
-
- // Handle Function
- const handleChickinClick = async (
- projectFlockKandang: ProjectFlockKandang
- ) => {
- router.push(
- `/production/project-flock/chickin/add/kandang?projectFlockKandangId=${projectFlockKandang.id}&projectFlockId=${projectFlockId ?? selectedProjectFlock?.value}`
- );
- };
-
- const handleChangeProjectFlock = (val: OptionType | null) => {
- setSelectedProjectFlock(val);
- if (isResponseSuccess(listProjectFlock) && val) {
- const selected = listProjectFlock.data.find(
- (pf) => pf.id === Number(val.value)
- );
- setProjectFlock(selected);
- } else {
- setProjectFlock(undefined);
- }
- if (projectFlockId) {
- router.push('/production/project-flock/chickin/add');
- }
- if (!val && projectFlockId) {
- router.push('/production/project-flock/chickin/add');
- }
- };
-
- useEffect(() => {
- if (projectFlockId && isResponseSuccess(listProjectFlock)) {
- setProjectFlock(
- listProjectFlock.data.find((pf) => pf.id === Number(projectFlockId))
- );
- }
- }, [projectFlockId, listProjectFlock]);
- return (
- <>
- {/* Header */}
-
-
-
-
-
-
-
- Chick In {projectFlock?.flock_name}
-
-
-
- {/* */}
- {/*
-
- {
- setSearchProjectFlock(val);
- }}
- isLoading={isLoadingListProjectFlock}
- value={
- projectFlock
- ? {
- label: `${projectFlock?.flock_name}`,
- value: projectFlock?.id,
- }
- : null
- }
- onChange={(val) => {
- handleChangeProjectFlock(val as OptionType | null);
- }}
- isSearchable
- isClearable
- startAdornment={
- projectFlock && (
-
- Periode {projectFlock?.period}
-
- )
- }
- />
-
-
*/}
- {/* Informasi Umum */}
- {projectFlock && (
-
-
-
Informasi Umum
- {/* Badge Row */}
-
-
= 3
- ? 'error'
- : undefined
- }
- className={{
- badge: 'rounded-lg px-2',
- }}
- >
- = 3
- ? 'error'
- : undefined
- }
- />{' '}
- {projectFlock.approval.step_name}
-
-
-
-
- {` ${formatTitleCase(projectFlock.category)}`}
-
-
- {/* Information Grid */}
-
-
- Submitted
-
-
-
- {' '}
- {projectFlock.created_user.name}
-
-
-
-
- History
-
-
-
-
-
- {/* BARIS 1 */}
-
- Area
-
-
{projectFlock.area.name}
-
- {/* BARIS 2 */}
-
- Lokasi
-
-
{projectFlock.location.name}
-
-
- FCR
-
-
{projectFlock.fcr.name}
-
- {/* BARIS 3 (Terakhir - TIDAK PERLU garis di bawahnya) */}
-
- {' '}
- Kategori
-
-
- {formatTitleCase(projectFlock.category)}
-
-
-
-
- )}
- {/*
-
- emptyContent={
-
-
- Pilih project flock terlebih dahulu...
-
-
- }
- data={projectFlock ? [projectFlock] : []}
- columns={[
- {
- header: 'ID',
- accessorKey: 'id',
- },
- {
- header: 'Area',
- accessorKey: 'area.name',
- },
- {
- header: 'Lokasi',
- accessorKey: 'location.name',
- },
- {
- header: 'Nama Flock',
- accessorKey: 'flock_name',
- },
- {
- header: 'Kategori',
- accessorKey: 'category',
- },
- {
- header: 'Status',
- accessorKey: 'status',
- cell: (props) => {
- return props.row.original.approval?.step_name ? (
- {
- switch (
- props.row.original.approval?.step_name.toUpperCase()
- ) {
- case 'AKTIF':
- return 'red';
- case 'PENGAJUAN':
- return 'green';
- default:
- return 'gray';
- }
- })()}
- content={props.row.original.approval?.step_name
- .toLowerCase()
- .replace(/_/g, ' ')
- .replace(/\b\w/g, (char) => char.toUpperCase())}
- />
- ) : (
- '-'
- );
- },
- },
- {
- header: 'FCR Layer',
- accessorKey: 'fcr.name',
- },
- ]}
- page={undefined}
- className={{
- containerClassName: cn({
- 'mb-20': projectFlock && projectFlock.kandangs?.length === 0,
- }),
- tableWrapperClassName: 'overflow-x-auto min-h-full!',
- tableClassName: 'font-inter w-full table-auto min-h-full!',
- headerRowClassName: 'border-b border-b-gray-200',
- headerColumnClassName:
- 'px-6 py-3 text-xs font-semibold text-gray-500 last:flex last:flex-row last:justify-end',
- bodyRowClassName: 'border-b border-b-gray-200',
- bodyColumnClassName:
- 'px-6 py-3 last:flex last:flex-row last:justify-end',
- paginationClassName: 'hidden',
- }}
- />
- */}
- {/* Card Kandangs */}
-
-
-
Daftar Kandang
- {isResponseSuccess(listProjectFlock) ? (
- <>
- {/* Badge Row */}
-
-
- {' '}
- Disetujui (
- {isResponseSuccess(listProjectFlockKandang) &&
- listProjectFlockKandang.data.filter(
- (k) => k.approval?.step_number == 1
- ).length}
- )
-
-
-
- {' '}
- Pengajuan (
- {isResponseSuccess(listProjectFlockKandang) &&
- listProjectFlockKandang.data.filter(
- (k) => k.approval?.step_number == 2
- ).length}
- )
-
-
-
-
- Belum Chickin (
- {isResponseSuccess(listProjectFlockKandang) &&
- listProjectFlockKandang.data.filter(
- (k) => k.approval == null
- ).length}
- )
-
-
- {/* Card Kandang */}
-
-
- {isResponseSuccess(listProjectFlockKandang) &&
- listProjectFlockKandang.data.map((kandang) => (
-
-
-
-
-
-
- {kandang.kandang.name}
-
-
-
-
-
-
- ))}
-
-
- >
- ) : (
-
-
- Pilih project flock terlebih dahulu...
-
-
- )}
-
-
- {/*
-
- emptyContent={
-
-
- Pilih project flock terlebih dahulu...
-
-
- }
- data={
- projectFlock && isResponseSuccess(listProjectFlockKandang)
- ? listProjectFlockKandang.data
- : []
- }
- columns={[
- {
- header: '#',
- cell: (props) =>
- tableFilterState.pageSize * (tableFilterState.page - 1) +
- props.row.index +
- 1,
- },
- {
- accessorFn: (row) => row?.project_flock?.area?.name,
- header: 'Area',
- },
- {
- accessorFn: (row) => row?.project_flock?.location?.name,
- header: 'Lokasi',
- },
- {
- accessorKey: 'kandang.name',
- header: 'Kandang',
- },
- {
- accessorKey: 'kandang.capacity',
- header: 'Kapasitas',
- },
- {
- accessorFn: () => projectFlock?.period,
- header: 'Periode',
- },
- {
- accessorKey: 'approval.step_name',
- header: 'Status',
- cell: (props) => {
- return props.row.original.approval?.step_name ? (
- {
- switch (
- props.row.original.approval?.step_name.toUpperCase()
- ) {
- case 'DISETUJUI':
- return 'green';
- case 'PENGAJUAN':
- return 'yellow';
- default:
- return 'gray';
- }
- })()}
- content={props.row.original.approval?.step_name
- .toLowerCase()
- .replace(/_/g, ' ')
- .replace(/\b\w/g, (char) => char.toUpperCase())}
- />
- ) : projectFlock?.approval?.step_number === 1 ? (
-
- ) : (
-
- );
- },
- },
- {
- header: 'Aksi',
- cell: (props) => {
- return (
- <>
-
- >
- );
- },
- },
- ]}
- page={undefined}
- className={{
- containerClassName: cn({
- 'mb-20': projectFlock && projectFlock.kandangs?.length === 0,
- }),
- tableWrapperClassName: 'overflow-x-auto min-h-full!',
- tableClassName: 'font-inter w-full table-auto min-h-full!',
- headerRowClassName: 'border-b border-b-gray-200',
- headerColumnClassName:
- 'px-6 py-3 text-xs font-semibold text-gray-500 last:flex last:flex-row last:justify-end',
- bodyRowClassName: 'border-b border-b-gray-200',
- bodyColumnClassName:
- 'px-6 py-3 last:flex last:flex-row last:justify-end',
- paginationClassName: 'hidden',
- }}
- />
- */}
- >
- );
-};
-
-export default ProjectFlockChickinDetail;
diff --git a/src/components/pages/production/project-flock/closing/ProjectFlockClosingForm.tsx b/src/components/pages/production/project-flock/closing/ProjectFlockClosingForm.tsx
index 8caaf216..ead77e30 100644
--- a/src/components/pages/production/project-flock/closing/ProjectFlockClosingForm.tsx
+++ b/src/components/pages/production/project-flock/closing/ProjectFlockClosingForm.tsx
@@ -22,6 +22,7 @@ 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';
const ProjectFlockClosingForm = ({
projectFlock,
@@ -285,16 +286,18 @@ const ProjectFlockClosingForm = ({
-
+
+
+
-
+
-
+