diff --git a/src/pages/master/provider/blocks/AddDialog.tsx b/src/pages/master/provider/blocks/AddDialog.tsx index 84bc992..c49d056 100644 --- a/src/pages/master/provider/blocks/AddDialog.tsx +++ b/src/pages/master/provider/blocks/AddDialog.tsx @@ -61,7 +61,17 @@ const AddDialog = () => { show: false, message: '' }); - const initialState = { + + const initialState: { + name: string; + description: string; + type: string; + status: string; + transaction_type: string; + agent: string; + created_by: string; + created_at: string; + } = { name: '', description: '', type: '', @@ -71,6 +81,7 @@ const AddDialog = () => { created_by: '', created_at: '' }; + const [formField, setFormField] = useState(initialState); const [customers, setCustomers] = useState([]); const [transactions, setTransactions] = useState([]); @@ -116,8 +127,7 @@ const AddDialog = () => { formField.description.trim() === '' || formField.type.trim() === '' || formField.status.trim() === '' || - formField.transaction_type === '' || - formField.agent.trim() === '' + formField.transaction_type === '' ) { setAlert({ show: true, message: 'Please fill in all required fields.' }); return; @@ -242,7 +252,7 @@ const AddDialog = () => { - H2H + Host to Host Agent @@ -294,56 +304,67 @@ const AddDialog = () => { -
-
- - - - - - - - - { - e.currentTarget.scrollTop += e.deltaY; - }} + {formField.type === 'agent' ? ( +
+
+ + + + + + + + + { + e.currentTarget.scrollTop += e.deltaY; + }} + > + No Agent found. + + {customers.map((customer) => ( + { + setFormField({ + ...formField, + agent: customer.id + }); + setOpen(false); + }} + > + {customer.username} + + ))} + + + + + +
-
+ ) : ( +
+
+ + +
+
+ )}
-
-
- - - - - - - - - { - e.currentTarget.scrollTop += e.deltaY; - }} + {formField.type === 'agent' ? ( +
+
+ + + + + + + + + { + e.currentTarget.scrollTop += e.deltaY; + }} + > + No Agent found. + + {customers.map((customer) => ( + { + setFormField({ + ...formField, + agent: customer.id + }); + setOpen(false); + }} + > + {customer.username} + + ))} + + + + + +
-
+ ) : ( +
+
+ + +
+
+ )}