[skip ci] update search customer on add and edit transferfee
This commit is contained in:
@ -9,7 +9,8 @@ import {
|
|||||||
KeenIcon,
|
KeenIcon,
|
||||||
useDataGrid
|
useDataGrid
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
import { useCallApi } from '@/hooks';3
|
import { useCallApi } from '@/hooks';
|
||||||
|
3;
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogBody,
|
DialogBody,
|
||||||
@ -84,8 +85,8 @@ const AddFeeDialog = () => {
|
|||||||
const [wallets, setWallets] = useState<WalletProps[]>([]);
|
const [wallets, setWallets] = useState<WalletProps[]>([]);
|
||||||
const [deductFilteredCustomers, setDeductFilteredCustomers] = useState<CustomerProps[]>([]);
|
const [deductFilteredCustomers, setDeductFilteredCustomers] = useState<CustomerProps[]>([]);
|
||||||
const [creditFilteredCustomers, setCreditFilteredCustomers] = useState<CustomerProps[]>([]);
|
const [creditFilteredCustomers, setCreditFilteredCustomers] = useState<CustomerProps[]>([]);
|
||||||
const [isSearchingDeductCustomers, setIsSearchingDeductCustomers] = useState(false);
|
const [isSearchingDeductCustomers, setIsSearchingDeductCustomers] = useState(false);
|
||||||
const [isSearchingCreditCustomers, setIsSearchingCreditCustomers] = useState(false);
|
const [isSearchingCreditCustomers, setIsSearchingCreditCustomers] = useState(false);
|
||||||
const [transactionTypeName, setTransactionTypeName] = useState('');
|
const [transactionTypeName, setTransactionTypeName] = useState('');
|
||||||
|
|
||||||
const [isLoadingTransactionType, setIsLoadingTransactionType] = useState(false);
|
const [isLoadingTransactionType, setIsLoadingTransactionType] = useState(false);
|
||||||
@ -120,14 +121,14 @@ const [isSearchingCreditCustomers, setIsSearchingCreditCustomers] = useState(fal
|
|||||||
|
|
||||||
const [formField, setFormField] = useState(initialState);
|
const [formField, setFormField] = useState(initialState);
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
setFormField(initialState);
|
setFormField(initialState);
|
||||||
setTransactionTypeName('');
|
setTransactionTypeName('');
|
||||||
setDeductFilteredCustomers([]);
|
setDeductFilteredCustomers([]);
|
||||||
setCreditFilteredCustomers([]);
|
setCreditFilteredCustomers([]);
|
||||||
setDeductSearchTerm('');
|
setDeductSearchTerm('');
|
||||||
setCreditSearchTerm('');
|
setCreditSearchTerm('');
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCloseDialog = () => {
|
const handleCloseDialog = () => {
|
||||||
setFormField(initialState);
|
setFormField(initialState);
|
||||||
@ -144,7 +145,6 @@ const resetForm = () => {
|
|||||||
const [showTransactionFeeDialog, setShowTransactionFeeDialog] = useState(false);
|
const [showTransactionFeeDialog, setShowTransactionFeeDialog] = useState(false);
|
||||||
const parsedUser = getAuth()?.user;
|
const parsedUser = getAuth()?.user;
|
||||||
|
|
||||||
|
|
||||||
const useDebounce = (value: string, delay: number) => {
|
const useDebounce = (value: string, delay: number) => {
|
||||||
const [debouncedValue, setDebouncedValue] = useState(value);
|
const [debouncedValue, setDebouncedValue] = useState(value);
|
||||||
|
|
||||||
@ -159,9 +159,9 @@ const resetForm = () => {
|
|||||||
}, [value, delay]);
|
}, [value, delay]);
|
||||||
|
|
||||||
return debouncedValue;
|
return debouncedValue;
|
||||||
};
|
};
|
||||||
const debouncedDeductSearchTerm = useDebounce(deductSearchTerm, 500);
|
const debouncedDeductSearchTerm = useDebounce(deductSearchTerm, 500);
|
||||||
const debouncedCreditSearchTerm = useDebounce(creditSearchTerm, 500);
|
const debouncedCreditSearchTerm = useDebounce(creditSearchTerm, 500);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (showAddFeeDialog && transactionTypeId) {
|
if (showAddFeeDialog && transactionTypeId) {
|
||||||
setIsLoadingTransactionType(true);
|
setIsLoadingTransactionType(true);
|
||||||
@ -305,8 +305,7 @@ const debouncedCreditSearchTerm = useDebounce(creditSearchTerm, 500);
|
|||||||
if (openDeductOrigin && formField.deduct_from === 'I') {
|
if (openDeductOrigin && formField.deduct_from === 'I') {
|
||||||
searchDeductCustomers(debouncedDeductSearchTerm);
|
searchDeductCustomers(debouncedDeductSearchTerm);
|
||||||
}
|
}
|
||||||
}, [debouncedDeductSearchTerm, openDeductOrigin, formField.deduct_from, searchDeductCustomers]);
|
}, [debouncedDeductSearchTerm, openDeductOrigin, formField.deduct_from, searchDeductCustomers]);
|
||||||
|
|
||||||
|
|
||||||
const searchCreditCustomers = useCallback(
|
const searchCreditCustomers = useCallback(
|
||||||
async (searchTerm: string) => {
|
async (searchTerm: string) => {
|
||||||
@ -347,7 +346,12 @@ const debouncedCreditSearchTerm = useDebounce(creditSearchTerm, 500);
|
|||||||
if (openCreditDestination && formField.credit_to === 'I') {
|
if (openCreditDestination && formField.credit_to === 'I') {
|
||||||
searchCreditCustomers(debouncedCreditSearchTerm);
|
searchCreditCustomers(debouncedCreditSearchTerm);
|
||||||
}
|
}
|
||||||
}, [debouncedCreditSearchTerm, openCreditDestination, formField.credit_to, searchCreditCustomers]);
|
}, [
|
||||||
|
debouncedCreditSearchTerm,
|
||||||
|
openCreditDestination,
|
||||||
|
formField.credit_to,
|
||||||
|
searchCreditCustomers
|
||||||
|
]);
|
||||||
|
|
||||||
const doCreateTransferType = useCallback(
|
const doCreateTransferType = useCallback(
|
||||||
async (e: React.FormEvent<HTMLFormElement>) => {
|
async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
|
|||||||
@ -118,7 +118,7 @@ const EditFeeDialog = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const [formField, setFormField] = useState(initialState);
|
const [formField, setFormField] = useState(initialState);
|
||||||
const useDebounce = (value:string, delay:number) => {
|
const useDebounce = (value: string, delay: number) => {
|
||||||
const [debouncedValue, setDebouncedValue] = useState(value);
|
const [debouncedValue, setDebouncedValue] = useState(value);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -132,10 +132,10 @@ const EditFeeDialog = () => {
|
|||||||
}, [value, delay]);
|
}, [value, delay]);
|
||||||
|
|
||||||
return debouncedValue;
|
return debouncedValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
const debouncedDeductSearch = useDebounce(deductSearchTerm, 300);
|
const debouncedDeductSearch = useDebounce(deductSearchTerm, 300);
|
||||||
const debouncedCreditSearch = useDebounce(creditSearchTerm, 300);
|
const debouncedCreditSearch = useDebounce(creditSearchTerm, 300);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const updated_time = new Date();
|
const updated_time = new Date();
|
||||||
const formattedTime = updated_time.toISOString().slice(0, 19).replace('T', ' ');
|
const formattedTime = updated_time.toISOString().slice(0, 19).replace('T', ' ');
|
||||||
@ -358,17 +358,17 @@ const debouncedCreditSearch = useDebounce(creditSearchTerm, 300);
|
|||||||
[GetData]
|
[GetData]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (openDeductOrigin) {
|
if (openDeductOrigin) {
|
||||||
searchDeductCustomers(debouncedDeductSearch);
|
searchDeductCustomers(debouncedDeductSearch);
|
||||||
}
|
}
|
||||||
}, [debouncedDeductSearch, openDeductOrigin, searchDeductCustomers]);
|
}, [debouncedDeductSearch, openDeductOrigin, searchDeductCustomers]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (openCreditDestination) {
|
if (openCreditDestination) {
|
||||||
searchCreditCustomers(debouncedCreditSearch);
|
searchCreditCustomers(debouncedCreditSearch);
|
||||||
}
|
}
|
||||||
}, [debouncedCreditSearch, openCreditDestination, searchCreditCustomers]);
|
}, [debouncedCreditSearch, openCreditDestination, searchCreditCustomers]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!showEditFeeDialog) return;
|
if (!showEditFeeDialog) return;
|
||||||
@ -377,7 +377,7 @@ useEffect(() => {
|
|||||||
setIsLoadingTransactionType(true);
|
setIsLoadingTransactionType(true);
|
||||||
try {
|
try {
|
||||||
sorting = sorting.length === 0 ? [{ id: 'name', desc: false }] : sorting;
|
sorting = sorting.length === 0 ? [{ id: 'name', desc: false }] : sorting;
|
||||||
const response = await GetData(`${API_URL}/transactiontype/list`, {
|
const response = await GetData(`${API_URL}/transactiontype/list `, {
|
||||||
limit: 100,
|
limit: 100,
|
||||||
page: 1,
|
page: 1,
|
||||||
with_deleted: false,
|
with_deleted: false,
|
||||||
@ -793,7 +793,6 @@ useEffect(() => {
|
|||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const value = e.target.value;
|
const value = e.target.value;
|
||||||
setDeductSearchTerm(value);
|
setDeductSearchTerm(value);
|
||||||
|
|
||||||
}}
|
}}
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
|||||||
Reference in New Issue
Block a user