diff --git a/src/pages/master/walletRule/blocks/AddDialog.tsx b/src/pages/master/walletRule/blocks/AddDialog.tsx
index 9228226..885c15a 100644
--- a/src/pages/master/walletRule/blocks/AddDialog.tsx
+++ b/src/pages/master/walletRule/blocks/AddDialog.tsx
@@ -30,6 +30,7 @@ import {
CommandItem,
CommandList
} from '@/components/ui/command';
+import { NumericFormat } from 'react-number-format';
interface GroupProps {
ID: string;
@@ -58,11 +59,11 @@ const AddDialog = () => {
const initialState: {
id_wallet: string;
id_group: string;
- max_transaction_per_day: number | null;
- balance_minimum: number | null;
- balance_maximum: number | null;
- credit_limit: number | null;
- monthly_limit: number | null;
+ max_transaction_per_day: string | number | null;
+ balance_minimum: string | number | null;
+ balance_maximum: string | number | null;
+ credit_limit: string | number | null;
+ monthly_limit: string | number | null;
status: string;
} = {
id_wallet: '',
@@ -235,16 +236,20 @@ const AddDialog = () => {
-
- setFormField({
- ...formField,
- max_transaction_per_day: parseInt(e.target.value)
- })
- }
+ thousandSeparator="."
+ decimalSeparator=","
+ allowNegative={false}
+ onValueChange={(values) => {
+ setFormField((prev) => ({
+ ...prev,
+ max_transaction_per_day:
+ values.floatValue !== undefined ? values.floatValue : ''
+ }));
+ }}
+ placeholder="Enter Max Transaction Per Day"
/>
@@ -254,13 +259,19 @@ const AddDialog = () => {
-
- setFormField({ ...formField, balance_minimum: parseInt(e.target.value) })
- }
+ thousandSeparator="."
+ decimalSeparator=","
+ allowNegative={false}
+ onValueChange={(values) => {
+ setFormField((prev) => ({
+ ...prev,
+ balance_minimum: values.floatValue !== undefined ? values.floatValue : ''
+ }));
+ }}
+ placeholder="Enter Balance Minimum"
/>
@@ -270,13 +281,19 @@ const AddDialog = () => {
-
- setFormField({ ...formField, balance_maximum: parseInt(e.target.value) })
- }
+ thousandSeparator="."
+ decimalSeparator=","
+ allowNegative={false}
+ onValueChange={(values) => {
+ setFormField((prev) => ({
+ ...prev,
+ balance_maximum: values.floatValue !== undefined ? values.floatValue : ''
+ }));
+ }}
+ placeholder="Enter Balance Maximum"
/>
@@ -286,13 +303,19 @@ const AddDialog = () => {
-
- setFormField({ ...formField, credit_limit: parseInt(e.target.value) })
- }
+ thousandSeparator="."
+ decimalSeparator=","
+ allowNegative={false}
+ onValueChange={(values) => {
+ setFormField((prev) => ({
+ ...prev,
+ credit_limit: values.floatValue !== undefined ? values.floatValue : ''
+ }));
+ }}
+ placeholder="Enter Credit Limit"
/>
@@ -302,13 +325,19 @@ const AddDialog = () => {
-
- setFormField({ ...formField, monthly_limit: parseInt(e.target.value) })
- }
+ thousandSeparator="."
+ decimalSeparator=","
+ allowNegative={false}
+ onValueChange={(values) => {
+ setFormField((prev) => ({
+ ...prev,
+ monthly_limit: values.floatValue !== undefined ? values.floatValue : ''
+ }));
+ }}
+ placeholder="Enter Monthly Limit"
/>
diff --git a/src/pages/master/walletRule/blocks/EditDialog.tsx b/src/pages/master/walletRule/blocks/EditDialog.tsx
index 127df2a..de2d497 100644
--- a/src/pages/master/walletRule/blocks/EditDialog.tsx
+++ b/src/pages/master/walletRule/blocks/EditDialog.tsx
@@ -30,6 +30,7 @@ import {
} from '@/components/ui/command';
import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
+import { NumericFormat } from 'react-number-format';
interface GroupProps {
ID: string;
@@ -51,7 +52,6 @@ const EditDialog = () => {
const { showEditDialog, handleEditDialog, selectedWalletRule } = useManageWalletRuleContext();
const { GetData, PutData } = useCallApi();
const { reload } = useDataGrid();
- const [open, setOpen] = useState(false);
const [alert, setAlert] = useState({
show: false,
message: ''
@@ -59,11 +59,11 @@ const EditDialog = () => {
const initialState: {
id_wallet: string;
id_group: string;
- max_transaction_per_day: number | null;
- balance_minimum: number | null;
- balance_maximum: number | null;
- credit_limit: number | null;
- monthly_limit: number | null;
+ max_transaction_per_day: string | number | null;
+ balance_minimum: string | number | null;
+ balance_maximum: string | number | null;
+ credit_limit: string | number | null;
+ monthly_limit: string | number | null;
status: string;
} = {
id_wallet: '',
@@ -89,7 +89,7 @@ const EditDialog = () => {
e.preventDefault();
const response = await PutData(
- `${API_URL_WALLET}/dashboard/wallet_rule/${selectedWalletRule}`,
+ `${API_URL_WALLET}/dashboard/wallet_rule/${selectedWalletRule?.ID}`,
formField
);
@@ -192,10 +192,20 @@ const EditDialog = () => {
useEffect(() => {
if (selectedWalletRule) {
- doFetchData(selectedWalletRule);
+ setFormField((prev) => ({
+ ...prev,
+ id_wallet: selectedWalletRule?.id_wallet,
+ id_group: selectedWalletRule?.id_group,
+ max_transaction_per_day: selectedWalletRule?.max_transaction_per_day,
+ balance_minimum: selectedWalletRule?.balance_minimum,
+ balance_maximum: selectedWalletRule?.balance_maximum,
+ credit_limit: selectedWalletRule?.credit_limit,
+ monthly_limit: selectedWalletRule?.monthly_limit,
+ status: selectedWalletRule?.status
+ }));
}
}, [selectedWalletRule]);
-// console.log(selectedWalletRule);
+ // console.log(selectedWalletRule);
return (