mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 05:22:02 +00:00
refactor(FE-208): remove unused supplier state and handlers in PurchaseTable
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { ChangeEventHandler, useCallback, useMemo, useState } from 'react';
|
||||
import { ChangeEventHandler, useCallback, useState } from 'react';
|
||||
import useSWR from 'swr';
|
||||
import { CellContext, ColumnDef, SortingState } from '@tanstack/react-table';
|
||||
import toast from 'react-hot-toast';
|
||||
@@ -11,13 +11,9 @@ import DebouncedTextInput from '@/components/input/DebouncedTextInput';
|
||||
import Button from '@/components/Button';
|
||||
import { useModal } from '@/components/Modal';
|
||||
import ConfirmationModal from '@/components/modal/ConfirmationModal';
|
||||
import SelectInput, {
|
||||
OptionType,
|
||||
useSelect,
|
||||
} from '@/components/input/SelectInput';
|
||||
import SelectInput, { OptionType } from '@/components/input/SelectInput';
|
||||
import RowDropdownOptions from '@/components/table/RowDropdownOptions';
|
||||
import RowCollapseOptions from '@/components/table/RowCollapseOptions';
|
||||
import TextInput from '@/components/input/TextInput';
|
||||
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
|
||||
|
||||
import { cn, formatDate, formatCurrency } from '@/lib/helper';
|
||||
@@ -27,7 +23,6 @@ import { useTableFilter } from '@/services/hooks/useTableFilter';
|
||||
import { ROWS_OPTIONS } from '@/config/constant';
|
||||
import { Purchase } from '@/types/api/purchase/purchase';
|
||||
import { PurchaseRequestApi } from '@/services/api/purchase';
|
||||
import { SupplierApi } from '@/services/api/master-data';
|
||||
|
||||
// ===== INTERFACES =====
|
||||
interface RowOptionsMenuProps {
|
||||
@@ -83,9 +78,6 @@ const RowOptionsMenu = ({
|
||||
|
||||
const PurchaseTable = () => {
|
||||
// ===== STATE MANAGEMENT =====
|
||||
const [selectedSupplier, setSelectedSupplier] = useState<OptionType | null>(
|
||||
null
|
||||
);
|
||||
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
|
||||
const [selectedPurchase, setSelectedPurchase] = useState<Purchase | null>(
|
||||
null
|
||||
@@ -116,13 +108,6 @@ const PurchaseTable = () => {
|
||||
// ===== MODAL HOOKS =====
|
||||
const deleteModal = useModal();
|
||||
|
||||
// ===== USE SELECT HOOKS =====
|
||||
const {
|
||||
setInputValue: setSupplierInputValue,
|
||||
options: supplierOptions,
|
||||
isLoadingOptions: isLoadingSupplierOptions,
|
||||
} = useSelect(SupplierApi.basePath, 'id', 'name');
|
||||
|
||||
// ===== API DATA FETCHING =====
|
||||
const {
|
||||
data: purchaseRequests,
|
||||
@@ -253,24 +238,6 @@ const PurchaseTable = () => {
|
||||
[setPageSize]
|
||||
);
|
||||
|
||||
const poDateChangeHandler: ChangeEventHandler<HTMLInputElement> = useCallback(
|
||||
(e) => {
|
||||
updateFilter('poDate', e.target.value);
|
||||
},
|
||||
[updateFilter]
|
||||
);
|
||||
|
||||
const supplierChangeHandler = useCallback(
|
||||
(val: OptionType | OptionType[] | null) => {
|
||||
setSelectedSupplier(val as OptionType);
|
||||
updateFilter(
|
||||
'supplier',
|
||||
val ? ((val as OptionType).value as string) : ''
|
||||
);
|
||||
},
|
||||
[updateFilter]
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className='w-full p-0 sm:p-4'>
|
||||
@@ -299,35 +266,7 @@ const PurchaseTable = () => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className='flex flex-wrap justify-between gap-4'>
|
||||
<div className='flex flex-wrap gap-4'>
|
||||
<TextInput
|
||||
required
|
||||
type='date'
|
||||
label='Tanggal PO'
|
||||
name='po_date'
|
||||
placeholder='Masukkan tanggal PO'
|
||||
value={tableFilterState.poDate}
|
||||
onChange={poDateChangeHandler}
|
||||
className={{
|
||||
wrapper: 'w-full sm:w-48',
|
||||
}}
|
||||
/>
|
||||
|
||||
<SelectInput
|
||||
label='Vendor'
|
||||
options={supplierOptions}
|
||||
isLoading={isLoadingSupplierOptions}
|
||||
value={selectedSupplier}
|
||||
onChange={supplierChangeHandler}
|
||||
onInputChange={setSupplierInputValue}
|
||||
isClearable
|
||||
className={{
|
||||
wrapper: 'w-full sm:w-56',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className='flex flex-wrap justify-end gap-4'>
|
||||
<SelectInput
|
||||
label='Baris'
|
||||
options={ROWS_OPTIONS}
|
||||
|
||||
Reference in New Issue
Block a user