diff --git a/src/pages/Organization/DetailPage/OrganizationCard.js b/src/pages/Organization/DetailPage/OrganizationCard.js
index 344ecff..3a4026f 100644
--- a/src/pages/Organization/DetailPage/OrganizationCard.js
+++ b/src/pages/Organization/DetailPage/OrganizationCard.js
@@ -2,6 +2,7 @@
import {
Grid, Button, Checkbox, FormControlLabel, Typography,
Dialog, DialogTitle, DialogContent, DialogActions,
+ FormHelperText
} from '@mui/material';
// import { FormControlLabel } from '@material-ui/core';
import MainCard from "components/MainCard";
@@ -33,6 +34,7 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => {
const [editMode, setEditMode] = useState(false);
const [createMode, setCreateMode] = useState(false);
const [onReady, setOnReady] = useState(false);
+ const [errorMsg, setErrorMsg] = useState("");
useEffect(() => {
//if state data are ready and assign to different field
@@ -71,43 +73,50 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => {
}
}),
}),
- onSubmit: vaule => {
- console.log(vaule)
- HttpUtils.post({
- url: UrlUtils.POST_ORG_SAVE_PATH,
- params: {
- id: id > 0 ? id : null,
- enCompanyName: vaule.enCompanyName,
- chCompanyName: vaule.chCompanyName,
- brNo: vaule.brNo,
- brExpiryDate: vaule.brExpiryDate,
- enCompanyNameTemp: vaule.enCompanyNameTemp,
- chCompanyNameTemp: vaule.chCompanyNameTemp,
- brExpiryDateTemp: vaule.brExpiryDateTemp,
- contactPerson: vaule.contactPerson,
- contactTel: {
- countryCode: vaule.tel_countryCode,
- phoneNumber: vaule.phoneNumber
- },
- faxNo: {
- countryCode: vaule.fax_countryCode,
- faxNumber: vaule.faxNumber
- },
- addressTemp: {
- country: vaule.country.id,
- district: vaule.district.id,
- addressLine1: vaule.addressLine1,
- addressLine2: vaule.addressLine2,
- addressLine3: vaule.addressLine3,
- },
- //creditor: vaule.creditor,
- },
- onSuccess: function () {
- notifySaveSuccess()
- loadDataFun();
- setEditMode(false);
- }
- });
+ onSubmit: values => {
+ if (values.country==null){
+ setErrorMsg(intl.formatMessage({id: 'pleaseFillInCountry'}))
+ } else {
+ if (values.country.key ==1 && values.district == null){
+ setErrorMsg(intl.formatMessage({id: 'pleaseFillInDistrict'}))
+ } else {
+ HttpUtils.post({
+ url: UrlUtils.POST_ORG_SAVE_PATH,
+ params: {
+ id: id > 0 ? id : null,
+ enCompanyName: values.enCompanyName,
+ chCompanyName: values.chCompanyName,
+ brNo: values.brNo,
+ brExpiryDate: values.brExpiryDate,
+ enCompanyNameTemp: values.enCompanyNameTemp,
+ chCompanyNameTemp: values.chCompanyNameTemp,
+ brExpiryDateTemp: values.brExpiryDateTemp,
+ contactPerson: values.contactPerson,
+ contactTel: {
+ countryCode: values.tel_countryCode,
+ phoneNumber: values.phoneNumber
+ },
+ faxNo: {
+ countryCode: values.fax_countryCode,
+ faxNumber: values.faxNumber
+ },
+ addressTemp: {
+ country: values.country.id,
+ district: values.district?.id,
+ addressLine1: values.addressLine1,
+ addressLine2: values.addressLine2,
+ addressLine3: values.addressLine3,
+ },
+ //creditor: values.creditor,
+ },
+ onSuccess: function () {
+ notifySaveSuccess()
+ loadDataFun();
+ setEditMode(false);
+ }
+ });
+ }
+ }
}
});
@@ -263,6 +272,13 @@ const OrganizationCard = ({ userData, loadDataFun, id, setEditModeFun }) => {
Organization Details
+
+
+
+ {errorMsg}
+
+
+
{FieldUtils.getTextField({
label: FieldUtils.notNullFieldLabel("BR No.:"),
diff --git a/src/pages/Organization/DetailPage/OrganizationPubCard.js b/src/pages/Organization/DetailPage/OrganizationPubCard.js
index 32ec1bd..3487a05 100644
--- a/src/pages/Organization/DetailPage/OrganizationPubCard.js
+++ b/src/pages/Organization/DetailPage/OrganizationPubCard.js
@@ -4,6 +4,7 @@ import {
// Checkbox, FormControlLabel,
Typography,
Dialog, DialogTitle, DialogContent, DialogActions,
+ FormHelperText
} from '@mui/material';
// import { FormControlLabel } from '@material-ui/core';
import MainCard from "components/MainCard";
@@ -35,6 +36,7 @@ const OrganizationPubCard = ({ userData, loadDataFun, id, setEditModeFun }) => {
const [editMode, setEditMode] = useState(false);
const [createMode, setCreateMode] = useState(false);
const [onReady, setOnReady] = useState(false);
+ const [errorMsg, setErrorMsg] = useState("");
useEffect(() => {
//if state data are ready and assign to different field
@@ -58,31 +60,38 @@ const OrganizationPubCard = ({ userData, loadDataFun, id, setEditModeFun }) => {
tel_countryCode: yup.string().min(3, displayErrorMsg(intl.formatMessage({id: 'requireDialingCode'}))),
phoneNumber: yup.string().min(8, displayErrorMsg(intl.formatMessage({id: 'requiredValidNumber'}))).required(displayErrorMsg(intl.formatMessage({id: 'requireContactNumber'}))),
}),
- onSubmit: vaule => {
- console.log(vaule)
- HttpUtils.post({
- url: UrlUtils.POST_PUB_ORG_SAVE_PATH,
- params: {
- contactPerson: vaule.contactPerson,
- contactTel: {
- countryCode: vaule.tel_countryCode,
- phoneNumber: vaule.phoneNumber
- },
- addressTemp: {
- country: vaule.country.id,
- district: vaule.district.id,
- addressLine1: vaule.addressLine1,
- addressLine2: vaule.addressLine2,
- addressLine3: vaule.addressLine3,
- },
- //creditor: vaule.creditor,
- },
- onSuccess: function () {
- notifySaveSuccess()
- loadDataFun();
- setEditMode(false);
+ onSubmit: values => {
+ if (values.country==null){
+ setErrorMsg(intl.formatMessage({id: 'pleaseFillInCountry'}))
+ } else {
+ if (values.country.key ==1 && values.district == null){
+ setErrorMsg(intl.formatMessage({id: 'pleaseFillInDistrict'}))
+ } else {
+ HttpUtils.post({
+ url: UrlUtils.POST_PUB_ORG_SAVE_PATH,
+ params: {
+ contactPerson: values.contactPerson,
+ contactTel: {
+ countryCode: values.tel_countryCode,
+ phoneNumber: values.phoneNumber
+ },
+ addressTemp: {
+ country: values.country.id,
+ district: values.district?.id,
+ addressLine1: values.addressLine1,
+ addressLine2: values.addressLine2,
+ addressLine3: values.addressLine3,
+ },
+ //creditor: values.creditor,
+ },
+ onSuccess: function () {
+ notifySaveSuccess()
+ loadDataFun();
+ setEditMode(false);
+ }
+ });
}
- });
+ }
}
});
@@ -193,6 +202,13 @@ const OrganizationPubCard = ({ userData, loadDataFun, id, setEditModeFun }) => {
+
+
+
+ {errorMsg}
+
+
+
{FieldUtils.getTextField({
label: intl.formatMessage({id: 'brNo'}) + ":",
diff --git a/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js b/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js
index 0a0fd79..6b47d89 100644
--- a/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js
+++ b/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js
@@ -1,23 +1,24 @@
// material-ui
import {
- Grid, Button, Typography
+ Grid, Button, Typography,
+ FormHelperText
} from '@mui/material';
-import MainCard from "../../../components/MainCard";
+import MainCard from "components/MainCard";
import * as React from "react";
import { useEffect, useState } from "react";
import * as yup from 'yup';
import { useFormik } from 'formik';
-import * as FieldUtils from "../../../utils/FieldUtils";
-import * as HttpUtils from '../../../utils/HttpUtils';
-import * as UrlUtils from "../../../utils/ApiPathConst";
-import * as ComboData from "../../../utils/ComboData";
+import * as FieldUtils from "utils/FieldUtils";
+import * as HttpUtils from 'utils/HttpUtils';
+import * as UrlUtils from "utils/ApiPathConst";
+import * as ComboData from "utils/ComboData";
const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent')));
import Loadable from 'components/Loadable';
import { lazy } from 'react';
import { notifyActiveSuccess, notifyLockSuccess, notifySaveSuccess, notifyVerifySuccess } from 'utils/CommonFunction';
import {useIntl} from "react-intl";
-import {PNSPS_BUTTON_THEME} from "../../../themes/buttonConst";
+import {PNSPS_BUTTON_THEME} from "themes/buttonConst";
import {ThemeProvider} from "@emotion/react";
// ==============================|| DASHBOARD - DEFAULT ||============================== //
@@ -29,6 +30,7 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => {
const [editMode, setEditMode] = useState(false);
const [locked, setLocked] = useState(false);
const [onReady, setOnReady] = useState(false);
+ const [errorMsg, setErrorMsg] = useState("");
useEffect(() => {
//if state data are ready and assign to different field
@@ -57,38 +59,45 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => {
faxNumber: yup.string().min(8, intl.formatMessage({id: 'require8Number'})).nullable(),
}),
onSubmit: values => {
- console.log(values);
- HttpUtils.post({
- url: UrlUtils.POST_IND_USER + "/" + formData.id,
- params: {
- prefix: values.prefix,
- enName: values.enName,
- chName: values.chName,
- idDocType: values.idDocType,
- mobileNumber: {
- countryCode: values.tel_countryCode,
- phoneNumber: values.phoneNumber
- },
- identification: values.identification,
- checkDigit: values.checkDigit,
- faxNo: {
- countryCode: values.fax_countryCode,
- faxNumber: values.faxNumber
- },
- emailAddress: values.emailAddress,
- address: {
- country: values.country.key,
- district: values.district.key,
- addressLine1: values.addressLine1,
- addressLine2: values.addressLine2,
- addressLine3: values.addressLine3,
- },
- },
- onSuccess: function () {
- notifySaveSuccess();
- loadDataFun();
+ if (values.country==null){
+ setErrorMsg(intl.formatMessage({id: 'pleaseFillInCountry'}))
+ } else {
+ if (values.country.key ==1 && values.district == null){
+ setErrorMsg(intl.formatMessage({id: 'pleaseFillInDistrict'}))
+ } else {
+ HttpUtils.post({
+ url: UrlUtils.POST_IND_USER + "/" + formData.id,
+ params: {
+ prefix: values.prefix,
+ enName: values.enName,
+ chName: values.chName,
+ idDocType: values.idDocType,
+ mobileNumber: {
+ countryCode: values.tel_countryCode,
+ phoneNumber: values.phoneNumber
+ },
+ identification: values.identification,
+ checkDigit: values.checkDigit,
+ faxNo: {
+ countryCode: values.fax_countryCode,
+ faxNumber: values.faxNumber
+ },
+ emailAddress: values.emailAddress,
+ address: {
+ country: values.country.key,
+ district: values.district?.key,
+ addressLine1: values.addressLine1,
+ addressLine2: values.addressLine2,
+ addressLine3: values.addressLine3,
+ },
+ },
+ onSuccess: function () {
+ notifySaveSuccess();
+ loadDataFun();
+ }
+ });
}
- });
+ }
}
});
@@ -196,6 +205,13 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => {
+
+
+
+ {errorMsg}
+
+
+
{FieldUtils.getTextField({
label: "Username:",
diff --git a/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual_Pub.js b/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual_Pub.js
index 62abe00..3f677f7 100644
--- a/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual_Pub.js
+++ b/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual_Pub.js
@@ -1,6 +1,7 @@
// material-ui
import {
- Grid, Button, Typography
+ Grid, Button, Typography,
+ FormHelperText
} from '@mui/material';
import MainCard from "components/MainCard";
import * as React from "react";
@@ -28,6 +29,7 @@ const UserInformationCard_Individual_Pub = ({ formData, loadDataFun }) => {
const [currentUserData, setCurrentUserData] = useState(formData);
const [editMode, setEditMode] = useState(false);
const [onReady, setOnReady] = useState(false);
+ const [errorMsg, setErrorMsg] = useState("");
useEffect(() => {
//if state data are ready and assign to different field
@@ -53,33 +55,40 @@ const UserInformationCard_Individual_Pub = ({ formData, loadDataFun }) => {
faxNumber: yup.string().min(8, intl.formatMessage({id: 'require8Number'})).nullable(),
}),
onSubmit: values => {
- console.log(values);
- HttpUtils.post({
- url: UrlUtils.POST_PUB_IND_USER,
- params: {
- enName: values.enName,
- chName: values.chName,
- mobileNumber: {
- countryCode: values.tel_countryCode,
- phoneNumber: values.phoneNumber
- },
- faxNo: {
- countryCode: values.fax_countryCode,
- faxNumber: values.faxNumber
- },
- address: {
- country: values.country.key,
- district: values.district.key,
- addressLine1: values.addressLine1,
- addressLine2: values.addressLine2,
- addressLine3: values.addressLine3,
- },
- },
- onSuccess: function () {
- notifySaveSuccess();
- loadDataFun();
+ if (values.country==null){
+ setErrorMsg(intl.formatMessage({id: 'pleaseFillInCountry'}))
+ } else {
+ if (values.country.key ==1 && values.district == null){
+ setErrorMsg(intl.formatMessage({id: 'pleaseFillInDistrict'}))
+ } else {
+ HttpUtils.post({
+ url: UrlUtils.POST_PUB_IND_USER,
+ params: {
+ enName: values.enName,
+ chName: values.chName,
+ mobileNumber: {
+ countryCode: values.tel_countryCode,
+ phoneNumber: values.phoneNumber
+ },
+ faxNo: {
+ countryCode: values.fax_countryCode,
+ faxNumber: values.faxNumber
+ },
+ address: {
+ country: values.country.key,
+ district: values.district?.key,
+ addressLine1: values.addressLine1,
+ addressLine2: values.addressLine2,
+ addressLine3: values.addressLine3,
+ },
+ },
+ onSuccess: function () {
+ notifySaveSuccess();
+ loadDataFun();
+ }
+ });
}
- });
+ }
}
});
@@ -160,6 +169,13 @@ const UserInformationCard_Individual_Pub = ({ formData, loadDataFun }) => {
+
+
+
+ {errorMsg}
+
+
+
{FieldUtils.getTextField({
label: intl.formatMessage({id: 'userLoginName'}) + ":",