fix some sub module in master data
This commit is contained in:
@ -83,18 +83,18 @@ const AddDialog = () => {
|
|||||||
};
|
};
|
||||||
const validateForm = () => {
|
const validateForm = () => {
|
||||||
const requiredFields = [
|
const requiredFields = [
|
||||||
{key:'name', label: 'Name'},
|
{ key: 'name', label: 'Name' },
|
||||||
{key:'type', label: 'Type'},
|
{ key: 'type', label: 'Type' },
|
||||||
{key:'code', label: 'Code'},
|
{ key: 'code', label: 'Code' },
|
||||||
{key:'description', label: 'Description'},
|
{ key: 'description', label: 'Description' },
|
||||||
{key:'price_point', label: 'Price Point'},
|
{ key: 'price_point', label: 'Price Point' },
|
||||||
{key:'price_cash', label: 'Price Cash'},
|
{ key: 'price_cash', label: 'Price Cash' },
|
||||||
{key:'cashback_point', label: 'Cashback Point'},
|
{ key: 'cashback_point', label: 'Cashback Point' },
|
||||||
{key:'cashback_cash', label: 'Cashback Cash'},
|
{ key: 'cashback_cash', label: 'Cashback Cash' },
|
||||||
{key:'status', label: 'Status'},
|
{ key: 'status', label: 'Status' },
|
||||||
{key:'provider', label: 'Provider'},
|
{ key: 'provider', label: 'Provider' },
|
||||||
{key:'process_on_third_party', label: 'Process On Third Party'}
|
{ key: 'process_on_third_party', label: 'Process On Third Party' }
|
||||||
]
|
];
|
||||||
const newErrors: Record<string, string> = {};
|
const newErrors: Record<string, string> = {};
|
||||||
let isValid = true;
|
let isValid = true;
|
||||||
requiredFields.forEach(({ key, label }) => {
|
requiredFields.forEach(({ key, label }) => {
|
||||||
@ -110,7 +110,7 @@ const AddDialog = () => {
|
|||||||
});
|
});
|
||||||
setErrors(newErrors);
|
setErrors(newErrors);
|
||||||
return isValid;
|
return isValid;
|
||||||
}
|
};
|
||||||
|
|
||||||
const doCreateProduct = useCallback(
|
const doCreateProduct = useCallback(
|
||||||
async (e: React.FormEvent<HTMLFormElement>) => {
|
async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
@ -214,7 +214,7 @@ const AddDialog = () => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<div className="card-body grid gap-5">
|
<div className="card-body grid gap-5">
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||||
@ -233,7 +233,9 @@ const AddDialog = () => {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{errors.name && <span className="text-red-500 text-xs mt-1">{errors.name}</span>}
|
{errors.name && (
|
||||||
|
<span className="text-red-500 text-xs mt-1">{errors.name}</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -255,7 +257,9 @@ const AddDialog = () => {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{errors.type && <span className="text-red-500 text-xs mt-1">{errors.type}</span>}
|
{errors.type && (
|
||||||
|
<span className="text-red-500 text-xs mt-1">{errors.type}</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -277,7 +281,9 @@ const AddDialog = () => {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{errors.code && <span className="text-red-500 text-xs mt-1">{errors.code}</span>}
|
{errors.code && (
|
||||||
|
<span className="text-red-500 text-xs mt-1">{errors.code}</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -447,14 +453,18 @@ const AddDialog = () => {
|
|||||||
<SelectItem value="N">No</SelectItem>
|
<SelectItem value="N">No</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
{errors.status && <span className="text-red-500 text-xs mt-1">{errors.status}</span>}
|
{errors.status && (
|
||||||
|
<span className="text-red-500 text-xs mt-1">{errors.status}</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
<div className="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||||
<label className="form-label flex items-center gap-1 max-w-56">Provider<span className="text-red-500">*</span></label>
|
<label className="form-label flex items-center gap-1 max-w-56">
|
||||||
|
Provider<span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
<div className="grow flex flex-col">
|
<div className="grow flex flex-col">
|
||||||
<Select
|
<Select
|
||||||
value={formField.provider}
|
value={formField.provider}
|
||||||
@ -463,7 +473,9 @@ const AddDialog = () => {
|
|||||||
setErrors((prev) => ({ ...prev, provider: '' }));
|
setErrors((prev) => ({ ...prev, provider: '' }));
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SelectTrigger className={`input ${errors.provider ? 'border-red-500' : ''}`}>
|
<SelectTrigger
|
||||||
|
className={`input ${errors.provider ? 'border-red-500' : ''}`}
|
||||||
|
>
|
||||||
<SelectValue placeholder="Select Provider" />
|
<SelectValue placeholder="Select Provider" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
@ -477,7 +489,9 @@ const AddDialog = () => {
|
|||||||
))}
|
))}
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
{errors.provider && <span className="text-red-500 text-xs mt-1">{errors.provider}</span>}
|
{errors.provider && (
|
||||||
|
<span className="text-red-500 text-xs mt-1">{errors.provider}</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -495,7 +509,9 @@ const AddDialog = () => {
|
|||||||
setErrors((prev) => ({ ...prev, process_on_third_party: '' }));
|
setErrors((prev) => ({ ...prev, process_on_third_party: '' }));
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SelectTrigger className={`input ${errors.process_on_third_party ? 'border-red-500' : ''}`}>
|
<SelectTrigger
|
||||||
|
className={`input ${errors.process_on_third_party ? 'border-red-500' : ''}`}
|
||||||
|
>
|
||||||
<SelectValue placeholder="Select Status" />
|
<SelectValue placeholder="Select Status" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
@ -504,7 +520,9 @@ const AddDialog = () => {
|
|||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
{errors.process_on_third_party && (
|
{errors.process_on_third_party && (
|
||||||
<span className="text-red-500 text-xs mt-1">{errors.process_on_third_party}</span>
|
<span className="text-red-500 text-xs mt-1">
|
||||||
|
{errors.process_on_third_party}
|
||||||
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -523,8 +541,7 @@ const AddDialog = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</DialogBody>
|
</DialogBody>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|||||||
@ -273,8 +273,6 @@ const ManageProductsContextProvider = ({ children }: { children: React.ReactNode
|
|||||||
getProductsLists
|
getProductsLists
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Toaster expand visibleToasts={9} duration={3000} />
|
|
||||||
|
|
||||||
<DataGridProvider
|
<DataGridProvider
|
||||||
columns={columns}
|
columns={columns}
|
||||||
pagination={{ size: 10 }}
|
pagination={{ size: 10 }}
|
||||||
|
|||||||
@ -116,7 +116,7 @@ const AddDialog = () => {
|
|||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
setFormField(initialState);
|
setFormField(initialState);
|
||||||
setAlert({ show: false, message: '' });
|
setErrors({});
|
||||||
};
|
};
|
||||||
|
|
||||||
const doCreateProvider = useCallback(
|
const doCreateProvider = useCallback(
|
||||||
|
|||||||
Reference in New Issue
Block a user