diff --git a/src/pages/master/products/blocks/EditDialog.tsx b/src/pages/master/products/blocks/EditDialog.tsx
index f669b9e..493489d 100644
--- a/src/pages/master/products/blocks/EditDialog.tsx
+++ b/src/pages/master/products/blocks/EditDialog.tsx
@@ -23,6 +23,7 @@ import {
SelectValue
} from '@/components/ui/select';
import { doSaveLogActivity } from '@/actions/GlobalActions';
+import { NumericFormat } from 'react-number-format';
interface ProviderProps {
provider_id: string;
@@ -41,15 +42,29 @@ const EditDialog = () => {
show: false,
message: ''
});
- const initialState = {
+ const initialState: {
+ name: string;
+ code: string;
+ type: string;
+ description: string;
+ price_point: string | number | null;
+ price_cash: string | number | null;
+ cashback_point: string | number | null;
+ cashback_cash: string | number | null;
+ status: string;
+ provider: string;
+ process_on_third_party: string;
+ updated_by: string;
+ updated_at: string;
+ } = {
name: '',
code: '',
type: '',
description: '',
- price_point: 0,
- price_cash: 0,
- cashback_point: 0,
- cashback_cash: 0,
+ price_point: null,
+ price_cash: null,
+ cashback_point: null,
+ cashback_cash: null,
status: '',
provider: '',
process_on_third_party: '',
@@ -139,7 +154,13 @@ const EditDialog = () => {
formField.type.trim() === '' ||
formField.code.trim() === '' ||
formField.description.trim() === '' ||
- formField.status === '' ||
+ formField.price_point === null ||
+ formField.price_cash === null ||
+ formField.cashback_point === null ||
+ formField.cashback_cash === null ||
+ formField.status.trim() === '' ||
+ formField.provider.trim() === '' ||
+ formField.process_on_third_party.trim() === '' ||
formField.updated_by.trim() === '' ||
formField.updated_at.trim() === ''
) {
@@ -256,16 +277,19 @@ const EditDialog = () => {
- {
- const value = parseFloat(e.target.value);
- setFormField({ ...formField, price_point: isNaN(value) ? 0 : value });
+ value={formField.price_point ?? ''}
+ thousandSeparator="."
+ decimalSeparator=","
+ allowNegative={false}
+ onValueChange={(values) => {
+ setFormField((prev) => ({
+ ...prev,
+ price_point: values.floatValue !== undefined ? values.floatValue : ''
+ }));
}}
+ placeholder="Enter Price Point"
/>
@@ -275,16 +299,19 @@ const EditDialog = () => {
- {
- const value = parseFloat(e.target.value);
- setFormField({ ...formField, price_cash: isNaN(value) ? 0 : value });
+ value={formField.price_cash ?? ''}
+ thousandSeparator="."
+ decimalSeparator=","
+ allowNegative={false}
+ onValueChange={(values) => {
+ setFormField((prev) => ({
+ ...prev,
+ price_cash: values.floatValue !== undefined ? values.floatValue : ''
+ }));
}}
+ placeholder="Enter Price Cash"
/>
@@ -294,16 +321,19 @@ const EditDialog = () => {
- {
- const value = parseFloat(e.target.value);
- setFormField({ ...formField, cashback_point: isNaN(value) ? 0 : value });
+ value={formField.cashback_point ?? ''}
+ thousandSeparator="."
+ decimalSeparator=","
+ allowNegative={false}
+ onValueChange={(values) => {
+ setFormField((prev) => ({
+ ...prev,
+ cashback_point: values.floatValue !== undefined ? values.floatValue : ''
+ }));
}}
+ placeholder="Enter Cashback Point"
/>
@@ -313,16 +343,19 @@ const EditDialog = () => {
- {
- const value = parseFloat(e.target.value);
- setFormField({ ...formField, cashback_cash: isNaN(value) ? 0 : value });
+ value={formField.cashback_cash ?? ''}
+ thousandSeparator="."
+ decimalSeparator=","
+ allowNegative={false}
+ onValueChange={(values) => {
+ setFormField((prev) => ({
+ ...prev,
+ cashback_cash: values.floatValue !== undefined ? values.floatValue : ''
+ }));
}}
+ placeholder="Enter Cashback Cash"
/>