diff --git a/src/app/closing/detail/page.tsx b/src/app/closing/detail/page.tsx index 96487258..d83b7608 100644 --- a/src/app/closing/detail/page.tsx +++ b/src/app/closing/detail/page.tsx @@ -7,7 +7,6 @@ import ClosingDetail from '@/components/pages/closing/ClosingDetailTabs'; import { ClosingApi } from '@/services/api/closing'; import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; -import { FlockApi } from '@/services/api/master-data'; import { ProjectFlockApi } from '@/services/api/production/project-flock'; import { ProjectFlockKandangApi } from '@/services/api/production'; diff --git a/src/app/finance/detail/edit/page.tsx b/src/app/finance/detail/edit/page.tsx index 93a0daea..331f4101 100644 --- a/src/app/finance/detail/edit/page.tsx +++ b/src/app/finance/detail/edit/page.tsx @@ -5,7 +5,6 @@ import useSWR from 'swr'; import { FinanceApi } from '@/services/api/finance'; import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; import FormFinanceAdd from '@/components/pages/finance/add/FormFinanceAdd'; -import FormFinanceAddInitialBalance from '@/components/pages/finance/add/initial-balance/FormFinanceAddInitialBalance'; const EditFinanceTransactionPage = () => { const router = useRouter(); diff --git a/src/app/finance/detail/page.tsx b/src/app/finance/detail/page.tsx index b80e8acb..f23d7770 100644 --- a/src/app/finance/detail/page.tsx +++ b/src/app/finance/detail/page.tsx @@ -4,7 +4,7 @@ import FinanceDetail from '@/components/pages/finance/FinanceDetail'; import useSWR from 'swr'; import { useRouter, useSearchParams } from 'next/navigation'; import { FinanceApi } from '@/services/api/finance'; -import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; +import { isResponseSuccess } from '@/lib/api-helper'; const FinanceDetailPage = () => { const router = useRouter(); diff --git a/src/app/page.tsx b/src/app/page.tsx index 33d01de7..8c10b702 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -3,10 +3,9 @@ import { useEffect } from 'react'; import { usePathname, useRouter } from 'next/navigation'; import { useAuth } from '@/services/hooks/useAuth'; -import { redirectToSSO } from '@/lib/auth-helper'; export default function Home() { - const { user, isLoadingUser } = useAuth(); + const { isLoadingUser } = useAuth(); const router = useRouter(); const pathname = usePathname(); diff --git a/src/app/production/project-flock/add/page.tsx b/src/app/production/project-flock/add/page.tsx index 2eb2c090..eb2b6dd1 100644 --- a/src/app/production/project-flock/add/page.tsx +++ b/src/app/production/project-flock/add/page.tsx @@ -1,8 +1,8 @@ 'use client'; import ProjectFlockForm from '@/components/pages/production/project-flock/form/ProjectFlockForm'; -import React, { useImperativeHandle } from 'react'; -import toast from 'react-hot-toast'; +import React from 'react'; +// import React, { useImperativeHandle } from 'react'; const AddProjectFlock = () => { // useImperativeHandle(ref, () => ({ diff --git a/src/app/production/project-flock/detail/edit/page.tsx b/src/app/production/project-flock/detail/edit/page.tsx index e5f88f19..4551dd85 100644 --- a/src/app/production/project-flock/detail/edit/page.tsx +++ b/src/app/production/project-flock/detail/edit/page.tsx @@ -12,11 +12,10 @@ const ProjectFlockEdit = () => { const projectFlockId = searchParams.get('projectFlockId'); - const { - data: projectFlock, - isLoading: isLoadingProjectFlock, - mutate: refreshProjectFlocks, - } = useSWR(projectFlockId, (id: number) => ProjectFlockApi.getSingle(id)); + const { data: projectFlock, isLoading: isLoadingProjectFlock } = useSWR( + projectFlockId, + (id: number) => ProjectFlockApi.getSingle(id) + ); if (!projectFlockId) { router.back(); diff --git a/src/app/production/project-flock/detail/page.tsx b/src/app/production/project-flock/detail/page.tsx index 6187898e..f4d58f9a 100644 --- a/src/app/production/project-flock/detail/page.tsx +++ b/src/app/production/project-flock/detail/page.tsx @@ -1,7 +1,6 @@ 'use client'; import ProjectFlockDetail from '@/components/pages/production/project-flock/detail/ProjectFlockDetail'; -import ProjectFlockForm from '@/components/pages/production/project-flock/form/ProjectFlockForm'; import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; import { ProjectFlockApi } from '@/services/api/production/project-flock'; import { useRouter, useSearchParams } from 'next/navigation'; @@ -13,11 +12,10 @@ const ProjectFlockDetailPage = () => { const projectFlockId = searchParams.get('projectFlockId'); - const { - data: projectFlock, - isLoading: isLoadingProjectFlock, - mutate: refreshProjectFlock, - } = useSWR(projectFlockId, (id: number) => ProjectFlockApi.getSingle(id)); + const { data: projectFlock, isLoading: isLoadingProjectFlock } = useSWR( + projectFlockId, + (id: number) => ProjectFlockApi.getSingle(id) + ); if (!projectFlockId) { router.back(); diff --git a/src/components/MainDrawer.tsx b/src/components/MainDrawer.tsx index 71da0789..724e4b0a 100644 --- a/src/components/MainDrawer.tsx +++ b/src/components/MainDrawer.tsx @@ -1,6 +1,5 @@ 'use client'; -import { useCallback } from 'react'; import { usePathname } from 'next/navigation'; import Image from 'next/image'; @@ -13,7 +12,6 @@ import PermissionNotFound from '@/components/helper/PermissionNotFound'; import { useUiStore } from '@/stores/ui/ui.store'; import { MAIN_DRAWER_LINKS } from '@/config/constant'; -import { isPathActive } from '@/lib/helper'; import { ROUTE_PERMISSIONS } from '@/config/route-permission'; import { useAuth } from '@/services/hooks/useAuth'; diff --git a/src/components/Tabs.tsx b/src/components/Tabs.tsx index 8a06f9ed..52047d8b 100644 --- a/src/components/Tabs.tsx +++ b/src/components/Tabs.tsx @@ -1,4 +1,4 @@ -import { HTMLAttributes, ReactNode, useEffect, useState } from 'react'; +import { HTMLAttributes, ReactNode, useState } from 'react'; import { cn } from '@/lib/helper'; export interface TabItem { diff --git a/src/components/helper/skeleton/DataStateSkeleton.tsx b/src/components/helper/skeleton/DataStateSkeleton.tsx index cd5474e0..f3e9fdef 100644 --- a/src/components/helper/skeleton/DataStateSkeleton.tsx +++ b/src/components/helper/skeleton/DataStateSkeleton.tsx @@ -1,5 +1,4 @@ import IconSkeleton from '@/components/helper/skeleton/IconSkeleton'; -import { Icon } from '@iconify/react'; const DataStateSkeleton = ({ icon, diff --git a/src/components/input/PatternInput.tsx b/src/components/input/PatternInput.tsx index 9af1b68e..290614c7 100644 --- a/src/components/input/PatternInput.tsx +++ b/src/components/input/PatternInput.tsx @@ -4,7 +4,6 @@ import { ChangeEvent } from 'react'; import { PatternFormat, NumberFormatBase, - NumberFormatBaseProps, OnValueChange, } from 'react-number-format'; import TextInput, { TextInputProps } from '@/components/input/TextInput'; diff --git a/src/components/modal/ConfirmationModalWithNotes.tsx b/src/components/modal/ConfirmationModalWithNotes.tsx index e862dffc..20f63019 100644 --- a/src/components/modal/ConfirmationModalWithNotes.tsx +++ b/src/components/modal/ConfirmationModalWithNotes.tsx @@ -56,7 +56,7 @@ const ConfirmationModalWithNotes: React.FC = ({ closeOnBackdrop={closeOnBackdrop} primaryButton={{ ...primaryButton, - onClick: (e) => { + onClick: () => { if (primaryButton && primaryButton?.onClick) { primaryButton?.onClick?.(notes); } else { diff --git a/src/components/pages/closing/table/OverheadClosingTable.tsx b/src/components/pages/closing/table/OverheadClosingTable.tsx index a6c31e6c..421817f9 100644 --- a/src/components/pages/closing/table/OverheadClosingTable.tsx +++ b/src/components/pages/closing/table/OverheadClosingTable.tsx @@ -1,5 +1,5 @@ import Card from '@/components/Card'; -import Table, { TABLE_DEFAULT_STYLING } from '@/components/Table'; +import Table from '@/components/Table'; import { isResponseSuccess } from '@/lib/api-helper'; import { cn, formatCurrency, formatDate, formatNumber } from '@/lib/helper'; import { ClosingApi } from '@/services/api/closing'; @@ -38,7 +38,7 @@ const OverheadClosingTable = ({ } ); - const { data: overheadKandang, isLoading: isLoadingOverheadKandang } = useSWR( + const { data: overheadKandang } = useSWR( kandangId ? `${ClosingApi.basePath}/${projectFlockId}/${kandangId}/overhead` : undefined, diff --git a/src/components/pages/dashboard/export/DashboardPDF.ts b/src/components/pages/dashboard/export/DashboardPDF.ts index 8b4c7e6a..340abcbc 100644 --- a/src/components/pages/dashboard/export/DashboardPDF.ts +++ b/src/components/pages/dashboard/export/DashboardPDF.ts @@ -256,7 +256,7 @@ export const generateDashboardPDF = async ({ pdf.save(fileName); toast.success('PDF exported successfully!', { id: 'export-pdf' }); - } catch (error) { + } catch { toast.error('Failed to export PDF. Please try again.', { id: 'export-pdf', }); diff --git a/src/components/pages/finance/FinanceTable.tsx b/src/components/pages/finance/FinanceTable.tsx index 6f422753..f83fa469 100644 --- a/src/components/pages/finance/FinanceTable.tsx +++ b/src/components/pages/finance/FinanceTable.tsx @@ -1,6 +1,5 @@ import { useEffect, useMemo, useRef, useState } from 'react'; import { CellContext } from '@tanstack/react-table'; -import { useSearchParams } from 'next/navigation'; import useSWR from 'swr'; import { useFormik } from 'formik'; diff --git a/src/components/pages/finance/add/initial-balance/FormFinanceAddInitialBalance.tsx b/src/components/pages/finance/add/initial-balance/FormFinanceAddInitialBalance.tsx index a63caa94..621557b2 100644 --- a/src/components/pages/finance/add/initial-balance/FormFinanceAddInitialBalance.tsx +++ b/src/components/pages/finance/add/initial-balance/FormFinanceAddInitialBalance.tsx @@ -48,9 +48,9 @@ const FormFinanceAddInitialBalance = ({ // ===== Formik ===== const formikInitialValues = useMemo((): InitialBalanceFormValues => { // Type assertion to handle potential initial_balance_type field - const extendedInitialValues = initialValues as Finance & { - initial_balance_type?: string; - }; + // const extendedInitialValues = initialValues as Finance & { + // initial_balance_type?: string; + // }; return { party_type_option: @@ -122,8 +122,6 @@ const FormFinanceAddInitialBalance = ({ options: bankOptions, rawData: bankRawData, isLoadingOptions: isLoadingBankOptions, - setInputValue: setBankInputValue, - loadMore: loadMoreBankOptions, } = useSelect(BankApi.basePath, 'id', 'name'); // ===== Helper Functions ===== diff --git a/src/components/pages/finance/add/injection/FormFinanceInjection.tsx b/src/components/pages/finance/add/injection/FormFinanceInjection.tsx index a4b77baf..b729ce11 100644 --- a/src/components/pages/finance/add/injection/FormFinanceInjection.tsx +++ b/src/components/pages/finance/add/injection/FormFinanceInjection.tsx @@ -28,10 +28,7 @@ import { useCallback, useMemo, useState } from 'react'; import toast from 'react-hot-toast'; import Alert from '@/components/Alert'; import { Icon } from '@iconify/react'; -import { - FINANCE_INJECTION_STATUS, - FINANCE_INJECTION_TYPE_OPTIONS, -} from '@/config/constant'; +import { FINANCE_INJECTION_TYPE_OPTIONS } from '@/config/constant'; interface FormFinanceInjectionProps { type?: 'add' | 'edit'; diff --git a/src/components/pages/inventory/adjustment/InventoryAdjustmentTable.tsx b/src/components/pages/inventory/adjustment/InventoryAdjustmentTable.tsx index 8da2abf8..1bd47caf 100644 --- a/src/components/pages/inventory/adjustment/InventoryAdjustmentTable.tsx +++ b/src/components/pages/inventory/adjustment/InventoryAdjustmentTable.tsx @@ -15,7 +15,6 @@ import { Icon } from '@iconify/react'; import { ColumnDef, ColumnSort, SortingState } from '@tanstack/react-table'; import { useCallback, useEffect, useState } from 'react'; import useSWR from 'swr'; -import { useFormikErrorList } from '@/services/hooks/useFormikErrorList'; const InventoryAdjustmentTable = () => { const { diff --git a/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.tsx b/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.tsx index 3bae393d..612fbb20 100644 --- a/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.tsx +++ b/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.tsx @@ -14,7 +14,6 @@ import { InventoryAdjustmentFormSchema, InventoryAdjustmentFormValues, } from '@/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.schema'; -import useSWR from 'swr'; import { ProductApi, ProductCategoryApi, diff --git a/src/components/pages/inventory/movement/form/MovementForm.tsx b/src/components/pages/inventory/movement/form/MovementForm.tsx index dbb30314..f723e763 100644 --- a/src/components/pages/inventory/movement/form/MovementForm.tsx +++ b/src/components/pages/inventory/movement/form/MovementForm.tsx @@ -33,7 +33,6 @@ import { toast } from 'react-hot-toast'; import { MovementApi } from '@/services/api/inventory'; import FileInput from '@/components/input/FileInput'; import CheckboxInput from '@/components/input/CheckboxInput'; -import Badge from '@/components/Badge'; import Card from '@/components/Card'; import { S3_PUBLIC_BASE_URL } from '@/config/constant'; import { getUniqueFormikErrors } from '@/lib/formik-helper'; diff --git a/src/components/pages/inventory/product/InventoryProductTable.tsx b/src/components/pages/inventory/product/InventoryProductTable.tsx index fce21b2c..316bd103 100644 --- a/src/components/pages/inventory/product/InventoryProductTable.tsx +++ b/src/components/pages/inventory/product/InventoryProductTable.tsx @@ -15,12 +15,7 @@ import { InventoryProductApi } from '@/services/api/inventory'; import { useTableFilter } from '@/services/hooks/useTableFilter'; import { InventoryProduct } from '@/types/api/inventory/product'; import { Icon } from '@iconify/react'; -import { - CellContext, - ColumnDef, - Row, - SortingState, -} from '@tanstack/react-table'; +import { CellContext, ColumnDef, SortingState } from '@tanstack/react-table'; import { ChangeEventHandler, useMemo, useState } from 'react'; import useSWR from 'swr'; diff --git a/src/components/pages/inventory/product/detail/StockProductWarehouseTable.tsx b/src/components/pages/inventory/product/detail/StockProductWarehouseTable.tsx index 6f48f7cd..aa375bdc 100644 --- a/src/components/pages/inventory/product/detail/StockProductWarehouseTable.tsx +++ b/src/components/pages/inventory/product/detail/StockProductWarehouseTable.tsx @@ -1,10 +1,7 @@ import Card from '@/components/Card'; import Table from '@/components/Table'; import { formatNumber } from '@/lib/helper'; -import { - InventoryProduct, - ProductWarehouseStock, -} from '@/types/api/inventory/product'; +import { ProductWarehouseStock } from '@/types/api/inventory/product'; const StockProductWarehouseTable = ({ productWarehouseStock, diff --git a/src/components/pages/marketing/DeliveryOrderFormModal.tsx b/src/components/pages/marketing/DeliveryOrderFormModal.tsx index f1d5e3cc..ae559328 100644 --- a/src/components/pages/marketing/DeliveryOrderFormModal.tsx +++ b/src/components/pages/marketing/DeliveryOrderFormModal.tsx @@ -48,11 +48,7 @@ import RequirePermission from '@/components/helper/RequirePermission'; const MemoizedDeliveryOrderProductTable = memo(DeliveryOrderProductTable); const MemoizedDeliveryOrderProductForm = memo(DeliveryOrderProductForm); -const DeliveryOrderFormModal = ({ - initialValues, -}: { - initialValues?: Marketing; -}) => { +const DeliveryOrderFormModal = ({}: { initialValues?: Marketing }) => { const router = useRouter(); const searchParams = useSearchParams(); @@ -76,19 +72,14 @@ const DeliveryOrderFormModal = ({ ); }; - const { data: marketing, isLoading: isLoadingMarketing } = useSWR( + const { data: marketing } = useSWR( isModalActionForForm && marketingId ? `detail-marketing-${marketingId}` : undefined, () => MarketingApi.getSingle(Number(marketingId)) ); - const { - approvals, - rawDataApprovals, - isLoading: isLoadingApproval, - refresh: refreshApproval, - } = useApprovalSteps({ + const { rawDataApprovals, refresh: refreshApproval } = useApprovalSteps({ latestApproval: isResponseSuccess(marketing) ? marketing?.data.latest_approval : undefined, @@ -284,29 +275,10 @@ const DeliveryOrderFormModal = ({ setIsLoading(false); }; - const memoSalesOrder = formik.values.sales_order; - // ================== HANDLER ================== - const nextButtonHandler = () => { - setStep(step + 1); - }; const prevButtonHandler = () => { setStep(step - 1); }; - const handleChangeCustomer = useCallback( - (val: OptionType | OptionType[] | null) => { - formik.setFieldValue('customer_id', (val as OptionType)?.value); - formik.setFieldValue('customer', val as OptionType); - }, - [] - ); - const handleChangeSalesPerson = useCallback( - (val: OptionType | OptionType[] | null) => { - formik.setFieldValue('sales_person_id', (val as OptionType)?.value); - formik.setFieldValue('sales_person', val as OptionType); - }, - [] - ); const rejectMarketingHandler = async (notes: string) => { if (!marketingId) { toast.error(`Tidak ada data yang valid untuk di reject.`); @@ -507,18 +479,18 @@ const DeliveryOrderFormModal = ({ }, []); // ================== MEMOIZED ================== - const isNextButtonDisabled = useMemo(() => { - if (step === 1) { - return Boolean( - !formik.values.customer_id || - !formik.values.sales_person_id || - !formik.values.so_date || - !formik.values.notes - ); - } + // const isNextButtonDisabled = useMemo(() => { + // if (step === 1) { + // return Boolean( + // !formik.values.customer_id || + // !formik.values.sales_person_id || + // !formik.values.so_date || + // !formik.values.notes + // ); + // } - return true; - }, [step, formik.values]); + // return true; + // }, [step, formik.values]); const deliveryRejected = useMemo(() => { return ( isResponseSuccess(marketing) && @@ -877,7 +849,7 @@ const DeliveryOrderFormModal = ({ text: 'Oke', color: 'primary', className: 'rounded-lg', - onClick: (e) => { + onClick: () => { closeModalHandler(); }, }} diff --git a/src/components/pages/marketing/MarketingTable.tsx b/src/components/pages/marketing/MarketingTable.tsx index 6368df11..0bf00833 100644 --- a/src/components/pages/marketing/MarketingTable.tsx +++ b/src/components/pages/marketing/MarketingTable.tsx @@ -25,8 +25,6 @@ import { useMemo, useState } from 'react'; import toast from 'react-hot-toast'; import useSWR from 'swr'; import RequirePermission from '@/components/helper/RequirePermission'; -import { useAuth } from '@/services/hooks/useAuth'; -import ButtonFilter from '@/components/helper/ButtonFilter'; import Dropdown from '@/components/Dropdown'; import PopoverButton from '@/components/popover/PopoverButton'; import PopoverContent from '@/components/popover/PopoverContent'; @@ -136,7 +134,7 @@ const RowsOptionsMenu = ({ onClick={deleteClickHandler} variant='ghost' color='none' - className='relative p-3 overflow-hidden justify-start text-sm font-semibold w-full text-error before:content-[""] before:absolute before:h-0.25 before:p-3 before:top-0 before:left-0 before:right-0 before:border-t before:border-base-content/5' + className='relative p-3 overflow-hidden justify-start text-sm font-semibold w-full text-error before:content-[""] before:absolute before:h-px before:p-3 before:top-0 before:left-0 before:right-0 before:border-t before:border-base-content/5' > Delete Item @@ -149,14 +147,11 @@ const RowsOptionsMenu = ({ }; const MarketingTable = () => { - const [search, setSearch] = useState(''); - const [approveAction, setApproveAction] = useState<'APPROVED' | 'REJECTED'>( 'APPROVED' ); const [selectedItem, setSelectedItem] = useState(null); const [rowSelection, setRowSelection] = useState>({}); - const { permissionCheck } = useAuth(); const router = useRouter(); const deleteModal = useModal(); @@ -219,6 +214,32 @@ const MarketingTable = () => { updateFilter('customer_id', ''); }; + // ===== ACTIVE FILTERS COUNT ===== + const activeFiltersCount = useMemo(() => { + let count = 0; + + // Product filter + if (tableFilterState.product_ids) { + count += 1; + } + + // Status filter + if (tableFilterState.status) { + count += 1; + } + + // Customer filter + if (tableFilterState.customer_id) { + count += 1; + } + + return count; + }, [ + tableFilterState.product_ids, + tableFilterState.status, + tableFilterState.customer_id, + ]); + const approveClickHandler = () => { setApproveAction('APPROVED'); confirmationModal.openModal(); @@ -530,7 +551,7 @@ const MarketingTable = () => { {idsToProcess.length > 0 && ( <> -
+
{ + onClick: () => { closeModalHandler(); }, }} diff --git a/src/components/pages/marketing/form/repeater/delivery-order/DeliverOrderProduct.tsx b/src/components/pages/marketing/form/repeater/delivery-order/DeliverOrderProduct.tsx index f233521c..aae37d8e 100644 --- a/src/components/pages/marketing/form/repeater/delivery-order/DeliverOrderProduct.tsx +++ b/src/components/pages/marketing/form/repeater/delivery-order/DeliverOrderProduct.tsx @@ -34,7 +34,6 @@ const DeliveryOrderProductForm = ({ salesOrders, initialValues, exisitingValues, - onSubmitForm, onUpdateForm, isLoading, }: { @@ -96,12 +95,12 @@ const DeliveryOrderProductForm = ({ ); // Options Week dari minggu 1 - 22 - const optionsWeek = useMemo(() => { - return Array.from({ length: 22 }, (_, i) => ({ - value: i + 1, - label: `Week ${i + 1}`, - })); - }, []); + // const optionsWeek = useMemo(() => { + // return Array.from({ length: 22 }, (_, i) => ({ + // value: i + 1, + // label: `Week ${i + 1}`, + // })); + // }, []); const options = exisitingValues ?.map((item) => { diff --git a/src/components/pages/marketing/form/repeater/sales-order/SalesOrderProductForm.tsx b/src/components/pages/marketing/form/repeater/sales-order/SalesOrderProductForm.tsx index d99e3db8..70965071 100644 --- a/src/components/pages/marketing/form/repeater/sales-order/SalesOrderProductForm.tsx +++ b/src/components/pages/marketing/form/repeater/sales-order/SalesOrderProductForm.tsx @@ -139,12 +139,12 @@ const SalesOrderProductForm = ({ } = useSelect(WarehouseApi.basePath, 'id', 'name'); // Options Week dari minggu 1 - 22 - const optionsWeek = useMemo(() => { - return Array.from({ length: 22 }, (_, i) => ({ - value: i + 1, - label: `Week ${i + 1}`, - })); - }, []); + // const optionsWeek = useMemo(() => { + // return Array.from({ length: 22 }, (_, i) => ({ + // value: i + 1, + // label: `Week ${i + 1}`, + // })); + // }, []); const { options: warehouseSourceOptions, diff --git a/src/components/pages/marketing/pdf/DeliveryOrderExport.tsx b/src/components/pages/marketing/pdf/DeliveryOrderExport.tsx index 61ce7913..5db89450 100644 --- a/src/components/pages/marketing/pdf/DeliveryOrderExport.tsx +++ b/src/components/pages/marketing/pdf/DeliveryOrderExport.tsx @@ -49,7 +49,7 @@ const DeliveryOrderExport = ({ document.body.removeChild(link); window.URL.revokeObjectURL(url); }, 150); - } catch (error) { + } catch { toast.error('Failed to generate PDF. Please try again.'); } finally { setIsGeneratingPDF(false); diff --git a/src/components/pages/marketing/pdf/SalesOrderExport.tsx b/src/components/pages/marketing/pdf/SalesOrderExport.tsx index 5767c049..55eb3b5b 100644 --- a/src/components/pages/marketing/pdf/SalesOrderExport.tsx +++ b/src/components/pages/marketing/pdf/SalesOrderExport.tsx @@ -1,7 +1,7 @@ import Button from '@/components/Button'; import { Marketing } from '@/types/api/marketing/marketing'; import { Icon } from '@iconify/react'; -import { Document, Image, Page, pdf, Text, View } from '@react-pdf/renderer'; +import { Document, Page, pdf, Text, View } from '@react-pdf/renderer'; import { useMemo, useState } from 'react'; import { formatDate, formatNumber } from '@/lib/helper'; import pdfStyles from '@/components/pages/marketing/pdf/styles/MarketingPDFStyles'; @@ -43,7 +43,7 @@ const SalesOrderExport = ({ data }: SalesOrderExportProps) => { document.body.removeChild(link); window.URL.revokeObjectURL(url); }, 150); - } catch (error) { + } catch { toast.error('Failed to generate PDF. Please try again.'); } finally { setIsGeneratingPDF(false); @@ -162,7 +162,7 @@ const PDFDocument = ({ data }: { data: Marketing }) => { {data?.sales_order?.map((item, index) => { - const isLastItem = index === (data?.sales_order?.length || 0) - 1; + // const isLastItem = index === (data?.sales_order?.length || 0) - 1; return ( { >(undefined); const [isDeleteLoading, setIsDeleteLoading] = useState(false); - const { - data: productionStandards, - isLoading: productionStandardsLoading, - mutate: refreshProductionStandards, - } = useSWR( - `${ProductionStandardApi.basePath}`, - ProductionStandardApi.getAllFetcher - ); + const { data: productionStandards, mutate: refreshProductionStandards } = + useSWR( + `${ProductionStandardApi.basePath}`, + ProductionStandardApi.getAllFetcher + ); const confirmationModalDeleteClickHandler = async () => { setIsDeleteLoading(true); diff --git a/src/components/pages/master-data/warehouse/form/WarehouseForm.tsx b/src/components/pages/master-data/warehouse/form/WarehouseForm.tsx index a6a53e3f..307a8c92 100644 --- a/src/components/pages/master-data/warehouse/form/WarehouseForm.tsx +++ b/src/components/pages/master-data/warehouse/form/WarehouseForm.tsx @@ -4,7 +4,6 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; import { useRouter } from 'next/navigation'; import { useFormik } from 'formik'; import { toast } from 'react-hot-toast'; -import useSWR from 'swr'; import { Icon } from '@iconify/react'; import Button from '@/components/Button'; @@ -22,7 +21,7 @@ import { WarehouseFormValues, UpdateWarehouseFormSchema, } from '@/components/pages/master-data/warehouse/form/WarehouseForm.schema'; -import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; +import { isResponseError } from '@/lib/api-helper'; import { Warehouse, CreateWarehousePayload, diff --git a/src/components/pages/production/chickin/form/ChickinForm.tsx b/src/components/pages/production/chickin/form/ChickinForm.tsx index b9c73934..64ff2ffd 100644 --- a/src/components/pages/production/chickin/form/ChickinForm.tsx +++ b/src/components/pages/production/chickin/form/ChickinForm.tsx @@ -1,12 +1,8 @@ 'use client'; import Card from '@/components/Card'; -import { FormHeader } from '@/components/helper/form/FormHeader'; -import Table from '@/components/Table'; import { formatNumber } from '@/lib/helper'; -import { Kandang } from '@/types/api/master-data/kandang'; import { ProjectFlockKandang } from '@/types/api/production/project-flock-kandang'; -import Tabs from '@/components/Tabs'; import { useState } from 'react'; import ApprovalSteps, { useApprovalSteps, @@ -15,7 +11,6 @@ import ChickinFormView from '@/components/pages/production/chickin/form/tabs/Chi import ChickinLogsView from '@/components/pages/production/chickin/form/tabs/ChickLogsView'; import DrawerHeader from '@/components/helper/drawer/DrawerHeader'; import { Icon } from '@iconify/react'; -import Badge from '@/components/Badge'; import StatusBadge from '@/components/helper/StatusBadge'; import { CHICKINS_APPROVAL_LINE } from '@/config/approval-line'; import RequirePermission from '@/components/helper/RequirePermission'; diff --git a/src/components/pages/production/chickin/form/tabs/ChickinFormView.tsx b/src/components/pages/production/chickin/form/tabs/ChickinFormView.tsx index 2dcc502e..f14b8710 100644 --- a/src/components/pages/production/chickin/form/tabs/ChickinFormView.tsx +++ b/src/components/pages/production/chickin/form/tabs/ChickinFormView.tsx @@ -1,10 +1,8 @@ 'use client'; import Card from '@/components/Card'; -import Table from '@/components/Table'; import { ChickinFormValues, - ChickinRequestFormValues, ChickinSchema, } from '@/components/pages/production/chickin/form/ChickinForm.schema'; import DateInput from '@/components/input/DateInput'; diff --git a/src/components/pages/production/project-flock/ProjectFlockConfirmationModal.tsx b/src/components/pages/production/project-flock/ProjectFlockConfirmationModal.tsx index 45834ee5..4a03b7ab 100644 --- a/src/components/pages/production/project-flock/ProjectFlockConfirmationModal.tsx +++ b/src/components/pages/production/project-flock/ProjectFlockConfirmationModal.tsx @@ -60,11 +60,7 @@ const ProjectFlockConfirmationModal = ({ : '', limit: '500', }).toString()}`; - const { - data: kandang, - isLoading: isLoadingKandang, - mutate: refreshKandang, - } = useSWR(kandangUrl, KandangApi.getAllFetcher); + const { data: kandang } = useSWR(kandangUrl, KandangApi.getAllFetcher); const notesChangeHandler: ChangeEventHandler = (e) => { setNotes(e.target.value); @@ -85,7 +81,7 @@ const ProjectFlockConfirmationModal = ({ text: primaryButton?.text ?? 'Oke', color: primaryButton?.color ?? 'primary', className: 'rounded-lg', - onClick: (e) => { + onClick: () => { if (withNote) { primaryButton?.onClick?.(notes); } else if (primaryButton && primaryButton?.onClick) { diff --git a/src/components/pages/production/project-flock/ProjectFlockTable.tsx b/src/components/pages/production/project-flock/ProjectFlockTable.tsx index 040771a8..7a8ba4e1 100644 --- a/src/components/pages/production/project-flock/ProjectFlockTable.tsx +++ b/src/components/pages/production/project-flock/ProjectFlockTable.tsx @@ -1,22 +1,16 @@ 'use client'; -import Badge from '@/components/Badge'; import Button from '@/components/Button'; -import FloatingActionsButton from '@/components/FloatingActionsButton'; import CheckboxInput from '@/components/input/CheckboxInput'; import DebouncedTextInput from '@/components/input/DebouncedTextInput'; -import SelectInput, { - OptionType, - useSelect, -} from '@/components/input/SelectInput'; +import { OptionType, useSelect } from '@/components/input/SelectInput'; import { useModal } from '@/components/Modal'; import ConfirmationModal from '@/components/modal/ConfirmationModal'; import ConfirmationModalWithNotes from '@/components/modal/ConfirmationModalWithNotes'; import Table from '@/components/Table'; import Dropdown from '@/components/Dropdown'; -import { ROWS_OPTIONS } from '@/config/constant'; import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; -import { cn, formatDate, formatTitleCase } from '@/lib/helper'; +import { cn, formatDate } from '@/lib/helper'; import { AreaApi, KandangApi, LocationApi } from '@/services/api/master-data'; import { ProjectFlockApi } from '@/services/api/production/project-flock'; import { useTableFilter } from '@/services/hooks/useTableFilter'; @@ -183,14 +177,6 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => { .filter((id) => rowSelection[id]) .map((id) => parseInt(id)); - const [selectedArea, setSelectedArea] = useState(null); - const [selectedLocation, setSelectedLocation] = useState( - null - ); - const [selectedKandang, setSelectedKandang] = useState( - null - ); - const [periodInputValue, setPeriodInputValue] = useState(null); const [sorting, setSorting] = useState([]); const deleteModal = useModal(); const confirmModal = useModal(); @@ -232,26 +218,6 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => { { revalidateOnMount: true } ); - // ===== Fetch Data Select ===== - const { - options: optionsArea, - isLoadingOptions: isLoadingArea, - setInputValue: setAreaSelectInputValue, - loadMore: loadMoreArea, - } = useSelect(AreaApi.basePath, 'id', 'name'); - const { - options: optionsLocation, - isLoadingOptions: isLoadingLocation, - setInputValue: setLocationSelectInputValue, - loadMore: loadMoreLocation, - } = useSelect(LocationApi.basePath, 'id', 'name'); - const { - options: optionsKandang, - isLoadingOptions: isLoadingKandang, - setInputValue: setKandangSelectInputValue, - loadMore: loadMoreKandang, - } = useSelect(KandangApi.basePath, 'id', 'name'); - // ====== HANDLER ====== const confirmationModalDeleteClickHandler = async () => { setIsDeleteLoading(true); diff --git a/src/components/pages/production/project-flock/closing/ProjectFlockClosingForm.tsx b/src/components/pages/production/project-flock/closing/ProjectFlockClosingForm.tsx index e73a157a..935ee071 100644 --- a/src/components/pages/production/project-flock/closing/ProjectFlockClosingForm.tsx +++ b/src/components/pages/production/project-flock/closing/ProjectFlockClosingForm.tsx @@ -4,7 +4,6 @@ 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 StatusBadge from '@/components/helper/StatusBadge'; import { formatDate, formatNumber, formatTitleCase } from '@/lib/helper'; import { ProjectFlock } from '@/types/api/production/project-flock'; @@ -21,7 +20,6 @@ import { useProjectFlockClosingStore } from '@/stores/production/project-flock-c import { useMemo } from 'react'; import toast from 'react-hot-toast'; import { useRouter } from 'next/navigation'; -import { ApprovalApi } from '@/services/api/approval'; import RequirePermission from '@/components/helper/RequirePermission'; import { Color } from '@/types/theme'; @@ -60,24 +58,10 @@ const ProjectFlockClosingForm = ({ () => ProjectFlockKandangApi.checkClosing(projectFlockKandang.id) ); - const { data: projectFlockKandangApprovals } = useSWR( - `${ApprovalApi.basePath}?module_name=PROJECT_FLOCK_KANDANGS&module_id=${projectFlockKandang.id}`, - () => - ApprovalApi.getAllFetcher( - `${ApprovalApi.basePath}?module_name=PROJECT_FLOCK_KANDANGS&module_id=${projectFlockKandang.id}` - ) - ); - const isKandangClosed = useMemo(() => { return projectFlockKandang.kandang?.status === 'NON_ACTIVE'; }, [projectFlockKandang]); - const isCanClose = useMemo(() => { - return isResponseSuccess(projectFlockKandangApprovals) - ? projectFlockKandangApprovals?.data?.[0]?.step_number <= 2 - : true; - }, [projectFlockKandangApprovals]); - const handleCloseClick = () => { const closingCallback = async (action: 'close' | 'unclose') => { const deleteProjectFlockRes = await ProjectFlockKandangApi.closing( diff --git a/src/components/pages/production/project-flock/detail/ProjectFlockDetail.tsx b/src/components/pages/production/project-flock/detail/ProjectFlockDetail.tsx index db3d45aa..d3812e47 100644 --- a/src/components/pages/production/project-flock/detail/ProjectFlockDetail.tsx +++ b/src/components/pages/production/project-flock/detail/ProjectFlockDetail.tsx @@ -1,4 +1,3 @@ -import Badge from '@/components/Badge'; import Button from '@/components/Button'; import Card from '@/components/Card'; import { RadioGroup, RadioGroupItem } from '@/components/input/RadioInput'; @@ -42,19 +41,6 @@ const ProjectFlockDetail = ({ (kandang) => kandang.id === Number(selectedKandangId) ); - const { data: projectFlockKandang, isLoading: projectFlockKandangLoading } = - useSWR( - selectedKandangId - ? `${ProjectFlockKandangApi.basePath}/get-detail/${selectedKandangId}` - : null, - selectedKandangId - ? () => - ProjectFlockKandangApi.getSingle( - Number(selectedKandang?.project_flock_kandang_id) - ) - : null - ); - const { data: projectFlockApprovalResponse } = useSWR( projectFlock.id ? ['approval-project-flock', projectFlock.id] : undefined, ([, id]) => ProjectFlockApi.getApprovalLineHistory(Number(id)) diff --git a/src/components/pages/production/project-flock/form/ProjectFlockForm.tsx b/src/components/pages/production/project-flock/form/ProjectFlockForm.tsx index 57cde405..2dfff34f 100644 --- a/src/components/pages/production/project-flock/form/ProjectFlockForm.tsx +++ b/src/components/pages/production/project-flock/form/ProjectFlockForm.tsx @@ -39,7 +39,6 @@ import { FLOCK_CATEGORY_OPTIONS } from '@/config/constant'; import { useModal } from '@/components/Modal'; import ConfirmationModal from '@/components/modal/ConfirmationModal'; import NumberInput from '@/components/input/NumberInput'; -import Card from '@/components/Card'; import ProjectFlockKandangTable from '@/components/pages/production/project-flock/form/ProjectFlockKandangTable'; import { Nonstock } from '@/types/api/master-data/nonstock'; import { useUiStore } from '@/stores/ui/ui.store'; @@ -209,7 +208,6 @@ export const ProjectFlockFormConfirmationTable = ({ const ProjectFlockForm = ({ formType = 'add', initialValues, - refreshProjectFlocks, }: ProjectFlockFormProps) => { // State const router = useRouter(); @@ -228,7 +226,7 @@ const ProjectFlockForm = ({ const [disabledLocation, setDisabledLocation] = useState( initialValues?.location?.id ? false : true ); - const [openSelectKandangs, setOpenSelectKandangs] = useState( + const [, setOpenSelectKandangs] = useState( initialValues?.kandangs && initialValues?.kandangs?.length > 0 ); const [optionsKandang, setOptionsKandang] = useState( @@ -475,9 +473,9 @@ const ProjectFlockForm = ({ formikSetValues(formikInitialValues); }; - const [formikLastValues, setFormikLastValues] = useState< - ProjectFlockFormValues | undefined - >(undefined); + const [, setFormikLastValues] = useState( + undefined + ); // Formik InitialValue const formikInitialValues = useMemo(() => { @@ -486,9 +484,9 @@ const ProjectFlockForm = ({ 0, initialValues?.flock_name?.lastIndexOf(' ') ) ?? ''; - const optionFind = optionsFlock.find((flock) => { - return flock.label == trimFlock; - }) as OptionType; + // const optionFind = optionsFlock.find((flock) => { + // return flock.label == trimFlock; + // }) as OptionType; return { flock: optionsFlock.find((flock) => { diff --git a/src/components/pages/production/project-flock/form/ProjectFlockKandangTable.tsx b/src/components/pages/production/project-flock/form/ProjectFlockKandangTable.tsx index bba4a229..9fa64982 100644 --- a/src/components/pages/production/project-flock/form/ProjectFlockKandangTable.tsx +++ b/src/components/pages/production/project-flock/form/ProjectFlockKandangTable.tsx @@ -1,28 +1,21 @@ 'use client'; -import Badge from '@/components/Badge'; import Card from '@/components/Card'; import StatusBadge from '@/components/helper/StatusBadge'; import CheckboxInput from '@/components/input/CheckboxInput'; -import PillBadge from '@/components/PillBadge'; -import Table from '@/components/Table'; import { cn } from '@/lib/helper'; import { Kandang } from '@/types/api/master-data/kandang'; import { ProjectFlock, ProjectFlockPeriods, } from '@/types/api/production/project-flock'; -import { Icon } from '@iconify/react'; -import { OnChangeFn, Row } from '@tanstack/react-table'; -import { useMemo } from 'react'; +import { OnChangeFn } from '@tanstack/react-table'; const ProjectFlockKandangTable = ({ - listPeriods, listKandang, rowSelection, setRowSelection, selectedIds, - initialValues, formType = 'add', }: { listPeriods: ProjectFlockPeriods; diff --git a/src/components/pages/production/transfer-to-laying/TransferToLayingConfirmationModal.tsx b/src/components/pages/production/transfer-to-laying/TransferToLayingConfirmationModal.tsx index 335a6337..2975a865 100644 --- a/src/components/pages/production/transfer-to-laying/TransferToLayingConfirmationModal.tsx +++ b/src/components/pages/production/transfer-to-laying/TransferToLayingConfirmationModal.tsx @@ -55,7 +55,7 @@ const TransferToLayingConfirmationModalTable = ({ transferToLayingId ? ['detail-transfer-to-laying', String(transferToLayingId)] : undefined, - ([_, id]) => TransferToLayingApi.getSingle(Number(id)) + ([id]) => TransferToLayingApi.getSingle(Number(id)) ); const confirmationTableColumns: ColumnDef[] = @@ -230,7 +230,7 @@ const TransferToLayingConfirmationModal = ({ text: primaryButton?.text ?? 'Oke', color: primaryButton?.color ?? 'primary', className: 'rounded-lg', - onClick: (e) => { + onClick: () => { if (withNote) { primaryButton?.onClick?.(notes); } else if (primaryButton && primaryButton?.onClick) { diff --git a/src/components/pages/production/transfer-to-laying/TransferToLayingDetailModal.tsx b/src/components/pages/production/transfer-to-laying/TransferToLayingDetailModal.tsx index 7be756e2..f73ab265 100644 --- a/src/components/pages/production/transfer-to-laying/TransferToLayingDetailModal.tsx +++ b/src/components/pages/production/transfer-to-laying/TransferToLayingDetailModal.tsx @@ -40,10 +40,7 @@ const TransferToLayingDetailModal = () => { ? transferToLayingResponse.data : undefined; - const { - data: transferToLayingApprovalResponse, - isLoading: isLoadingTransferToLayingApproval, - } = useSWR( + const { data: transferToLayingApprovalResponse } = useSWR( transferToLayingId ? ['approval-transfer-to-laying', transferToLayingId] : undefined, diff --git a/src/components/pages/production/transfer-to-laying/TransferToLayingFormModal.tsx b/src/components/pages/production/transfer-to-laying/TransferToLayingFormModal.tsx index 84e67a5b..2487f10b 100644 --- a/src/components/pages/production/transfer-to-laying/TransferToLayingFormModal.tsx +++ b/src/components/pages/production/transfer-to-laying/TransferToLayingFormModal.tsx @@ -60,13 +60,12 @@ const TransferToLayingFormModal = () => { ); }; - const { data: transferToLaying, isLoading: isLoadingTransferToLaying } = - useSWR( - isModalActionForForm && transferToLayingId - ? ['detail-transfer-to-laying', transferToLayingId] - : undefined, - ([, id]) => TransferToLayingApi.getSingle(Number(id)) - ); + const { data: transferToLaying } = useSWR( + isModalActionForForm && transferToLayingId + ? ['detail-transfer-to-laying', transferToLayingId] + : undefined, + ([, id]) => TransferToLayingApi.getSingle(Number(id)) + ); /** * Step 1: General Information @@ -178,7 +177,7 @@ const TransferToLayingFormModal = () => { [router] ); - const [formikInitialValues, setFormikInitialValues] = useState( + const [formikInitialValues] = useState( getTransferToLayingFormInitialValues() ); @@ -238,10 +237,7 @@ const TransferToLayingFormModal = () => { ) : undefined; - const { - data: flockSourceKandangsAvailability, - isLoading: isLoadingFlockSourceKandangsAvailability, - } = useSWR( + const { data: flockSourceKandangsAvailability } = useSWR( formik.values.flockSource ? [ 'transfer-to-laying', @@ -297,10 +293,7 @@ const TransferToLayingFormModal = () => { return { available: countAvailable, unavailable: countUnavailable }; }, [mappedFlockSourceKandangsAvailability]); - const { - data: flockDestinationKandangsMaxTargetQty, - isLoading: isLoadingFlockDestinationKandangsMaxTargetQty, - } = useSWR( + const { data: flockDestinationKandangsMaxTargetQty } = useSWR( formik.values.flockDestination ? [ 'transfer-to-laying', diff --git a/src/components/pages/production/transfer-to-laying/form/TransferToLayingForm.schema.ts b/src/components/pages/production/transfer-to-laying/form/TransferToLayingForm.schema.ts index b34bef24..9211c2bc 100644 --- a/src/components/pages/production/transfer-to-laying/form/TransferToLayingForm.schema.ts +++ b/src/components/pages/production/transfer-to-laying/form/TransferToLayingForm.schema.ts @@ -2,9 +2,6 @@ import * as Yup from 'yup'; import { TransferToLaying } from '@/types/api/production/transfer-to-laying'; import { TransferToLayingApi } from '@/services/api/production/transfer-to-laying'; import { formatDate, formatNumber } from '@/lib/helper'; -import { ProjectFlock } from '@/types/api/production/project-flock'; -import { ProjectFlockApi } from '@/services/api/production/project-flock'; -import { isResponseSuccess } from '@/lib/api-helper'; type TransferToLayingFormSchemaType = { transfer_date?: string; diff --git a/src/components/pages/purchase/form/order/PurchaseOrderAcceptApprovalForm.tsx b/src/components/pages/purchase/form/order/PurchaseOrderAcceptApprovalForm.tsx index f872e7e0..35882869 100644 --- a/src/components/pages/purchase/form/order/PurchaseOrderAcceptApprovalForm.tsx +++ b/src/components/pages/purchase/form/order/PurchaseOrderAcceptApprovalForm.tsx @@ -153,11 +153,9 @@ const PurchaseOrderAcceptApprovalForm = ({ // ===== SELECT INPUT DATA ===== const { - setInputValue: setExpeditionsSelectInputValue, options: expeditionVendors, isLoadingOptions: isLoadingExpeditions, loadMore: loadMoreExpeditions, - hasMore: hasMoreExpeditions, } = useSelect(SupplierApi.basePath, 'id', 'name', 'search', { category: 'BOP', flag: 'EKSPEDISI', @@ -343,19 +341,6 @@ const PurchaseOrderAcceptApprovalForm = ({ ) => { const numValue = typeof value === 'string' ? parseFloat(value) || 0 : value; formik.setFieldValue(`items.${idx}.${field}`, numValue); - - if (field === 'received_qty' || field === 'transport_per_item') { - const receivedQty = - field === 'received_qty' - ? numValue - : parseFloat(formik.values.items?.[idx]?.received_qty as string) || 0; - const transportPerItem = - field === 'transport_per_item' - ? numValue - : parseFloat( - formik.values.items?.[idx]?.transport_per_item as string - ) || 0; - } }; return ( diff --git a/src/components/pages/purchase/form/request/PurchaseRequestForm.tsx b/src/components/pages/purchase/form/request/PurchaseRequestForm.tsx index 90f79e6d..53ff5027 100644 --- a/src/components/pages/purchase/form/request/PurchaseRequestForm.tsx +++ b/src/components/pages/purchase/form/request/PurchaseRequestForm.tsx @@ -55,7 +55,7 @@ const PurchaseRequestForm = ({ const deleteModal = useModal(); const [isDeleteLoading, setIsDeleteLoading] = useState(false); - const [locationSelectInputValue, setLocationSelectInputValue] = useState(''); + const [, setLocationSelectInputValue] = useState(''); const [selectedPurchaseItems, setSelectedPurchaseItems] = useState( [] ); @@ -149,7 +149,6 @@ const PurchaseRequestForm = ({ isLoadingOptions: isLoadingSuppliers, rawData: supplierRawData, loadMore: loadMoreSuppliers, - hasMore: hasMoreSuppliers, } = useSelect(SupplierApi.basePath, 'id', 'name', 'search', { category: 'SAPRONAK', }); @@ -164,7 +163,6 @@ const PurchaseRequestForm = ({ options: locationOptions, isLoadingOptions: isLoadingLocations, loadMore: loadMoreLocations, - hasMore: hasMoreLocations, } = useSelect(LocationApi.basePath, 'id', 'name', '', { area_id: selectedArea != '' @@ -173,12 +171,10 @@ const PurchaseRequestForm = ({ }); const { - inputValue: warehouseSelectInputValue, setInputValue: setWarehouseSelectInputValue, options: warehouseOptions, isLoadingOptions: isLoadingWarehouses, loadMore: loadMoreWarehouses, - hasMore: hasMoreWarehouses, } = useSelect(WarehouseApi.basePath, 'id', 'name', 'search', { area_id: selectedArea != '' @@ -651,7 +647,7 @@ const PurchaseRequestForm = ({ {formik.values.items?.map((item, idx) => ( {type !== 'detail' && ( - + { @@ -1042,7 +1041,7 @@ const PurchaseOrderDetail = ({ ref={staffApprovalModal.ref} closeOnBackdrop className={{ - modalBox: 'w-full max-w-screen-2xl max-h-[90vh] overflow-y-auto', + modalBox: 'w-full max-w-2xl max-h-[90vh] overflow-y-auto', }} > index + 1, + cell: ({ index }) => index + 1, footer: 'Total', }, { diff --git a/src/components/pages/report/finance/export/DebtSupllierExportPDF.tsx b/src/components/pages/report/finance/export/DebtSupllierExportPDF.tsx index e10839c6..1b5fc933 100644 --- a/src/components/pages/report/finance/export/DebtSupllierExportPDF.tsx +++ b/src/components/pages/report/finance/export/DebtSupllierExportPDF.tsx @@ -49,7 +49,7 @@ const getTableColumns = (total?: DebtSupplier['total']): PdfColumn[] => { header: 'No', flex: 0.5, align: 'center', - cell: ({ row, index }) => index + 1, + cell: ({ index }) => index + 1, footer: 'Total', }, { diff --git a/src/components/pages/report/finance/export/DebtSupplierExportXLSX.tsx b/src/components/pages/report/finance/export/DebtSupplierExportXLSX.tsx index e5de3ae2..b19ee86e 100644 --- a/src/components/pages/report/finance/export/DebtSupplierExportXLSX.tsx +++ b/src/components/pages/report/finance/export/DebtSupplierExportXLSX.tsx @@ -2,7 +2,7 @@ import ExcelJS from 'exceljs'; import { formatDate } from '@/lib/helper'; -import { DebtRow, DebtSupplier } from '@/types/api/report/debt-supplier'; +import { DebtSupplier } from '@/types/api/report/debt-supplier'; interface DebtSupplierExportExcelParams { data: DebtSupplier[]; diff --git a/src/components/pages/report/finance/skeleton/DebtSupplierSkeleton.tsx b/src/components/pages/report/finance/skeleton/DebtSupplierSkeleton.tsx index b9397f8f..385877fc 100644 --- a/src/components/pages/report/finance/skeleton/DebtSupplierSkeleton.tsx +++ b/src/components/pages/report/finance/skeleton/DebtSupplierSkeleton.tsx @@ -1,7 +1,6 @@ import DataStateSkeleton from '@/components/helper/skeleton/DataStateSkeleton'; import Table from '@/components/Table'; import { DebtRow } from '@/types/api/report/debt-supplier'; -import { Icon } from '@iconify/react'; import { ColumnDef } from '@tanstack/react-table'; const DebtSupplierSkeleton = ({ diff --git a/src/components/pages/report/finance/tab/DebtSupplierTab.tsx b/src/components/pages/report/finance/tab/DebtSupplierTab.tsx index d0a27b92..635bece8 100644 --- a/src/components/pages/report/finance/tab/DebtSupplierTab.tsx +++ b/src/components/pages/report/finance/tab/DebtSupplierTab.tsx @@ -129,7 +129,7 @@ const DebtSupplierTab = ({ tabId }: DebtSupplierTabProps) => { filterModal.closeModal(); setIsSubmitted(true); }, - onReset: (values) => { + onReset: () => { setFilterParams({ start_date: undefined, end_date: undefined, @@ -170,10 +170,6 @@ const DebtSupplierTab = ({ tabId }: DebtSupplierTabProps) => { : [], [debtSupplier] ); - const meta = - isResponseSuccess(debtSupplier) && debtSupplier?.meta - ? debtSupplier.meta - : null; // ===== EXPORT DATA FETCHER ===== const debtSupplierExport = useCallback(async (): Promise< diff --git a/src/components/pages/report/logistic-stock/export/PurchasesPerSupplierExportPDF.tsx b/src/components/pages/report/logistic-stock/export/PurchasesPerSupplierExportPDF.tsx index d265d08f..83f34a28 100644 --- a/src/components/pages/report/logistic-stock/export/PurchasesPerSupplierExportPDF.tsx +++ b/src/components/pages/report/logistic-stock/export/PurchasesPerSupplierExportPDF.tsx @@ -61,7 +61,7 @@ const getTableColumns = ( header: 'No', flex: 0.5, align: 'center', - cell: ({ row, index }) => index + 1, + cell: ({ index }) => index + 1, footer: 'Total', }, { diff --git a/src/components/pages/report/logistic-stock/tab/PurchasesPerSupplierTab.tsx b/src/components/pages/report/logistic-stock/tab/PurchasesPerSupplierTab.tsx index 36476956..87c5ee8d 100644 --- a/src/components/pages/report/logistic-stock/tab/PurchasesPerSupplierTab.tsx +++ b/src/components/pages/report/logistic-stock/tab/PurchasesPerSupplierTab.tsx @@ -336,11 +336,6 @@ const PurchasesPerSupplierTab = ({ tabId }: PurchasesPerSupplierTabProps) => { [purchasePerSupplier] ); - const meta = - isResponseSuccess(purchasePerSupplier) && purchasePerSupplier?.meta - ? purchasePerSupplier.meta - : null; - // ===== EXPORT DATA FETCHER ===== const logisticPurchasePerSupplierExport = useCallback(async (): Promise< LogisticPurchasePerSupplierReport[] | null diff --git a/src/components/pages/report/marketing/export/DailyMarketingExportPDF.tsx b/src/components/pages/report/marketing/export/DailyMarketingExportPDF.tsx index 29c1d619..c5e1a3a5 100644 --- a/src/components/pages/report/marketing/export/DailyMarketingExportPDF.tsx +++ b/src/components/pages/report/marketing/export/DailyMarketingExportPDF.tsx @@ -52,7 +52,7 @@ const getTableColumns = ( header: 'No', flex: 0.5, align: 'center', - cell: ({ row, index }) => index + 1, + cell: ({ index }) => index + 1, }, { key: 'so_date', diff --git a/src/components/pages/report/marketing/export/HppPerkandangExportPDF.tsx b/src/components/pages/report/marketing/export/HppPerkandangExportPDF.tsx index f2a3c835..bf68a195 100644 --- a/src/components/pages/report/marketing/export/HppPerkandangExportPDF.tsx +++ b/src/components/pages/report/marketing/export/HppPerkandangExportPDF.tsx @@ -142,7 +142,7 @@ const getDetailColumns = ( header: 'No', flex: 0.5, align: 'center', - cell: ({ row, index }) => index + 1, + cell: ({ index }) => index + 1, footer: 'TOTAL', }, { diff --git a/src/components/pages/report/marketing/tab/HppPerKandangTab.tsx b/src/components/pages/report/marketing/tab/HppPerKandangTab.tsx index e106dbf4..991c6546 100644 --- a/src/components/pages/report/marketing/tab/HppPerKandangTab.tsx +++ b/src/components/pages/report/marketing/tab/HppPerKandangTab.tsx @@ -324,11 +324,6 @@ const HppPerKandangTab = ({ tabId }: HppPerKandangTabProps) => { [hppPerKandang] ); - const period = - isResponseSuccess(hppPerKandang) && hppPerKandang?.data?.period - ? hppPerKandang.data.period - : undefined; - // ===== EXPORT DATA FETCHER ===== const hppPerKandangExport = useCallback(async (): Promise => { diff --git a/src/components/pages/report/production-result/tab/ProductionResultProjectFlockKandangTable.tsx b/src/components/pages/report/production-result/tab/ProductionResultProjectFlockKandangTable.tsx index ded97d02..25b1bd28 100644 --- a/src/components/pages/report/production-result/tab/ProductionResultProjectFlockKandangTable.tsx +++ b/src/components/pages/report/production-result/tab/ProductionResultProjectFlockKandangTable.tsx @@ -28,7 +28,6 @@ const ProductionResultProjectFlockKandangTable = ({ setPage, setPageSize, toQueryString: getTableFilterQueryString, - reset: resetFilter, } = useTableFilter({ initial: { filter_by: '', diff --git a/src/figma-make/components/base/date-picker.tsx b/src/figma-make/components/base/date-picker.tsx index abd3414f..b19fff3d 100644 --- a/src/figma-make/components/base/date-picker.tsx +++ b/src/figma-make/components/base/date-picker.tsx @@ -46,15 +46,15 @@ export function DatePicker({ }); }; - const formatDateInput = (dateStr: string) => { - if (!dateStr) return ''; - const d = new Date(dateStr + 'T00:00:00'); - return d.toLocaleDateString('en-GB', { - day: '2-digit', - month: '2-digit', - year: 'numeric', - }); - }; + // const formatDateInput = (dateStr: string) => { + // if (!dateStr) return ''; + // const d = new Date(dateStr + 'T00:00:00'); + // return d.toLocaleDateString('en-GB', { + // day: '2-digit', + // month: '2-digit', + // year: 'numeric', + // }); + // }; const displayFormatter = formatDisplay || defaultFormatDisplay; diff --git a/src/figma-make/components/base/date-range-picker.tsx b/src/figma-make/components/base/date-range-picker.tsx index d1bca47e..01b197b7 100644 --- a/src/figma-make/components/base/date-range-picker.tsx +++ b/src/figma-make/components/base/date-range-picker.tsx @@ -13,11 +13,6 @@ import { } from '@/figma-make/components/base/popover'; import { Input } from '@/figma-make/components/base/input'; -interface DateRange { - from: string; - to: string; -} - interface DateRangePickerProps { dateFrom: string; dateTo: string; diff --git a/src/figma-make/components/pages/daily-checklist/DailyChecklistContent.tsx b/src/figma-make/components/pages/daily-checklist/DailyChecklistContent.tsx index 8cef1da7..601025ad 100644 --- a/src/figma-make/components/pages/daily-checklist/DailyChecklistContent.tsx +++ b/src/figma-make/components/pages/daily-checklist/DailyChecklistContent.tsx @@ -86,17 +86,18 @@ export function DailyChecklistContent() { searchParams.get('category') || '' ); - const { options: kandangOptions, isLoadingOptions: isLoadingKandangs } = - useSelect(KandangApi.basePath, 'id', 'name', 'search', { + const { options: kandangOptions } = useSelect( + KandangApi.basePath, + 'id', + 'name', + 'search', + { page: '1', limit: '100', - }); + } + ); - const { - data: phases, - isLoading: isLoadingPhases, - mutate: refreshPhases, - } = useSWR< + const { data: phases } = useSWR< BaseApiResponse, AxiosError, SWRHttpKey @@ -104,11 +105,7 @@ export function DailyChecklistContent() { keepPreviousData: true, }); - const { - data: employeesRes, - isLoading: isLoadingEmployees, - mutate: refreshEmployees, - } = useSWR( + const { data: employeesRes } = useSWR( `${EmployeeApi.basePath}?page=1&limit=500&kandang_id=${kandangId}&is_active=true`, EmployeeApi.getAllFetcher, { diff --git a/src/figma-make/components/pages/dashboard/Dashboard.tsx b/src/figma-make/components/pages/dashboard/Dashboard.tsx index 8953ccf6..a924c2b3 100644 --- a/src/figma-make/components/pages/dashboard/Dashboard.tsx +++ b/src/figma-make/components/pages/dashboard/Dashboard.tsx @@ -16,12 +16,7 @@ import { SelectValue, } from '@/figma-make/components/base/select'; import { Badge } from '@/figma-make/components/base/badge'; -import { - Calendar as CalendarIcon, - Users, - AlertCircle, - Info, -} from 'lucide-react'; +import { Users, AlertCircle, Info } from 'lucide-react'; import { DateRangePicker } from '@/figma-make/components/base/date-range-picker'; import { BarChart, @@ -71,11 +66,7 @@ export function Dashboard() { const [kandangFilter, setKandangFilter] = useState('ALL'); const [categoryFilter, setCategoryFilter] = useState('ALL'); - const { - data: summaryResponse, - isLoading: isLoadingSummary, - mutate: refreshSummary, - } = useSWR< + const { data: summaryResponse, isLoading: isLoadingSummary } = useSWR< BaseApiResponse, AxiosError, SWRHttpKey @@ -86,11 +77,16 @@ export function Dashboard() { httpClientFetcher ); - const { options: kandangOptions, isLoadingOptions: isLoadingKandangs } = - useSelect(KandangApi.basePath, 'id', 'name', 'search', { + const { options: kandangOptions } = useSelect( + KandangApi.basePath, + 'id', + 'name', + 'search', + { page: '1', limit: '100', - }); + } + ); const kandangColorMap: { [key: string]: string } = {}; (kandangOptions || []).forEach((k, index) => { diff --git a/src/figma-make/components/pages/list-daily-checklist/ListDailyChecklistContent.tsx b/src/figma-make/components/pages/list-daily-checklist/ListDailyChecklistContent.tsx index 634d8716..6509a91d 100644 --- a/src/figma-make/components/pages/list-daily-checklist/ListDailyChecklistContent.tsx +++ b/src/figma-make/components/pages/list-daily-checklist/ListDailyChecklistContent.tsx @@ -38,11 +38,6 @@ import { KandangApi } from '@/services/api/master-data'; import DebouncedTextInput from '@/components/input/DebouncedTextInput'; import RequirePermission from '@/components/helper/RequirePermission'; -interface Kandang { - id: string; - name: string; -} - const STATUS_OPTIONS = [ { value: 'ALL', label: 'Semua Status' }, { value: 'DRAFT', label: 'Draft' }, @@ -98,11 +93,16 @@ export function ListDailyChecklistContent() { } ); - const { options: kandangOptions, isLoadingOptions: isLoadingKandangs } = - useSelect(KandangApi.basePath, 'id', 'name', 'search', { + const { options: kandangOptions } = useSelect( + KandangApi.basePath, + 'id', + 'name', + 'search', + { page: '1', limit: '100', - }); + } + ); const checklistList = isResponseSuccess(checklistListRes) ? checklistListRes.data || [] diff --git a/src/figma-make/components/pages/list-daily-checklist/detail/DetailDailyChecklistContent.tsx b/src/figma-make/components/pages/list-daily-checklist/detail/DetailDailyChecklistContent.tsx index 846a2670..88f04a80 100644 --- a/src/figma-make/components/pages/list-daily-checklist/detail/DetailDailyChecklistContent.tsx +++ b/src/figma-make/components/pages/list-daily-checklist/detail/DetailDailyChecklistContent.tsx @@ -17,7 +17,7 @@ import { DialogFooter, } from '@/figma-make/components/base/dialog'; import { toast } from 'sonner'; -import { notFound, useRouter, useSearchParams } from 'next/navigation'; +import { useRouter, useSearchParams } from 'next/navigation'; import { DailyChecklistApi } from '@/services/api/daily-checklist/daily-checklist'; import { isResponseError } from '@/lib/api-helper'; import Link from 'next/link'; @@ -90,16 +90,16 @@ interface ChecklistData { }; } -interface AssignmentQueryResult { - task_id: number; - employee_id: string; - checked: boolean; - note: string | null; - employees: { - id: number; - name: string; - } | null; -} +// interface AssignmentQueryResult { +// task_id: number; +// employee_id: string; +// checked: boolean; +// note: string | null; +// employees: { +// id: number; +// name: string; +// } | null; +// } const CATEGORY_LABELS: { [key: string]: string } = { pullet_open: 'Pullet Open', @@ -124,7 +124,7 @@ export function DetailDailyChecklistContent() { const [loading, setLoading] = useState(true); const [header, setHeader] = useState(null); - const [detailRows, setDetailRows] = useState([]); + const [, setDetailRows] = useState([]); const [phaseGroups, setPhaseGroups] = useState([]); const [employees, setEmployees] = useState<{ id: string; name: string }[]>( [] @@ -381,7 +381,7 @@ export function DetailDailyChecklistContent() { // Convert to array and group by time_type const grouped: PhaseGroup[] = []; - phaseMap.forEach((phaseData, phaseId) => { + phaseMap.forEach((phaseData) => { const timeGroups: { [timeType: string]: { activities: { @@ -570,9 +570,6 @@ export function DetailDailyChecklistContent() { return null; } - const isReadOnly = - header.status === 'APPROVED' || header.status === 'REJECTED'; - return (
@@ -680,7 +677,7 @@ export function DetailDailyChecklistContent() { {header.status === 'REJECTED' && header.reject_reason && (
- +