fix create and edit provider

This commit is contained in:
Wikzyy
2025-03-25 16:48:23 +07:00
parent d8400c49d2
commit 72825d737b
3 changed files with 16 additions and 16 deletions

View File

@ -55,7 +55,7 @@ const EditDialog = () => {
description: '',
type: '',
status: '',
transactionTypeId: '',
transaction_type: '',
agent: '',
updated_by: '',
updated_at: ''
@ -128,7 +128,7 @@ const EditDialog = () => {
const doFetchData = useCallback(async (id: string) => {
const response = await GetData(`${API_URL_MASTERDATA}/provider/getdata/${id}`, { id });
// console.log(response);
console.log(response);
if (response?.status) {
setFormField((prev) => ({
...prev,
@ -136,8 +136,8 @@ const EditDialog = () => {
description: response?.data.description,
type: response?.data.type,
status: response?.data.status,
transactionTypeId: response?.data.transaction_type.id,
agent: response?.data.agent
transaction_type: response?.data.transaction_type.id,
agent: response?.data.agent.id
}));
}
}, []);
@ -150,7 +150,7 @@ const EditDialog = () => {
formField.description.trim() === '' ||
formField.type.trim() === '' ||
formField.status.trim() === '' ||
formField.transactionTypeId.trim() === '' ||
formField.transaction_type.trim() === '' ||
formField.agent.trim() === ''
) {
setAlert({ show: true, message: 'Please fill in all required fields.' });
@ -188,7 +188,7 @@ const EditDialog = () => {
getCustomerList([{ id: 'id', desc: false }]);
getTransactionTypeList([{ id: 'name', desc: false }]);
}, []);
// console.log(selectedProvider);
return (
<Dialog open={showEditDialog} onOpenChange={(open) => handleEditDialog(open, null)}>
<DialogContent className="container-fixed max-w-[768px] flex flex-col p-5 overflow-hidden">
@ -282,9 +282,9 @@ const EditDialog = () => {
Transaction Type Id<span className="text-red-500">*</span>
</label>
<Select
value={formField.transactionTypeId}
value={formField.transaction_type}
onValueChange={(value) =>
setFormField({ ...formField, transactionTypeId: value })
setFormField({ ...formField, transaction_type: value })
}
>
<SelectTrigger>
@ -309,7 +309,7 @@ const EditDialog = () => {
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<button type="button" className="input col-span-5 text-left">
{customers.find((customer) => customer.msisdn === formField.agent)
{customers.find((customer) => customer.id === formField.agent)
?.fullname || 'Select Agent'}
</button>
</PopoverTrigger>
@ -321,12 +321,12 @@ const EditDialog = () => {
<CommandGroup>
{customers.map((customer) => (
<CommandItem
key={customer.msisdn}
value={customer.fullname}
key={customer.id}
value={customer.id}
onSelect={() => {
setFormField({
...formField,
agent: customer.msisdn
agent: customer.id
});
setOpen(false);
}}