fixing tranfer fee
This commit is contained in:
@ -90,6 +90,10 @@ const AddFeeDialog = () => {
|
||||
id: customer.id,
|
||||
name: customer.username
|
||||
}));
|
||||
|
||||
const [openDeductOrigin, setOpenDeductOrigin] = useState(false);
|
||||
const [openCreditDestination, setOpenCreditDestination] = useState(false);
|
||||
|
||||
const [errors, setErrors] = useState<Record<string, string>>({});
|
||||
const initialState = {
|
||||
name: '',
|
||||
@ -120,6 +124,16 @@ const AddFeeDialog = () => {
|
||||
setTransactionTypeName('');
|
||||
};
|
||||
|
||||
const handleCloseDialog = () => {
|
||||
setFormField(initialState);
|
||||
setAlert({ show: false, message: '' });
|
||||
setCustomerSearchTerm('');
|
||||
setOpenCreditDestination(false);
|
||||
setOpenDeductOrigin(false);
|
||||
setOpen(false);
|
||||
handleEditFeeDialog(false, null);
|
||||
};
|
||||
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [showTransactionFeeDialog, setShowTransactionFeeDialog] = useState(false);
|
||||
const parsedUser = getAuth()?.user;
|
||||
@ -376,7 +390,15 @@ const AddFeeDialog = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={showAddFeeDialog} onOpenChange={(open) => handleAddFeeDialog(open)}>
|
||||
<Dialog
|
||||
open={showAddFeeDialog}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) {
|
||||
handleAddFeeDialog(open);
|
||||
handleCloseDialog();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<DialogContent className="container-fixed max-w-[1080px] flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
||||
<DialogTitle></DialogTitle>
|
||||
<DialogDescription></DialogDescription>
|
||||
@ -595,16 +617,15 @@ const AddFeeDialog = () => {
|
||||
<div className="relative">
|
||||
<div
|
||||
className="flex w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 cursor-pointer"
|
||||
onClick={() => setOpen(!open)}
|
||||
onClick={() => setOpenDeductOrigin(!openDeductOrigin)}
|
||||
>
|
||||
<span className="truncate">
|
||||
{customers.find((customer) => customer.id === formField.deduct_origin)
|
||||
?.username || 'Search customer...'}
|
||||
</span>
|
||||
<path d="m6 9 6 6 6-6"></path>
|
||||
</div>
|
||||
|
||||
{open && (
|
||||
{openDeductOrigin && (
|
||||
<div className="absolute left-0 right-0 top-full z-50 mt-1 max-h-52 overflow-auto rounded-md border border-gray-200 bg-white shadow-lg">
|
||||
<div className="sticky top-0 bg-white p-2 border-b">
|
||||
<Input
|
||||
@ -632,11 +653,8 @@ const AddFeeDialog = () => {
|
||||
key={customer.id}
|
||||
className="cursor-pointer px-3 py-1.5 text-sm hover:bg-gray-100"
|
||||
onClick={() => {
|
||||
setFormField({
|
||||
...formField,
|
||||
deduct_origin: customer.id
|
||||
});
|
||||
setOpen(false);
|
||||
setFormField({ ...formField, deduct_origin: customer.id });
|
||||
setOpenDeductOrigin(false);
|
||||
}}
|
||||
>
|
||||
{customer.username}
|
||||
@ -706,17 +724,16 @@ const AddFeeDialog = () => {
|
||||
<div className="relative">
|
||||
<div
|
||||
className="flex w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 cursor-pointer"
|
||||
onClick={() => setOpen(!open)}
|
||||
onClick={() => setOpenCreditDestination(!openCreditDestination)}
|
||||
>
|
||||
<span className="truncate">
|
||||
{customers.find(
|
||||
(customer) => customer.id === formField.credit_destination
|
||||
)?.username || 'Search customer...'}
|
||||
</span>
|
||||
<path d="m6 9 6 6 6-6"></path>
|
||||
</div>
|
||||
|
||||
{open && (
|
||||
{openCreditDestination && (
|
||||
<div className="absolute left-0 right-0 top-full z-50 mt-1 max-h-52 overflow-auto rounded-md border border-gray-200 bg-white shadow-lg">
|
||||
<div className="sticky top-0 bg-white p-2 border-b">
|
||||
<Input
|
||||
@ -748,7 +765,7 @@ const AddFeeDialog = () => {
|
||||
...formField,
|
||||
credit_destination: customer.id
|
||||
});
|
||||
setOpen(false);
|
||||
setOpenCreditDestination(false);
|
||||
}}
|
||||
>
|
||||
{customer.username}
|
||||
|
||||
Reference in New Issue
Block a user