From 9d856172bcadf8688eac2218efaef4757defc09e Mon Sep 17 00:00:00 2001 From: Alex Cheung Date: Sat, 9 Sep 2023 18:25:57 +0800 Subject: [PATCH 1/2] fix Valid --- src/pages/authentication/auth-forms/BusCustomFormWizard.js | 2 +- src/pages/authentication/auth-forms/CustomFormWizard.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pages/authentication/auth-forms/BusCustomFormWizard.js b/src/pages/authentication/auth-forms/BusCustomFormWizard.js index a0bd207..2501d94 100644 --- a/src/pages/authentication/auth-forms/BusCustomFormWizard.js +++ b/src/pages/authentication/auth-forms/BusCustomFormWizard.js @@ -302,7 +302,7 @@ const BusCustomFormWizard = (props) => { } function handlePhone(phone) { - if (phone.length < 11) { + if (phone.length < 8) { return false; } else { return true; diff --git a/src/pages/authentication/auth-forms/CustomFormWizard.js b/src/pages/authentication/auth-forms/CustomFormWizard.js index e6d5072..7287f83 100644 --- a/src/pages/authentication/auth-forms/CustomFormWizard.js +++ b/src/pages/authentication/auth-forms/CustomFormWizard.js @@ -311,9 +311,10 @@ const CustomFormWizard = (props) => { } function handlePhone(value) { - if (value.length < 11) { + if (value.length < 8) { return false; } else { + console.log("Phone true") return true; } } @@ -322,6 +323,7 @@ const CustomFormWizard = (props) => { if (value.length < 6) { return false; } else { + console.log("Username true") return true; } } @@ -334,6 +336,7 @@ const CustomFormWizard = (props) => { else if (idNo.length < 7) { return false; } else { + console.log("IdNo true") return true; } } @@ -356,6 +359,7 @@ const CustomFormWizard = (props) => { } else if (new_pass.length < 8) { return false; } else { + console.log("password true") return true; } } @@ -367,6 +371,7 @@ const CustomFormWizard = (props) => { if (result == false) { return false; } + console.log("email true") return true; } From d5ed2013e77289fd11754125191ee2d14d26b3e9 Mon Sep 17 00:00:00 2001 From: Alex Cheung Date: Mon, 11 Sep 2023 03:17:31 +0800 Subject: [PATCH 2/2] and user group and user data save --- src/pages/ManageOrgUserPage/index.js | 2 +- .../OrganizationTable.js | 2 +- .../pnspsUserDetailPage/UserAuthTable.js | 4 +- .../pnspsUserDetailPage/UserGroupTable.js | 7 +- .../UserInformationCard.js | 243 ++++++++---------- src/pages/pnspsUserDetailPage/index.js | 147 +++++++++-- .../pnspsUserGroupDetailPage/GroupAuthCard.js | 8 +- .../GroupAuthTable.js | 4 +- .../pnspsUserGroupDetailPage/UserAddCard.js | 48 ++-- .../pnspsUserGroupDetailPage/UserAddTable.js | 20 +- src/pages/pnspsUserGroupDetailPage/index.js | 149 +++++++++-- .../UserGroupTable.js | 2 +- src/pages/pnspsUserGroupSearchPage/index.js | 20 +- .../pnspsUserSearchPage/UserSearchForm.js | 98 ++----- src/pages/pnspsUserSearchPage/UserTable.js | 83 +++--- src/pages/pnspsUserSearchPage/index.js | 9 +- .../UserTable_Individual.js | 2 +- .../UserTable_Organization.js | 2 +- src/utils/ApiPathConst.js | 12 +- src/utils/CommonFunction.js | 98 ++++++- 20 files changed, 603 insertions(+), 357 deletions(-) diff --git a/src/pages/ManageOrgUserPage/index.js b/src/pages/ManageOrgUserPage/index.js index 826d1b5..e82473b 100644 --- a/src/pages/ManageOrgUserPage/index.js +++ b/src/pages/ManageOrgUserPage/index.js @@ -160,7 +160,7 @@ const ManageOrgUserPage = () => { }, }} pageSizeOptions={[5, 10]} - autoHeight = {true} + autoHeight /> diff --git a/src/pages/OrganizationSearchPage/OrganizationTable.js b/src/pages/OrganizationSearchPage/OrganizationTable.js index 2253f0d..24b8c55 100644 --- a/src/pages/OrganizationSearchPage/OrganizationTable.js +++ b/src/pages/OrganizationSearchPage/OrganizationTable.js @@ -86,7 +86,7 @@ export default function OrganizationTable({recordList}) { }, }} pageSizeOptions={[5, 10]} - autoHeight = {true} + autoHeight /> ); diff --git a/src/pages/pnspsUserDetailPage/UserAuthTable.js b/src/pages/pnspsUserDetailPage/UserAuthTable.js index 9bf2a9b..8a92d15 100644 --- a/src/pages/pnspsUserDetailPage/UserAuthTable.js +++ b/src/pages/pnspsUserDetailPage/UserAuthTable.js @@ -73,11 +73,11 @@ export default function UserAuthTable({setSelectedRow, userAuth}) { checkboxSelection rowSelectionModel={currentSelectedRow} onRowSelectionModelChange={(ids) => { - console.log(ids); + // console.log(ids); setSelectedRow(ids); setCurrentSelectedRow(ids); }} - autoHeight = {true} + autoHeight /> ); diff --git a/src/pages/pnspsUserDetailPage/UserGroupTable.js b/src/pages/pnspsUserDetailPage/UserGroupTable.js index e5db51c..b3ac9c8 100644 --- a/src/pages/pnspsUserDetailPage/UserGroupTable.js +++ b/src/pages/pnspsUserDetailPage/UserGroupTable.js @@ -5,10 +5,8 @@ import { import {useEffect, useState} from "react"; import axios from "axios"; import {apiPath} from "../../auth/utils"; -//import LoadingComponent from "../extra-pages/LoadingComponent"; import * as React from "react"; import {GET_GROUP_COMBO_PATH} from "../../utils/ApiPathConst"; - import Loadable from 'components/Loadable'; import { lazy } from 'react'; const LoadingComponent = Loadable(lazy(() => import('../extra-pages/LoadingComponent'))); @@ -35,8 +33,7 @@ export default function UserGroupTable({setSelectedRow, userGroup}) { useEffect(() => { //if state data are ready and assign to different field - console.log(groupData.length) - if (groupData !== "" && groupData !== undefined) { + if (groupData.length > 0) { setOnReady(true); } }, [groupData]); @@ -73,7 +70,7 @@ export default function UserGroupTable({setSelectedRow, userGroup}) { setSelectedRow(ids); setCurrentSelectedRow(ids); }} - autoHeight = {true} + autoHeight /> ); diff --git a/src/pages/pnspsUserDetailPage/UserInformationCard.js b/src/pages/pnspsUserDetailPage/UserInformationCard.js index 1c88171..01baee3 100644 --- a/src/pages/pnspsUserDetailPage/UserInformationCard.js +++ b/src/pages/pnspsUserDetailPage/UserInformationCard.js @@ -1,82 +1,32 @@ // material-ui import { - Grid, TextField, Typography + FormControl, IconButton, + Grid, InputAdornment, Typography, FormLabel, + OutlinedInput, } from '@mui/material'; import MainCard from "../../components/MainCard"; import * as React from "react"; import {useForm} from "react-hook-form"; -// import Autocomplete from "@mui/material/Autocomplete"; -// import { -// subDivision1, -// subDivision2, -// subDivision3, -// subDivision4, -// subDivision5, -// subDivision6 -// } from "../pnspsUserSearchPage/DummyComboRecord"; import {useEffect, useState} from "react"; import Checkbox from "@mui/material/Checkbox"; -//import LoadingComponent from "../extra-pages/LoadingComponent"; import Loadable from 'components/Loadable'; import { lazy } from 'react'; const LoadingComponent = Loadable(lazy(() => import('../extra-pages/LoadingComponent'))); //import {useParams} from "react-router-dom"; +import Visibility from '@mui/icons-material/Visibility'; +import VisibilityOff from '@mui/icons-material/VisibilityOff'; // ==============================|| DASHBOARD - DEFAULT ||============================== // - - -// const subDivisionArray = [ -// ...subDivision1, -// ...subDivision2, -// ...subDivision3, -// ...subDivision4, -// ...subDivision5, -// ...subDivision6 -// ]; - - -const UserInformationCard = ({isCollectData, updateUserObject,userData}) => { +const UserInformationCard = ({isCollectData, updateUserObject,userData,isNewRecord}) => { //const params = useParams(); const [currentUserData, setCurrentUserData] = React.useState({}); - // const [subDivision, setSubDivision] = useState(null); const [locked, setLocked] = useState(false); - // const [isLotusNoteUser, setIsLotusNoteUser] = useState(false); - // const [lotusNoteUserList, setLotusNoteUserList] = useState([]) - // const [selectedLotusUser, setSelectedLotusUser] = useState(null); - + const [showPassword, setShowPassword] = React.useState(false); const [onReady, setOnReady] = useState(false); const {register, getValues} = useForm() - // useEffect(() => { - // //TODO: Get lotus note user list - // setLotusNoteUserList([ - // { - // key: 1, - // label: "user01", - // account: "user123456" - // }, - // { - // key: 2, - // label: "user02", - // account: "userabcde1" - // }, - // { - // key: 3, - // label: "user03", - // account: "user2001" - // }, - // { - // key: 4, - // label: "user04", - // account: "user2000" - // }, - // { - // key: 5, - // label: "user05", - // account: "user1999" - // }, - // ]) - // }, []); + const handleClickShowPassword = () => setShowPassword((show) => !show); + const handleMouseDownPassword = () => setShowPassword(!showPassword); useEffect(() => { //if user data from parent are not null @@ -87,9 +37,12 @@ const UserInformationCard = ({isCollectData, updateUserObject,userData}) => { useEffect(() => { //if state data are ready and assign to different field - if (Object.keys(userData).length > 0 &¤tUserData !== undefined) { + if (Object.keys(userData).length > 0 &¤tUserData !== undefined&¤tUserData.id!==undefined) { setLocked(currentUserData.locked); setOnReady(true); + }else if(isNewRecord){ + setLocked(false); + setOnReady(true); } }, [currentUserData]); @@ -98,8 +51,6 @@ const UserInformationCard = ({isCollectData, updateUserObject,userData}) => { const values = getValues(); const objectData ={ ...values, - // selectedLotusUser: selectedLotusUser, - // subDivision: subDivision, locked: locked, } updateUserObject(objectData); @@ -120,25 +71,28 @@ const UserInformationCard = ({isCollectData, updateUserObject,userData}) => {
- - Username: + Username: - + + + @@ -151,12 +105,28 @@ const UserInformationCard = ({isCollectData, updateUserObject,userData}) => { - + + + + {showPassword ? : } + + + } + /> + @@ -165,18 +135,30 @@ const UserInformationCard = ({isCollectData, updateUserObject,userData}) => { - Full Name: + Full Name: - + id='enName' + /> */} + + + @@ -185,89 +167,76 @@ const UserInformationCard = ({isCollectData, updateUserObject,userData}) => { - Post: + Post: - + + + - {/* - - - Sub-Division: - - - - { - setSubDivision(newValue); - }} - renderInput={(params) => } - /> - - - */} - - Email: + Email: - + + + - + {/* - Phone: + Phone: - + + + - + */} - Locked: + Locked: diff --git a/src/pages/pnspsUserDetailPage/index.js b/src/pages/pnspsUserDetailPage/index.js index ec74398..4fc4523 100644 --- a/src/pages/pnspsUserDetailPage/index.js +++ b/src/pages/pnspsUserDetailPage/index.js @@ -1,14 +1,15 @@ // material-ui import { Button, - Grid, Typography + Grid, + Typography, + Stack } from '@mui/material'; import {useEffect, useState} from "react"; import * as React from "react"; import axios from "axios"; -import {apiPath} from "../../auth/utils"; -import {useParams} from "react-router-dom"; -import {GET_USER_PATH} from "../../utils/ApiPathConst"; +import {useNavigate,useParams} from "react-router-dom"; +import {GLD_USER_PATH,DELETE_USER} from "../../utils/ApiPathConst"; import Loadable from 'components/Loadable'; import { lazy } from 'react'; @@ -16,16 +17,17 @@ const UserInformationCard = Loadable(lazy(() => import('./UserInformationCard')) const LoadingComponent = Loadable(lazy(() => import('../extra-pages/LoadingComponent'))); const UserGroupCard = Loadable(lazy(() => import('./UserGroupCard'))); const UserAuthorityCard = Loadable(lazy(() => import('./UserAuthorityCard'))); -// import UserInformationCard from "./UserInformationCard"; -// import LoadingComponent from "../extra-pages/LoadingComponent"; -// import UserGroupCard from "./UserGroupCard"; -// import UserAuthorityCard from "./UserAuthorityCard"; +import { + GeneralConfirmWindow, + getDeletedRecordWithRefList, +} from "../../utils/CommonFunction"; // ==============================|| DASHBOARD - DEFAULT ||============================== // const UserMaintainPage = () => { const params = useParams(); + const navigate = useNavigate(); const [userData, setUserData] = React.useState({}); const [onReady, setOnReady] = useState(false); const [isCollectData, setIsCollectData] = useState(false); @@ -33,6 +35,9 @@ const UserMaintainPage = () => { const [userGroupData,setUserGroupData] = useState([]); const [userAuthData,setUserAuthData] = useState([]); const [userConfirm, setUserConfirm] = useState(false); + const [isNewRecord, setIsNewRecord] = useState(false); + const [refUserData, setRefUserData] = React.useState({}); + function updateUserObject(userData) { setEditedCustomerData(userData); @@ -51,30 +56,103 @@ const UserMaintainPage = () => { setIsCollectData(!isCollectData); } - useEffect(() => { - console.log(params) - axios.get(`${apiPath}${GET_USER_PATH}/${params.id}`) + // ==============================|| DELETE WINDOW RELATED ||============================== // + const [isWindowOpen, setIsWindowOpen] = useState(false); + const handleClose = () => { + setIsWindowOpen(false); + }; + + const handleDeleteClick = () => { + setIsWindowOpen(true); + }; + + function deleteData(){ + axios.delete(`${DELETE_USER}/${params.id}`, + ) .then((response) => { - if (response.status === 200) { - setUserData(response.data); + if (response.status === 204) { + // notifyDeleteSuccess(); + setIsWindowOpen(false); + navigate('/userSearchview'); } }) .catch(error => { console.log(error); return false; }); + } +// ==============================|| DELETE WINDOW RELATED ||============================== // + + useEffect(() => { + if(params.id > 0 ){ + axios.get(`${GLD_USER_PATH}/${params.id}`) + .then((response) => { + if (response.status === 200) { + setRefUserData(response.data); + setUserData(response.data); + } + }) + .catch(error => { + console.log(error); + return false; + }); + } + else{ + setUserData( + { + "authIds": [], + "data": {}, + "groupIds": [] + } + ); + setRefUserData( + { + "authIds": [], + "data": {}, + "groupIds": [] + } + ); + setIsNewRecord(true); + } + }, []); useEffect(() => { - setOnReady(true); + if (Object.keys(userData).length > 0 && userData !== undefined) { + setOnReady(true); + } + else if(isNewRecord){ + setOnReady(true); + } }, [userData]); useEffect(() => { if(userConfirm && onReady){ - console.log("update in parents"); - console.log(editedCustomerData); - console.log(userGroupData); - console.log(userAuthData); + const deletedUserAuth = getDeletedRecordWithRefList(refUserData.authIds,userAuthData); + const deletedUserGroup = getDeletedRecordWithRefList(refUserData.groupIds,userGroupData); + axios.post(`${GLD_USER_PATH}/${params.id}`, + { + "enName": editedCustomerData.enName, + "locked": editedCustomerData.locked, + // "password": editedCustomerData.password, + // "phone": editedCustomerData.phone, + "post": editedCustomerData.post, + "emailAddress": editedCustomerData.emailAddress, + "addGroupIds": userGroupData, + "removeGroupIds": deletedUserGroup, + "addAuthIds": userAuthData, + "removeAuthIds": deletedUserAuth, + }, + ).then((response) => { + if (response.status === 200) { + // notifySaveSuccess(); + navigate('/userSearchview'); + } + }) + .catch(error => { + console.log(error); + return false; + }); } setUserConfirm(false); }, [editedCustomerData,userGroupData,userAuthData]); @@ -83,9 +161,11 @@ const UserMaintainPage = () => { !onReady ? : - - - Maintain User + + + + Maintain User + {/*col 1*/} @@ -95,6 +175,7 @@ const UserMaintainPage = () => { updateUserObject={updateUserObject} userData={userData} isCollectData={isCollectData} + isNewRecord={isNewRecord} /> @@ -103,6 +184,7 @@ const UserMaintainPage = () => { updateUserGroupList={updateUserGroupList} userData={userData} isCollectData={isCollectData} + isNewRecord={isNewRecord} /> @@ -113,12 +195,35 @@ const UserMaintainPage = () => { updateUserAuthList={updateUserAuthList} userData={userData} isCollectData={isCollectData} + isNewRecord={isNewRecord} /> {/*bottom button*/} + + + + + + + + diff --git a/src/pages/pnspsUserGroupSearchPage/UserGroupTable.js b/src/pages/pnspsUserGroupSearchPage/UserGroupTable.js index a7786d7..ae9133b 100644 --- a/src/pages/pnspsUserGroupSearchPage/UserGroupTable.js +++ b/src/pages/pnspsUserGroupSearchPage/UserGroupTable.js @@ -68,7 +68,7 @@ export default function UserGroupTable({recordList}) { }, }} pageSizeOptions={[10, 15, 20]} - autoHeight = {true} + autoHeight /> ); diff --git a/src/pages/pnspsUserGroupSearchPage/index.js b/src/pages/pnspsUserGroupSearchPage/index.js index 43fa463..dc2209b 100644 --- a/src/pages/pnspsUserGroupSearchPage/index.js +++ b/src/pages/pnspsUserGroupSearchPage/index.js @@ -1,11 +1,11 @@ // material-ui import { - Box, - Button, + // Box, + Stack, + // Button, Grid, Typography } from '@mui/material'; import MainCard from "../../components/MainCard"; - import {useEffect, useState} from "react"; import axios from "axios"; import {apiPath} from "../../auth/utils"; @@ -64,15 +64,15 @@ const UserGroupSearchPanel = () => { !onReady ? : - + - - - View User Group - + + + View User Group + - + {/* - + */} diff --git a/src/pages/pnspsUserSearchPage/UserSearchForm.js b/src/pages/pnspsUserSearchPage/UserSearchForm.js index dc4078b..e2fc547 100644 --- a/src/pages/pnspsUserSearchPage/UserSearchForm.js +++ b/src/pages/pnspsUserSearchPage/UserSearchForm.js @@ -11,34 +11,16 @@ import {useForm} from "react-hook-form"; import { // useEffect, useState} from "react"; -// import Autocomplete from '@mui/material/Autocomplete'; -// import { -// subDivision1, -// subDivision2, -// subDivision3, -// subDivision4, -// subDivision5, -// subDivision6 -// } from "pages/pnspsUserSearchPage/DummyComboRecord"; + import Checkbox from "@mui/material/Checkbox"; import * as React from "react"; +// import AddCircleOutlineIcon from '@mui/icons-material/AddCircleOutline'; // ==============================|| DASHBOARD - DEFAULT ||============================== // -// const subDivisionArray =[ -// ...subDivision1, -// ...subDivision2, -// ...subDivision3, -// ...subDivision4, -// ...subDivision5, -// ...subDivision6 -// ]; const UserSearchForm = ({applySearch}) => { const [type, setType] = useState([]); - // const [division, setDivision] = useState(null); - // const [subDivision, setSubDivision] = useState(null); - // const [isLotusNoteUser, setIsLotusNoteUser] = useState(false); const [locked, setLocked] = useState(false); @@ -55,31 +37,24 @@ const UserSearchForm = ({applySearch}) => { username: data.userName, fullenName: data.fullenName, post: data.post, - // subDivision: subDivision, email: data.email, phone: data.phone, - // isLotusNoteUser: isLotusNoteUser, locked: locked, }; applySearch(temp); }; - // useEffect(() => { - // if(division != null){ - // setSubDivision(subDivisionArray[division.type-1][0]); - // } - - // }, [division]); function resetForm(){ setType([]); - // setDivision(null); - // setSubDivision(null); - // setIsLotusNoteUser(false); setLocked(false); reset(); } + // const handleNewUserClick = (id) => () => { + // navigate('/user/'+ id); + // }; + return ( { {/*row 1*/} - Search Form + Search Form (GLD User) @@ -122,19 +97,6 @@ const UserSearchForm = ({applySearch}) => { /> - {/* - { - setSubDivision(newValue); - }} - renderInput={(params) => } - /> - */} - { /> - {/* - setIsLotusNoteUser(event.target.checked)} - name="checked" - color="primary" - size="small" - /> - } - label={Lotus Notes User} - /> - */} - { label={Locked} /> - {/**/} - {/* */} - {/**/} - {/*last row*/} - - + - + + {/* + + + */} + {/* + + */} diff --git a/src/pages/pnspsUserSearchPage/UserTable.js b/src/pages/pnspsUserSearchPage/UserTable.js index c9b2e91..a122fbc 100644 --- a/src/pages/pnspsUserSearchPage/UserTable.js +++ b/src/pages/pnspsUserSearchPage/UserTable.js @@ -9,9 +9,12 @@ import {useEffect} from "react"; import {useNavigate} from "react-router-dom"; import { useTheme } from '@mui/material/styles'; import Checkbox from '@mui/material/Checkbox'; +import * as UrlUtils from "../../utils/ApiPathConst"; +import * as HttpUtils from '../../utils/HttpUtils'; + // ==============================|| EVENT TABLE ||============================== // -export default function UserTable({recordList}) { +export default function UserTable({recordList,setChangeLocked}) { const [rows, setRows] = React.useState(recordList); const [rowModesModel] = React.useState({}); const theme = useTheme(); @@ -26,6 +29,36 @@ export default function UserTable({recordList}) { navigate('/user/'+ id); }; + const handleLock = (params) => () => { + setChangeLocked(false) + if (params.row.locked==true){ + doUnlock(params.id) + }else{ + doLock(params.id) + setRows(recordList); + } + } + + const doLock = (id) => { + HttpUtils.get({ + url: UrlUtils.GET_USER_LOCK+"/"+id, + onSuccess: function(){ + setRows(recordList); + setChangeLocked(true) + } + }); + }; + + const doUnlock = (id) => { + HttpUtils.get({ + url: UrlUtils.GET_USER_UNLOCK+"/"+id, + onSuccess: function(){ + setRows(recordList); + setChangeLocked(true) + } + }); + }; + const columns = [ { field: 'actions', @@ -52,8 +85,8 @@ export default function UserTable({recordList}) { flex: 1, }, { - id: 'name', - field: 'name', + id: 'enName', + field: 'enName', headerName: 'Full Name', flex: 1, }, @@ -64,47 +97,11 @@ export default function UserTable({recordList}) { flex: 1, }, { - id: 'email', - field: 'email', + id: 'emailAddress', + field: 'emailAddress', headerName: 'Email', flex: 1, }, - // { - // id: 'subDivisionId', - // field: 'subDivisionId', - // //type: 'date', - // //sortable: false, - // headerName: 'Sub-Division', - // flex: 1, - // }, - - // { - // id: 'subDivisionId', - // field: 'subDivisionId', - // //type: 'date', - // //sortable: false, - // headerName: 'Sub-Division', - // flex: 1, - // }, - // { - // id: 'lotusNotesUser', - // field: 'lotusNotesUser', - // type: 'bool', - // headerName: 'Lotus Notes User', - // flex: 1, - // renderCell: (params) => { - // return ( - // - // ); - // }, - // }, { id: 'locked', @@ -120,7 +117,7 @@ export default function UserTable({recordList}) { checked={params.row.locked} color="primary" size="small" - //onChange={handleChange} + onClick={handleLock(params)} /> ); }, @@ -140,7 +137,7 @@ export default function UserTable({recordList}) { }, }} pageSizeOptions={[5, 10]} - autoHeight = {true} + autoHeight /> ); diff --git a/src/pages/pnspsUserSearchPage/index.js b/src/pages/pnspsUserSearchPage/index.js index 304fc61..73104fe 100644 --- a/src/pages/pnspsUserSearchPage/index.js +++ b/src/pages/pnspsUserSearchPage/index.js @@ -5,8 +5,7 @@ import { import MainCard from "../../components/MainCard"; import {useEffect, useState} from "react"; import axios from "axios"; -import {apiPath} from "../../auth/utils"; -import {GET_USER_PATH} from "../../utils/ApiPathConst"; +import {GLD_USER_PATH} from "../../utils/ApiPathConst"; import * as React from "react"; // import LoadingComponent from "../extra-pages/LoadingComponent"; @@ -25,10 +24,11 @@ const UserSettingPage = () => { const [record,setRecord] = useState([]); const [searchCriteria, setSearchCriteria] = useState({}); const [onReady, setOnReady] = useState(false); + const [changelocked, setChangeLocked] = React.useState(false); useEffect(() => { getUserList(); - }, []); + }, [changelocked]); useEffect(() => { setOnReady(true); @@ -39,7 +39,7 @@ const UserSettingPage = () => { }, [searchCriteria]); function getUserList(){ - axios.get(`${apiPath}${GET_USER_PATH}`, + axios.get(`${GLD_USER_PATH}`, {params: searchCriteria} ) .then((response) => { @@ -78,6 +78,7 @@ const UserSettingPage = () => { > diff --git a/src/pages/pnspsUserSearchPage_Individual/UserTable_Individual.js b/src/pages/pnspsUserSearchPage_Individual/UserTable_Individual.js index f2488fb..6d3f172 100644 --- a/src/pages/pnspsUserSearchPage_Individual/UserTable_Individual.js +++ b/src/pages/pnspsUserSearchPage_Individual/UserTable_Individual.js @@ -145,7 +145,7 @@ export default function UserTable_Individual({recordList}) { }, }} pageSizeOptions={[5, 10]} - autoHeight = {true} + autoHeight /> ); diff --git a/src/pages/pnspsUserSearchPage_Organization/UserTable_Organization.js b/src/pages/pnspsUserSearchPage_Organization/UserTable_Organization.js index 5270895..13043bb 100644 --- a/src/pages/pnspsUserSearchPage_Organization/UserTable_Organization.js +++ b/src/pages/pnspsUserSearchPage_Organization/UserTable_Organization.js @@ -139,7 +139,7 @@ export default function UserTable_Organization({recordList}) { }, }} pageSizeOptions={[5, 10]} - autoHeight = {true} + autoHeight /> ); diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index e148ada..c1e922a 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -8,7 +8,7 @@ export const GET_GROUP_COMBO_PATH = '/group/combo'; export const GET_GROUP_MEMBER_LIST_PATH = '/group/member'; export const GET_GROUP_AUTH_LIST = '/group/auth/combo'; -export const GET_USER_PATH = '/user/gld'; +export const GLD_USER_PATH = apiPath+'/user/gld'; export const GET_AUTH_LIST = '/user/auth/combo'; export const GET_USER_COMBO_LIST = '/user/combo'; export const GET_USER_LOCK = apiPath+'/user/lock'; @@ -40,6 +40,12 @@ export const POST_LOGIN = '/login'; export const POST_PUBLIC_USER_REGISTER = apiPath+'/user/register'; - //Public -export const GET_PUBLIC_ORG_USER_LIST = apiPath+'/user/listOrg'; \ No newline at end of file +export const GET_PUBLIC_ORG_USER_LIST = apiPath+'/user/listOrg'; + +//GLD User +export const POST_ADMIN_USER_REGISTER = apiPath+'/user/registry'; +export const DELETE_USER = apiPath+'/user'; + +//User Group +export const POST_AND_UPDATE_USER_GROUP = apiPath+'/group/save'; \ No newline at end of file diff --git a/src/utils/CommonFunction.js b/src/utils/CommonFunction.js index 5bf7263..ffbf70e 100644 --- a/src/utils/CommonFunction.js +++ b/src/utils/CommonFunction.js @@ -1,3 +1,16 @@ +// import {toast} from "react-toastify"; +import DialogTitle from "@mui/material/DialogTitle"; +import DialogContent from "@mui/material/DialogContent"; +import DialogContentText from "@mui/material/DialogContentText"; +import DialogActions from "@mui/material/DialogActions"; +import {Button} from "@mui/material"; +import Dialog from "@mui/material/Dialog"; +import * as React from "react"; + +export function getDeletedRecordWithRefList(referenceList, updatedList){ + return referenceList.filter(x => !updatedList.includes(x)) ; +} + export function getIdList(input){ const output = input.map(function (obj) { return obj.id; @@ -5,10 +18,93 @@ export function getIdList(input){ return output; } +export function getObjectById(list, id){ + const obj = list.find((element) => { + return element.id === id; + }); + return obj === undefined || Object.keys(obj).length <= 0? null : obj +} + export function removeObjectWithId(arr, id) { - // Making a copy with the Array from() method const arrCopy = Array.from(arr); const objWithIdIndex = arrCopy.findIndex((obj) => obj.id === id); arrCopy.splice(objWithIdIndex, 1); return arrCopy; +} + +export function getDateString(queryDateArray) { + return( + queryDateArray[0] + + "-" + + queryDateArray[1] + + "-" + + queryDateArray[2] + + " " + + queryDateArray[3] + + ":" + + queryDateArray[4] + + ":" + + queryDateArray[5] + ) +} + +// export const notifySaveSuccess = () => toast.success('Save success!', { +// position: "bottom-right", +// autoClose: 5000, +// hideProgressBar: false, +// closeOnClick: true, +// pauseOnHover: true, +// draggable: true, +// progress: undefined, +// theme: "light", +// }); + +export const notifyDeleteSuccess = () => toast.success('Delete Success!', { + position: "bottom-right", + autoClose: 5000, + hideProgressBar: false, + closeOnClick: true, + pauseOnHover: true, + draggable: true, + progress: undefined, + theme: "light", +}); + +export function prettyJson(json){ + console.log(json); + console.log(JSON.stringify(json, null, 2)); + return ( +
{JSON.stringify(json, null, 2)}
+ ); +} + +export function GeneralConfirmWindow({ + isWindowOpen, + title, + content, + onNormalClose, + onConfirmClose}){ + return ( + + + {title} + + + + {content} + + + + + + + + ) } \ No newline at end of file