diff --git a/src/pages/master/products/blocks/AddDialog.tsx b/src/pages/master/products/blocks/AddDialog.tsx
index 0a5e192..6c58950 100644
--- a/src/pages/master/products/blocks/AddDialog.tsx
+++ b/src/pages/master/products/blocks/AddDialog.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: number;
@@ -40,15 +41,29 @@ const AddDialog = () => {
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;
+ created_by: string;
+ created_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: '',
@@ -117,11 +132,13 @@ const AddDialog = () => {
formField.type.trim() === '' ||
formField.code.trim() === '' ||
formField.description.trim() === '' ||
- formField.price_point === 0 ||
- formField.price_cash === 0 ||
- formField.cashback_point === 0 ||
- formField.cashback_cash === 0 ||
+ 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.created_by.trim() === '' ||
formField.created_at.trim() === ''
) {
@@ -234,19 +251,19 @@ const AddDialog = () => {
- {
- 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"
/>
@@ -256,19 +273,19 @@ const AddDialog = () => {
- {
- 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"
/>
@@ -278,19 +295,19 @@ const AddDialog = () => {
- {
- 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"
/>
@@ -300,19 +317,19 @@ const AddDialog = () => {
- {
- 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"
/>