mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 05:22:02 +00:00
Merge branch 'development' into 'staging'
Development See merge request mbugroup/lti-web-client!331
This commit is contained in:
@@ -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';
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
+1
-2
@@ -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();
|
||||
|
||||
@@ -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, () => ({
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import IconSkeleton from '@/components/helper/skeleton/IconSkeleton';
|
||||
import { Icon } from '@iconify/react';
|
||||
|
||||
const DataStateSkeleton = ({
|
||||
icon,
|
||||
|
||||
@@ -4,7 +4,6 @@ import { ChangeEvent } from 'react';
|
||||
import {
|
||||
PatternFormat,
|
||||
NumberFormatBase,
|
||||
NumberFormatBaseProps,
|
||||
OnValueChange,
|
||||
} from 'react-number-format';
|
||||
import TextInput, { TextInputProps } from '@/components/input/TextInput';
|
||||
|
||||
@@ -56,7 +56,7 @@ const ConfirmationModalWithNotes: React.FC<ConfirmationModalWithNotesProps> = ({
|
||||
closeOnBackdrop={closeOnBackdrop}
|
||||
primaryButton={{
|
||||
...primaryButton,
|
||||
onClick: (e) => {
|
||||
onClick: () => {
|
||||
if (primaryButton && primaryButton?.onClick) {
|
||||
primaryButton?.onClick?.(notes);
|
||||
} else {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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',
|
||||
});
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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<Bank>(BankApi.basePath, 'id', 'name');
|
||||
|
||||
// ===== Helper Functions =====
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
InventoryAdjustmentFormSchema,
|
||||
InventoryAdjustmentFormValues,
|
||||
} from '@/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.schema';
|
||||
import useSWR from 'swr';
|
||||
import {
|
||||
ProductApi,
|
||||
ProductCategoryApi,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
},
|
||||
}}
|
||||
|
||||
@@ -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'
|
||||
>
|
||||
<Icon icon='heroicons:trash' width={20} height={20} />
|
||||
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<Marketing | null>(null);
|
||||
const [rowSelection, setRowSelection] = useState<Record<string, boolean>>({});
|
||||
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 = () => {
|
||||
</RequirePermission>
|
||||
{idsToProcess.length > 0 && (
|
||||
<>
|
||||
<div className='divider divider-horizontal w-0.25 p-0 m-0 bg-base-content/10 text-base-content/10 before:bg-base-content/10 before:w-0.25 after:bg-base-content/10 after:w-0.25'></div>
|
||||
<div className='divider divider-horizontal w-px p-0 m-0 bg-base-content/10 text-base-content/10 before:bg-base-content/10 before:w-px after:bg-base-content/10 after:w-px'></div>
|
||||
<RequirePermission permissions='lti.marketing.sales_order.approve'>
|
||||
<Button
|
||||
color='error'
|
||||
@@ -567,16 +588,28 @@ const MarketingTable = () => {
|
||||
)}
|
||||
</div>
|
||||
<div className='flex flex-row gap-3'>
|
||||
<ButtonFilter
|
||||
values={(() => {
|
||||
const { page, pageSize, ...rest } = tableFilterState;
|
||||
return rest;
|
||||
})()}
|
||||
<Button
|
||||
variant='outline'
|
||||
color='none'
|
||||
onClick={() => {
|
||||
filterModal.openModal();
|
||||
}}
|
||||
className='rounded-lg px-3 py-2.5'
|
||||
/>
|
||||
className={cn(
|
||||
'px-3 py-2.5 gap-1.5 text-sm text-base-content/50 border border-base-content/10 rounded-xl shadow-button-soft transition-all',
|
||||
{
|
||||
'border-primary-gradient text-primary':
|
||||
activeFiltersCount > 0,
|
||||
}
|
||||
)}
|
||||
>
|
||||
<Icon icon='heroicons:funnel' width={20} height={20} />
|
||||
Filter
|
||||
{activeFiltersCount > 0 && (
|
||||
<span className='w-5 h-5 text-white bg-[#FF3535] rounded-lg border border-base-300 flex items-center justify-center text-xs'>
|
||||
{activeFiltersCount}
|
||||
</span>
|
||||
)}
|
||||
</Button>
|
||||
<Dropdown
|
||||
align='end'
|
||||
direction='bottom'
|
||||
|
||||
@@ -81,7 +81,7 @@ const SalesOrderFormModal = ({
|
||||
);
|
||||
};
|
||||
|
||||
const { data: marketing, isLoading: isLoadingMarketing } = useSWR(
|
||||
const { data: marketing } = useSWR(
|
||||
isModalActionForForm && marketingId
|
||||
? `detail-marketing-${marketingId}`
|
||||
: undefined,
|
||||
@@ -750,7 +750,7 @@ const SalesOrderFormModal = ({
|
||||
text: 'Oke',
|
||||
color: 'primary',
|
||||
className: 'rounded-lg',
|
||||
onClick: (e) => {
|
||||
onClick: () => {
|
||||
closeModalHandler();
|
||||
},
|
||||
}}
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -139,12 +139,12 @@ const SalesOrderProductForm = ({
|
||||
} = useSelect<Kandang>(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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 }) => {
|
||||
</View>
|
||||
</View>
|
||||
{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 (
|
||||
<View
|
||||
key={index}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useModal } from '@/components/Modal';
|
||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||
import { isResponseError } from '@/lib/api-helper';
|
||||
import { CustomerApi } from '@/services/api/master-data';
|
||||
import {
|
||||
CreateCustomerPayload,
|
||||
@@ -27,7 +27,6 @@ import SelectInput, {
|
||||
OptionType,
|
||||
useSelect,
|
||||
} from '@/components/input/SelectInput';
|
||||
import useSWR from 'swr';
|
||||
import { UserApi } from '@/services/api/user';
|
||||
import { TYPE_OPTIONS } from '@/config/constant';
|
||||
import RequirePermission from '@/components/helper/RequirePermission';
|
||||
|
||||
@@ -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 {
|
||||
KandangFormValues,
|
||||
UpdateKandangFormSchema,
|
||||
} from '@/components/pages/master-data/kandang/form/KandangForm.schema';
|
||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||
import { isResponseError } from '@/lib/api-helper';
|
||||
import {
|
||||
Kandang,
|
||||
CreateKandangPayload,
|
||||
|
||||
@@ -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 {
|
||||
LocationFormValues,
|
||||
UpdateLocationFormSchema,
|
||||
} from '@/components/pages/master-data/location/form/LocationForm.schema';
|
||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||
import { isResponseError } from '@/lib/api-helper';
|
||||
import {
|
||||
Location,
|
||||
CreateLocationPayload,
|
||||
|
||||
@@ -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 {
|
||||
NonstockFormValues,
|
||||
UpdateNonstockFormSchema,
|
||||
} from '@/components/pages/master-data/nonstock/form/NonstockForm.schema';
|
||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||
import { isResponseError } from '@/lib/api-helper';
|
||||
import {
|
||||
Nonstock,
|
||||
CreateNonstockPayload,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import Button from '@/components/Button';
|
||||
import { FormHeader } from '@/components/helper/form/FormHeader';
|
||||
import Table, { TABLE_DEFAULT_STYLING } from '@/components/Table';
|
||||
import { ProductionStandard } from '@/types/api/master-data/production-standard';
|
||||
import { Icon } from '@iconify/react';
|
||||
@@ -82,14 +81,11 @@ const ProductionStandardTable = () => {
|
||||
>(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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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<HTMLTextAreaElement> = (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) {
|
||||
|
||||
@@ -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';
|
||||
@@ -37,6 +31,7 @@ import ProjectFlockConfirmationModal from './ProjectFlockConfirmationModal';
|
||||
import { useProjectFlockStore } from '@/stores/production/project-flock/project-flock.store';
|
||||
import { ProjectFlockFormValues } from './form/ProjectFlockForm.schema';
|
||||
import { useChickinStore } from '@/stores/production/chickin/chickin.store';
|
||||
import { useProjectFlockClosingStore } from '@/stores/production/project-flock-closing/project-flock-closing.store';
|
||||
|
||||
const RowOptionsMenu = ({
|
||||
props,
|
||||
@@ -182,19 +177,12 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
||||
.filter((id) => rowSelection[id])
|
||||
.map((id) => parseInt(id));
|
||||
|
||||
const [selectedArea, setSelectedArea] = useState<OptionType | null>(null);
|
||||
const [selectedLocation, setSelectedLocation] = useState<OptionType | null>(
|
||||
null
|
||||
);
|
||||
const [selectedKandang, setSelectedKandang] = useState<OptionType | null>(
|
||||
null
|
||||
);
|
||||
const [periodInputValue, setPeriodInputValue] = useState<number | null>(null);
|
||||
const [sorting, setSorting] = useState<SortingState>([]);
|
||||
const deleteModal = useModal();
|
||||
const confirmModal = useModal();
|
||||
const successModal = useModal();
|
||||
const chickinApproveModal = useModal();
|
||||
const closingModal = useModal();
|
||||
const [approvalAction, setApprovalAction] = useState<'APPROVED' | 'REJECTED'>(
|
||||
'APPROVED'
|
||||
);
|
||||
@@ -210,6 +198,15 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
||||
setChickinApproveLoading,
|
||||
} = useChickinStore();
|
||||
|
||||
const {
|
||||
isClosingModalOpen,
|
||||
isKandangClosed,
|
||||
isClosingLoading,
|
||||
closingCallback,
|
||||
closeClosingModal,
|
||||
setClosingLoading,
|
||||
} = useProjectFlockClosingStore();
|
||||
|
||||
// ===== Fetch Data =====
|
||||
const {
|
||||
data: projectFlocks,
|
||||
@@ -221,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);
|
||||
@@ -309,6 +286,14 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
||||
}
|
||||
}, [isChickinApproveModalOpen, chickinApproveModal]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isClosingModalOpen) {
|
||||
closingModal.openModal();
|
||||
} else {
|
||||
closingModal.closeModal();
|
||||
}
|
||||
}, [isClosingModalOpen, closingModal]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isSuccess) {
|
||||
successModal.openModal();
|
||||
@@ -1025,6 +1010,45 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
||||
isLoading: isChickinApproveLoading,
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Project Flock Closing Modal */}
|
||||
<ConfirmationModal
|
||||
ref={closingModal.ref}
|
||||
type='error'
|
||||
text={
|
||||
!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'
|
||||
}
|
||||
className={{
|
||||
modal: 'z-9999',
|
||||
}}
|
||||
secondaryButton={{
|
||||
text: 'Tidak',
|
||||
onClick: () => {
|
||||
closeClosingModal();
|
||||
closingModal.closeModal();
|
||||
},
|
||||
}}
|
||||
primaryButton={{
|
||||
text: 'Ya',
|
||||
color: 'error',
|
||||
isLoading: isClosingLoading,
|
||||
onClick: async () => {
|
||||
if (closingCallback) {
|
||||
setClosingLoading(true);
|
||||
try {
|
||||
await closingCallback(!isKandangClosed ? 'close' : 'unclose');
|
||||
} finally {
|
||||
setClosingLoading(false);
|
||||
closeClosingModal();
|
||||
closingModal.closeModal();
|
||||
refreshProjectFlocks();
|
||||
}
|
||||
}
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -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';
|
||||
@@ -17,12 +16,10 @@ import { Icon } from '@iconify/react';
|
||||
import useSWR from 'swr';
|
||||
import { ProjectFlockKandangApi } from '@/services/api/production/project-flock-kandang';
|
||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||
import { useModal } from '@/components/Modal';
|
||||
import ConfirmationModal from '@/components/modal/ConfirmationModal';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useProjectFlockClosingStore } from '@/stores/production/project-flock-closing/project-flock-closing.store';
|
||||
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';
|
||||
|
||||
@@ -53,56 +50,46 @@ const ProjectFlockClosingForm = ({
|
||||
projectFlockKandang: ProjectFlockKandang;
|
||||
}) => {
|
||||
const router = useRouter();
|
||||
const closeModal = useModal();
|
||||
|
||||
const [isClosingLoading, setIsClosingLoading] = useState(false);
|
||||
const { openClosingModal } = useProjectFlockClosingStore();
|
||||
|
||||
const { data: closingData, isLoading } = useSWR(
|
||||
`${ProjectFlockKandangApi.basePath}/${projectFlockKandang.id}/closing`,
|
||||
() => 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 confirmationModalCloseClickHandler = async () => {
|
||||
setIsClosingLoading(true);
|
||||
const deleteProjectFlockRes = await ProjectFlockKandangApi.closing(
|
||||
projectFlockKandang?.id as number,
|
||||
{
|
||||
closed_date: !isKandangClosed
|
||||
? formatDate(new Date(), 'YYYY-MM-DD')
|
||||
: '',
|
||||
action: !isKandangClosed ? 'close' : 'unclose',
|
||||
}
|
||||
);
|
||||
|
||||
if (isResponseSuccess(deleteProjectFlockRes)) {
|
||||
toast.success(deleteProjectFlockRes?.message as string);
|
||||
router.push(
|
||||
`/production/project-flock/detail?projectFlockId=${projectFlock.id}`
|
||||
const handleCloseClick = () => {
|
||||
const closingCallback = async (action: 'close' | 'unclose') => {
|
||||
const deleteProjectFlockRes = await ProjectFlockKandangApi.closing(
|
||||
projectFlockKandang?.id as number,
|
||||
{
|
||||
closed_date:
|
||||
action === 'close' ? formatDate(new Date(), 'YYYY-MM-DD') : '',
|
||||
action,
|
||||
}
|
||||
);
|
||||
}
|
||||
if (isResponseError(deleteProjectFlockRes)) {
|
||||
toast.error(deleteProjectFlockRes?.message as string);
|
||||
}
|
||||
setIsClosingLoading(false);
|
||||
closeModal.closeModal();
|
||||
|
||||
if (isResponseSuccess(deleteProjectFlockRes)) {
|
||||
toast.success(deleteProjectFlockRes?.message as string);
|
||||
router.push(
|
||||
`/production/project-flock/detail?projectFlockId=${projectFlock.id}`
|
||||
);
|
||||
}
|
||||
if (isResponseError(deleteProjectFlockRes)) {
|
||||
toast.error(deleteProjectFlockRes?.message as string);
|
||||
}
|
||||
};
|
||||
|
||||
openClosingModal(
|
||||
projectFlockKandang,
|
||||
projectFlock.id,
|
||||
isKandangClosed,
|
||||
closingCallback
|
||||
);
|
||||
};
|
||||
|
||||
// const errorStock = useMemo(() => {
|
||||
@@ -334,7 +321,7 @@ const ProjectFlockClosingForm = ({
|
||||
color='error'
|
||||
isLoading={isLoading}
|
||||
disabled={!isCanCloseValid}
|
||||
onClick={() => closeModal.openModal()}
|
||||
onClick={handleCloseClick}
|
||||
>
|
||||
<Icon
|
||||
icon={
|
||||
@@ -347,25 +334,6 @@ const ProjectFlockClosingForm = ({
|
||||
</Button>
|
||||
</RequirePermission>
|
||||
</div>
|
||||
|
||||
<ConfirmationModal
|
||||
ref={closeModal.ref}
|
||||
type='error'
|
||||
text={
|
||||
!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'
|
||||
}
|
||||
secondaryButton={{
|
||||
text: 'Tidak',
|
||||
}}
|
||||
primaryButton={{
|
||||
text: 'Ya',
|
||||
color: 'error',
|
||||
isLoading: isClosingLoading,
|
||||
onClick: confirmationModalCloseClickHandler,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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<Kandang[]>(
|
||||
@@ -475,9 +473,9 @@ const ProjectFlockForm = ({
|
||||
formikSetValues(formikInitialValues);
|
||||
};
|
||||
|
||||
const [formikLastValues, setFormikLastValues] = useState<
|
||||
ProjectFlockFormValues | undefined
|
||||
>(undefined);
|
||||
const [, setFormikLastValues] = useState<ProjectFlockFormValues | undefined>(
|
||||
undefined
|
||||
);
|
||||
|
||||
// Formik InitialValue
|
||||
const formikInitialValues = useMemo<ProjectFlockFormValues>(() => {
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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;
|
||||
|
||||
+2
-2
@@ -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<TransferToLayingConfirmationTableDataType>[] =
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
@@ -83,6 +82,9 @@ const TransferToLayingFormModal = () => {
|
||||
TransferToLayingFormValues | undefined
|
||||
>(undefined);
|
||||
const [formErrorMessage, setFormErrorMessage] = useState<string | null>(null);
|
||||
const [submittedActionType, setSubmittedActionType] = useState<
|
||||
'add' | 'edit' | null
|
||||
>(null);
|
||||
|
||||
// Flock Source
|
||||
const {
|
||||
@@ -175,7 +177,7 @@ const TransferToLayingFormModal = () => {
|
||||
[router]
|
||||
);
|
||||
|
||||
const [formikInitialValues, setFormikInitialValues] = useState(
|
||||
const [formikInitialValues] = useState(
|
||||
getTransferToLayingFormInitialValues()
|
||||
);
|
||||
|
||||
@@ -203,6 +205,7 @@ const TransferToLayingFormModal = () => {
|
||||
};
|
||||
|
||||
setFormikLastValues(values);
|
||||
setSubmittedActionType(modalAction as 'add' | 'edit');
|
||||
|
||||
switch (modalAction) {
|
||||
case 'add':
|
||||
@@ -234,10 +237,7 @@ const TransferToLayingFormModal = () => {
|
||||
)
|
||||
: undefined;
|
||||
|
||||
const {
|
||||
data: flockSourceKandangsAvailability,
|
||||
isLoading: isLoadingFlockSourceKandangsAvailability,
|
||||
} = useSWR(
|
||||
const { data: flockSourceKandangsAvailability } = useSWR(
|
||||
formik.values.flockSource
|
||||
? [
|
||||
'transfer-to-laying',
|
||||
@@ -293,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',
|
||||
@@ -1059,10 +1056,21 @@ const TransferToLayingFormModal = () => {
|
||||
<TransferToLayingConfirmationModal
|
||||
ref={successModal.ref}
|
||||
type='success'
|
||||
text='Data Berhasil Ditambahkan'
|
||||
subtitleText='Data transfer to laying telah berhasil disimpan.'
|
||||
text={
|
||||
submittedActionType === 'edit'
|
||||
? 'Data Berhasil Diperbarui'
|
||||
: 'Data Berhasil Ditambahkan'
|
||||
}
|
||||
subtitleText={
|
||||
submittedActionType === 'edit'
|
||||
? 'Data transfer to laying telah berhasil diperbarui.'
|
||||
: 'Data transfer to laying telah berhasil disimpan.'
|
||||
}
|
||||
transferToLayingForm={formikLastValues}
|
||||
onClose={() => setFormikLastValues(undefined)}
|
||||
onClose={() => {
|
||||
setFormikLastValues(undefined);
|
||||
setSubmittedActionType(null);
|
||||
}}
|
||||
secondaryButton={undefined}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -680,6 +680,7 @@ const TransferToLayingsTable = () => {
|
||||
subtitleText='Are you sure you want to delete this data? '
|
||||
transferToLayingIds={selectedRowIds}
|
||||
primaryButton={{
|
||||
text: 'Delete',
|
||||
isLoading: isDeleteLoading,
|
||||
color: 'error',
|
||||
onClick: confirmationModalDeleteClickHandler,
|
||||
@@ -704,6 +705,7 @@ const TransferToLayingsTable = () => {
|
||||
withNote
|
||||
noteLabel='Notes Approval'
|
||||
primaryButton={{
|
||||
text: 'Approve',
|
||||
isLoading: isApproveLoading,
|
||||
onClick: confirmationModalApproveClickHandler,
|
||||
}}
|
||||
@@ -735,6 +737,7 @@ const TransferToLayingsTable = () => {
|
||||
},
|
||||
}}
|
||||
primaryButton={{
|
||||
text: 'Reject',
|
||||
isLoading: isRejectLoading,
|
||||
color: 'error',
|
||||
onClick: confirmationModalRejectClickHandler,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -203,16 +203,19 @@ const UniformityForm = ({
|
||||
|
||||
// ===== RECORDINGS DATA (FOR WEEK CALCULATION) =====
|
||||
const recordingsUrl = useMemo(() => {
|
||||
if (!projectFlockKandangLookup?.project_flock_kandang_id) return null;
|
||||
const params = new URLSearchParams({
|
||||
page: '1',
|
||||
limit: '100',
|
||||
project_flock_kandang_id:
|
||||
projectFlockKandangLookup.project_flock_kandang_id.toString(),
|
||||
});
|
||||
return `${RecordingApi.basePath}?${params.toString()}`;
|
||||
}, []);
|
||||
}, [projectFlockKandangLookup?.project_flock_kandang_id]);
|
||||
|
||||
const { data: recordingsData } = useSWR(
|
||||
recordingsUrl,
|
||||
RecordingApi.getAllFetcher
|
||||
recordingsUrl ? RecordingApi.getAllFetcher : null
|
||||
);
|
||||
|
||||
// ===== FORM CONFIGURATION =====
|
||||
@@ -400,50 +403,46 @@ const UniformityForm = ({
|
||||
useEffect(() => {
|
||||
if (
|
||||
projectFlockKandangLookup?.chick_in_date &&
|
||||
projectFlockKandangLookup?.project_flock_kandang_id &&
|
||||
isResponseSuccess(recordingsData) &&
|
||||
recordingsData.data
|
||||
projectFlockKandangLookup?.project_flock_kandang_id
|
||||
) {
|
||||
const matchingRecordings = recordingsData.data.filter(
|
||||
(recording: Recording) =>
|
||||
recording.project_flock?.project_flock_kandang_id ===
|
||||
projectFlockKandangLookup.project_flock_kandang_id
|
||||
);
|
||||
const chickInDate = new Date(projectFlockKandangLookup.chick_in_date);
|
||||
chickInDate.setHours(0, 0, 0, 0);
|
||||
|
||||
matchingRecordings.sort(
|
||||
(a: Recording, b: Recording) =>
|
||||
new Date(a.record_datetime).getTime() -
|
||||
new Date(b.record_datetime).getTime()
|
||||
);
|
||||
let initialWeek = 18;
|
||||
|
||||
const earliestRecording = matchingRecordings[0];
|
||||
if (
|
||||
isResponseSuccess(recordingsData) &&
|
||||
recordingsData.data &&
|
||||
recordingsData.data.length > 0
|
||||
) {
|
||||
const sortedRecordings = [...recordingsData.data].sort(
|
||||
(a: Recording, b: Recording) =>
|
||||
new Date(a.record_datetime).getTime() -
|
||||
new Date(b.record_datetime).getTime()
|
||||
);
|
||||
|
||||
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);
|
||||
const earliestRecording = sortedRecordings[0];
|
||||
if (earliestRecording?.project_flock?.production_standart?.week) {
|
||||
initialWeek =
|
||||
earliestRecording.project_flock.production_standart.week;
|
||||
}
|
||||
}
|
||||
|
||||
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?.chick_in_date,
|
||||
|
||||
@@ -153,11 +153,9 @@ const PurchaseOrderAcceptApprovalForm = ({
|
||||
|
||||
// ===== SELECT INPUT DATA =====
|
||||
const {
|
||||
setInputValue: setExpeditionsSelectInputValue,
|
||||
options: expeditionVendors,
|
||||
isLoadingOptions: isLoadingExpeditions,
|
||||
loadMore: loadMoreExpeditions,
|
||||
hasMore: hasMoreExpeditions,
|
||||
} = useSelect<Supplier>(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 (
|
||||
|
||||
@@ -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<number[]>(
|
||||
[]
|
||||
);
|
||||
@@ -149,7 +149,6 @@ const PurchaseRequestForm = ({
|
||||
isLoadingOptions: isLoadingSuppliers,
|
||||
rawData: supplierRawData,
|
||||
loadMore: loadMoreSuppliers,
|
||||
hasMore: hasMoreSuppliers,
|
||||
} = useSelect<Supplier>(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) => (
|
||||
<tr key={`purchase-item-${idx}`}>
|
||||
{type !== 'detail' && (
|
||||
<td className='!align-middle'>
|
||||
<td className='align-middle!'>
|
||||
<CheckboxInput
|
||||
name={`purchase-item-${idx}`}
|
||||
checked={selectedPurchaseItems.includes(idx)}
|
||||
|
||||
@@ -84,7 +84,6 @@ interface PurchaseOrderDetailProps {
|
||||
}
|
||||
|
||||
const PurchaseOrderDetail = ({
|
||||
type = 'detail',
|
||||
initialValues,
|
||||
refetchData,
|
||||
}: PurchaseOrderDetailProps) => {
|
||||
@@ -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',
|
||||
}}
|
||||
>
|
||||
<PurchaseOrderStaffApprovalForm
|
||||
@@ -1061,7 +1060,7 @@ const PurchaseOrderDetail = ({
|
||||
ref={acceptApprovalModal.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',
|
||||
}}
|
||||
>
|
||||
<PurchaseOrderAcceptApprovalForm
|
||||
@@ -1079,7 +1078,7 @@ const PurchaseOrderDetail = ({
|
||||
ref={editModal.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',
|
||||
}}
|
||||
>
|
||||
<PurchaseOrderStaffApprovalForm
|
||||
@@ -1098,7 +1097,7 @@ const PurchaseOrderDetail = ({
|
||||
ref={penerimaanBarangModal.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',
|
||||
}}
|
||||
>
|
||||
<PurchaseOrderAcceptApprovalForm
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as XLSX from 'xlsx';
|
||||
import { ReportExpense } from '@/types/api/report/report-expense';
|
||||
import { formatCurrency, formatDate } from '@/lib/helper';
|
||||
import { formatDate } from '@/lib/helper';
|
||||
|
||||
export const generateReportExpenseExcel = async (
|
||||
data: ReportExpense[]
|
||||
|
||||
@@ -65,7 +65,7 @@ const getTableColumns = (
|
||||
header: 'No',
|
||||
flex: 0.5,
|
||||
align: 'center',
|
||||
cell: ({ row, index }) => index + 1,
|
||||
cell: ({ index }) => index + 1,
|
||||
footer: 'Total',
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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',
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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[];
|
||||
|
||||
@@ -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 = ({
|
||||
|
||||
@@ -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<
|
||||
|
||||
@@ -61,7 +61,7 @@ const getTableColumns = (
|
||||
header: 'No',
|
||||
flex: 0.5,
|
||||
align: 'center',
|
||||
cell: ({ row, index }) => index + 1,
|
||||
cell: ({ index }) => index + 1,
|
||||
footer: 'Total',
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -142,7 +142,7 @@ const getDetailColumns = (
|
||||
header: 'No',
|
||||
flex: 0.5,
|
||||
align: 'center',
|
||||
cell: ({ row, index }) => index + 1,
|
||||
cell: ({ index }) => index + 1,
|
||||
footer: 'TOTAL',
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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<HppPerKandangReport | null> => {
|
||||
|
||||
-1
@@ -28,7 +28,6 @@ const ProductionResultProjectFlockKandangTable = ({
|
||||
setPage,
|
||||
setPageSize,
|
||||
toQueryString: getTableFilterQueryString,
|
||||
reset: resetFilter,
|
||||
} = useTableFilter({
|
||||
initial: {
|
||||
filter_by: '',
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<Phase[] | undefined>,
|
||||
AxiosError<BaseApiResponse>,
|
||||
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,
|
||||
{
|
||||
|
||||
@@ -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<DailyChecklistSummary | undefined>,
|
||||
AxiosError<BaseApiResponse>,
|
||||
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) => {
|
||||
|
||||
@@ -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 || []
|
||||
|
||||
+14
-17
@@ -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<ChecklistHeader | null>(null);
|
||||
const [detailRows, setDetailRows] = useState<ChecklistDetailRow[]>([]);
|
||||
const [, setDetailRows] = useState<ChecklistDetailRow[]>([]);
|
||||
const [phaseGroups, setPhaseGroups] = useState<PhaseGroup[]>([]);
|
||||
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 (
|
||||
<div className='min-h-screen'>
|
||||
<div className='p-6'>
|
||||
@@ -680,7 +677,7 @@ export function DetailDailyChecklistContent() {
|
||||
{header.status === 'REJECTED' && header.reject_reason && (
|
||||
<div className='mt-6 pt-6 border-t border-gray-200'>
|
||||
<div className='flex items-start gap-3 p-4 bg-red-50 border border-red-200 rounded-lg'>
|
||||
<AlertCircle className='w-5 h-5 text-red-600 mt-0.5 flex-shrink-0' />
|
||||
<AlertCircle className='w-5 h-5 text-red-600 mt-0.5 shrink-0' />
|
||||
<div>
|
||||
<Label className='text-sm font-medium text-red-900'>
|
||||
Alasan Reject
|
||||
|
||||
@@ -69,11 +69,7 @@ export function MasterAktivitasContent() {
|
||||
const [selectedCategory, setSelectedCategory] = useState<string>('');
|
||||
const [selectedPhase, setSelectedPhase] = useState<Phase | null>(null);
|
||||
|
||||
const {
|
||||
data: phases,
|
||||
isLoading: isLoadingPhases,
|
||||
mutate: refreshPhases,
|
||||
} = useSWR<
|
||||
const { data: phases, mutate: refreshPhases } = useSWR<
|
||||
BaseApiResponse<Phase[] | undefined>,
|
||||
AxiosError<BaseApiResponse>,
|
||||
SWRHttpKey
|
||||
@@ -87,11 +83,7 @@ export function MasterAktivitasContent() {
|
||||
}
|
||||
);
|
||||
|
||||
const {
|
||||
data: phaseActivities,
|
||||
isLoading: isLoadingPhaseActivities,
|
||||
mutate: refreshPhaseActivities,
|
||||
} = useSWR<
|
||||
const { data: phaseActivities, mutate: refreshPhaseActivities } = useSWR<
|
||||
BaseApiResponse<PhaseActivity[] | undefined>,
|
||||
AxiosError<BaseApiResponse>,
|
||||
SWRHttpKey
|
||||
@@ -630,7 +622,7 @@ export function MasterAktivitasContent() {
|
||||
<th className='text-left py-3.5 px-6 text-sm font-semibold text-gray-700'>
|
||||
Nama Aktivitas
|
||||
</th>
|
||||
<th className='text-center py-3.5 px-6 text-sm font-semibold text-gray-700 w-[80px]'>
|
||||
<th className='text-center py-3.5 px-6 text-sm font-semibold text-gray-700 w-20'>
|
||||
Aksi
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
+1
-5
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useState } from 'react';
|
||||
import { Plus, MoreVertical, Pencil, Trash2 } from 'lucide-react';
|
||||
import { Card, CardContent } from '@/figma-make/components/base/card';
|
||||
import { Button } from '@/figma-make/components/base/button';
|
||||
@@ -295,10 +295,6 @@ export function MasterConfigurationContent() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleExport = (format: string) => {
|
||||
toast.success(`Data berhasil diekspor ke ${format}`);
|
||||
};
|
||||
|
||||
if (isLoadingDailyChecklistConfigurations && !dailyChecklistConfigurations) {
|
||||
return (
|
||||
<div className='min-h-screen'>
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import {
|
||||
Plus,
|
||||
Download,
|
||||
ChevronDown,
|
||||
MoreVertical,
|
||||
Pencil,
|
||||
Trash2,
|
||||
Search,
|
||||
} from 'lucide-react';
|
||||
import { Plus, MoreVertical, Pencil, Trash2, Search } from 'lucide-react';
|
||||
import { Card, CardContent } from '@/figma-make/components/base/card';
|
||||
import { Button } from '@/figma-make/components/base/button';
|
||||
import { Label } from '@/figma-make/components/base/label';
|
||||
@@ -93,11 +85,16 @@ export function MasterEmployeeContent() {
|
||||
keepPreviousData: true,
|
||||
}
|
||||
);
|
||||
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 [showModal, setShowModal] = useState(false);
|
||||
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
||||
@@ -373,7 +370,7 @@ export function MasterEmployeeContent() {
|
||||
updateFilter('status', value === 'all' ? '' : value);
|
||||
}}
|
||||
>
|
||||
<SelectTrigger className='w-[160px] border-gray-200'>
|
||||
<SelectTrigger className='w-40 border-gray-200'>
|
||||
<SelectValue placeholder='Semua Status' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import { useMemo } from 'react';
|
||||
import { Card, CardContent } from '@/figma-make/components/base/card';
|
||||
import { Badge } from '@/figma-make/components/base/badge';
|
||||
import { Label } from '@/figma-make/components/base/label';
|
||||
import {
|
||||
Select,
|
||||
@@ -11,8 +10,6 @@ import {
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/figma-make/components/base/select';
|
||||
import { toast } from 'sonner';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useSelect } from '@/components/input/SelectInput';
|
||||
import { AreaApi, KandangApi, LocationApi } from '@/services/api/master-data';
|
||||
import useSWR from 'swr';
|
||||
@@ -26,7 +23,6 @@ import { isResponseSuccess } from '@/lib/api-helper';
|
||||
import { useTableFilter } from '@/services/hooks/useTableFilter';
|
||||
import { cn } from '@/lib/helper';
|
||||
import { ColumnDef } from '@tanstack/react-table';
|
||||
import { report } from 'process';
|
||||
import { PhaseApi } from '@/services/api/daily-checklist/phase';
|
||||
import { EmployeeApi } from '@/services/api/daily-checklist/employee';
|
||||
import { Button } from '@/figma-make/components/base/button';
|
||||
@@ -66,8 +62,6 @@ const YEAR_OPTIONS = [
|
||||
// };
|
||||
|
||||
export function DailyChecklistReportsContent() {
|
||||
const router = useRouter();
|
||||
|
||||
const currentMonth = useMemo(() => new Date().getMonth() + 1, []);
|
||||
const currentYear = useMemo(() => new Date().getFullYear(), []);
|
||||
|
||||
@@ -100,11 +94,7 @@ export function DailyChecklistReportsContent() {
|
||||
},
|
||||
});
|
||||
|
||||
const {
|
||||
data: reportResponse,
|
||||
isLoading: isLoadingReport,
|
||||
mutate: refreshReport,
|
||||
} = useSWR<
|
||||
const { data: reportResponse, isLoading: isLoadingReport } = useSWR<
|
||||
BaseApiResponse<DailyChecklistReport[] | undefined>,
|
||||
AxiosError<BaseApiResponse>,
|
||||
SWRHttpKey
|
||||
@@ -116,7 +106,7 @@ export function DailyChecklistReportsContent() {
|
||||
}
|
||||
);
|
||||
|
||||
const { options: areaOptions, isLoadingOptions: isLoadingAreas } = useSelect(
|
||||
const { options: areaOptions } = useSelect(
|
||||
AreaApi.basePath,
|
||||
'id',
|
||||
'name',
|
||||
@@ -127,33 +117,53 @@ export function DailyChecklistReportsContent() {
|
||||
}
|
||||
);
|
||||
|
||||
const { options: locationOptions, isLoadingOptions: isLoadingLocations } =
|
||||
useSelect(LocationApi.basePath, 'id', 'name', 'search', {
|
||||
const { options: locationOptions } = useSelect(
|
||||
LocationApi.basePath,
|
||||
'id',
|
||||
'name',
|
||||
'search',
|
||||
{
|
||||
page: '1',
|
||||
limit: '100',
|
||||
area_id: tableFilterState.area_id,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const { options: kandangOptions, isLoadingOptions: isLoadingKandangs } =
|
||||
useSelect(KandangApi.basePath, 'id', 'name', 'search', {
|
||||
const { options: kandangOptions } = useSelect(
|
||||
KandangApi.basePath,
|
||||
'id',
|
||||
'name',
|
||||
'search',
|
||||
{
|
||||
page: '1',
|
||||
limit: '100',
|
||||
area_id: tableFilterState.area_id,
|
||||
location_id: tableFilterState.location_id,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const { options: phaseOptions, isLoadingOptions: isLoadingPhases } =
|
||||
useSelect(PhaseApi.basePath, 'id', 'name', 'search', {
|
||||
const { options: phaseOptions } = useSelect(
|
||||
PhaseApi.basePath,
|
||||
'id',
|
||||
'name',
|
||||
'search',
|
||||
{
|
||||
page: '1',
|
||||
limit: '100',
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const { options: employeeOptions, isLoadingOptions: isLoadingEmployees } =
|
||||
useSelect(EmployeeApi.basePath, 'id', 'name', 'search', {
|
||||
const { options: employeeOptions } = useSelect(
|
||||
EmployeeApi.basePath,
|
||||
'id',
|
||||
'name',
|
||||
'search',
|
||||
{
|
||||
page: '1',
|
||||
limit: '500',
|
||||
kandang_id: tableFilterState.kandang_id,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const currentMonthMaxDay = new Date(
|
||||
Number(tableFilterState.tahun),
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
} from '@/types/api/daily-checklist/daily-checklist';
|
||||
import { isResponseError } from '@/lib/api-helper';
|
||||
import { toast } from 'sonner';
|
||||
import { formatDate } from '@/lib/helper';
|
||||
|
||||
export class DailyChecklistApiService extends BaseApiService<
|
||||
DailyChecklist,
|
||||
@@ -316,7 +315,7 @@ export class DailyChecklistApiService extends BaseApiService<
|
||||
wb,
|
||||
`laporan-daily-checklist-${params.get('tahun')}-${params.get('bulan')}.xlsx`
|
||||
);
|
||||
} catch (error) {
|
||||
} catch {
|
||||
toast.error('Gagal melakukan export daily checklist! Coba lagi.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import axios from 'axios';
|
||||
import { sleep } from '@/lib/helper';
|
||||
import { BaseApiService } from '@/services/api/base';
|
||||
import { BaseApiResponse, GroupedApprovals } from '@/types/api/api-general';
|
||||
import {
|
||||
|
||||
@@ -17,12 +17,6 @@ import { formatCurrency, formatDate, formatTitleCase } from '@/lib/helper';
|
||||
* 💡 Helper untuk membuat respons dummy
|
||||
* @param data Data yang akan dimasukkan ke dalam body respons
|
||||
*/
|
||||
const createDummyResponse = <T>(data: T): BaseApiResponse<T> => ({
|
||||
code: 200,
|
||||
status: 'success',
|
||||
message: 'Data retrieved successfully (MOCK)',
|
||||
data: data,
|
||||
});
|
||||
|
||||
export class SalesOrderService extends BaseApiService<
|
||||
Marketing,
|
||||
@@ -168,7 +162,7 @@ class MarketingExportService extends BaseApiService<
|
||||
|
||||
// triggers download in browser
|
||||
XLSX.writeFile(wb, 'marketing.xlsx');
|
||||
} catch (error) {
|
||||
} catch {
|
||||
toast.error('Gagal melakukan export marketing! Coba lagi.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ export class TransferToLayingService extends BaseApiService<
|
||||
});
|
||||
|
||||
return mappedFlockKandangsAvailableQty;
|
||||
} catch (error) {
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -219,7 +219,7 @@ export class TransferToLayingService extends BaseApiService<
|
||||
});
|
||||
|
||||
return mappedFlockKandangsMaxTargetQty;
|
||||
} catch (error) {
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -273,7 +273,7 @@ export class TransferToLayingService extends BaseApiService<
|
||||
|
||||
// triggers download in browser
|
||||
XLSX.writeFile(wb, 'transfer-ke-laying.xlsx');
|
||||
} catch (error) {
|
||||
} catch {
|
||||
toast.error('Gagal melakukan export transfer to laying! Coba lagi.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { BaseApiService } from '@/services/api/base';
|
||||
import { httpClient, httpClientFetcher } from '@/services/http/client';
|
||||
import { httpClientFetcher } from '@/services/http/client';
|
||||
import { BaseApiResponse } from '@/types/api/api-general';
|
||||
import { ReportExpense } from '@/types/api/report/report-expense';
|
||||
import axios from 'axios';
|
||||
|
||||
export class ReportExpenseApiService extends BaseApiService<
|
||||
ReportExpense,
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
DailyMarketingReport,
|
||||
DailyMarketingReportResponse,
|
||||
} from '@/types/api/report/marketing';
|
||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||
import { isResponseError } from '@/lib/api-helper';
|
||||
import { formatDate } from '@/lib/helper';
|
||||
|
||||
export class MarketingReportApiService extends BaseApiService<
|
||||
@@ -68,7 +68,7 @@ export class MarketingReportApiService extends BaseApiService<
|
||||
|
||||
// triggers download in browser
|
||||
XLSX.writeFile(wb, 'laporan-penjualan-harian.xlsx');
|
||||
} catch (error) {
|
||||
} catch {
|
||||
toast.error('Gagal melakukan export penjualan harian! Coba lagi.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
'use client';
|
||||
|
||||
import { create } from 'zustand';
|
||||
import { devtools } from 'zustand/middleware';
|
||||
import { createProjectFlockClosingSlice } from '@/stores/production/project-flock-closing/slices/project-flock-closing.slice';
|
||||
import { ProjectFlockClosingSlice } from '@/stores/production/project-flock-closing/slices/project-flock-closing.slice';
|
||||
|
||||
export type ProjectFlockClosingStore = ProjectFlockClosingSlice;
|
||||
|
||||
export const useProjectFlockClosingStore = create<ProjectFlockClosingStore>()(
|
||||
devtools(
|
||||
(...args) => ({
|
||||
...createProjectFlockClosingSlice(...args),
|
||||
}),
|
||||
{
|
||||
name: 'ProjectFlockClosingStore',
|
||||
}
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,69 @@
|
||||
import { StateCreator } from 'zustand';
|
||||
import { ProjectFlockKandang } from '@/types/api/production/project-flock-kandang';
|
||||
|
||||
export type ProjectFlockClosingSlice = {
|
||||
// State
|
||||
isClosingModalOpen: boolean;
|
||||
selectedProjectFlockKandang: ProjectFlockKandang | null;
|
||||
projectFlockId: number | null;
|
||||
isKandangClosed: boolean;
|
||||
isClosingLoading: boolean;
|
||||
closingCallback: ((action: 'close' | 'unclose') => Promise<void>) | null;
|
||||
|
||||
// Actions
|
||||
openClosingModal: (
|
||||
data: ProjectFlockKandang,
|
||||
projectFlockId: number,
|
||||
isClosed: boolean,
|
||||
callback: (action: 'close' | 'unclose') => Promise<void>
|
||||
) => void;
|
||||
closeClosingModal: () => void;
|
||||
setClosingLoading: (loading: boolean) => void;
|
||||
resetClosing: () => void;
|
||||
};
|
||||
|
||||
export const createProjectFlockClosingSlice: StateCreator<
|
||||
ProjectFlockClosingSlice,
|
||||
[],
|
||||
[],
|
||||
ProjectFlockClosingSlice
|
||||
> = (set) => ({
|
||||
// Initial state
|
||||
isClosingModalOpen: false,
|
||||
selectedProjectFlockKandang: null,
|
||||
projectFlockId: null,
|
||||
isKandangClosed: false,
|
||||
isClosingLoading: false,
|
||||
closingCallback: null,
|
||||
|
||||
// Actions
|
||||
openClosingModal: (data, projectFlockId, isClosed, callback) =>
|
||||
set({
|
||||
isClosingModalOpen: true,
|
||||
selectedProjectFlockKandang: data,
|
||||
projectFlockId,
|
||||
isKandangClosed: isClosed,
|
||||
closingCallback: callback,
|
||||
}),
|
||||
|
||||
closeClosingModal: () =>
|
||||
set({
|
||||
isClosingModalOpen: false,
|
||||
selectedProjectFlockKandang: null,
|
||||
projectFlockId: null,
|
||||
isKandangClosed: false,
|
||||
closingCallback: null,
|
||||
}),
|
||||
|
||||
setClosingLoading: (loading) => set({ isClosingLoading: loading }),
|
||||
|
||||
resetClosing: () =>
|
||||
set({
|
||||
isClosingModalOpen: false,
|
||||
selectedProjectFlockKandang: null,
|
||||
projectFlockId: null,
|
||||
isKandangClosed: false,
|
||||
isClosingLoading: false,
|
||||
closingCallback: null,
|
||||
}),
|
||||
});
|
||||
Vendored
-3
@@ -1,6 +1,3 @@
|
||||
import { Area } from '@/types/api/master-data/area';
|
||||
import { Flock } from '@/types/api/master-data/flock';
|
||||
import { Location } from '@/types/api/master-data/location';
|
||||
import { Kandang } from '@/types/api/master-data/kandang';
|
||||
import { Product } from '@type/api/master-data/product';
|
||||
import { Customer } from '@type/api/master-data/customer';
|
||||
|
||||
-2
@@ -1,6 +1,4 @@
|
||||
import { BaseMetadata } from '@/types/api/api-general';
|
||||
import { BaseLocation } from '@/types/api/master-data/location';
|
||||
import { BaseUser } from '@/types/api/user';
|
||||
import { BaseKandang } from '@/types/api/master-data/kandang';
|
||||
|
||||
export type BaseEmployee = {
|
||||
|
||||
-2
@@ -1,5 +1,3 @@
|
||||
import { SuccessApiResponse } from '@/types/api/api-general';
|
||||
|
||||
export interface Dashboard {
|
||||
statistics_data: DashboardStatisticsData[];
|
||||
charts: DashboardComparisonCharts | DashboardOverviewCharts;
|
||||
|
||||
Vendored
+3
-5
@@ -1,9 +1,7 @@
|
||||
import { BaseApproval, BaseMetadata } from '@/types/api/api-general';
|
||||
import { BaseLocation, Location } from '@/types/api/master-data/location';
|
||||
import { BaseKandang, Kandang } from '@/types/api/master-data/kandang';
|
||||
import { BaseSupplier, Supplier } from '@/types/api/master-data/supplier';
|
||||
import { BaseNonstock, Nonstock } from '@/types/api/master-data/nonstock';
|
||||
import { BaseUser } from '@/types/api/user';
|
||||
import { BaseLocation } from '@/types/api/master-data/location';
|
||||
import { BaseSupplier } from '@/types/api/master-data/supplier';
|
||||
import { BaseNonstock } from '@/types/api/master-data/nonstock';
|
||||
|
||||
export type BaseExpense = {
|
||||
id: number;
|
||||
|
||||
Vendored
-1
@@ -1,5 +1,4 @@
|
||||
import { BaseMetadata, CreatedUser } from '@/types/api/api-general';
|
||||
import { ProductWarehouse } from '@/types/api/inventory/product-warehouse';
|
||||
import { ProductCategory } from '@/types/api/master-data/product-category';
|
||||
import { Supplier } from '@/types/api/master-data/supplier';
|
||||
import { Uom } from '@/types/api/master-data/uom';
|
||||
|
||||
-1
@@ -6,7 +6,6 @@ import {
|
||||
} from '@/types/api/api-general';
|
||||
import { ProductWarehouse } from '@/types/api/inventory/product-warehouse';
|
||||
import { Kandang } from '@/types/api/master-data/kandang';
|
||||
import { id } from 'react-day-picker/locale';
|
||||
import { Warehouse } from '@/types/api/master-data/warehouse';
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { BaseApiResponse, BaseMetadata, flags } from '@/types/api/api-general';
|
||||
import { BaseMetadata, flags } from '@/types/api/api-general';
|
||||
import { BaseUom } from '@/types/api/master-data/uom';
|
||||
import { BaseSupplier } from '@/types/api/master-data/supplier';
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { BaseMetadata } from '@/types/api/api-general';
|
||||
import { Uom } from '@/types/api/master-data/uom';
|
||||
import { ProductCategory } from '@/types/api/master-data/product-category';
|
||||
import { BaseSupplier, Supplier } from '@/types/api/master-data/supplier';
|
||||
import { BaseSupplier } from '@/types/api/master-data/supplier';
|
||||
|
||||
export type BaseProduct = {
|
||||
id: number;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Kandang } from '@/type/master-data/kandang';
|
||||
import { ProjectFlock } from '@/types/api/production/project-flock';
|
||||
import { ProductWarehouse } from '@/types/api/inventory/product-warehouse';
|
||||
import { Supplier } from '@/types/api/master-data/supplier';
|
||||
import { BaseApproval } from '@/types/api/api-general';
|
||||
|
||||
export type BaseProjectFlockKandang = {
|
||||
|
||||
+2
-7
@@ -1,10 +1,5 @@
|
||||
import {
|
||||
BaseApiResponse,
|
||||
BaseMetadata,
|
||||
CreatedUser,
|
||||
flags,
|
||||
} from '@/types/api/api-general';
|
||||
import { BaseKandang, Kandang } from '@/types/api/master-data/kandang';
|
||||
import { BaseMetadata, CreatedUser } from '@/types/api/api-general';
|
||||
import { BaseKandang } from '@/types/api/master-data/kandang';
|
||||
import { WarehouseType } from '@/types/api/master-data/warehouse';
|
||||
|
||||
export type BaseTransferToLaying = {
|
||||
|
||||
Vendored
+1
-4
@@ -1,13 +1,10 @@
|
||||
import { BaseApiResponse, BaseMetadata } from '@/types/api/api-general';
|
||||
import { BaseCustomer, Customer } from '@/types/api/master-data/customer';
|
||||
import { BaseCustomer } from '@/types/api/master-data/customer';
|
||||
import {
|
||||
BaseWarehouseArea,
|
||||
BaseWarehouseKandang,
|
||||
BaseWarehouseLocation,
|
||||
Warehouse,
|
||||
} from '@/types/api/master-data/warehouse';
|
||||
import { Location } from '@/types/api/master-data/location';
|
||||
import { Area } from '@/types/api/master-data/area';
|
||||
import { BaseProduct } from '@/types/api/master-data/product';
|
||||
import { BaseUser } from '@/types/api/user';
|
||||
|
||||
|
||||
-1
@@ -1,6 +1,5 @@
|
||||
import { BaseApproval, CreatedUser } from '@/types/api/api-general';
|
||||
import { Supplier } from '@/types/api/master-data/supplier';
|
||||
import { Location } from '@/types/api/master-data/location';
|
||||
import { Nonstock } from '@/types/api/master-data/nonstock';
|
||||
import { Kandang } from '@/types/api/master-data/kandang';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user