diff --git a/src/pages/transfer/transfertype/blocks/AddDialog.tsx b/src/pages/transfer/transfertype/blocks/AddDialog.tsx index 1458819..e164a1b 100644 --- a/src/pages/transfer/transfertype/blocks/AddDialog.tsx +++ b/src/pages/transfer/transfertype/blocks/AddDialog.tsx @@ -64,7 +64,7 @@ const AddDialog = () => { const [customers, setCustomers] = useState([]); const { reload } = useDataGrid(); const { PostData, PutData } = useCallApi(); - + const [errors, setErrors] = useState>({}); const initialState = { @@ -164,11 +164,12 @@ const AddDialog = () => { toast.error(response?.message || 'Failed to create transfer type'); return false; } - } catch (error) { + } catch (error: any) { toast.error( - error instanceof Error - ? error.message - : 'An error occurred while creating transfer type' + error?.response?.data?.message || + (error instanceof Error + ? error.message + : 'An error occurred while creating transfer type') ); return false; } @@ -203,8 +204,9 @@ const AddDialog = () => { order_direction: sorting[0].desc ? 'DESC' : 'ASC' }); setCustomers(response?.data.list); - } catch (error) { + } catch (error: any) { console.error('Error fetching customer', error); + toast.error(error?.response?.data?.message || 'Failed to fetch customer data'); } }; @@ -284,7 +286,9 @@ const AddDialog = () => { } }} /> - {errors.name && {errors.name}} + {errors.name && ( + {errors.name} + )} @@ -308,7 +312,9 @@ const AddDialog = () => { } }} /> - {errors.description && {errors.description}} + {errors.description && ( + {errors.description} + )} @@ -408,7 +414,9 @@ const AddDialog = () => { ))} - {errors.wallet_origin && {errors.wallet_origin}} + {errors.wallet_origin && ( + {errors.wallet_origin} + )} @@ -427,7 +435,9 @@ const AddDialog = () => { setErrors((prev) => ({ ...prev, wallet_destination: '' })); }} > - + @@ -438,7 +448,11 @@ const AddDialog = () => { ))} - {errors.wallet_destination && {errors.wallet_destination}} + {errors.wallet_destination && ( + + {errors.wallet_destination} + + )} @@ -485,7 +499,9 @@ const AddDialog = () => { Donation - {errors.type && {errors.type}} + {errors.type && ( + {errors.type} + )} @@ -512,7 +528,9 @@ const AddDialog = () => { No - {errors.status_approval && {errors.status_approval}} + {errors.status_approval && ( + {errors.status_approval} + )} @@ -543,7 +561,9 @@ const AddDialog = () => { Top Up Patner - {errors.status_kind && {errors.status_kind}} + {errors.status_kind && ( + {errors.status_kind} + )} @@ -571,7 +591,9 @@ const AddDialog = () => { Inactive - {errors.status && {errors.status}} + {errors.status && ( + {errors.status} + )} @@ -599,4 +621,4 @@ const AddDialog = () => { ); }; -export default AddDialog; \ No newline at end of file +export default AddDialog; diff --git a/src/pages/transfer/transfertype/blocks/EditDialog.tsx b/src/pages/transfer/transfertype/blocks/EditDialog.tsx index 84e0621..1fd1936 100644 --- a/src/pages/transfer/transfertype/blocks/EditDialog.tsx +++ b/src/pages/transfer/transfertype/blocks/EditDialog.tsx @@ -234,8 +234,10 @@ const EditDialog = () => { toast.error(response?.message || 'Failed to update transfer type'); return false; } - } catch (error) { - toast.error(error instanceof Error ? error.message : 'Failed to Update Transfer Type'); + } catch (error: any) { + toast.error( + error?.response?.data?.message || error.message || 'Failed to Update Transfer Type' + ); return false; } }, [formField, selectedTransferType]); @@ -257,8 +259,9 @@ const EditDialog = () => { if (response?.status && response?.data) { setCustomers(response.data.list); } - } catch (error) { + } catch (error: any) { console.error('Error fetching customer', error); + toast.error(error?.response?.data?.message || 'Failed to fetch customer data'); } }; @@ -281,8 +284,9 @@ const EditDialog = () => { if (response?.status && response?.data) { setGroups(response.data.list); } - } catch (error) { + } catch (error: any) { console.error('Error fetching groups', error); + toast.error(error?.response?.data?.message || 'Failed to fetch groups'); } }; @@ -305,8 +309,9 @@ const EditDialog = () => { if (response?.status && response?.data) { setWallets(response.data.list); } - } catch (error) { + } catch (error: any) { console.error('Error fetching wallets', error); + toast.error(error?.response?.data?.message || 'Failed to fetch wallets'); } }; @@ -353,8 +358,9 @@ const EditDialog = () => { })); } // console.log(response); - } catch (error) { + } catch (error: any) { console.error('Error fetching transaction type', error); + toast.error(error?.response?.data?.message || 'Failed to load transaction type data'); setAlert({ show: true, message: 'Failed to load transaction type data'