| @@ -130,7 +130,7 @@ export const SetupAxiosInterceptors = () => { | |||||
| return response; | return response; | ||||
| }, | }, | ||||
| async (error) => { | async (error) => { | ||||
| // ** const { config, response: { status } } = error | |||||
| // const { config, response: { status } } = error | |||||
| if (error.response.status === 401 && error.config.url !== apiPath + REFRESH_TOKEN) { | if (error.response.status === 401 && error.config.url !== apiPath + REFRESH_TOKEN) { | ||||
| // Make a request to refresh the access token | // Make a request to refresh the access token | ||||
| const refreshToken = localStorage.getItem('refreshToken'); | const refreshToken = localStorage.getItem('refreshToken'); | ||||
| @@ -170,25 +170,27 @@ export const SetupAxiosInterceptors = () => { | |||||
| } | } | ||||
| // ** if (status === 401) { | // ** if (status === 401) { | ||||
| if (response.status === 401) { | |||||
| if (localStorage.getItem("expiredAlertShown") === null) { | |||||
| localStorage.setItem("expiredAlertShown", true) | |||||
| alert("登入驗證已過期,請重新登入。") | |||||
| } | |||||
| } | |||||
| // if (response.status === 401) { | |||||
| // if (localStorage.getItem("expiredAlertShown") === null) { | |||||
| // localStorage.setItem("expiredAlertShown", true) | |||||
| // alert("登入驗證已過期,請重新登入。") | |||||
| // } | |||||
| // } | |||||
| if (response && response.status === 401) { | |||||
| if (localStorage.getItem("expiredAlertShown") === null) { | |||||
| localStorage.setItem("expiredAlertShown", true) | |||||
| alert("登入驗證已過期,請重新登入。") | |||||
| } | |||||
| } | |||||
| // if (response && response.status === 401) { | |||||
| // if (localStorage.getItem("expiredAlertShown") === null) { | |||||
| // localStorage.setItem("expiredAlertShown", true) | |||||
| // alert("登入驗證已過期,請重新登入。") | |||||
| // } | |||||
| // } | |||||
| if (localStorage.getItem("expiredAlertShown")) { | if (localStorage.getItem("expiredAlertShown")) { | ||||
| await dispatch(handleLogoutFunction()); | await dispatch(handleLogoutFunction()); | ||||
| await navigate('/login'); | await navigate('/login'); | ||||
| await window.location.reload(); | await window.location.reload(); | ||||
| } | } | ||||
| // console.log(error) | |||||
| } else { | } else { | ||||
| if (error.response.status === 401) { | if (error.response.status === 401) { | ||||
| await dispatch(handleLogoutFunction()); | await dispatch(handleLogoutFunction()); | ||||
| @@ -196,8 +198,8 @@ export const SetupAxiosInterceptors = () => { | |||||
| // await window.location.reload(); | // await window.location.reload(); | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| } | |||||
| return Promise.reject(error) | return Promise.reject(error) | ||||
| } | } | ||||
| @@ -75,6 +75,7 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria }) => { | |||||
| }; | }; | ||||
| function resetForm() { | function resetForm() { | ||||
| setStatus(ComboData.paymentStatus[0]); | |||||
| setMinDate(DateUtils.dateValue(new Date().setDate(new Date().getDate()-14))) | setMinDate(DateUtils.dateValue(new Date().setDate(new Date().getDate()-14))) | ||||
| setMaxDate(DateUtils.dateValue(new Date())) | setMaxDate(DateUtils.dateValue(new Date())) | ||||
| reset(); | reset(); | ||||
| @@ -222,7 +222,7 @@ export default function SubmittedTab({ setCount, url }) { | |||||
| <FormattedMessage id={utils.getPaymentMethod(params.row.paymentMethod)} /><br /> | <FormattedMessage id={utils.getPaymentMethod(params.row.paymentMethod)} /><br /> | ||||
| <div> | <div> | ||||
| {dateStr(params.row.closingDateOff)} | {dateStr(params.row.closingDateOff)} | ||||
| {params.row.paymentMethod=="online" ? " 2pm" | |||||
| {params.row.paymentMethod=="online" ? " 2:00pm" | |||||
| :params.row.paymentMethod=="demandNote" ? " 12:00pm" | :params.row.paymentMethod=="demandNote" ? " 12:00pm" | ||||
| : " 12:30pm"} | : " 12:30pm"} | ||||
| </div> | </div> | ||||
| @@ -16,7 +16,7 @@ const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingCo | |||||
| // ==============================|| DASHBOARD - DEFAULT ||============================== // | // ==============================|| DASHBOARD - DEFAULT ||============================== // | ||||
| const UserAuthorityCard = ({ isCollectData, updateUserAuthList, userData, isNewRecord, editMode}) => { | |||||
| const UserAuthorityCard = ({ isCollectData, updateUserAuthList, userData, isNewRecord, editMode, createMode}) => { | |||||
| const [currentAuthData, setCurrentAuthData] = React.useState({}); | const [currentAuthData, setCurrentAuthData] = React.useState({}); | ||||
| const [onReady, setOnReady] = useState(false); | const [onReady, setOnReady] = useState(false); | ||||
| const [selectedRow, setSelectedRow] = useState([]); | const [selectedRow, setSelectedRow] = useState([]); | ||||
| @@ -59,7 +59,7 @@ const UserAuthorityCard = ({ isCollectData, updateUserAuthList, userData, isNewR | |||||
| userAuth={userData.authIds} | userAuth={userData.authIds} | ||||
| setSelectedRow={setSelectedRow} | setSelectedRow={setSelectedRow} | ||||
| isNewRecord={isNewRecord} | isNewRecord={isNewRecord} | ||||
| editMode={editMode} | |||||
| editMode={createMode?true:editMode} | |||||
| /> | /> | ||||
| <br/> | <br/> | ||||
| </MainCard> | </MainCard> | ||||
| @@ -15,7 +15,7 @@ const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingCo | |||||
| // ==============================|| DASHBOARD - DEFAULT ||============================== // | // ==============================|| DASHBOARD - DEFAULT ||============================== // | ||||
| const UserGroupCard = ({isCollectData, updateUserGroupList,userData,isNewRecord,editMode}) => { | |||||
| const UserGroupCard = ({isCollectData, updateUserGroupList,userData,isNewRecord,editMode,createMode}) => { | |||||
| const [currentUserData, setCurrentUserData] = React.useState({}); | const [currentUserData, setCurrentUserData] = React.useState({}); | ||||
| const [onReady, setOnReady] = useState(false); | const [onReady, setOnReady] = useState(false); | ||||
| const [selectedRow, setSelectedRow] = useState([]); | const [selectedRow, setSelectedRow] = useState([]); | ||||
| @@ -58,7 +58,7 @@ const UserGroupCard = ({isCollectData, updateUserGroupList,userData,isNewRecord, | |||||
| userGroup={userData.groupIds} | userGroup={userData.groupIds} | ||||
| setSelectedRow={setSelectedRow} | setSelectedRow={setSelectedRow} | ||||
| isNewRecord={isNewRecord} | isNewRecord={isNewRecord} | ||||
| editMode={editMode} | |||||
| editMode={createMode?true:editMode} | |||||
| /> | /> | ||||
| <br/> | <br/> | ||||
| </MainCard> | </MainCard> | ||||
| @@ -22,7 +22,7 @@ import VisibilityOff from '@mui/icons-material/VisibilityOff'; | |||||
| import { useIntl } from "react-intl"; | import { useIntl } from "react-intl"; | ||||
| // ==============================|| DASHBOARD - DEFAULT ||============================== // | // ==============================|| DASHBOARD - DEFAULT ||============================== // | ||||
| const UserInformationCard = ({ isCollectData, updateUserObject, userData, isNewRecord, editMode}) => { | |||||
| const UserInformationCard = ({ isCollectData, updateUserObject, userData, isNewRecord, editMode, createMode}) => { | |||||
| //const params = useParams(); | //const params = useParams(); | ||||
| const [currentUserData, setCurrentUserData] = React.useState({}); | const [currentUserData, setCurrentUserData] = React.useState({}); | ||||
| const [locked, setLocked] = useState(false); | const [locked, setLocked] = useState(false); | ||||
| @@ -205,7 +205,7 @@ const UserInformationCard = ({ isCollectData, updateUserObject, userData, isNewR | |||||
| value: currentUserData.enName, | value: currentUserData.enName, | ||||
| })} | })} | ||||
| id='enName' | id='enName' | ||||
| disabled={!editMode} | |||||
| disabled={createMode?false:!editMode} | |||||
| /> | /> | ||||
| </FormControl> | </FormControl> | ||||
| </Grid> | </Grid> | ||||
| @@ -229,7 +229,7 @@ const UserInformationCard = ({ isCollectData, updateUserObject, userData, isNewR | |||||
| value: currentUserData.post, | value: currentUserData.post, | ||||
| })} | })} | ||||
| id='post' | id='post' | ||||
| disabled={!editMode} | |||||
| disabled={createMode?false:!editMode} | |||||
| /> | /> | ||||
| </FormControl> | </FormControl> | ||||
| </Grid> | </Grid> | ||||
| @@ -253,7 +253,7 @@ const UserInformationCard = ({ isCollectData, updateUserObject, userData, isNewR | |||||
| value: currentUserData.emailAddress, | value: currentUserData.emailAddress, | ||||
| })} | })} | ||||
| id='emailAddress' | id='emailAddress' | ||||
| disabled={!editMode} | |||||
| disabled={createMode?false:!editMode} | |||||
| /> | /> | ||||
| </FormControl> | </FormControl> | ||||
| </Grid> | </Grid> | ||||
| @@ -55,6 +55,7 @@ const UserMaintainPage = () => { | |||||
| const [isNewRecord, setIsNewRecord] = useState(false); | const [isNewRecord, setIsNewRecord] = useState(false); | ||||
| const [refUserData, setRefUserData] = useState({}); | const [refUserData, setRefUserData] = useState({}); | ||||
| const [editMode, setEditMode] = useState(false); | const [editMode, setEditMode] = useState(false); | ||||
| const [createMode, setCreateMode] = useState(false); | |||||
| function updateUserObject(userData) { | function updateUserObject(userData) { | ||||
| setEditedCustomerData(userData); | setEditedCustomerData(userData); | ||||
| @@ -120,6 +121,7 @@ const UserMaintainPage = () => { | |||||
| } | } | ||||
| ); | ); | ||||
| setIsNewRecord(true); | setIsNewRecord(true); | ||||
| setCreateMode(true) | |||||
| } | } | ||||
| }, []); | }, []); | ||||
| @@ -203,11 +205,14 @@ const UserMaintainPage = () => { | |||||
| navigate('/userSearchview'); | navigate('/userSearchview'); | ||||
| } | } | ||||
| }) | }) | ||||
| .catch(error => { | |||||
| console.log(error); | |||||
| return false; | |||||
| }); | |||||
| } | |||||
| .catch(function (error){ | |||||
| // console.log(error.response.data) | |||||
| if(error.response.data.error == "USERNAME_NOT_AVAILABLE"){ | |||||
| alert("Username is already used.") | |||||
| } | |||||
| return false; | |||||
| }); | |||||
| } | |||||
| } | } | ||||
| setUserConfirm(false); | setUserConfirm(false); | ||||
| }, [editedCustomerData, userGroupData, userAuthData]); | }, [editedCustomerData, userGroupData, userAuthData]); | ||||
| @@ -257,65 +262,84 @@ const UserMaintainPage = () => { | |||||
| isGrantedAny(["MAINTAIN_USER"]) ? | isGrantedAny(["MAINTAIN_USER"]) ? | ||||
| <Grid item s={12} md={12} lg={12} sx={{ mt: 2, mb: 2 }} alignItems={"start"} justifyContent="center"> | <Grid item s={12} md={12} lg={12} sx={{ mt: 2, mb: 2 }} alignItems={"start"} justifyContent="center"> | ||||
| <Grid container maxWidth justifyContent="flex-start"> | <Grid container maxWidth justifyContent="flex-start"> | ||||
| {editMode ? | |||||
| <ThemeProvider theme={PNSPS_BUTTON_THEME}> | |||||
| <Grid item sx={{ ml: 3, mr: 3 }}> | |||||
| <Button | |||||
| variant="contained" | |||||
| onClick={loadData} | |||||
| color="cancel" | |||||
| > | |||||
| Reset & Back | |||||
| </Button> | |||||
| </Grid> | |||||
| <Grid item sx={{ ml: 3, mr: 3 }}> | |||||
| <Button | |||||
| size="large" | |||||
| variant="contained" | |||||
| type="submit" | |||||
| sx={{ | |||||
| textTransform: 'capitalize', | |||||
| alignItems: 'end' | |||||
| }} | |||||
| onClick={submitData} | |||||
| > | |||||
| Save | |||||
| </Button> | |||||
| </Grid> | |||||
| </ThemeProvider> : | |||||
| <ThemeProvider theme={PNSPS_BUTTON_THEME}> | |||||
| <Grid item sx={{ ml: 3, mr: 3 }}> | |||||
| <Button | |||||
| variant="contained" | |||||
| onClick={onEditClick} | |||||
| > | |||||
| Edit | |||||
| </Button> | |||||
| </Grid> | |||||
| <Grid item sx={{ ml: 3, mr: 3 }}> | |||||
| <Button | |||||
| size="large" | |||||
| variant="contained" | |||||
| sx={{ | |||||
| textTransform: 'capitalize', | |||||
| alignItems: 'end' | |||||
| }} | |||||
| disabled={isNewRecord} | |||||
| onClick={handleDeleteClick} | |||||
| color='error' | |||||
| > | |||||
| Delete User | |||||
| </Button> | |||||
| <GeneralConfirmWindow | |||||
| isWindowOpen={isWindowOpen} | |||||
| title={"Attention"} | |||||
| content={`Confirm to delete User "${userData.data.username}" ?`} | |||||
| onNormalClose={handleClose} | |||||
| onConfirmClose={deleteData} | |||||
| /> | |||||
| </Grid> | |||||
| </ThemeProvider> | |||||
| { | |||||
| createMode? | |||||
| <ThemeProvider theme={PNSPS_BUTTON_THEME}> | |||||
| <Grid item sx={{ ml: 3, mr: 3 }}> | |||||
| <Button | |||||
| size="large" | |||||
| variant="contained" | |||||
| type="submit" | |||||
| sx={{ | |||||
| textTransform: 'capitalize', | |||||
| alignItems: 'end' | |||||
| }} | |||||
| onClick={submitData} | |||||
| > | |||||
| Create User | |||||
| </Button> | |||||
| </Grid> | |||||
| </ThemeProvider> | |||||
| : | |||||
| editMode ? | |||||
| <ThemeProvider theme={PNSPS_BUTTON_THEME}> | |||||
| <Grid item sx={{ ml: 3, mr: 3 }}> | |||||
| <Button | |||||
| variant="contained" | |||||
| onClick={loadData} | |||||
| color="cancel" | |||||
| > | |||||
| Reset & Back | |||||
| </Button> | |||||
| </Grid> | |||||
| <Grid item sx={{ ml: 3, mr: 3 }}> | |||||
| <Button | |||||
| size="large" | |||||
| variant="contained" | |||||
| type="submit" | |||||
| sx={{ | |||||
| textTransform: 'capitalize', | |||||
| alignItems: 'end' | |||||
| }} | |||||
| onClick={submitData} | |||||
| > | |||||
| Save | |||||
| </Button> | |||||
| </Grid> | |||||
| </ThemeProvider> | |||||
| : | |||||
| <ThemeProvider theme={PNSPS_BUTTON_THEME}> | |||||
| <Grid item sx={{ ml: 3, mr: 3 }}> | |||||
| <Button | |||||
| variant="contained" | |||||
| onClick={onEditClick} | |||||
| > | |||||
| Edit | |||||
| </Button> | |||||
| </Grid> | |||||
| <Grid item sx={{ ml: 3, mr: 3 }}> | |||||
| <Button | |||||
| size="large" | |||||
| variant="contained" | |||||
| sx={{ | |||||
| textTransform: 'capitalize', | |||||
| alignItems: 'end' | |||||
| }} | |||||
| disabled={isNewRecord} | |||||
| onClick={handleDeleteClick} | |||||
| color='error' | |||||
| > | |||||
| Delete User | |||||
| </Button> | |||||
| <GeneralConfirmWindow | |||||
| isWindowOpen={isWindowOpen} | |||||
| title={"Attention"} | |||||
| content={`Confirm to delete User "${userData.data.username}" ?`} | |||||
| onNormalClose={handleClose} | |||||
| onConfirmClose={deleteData} | |||||
| /> | |||||
| </Grid> | |||||
| </ThemeProvider> | |||||
| } | } | ||||
| </Grid> | </Grid> | ||||
| </Grid> | </Grid> | ||||
| @@ -332,6 +356,7 @@ const UserMaintainPage = () => { | |||||
| isCollectData={isCollectData} | isCollectData={isCollectData} | ||||
| isNewRecord={isNewRecord} | isNewRecord={isNewRecord} | ||||
| editMode={editMode} | editMode={editMode} | ||||
| createMode={createMode} | |||||
| /> | /> | ||||
| </Box> | </Box> | ||||
| </Grid> | </Grid> | ||||
| @@ -344,6 +369,7 @@ const UserMaintainPage = () => { | |||||
| isCollectData={isCollectData} | isCollectData={isCollectData} | ||||
| isNewRecord={isNewRecord} | isNewRecord={isNewRecord} | ||||
| editMode={editMode} | editMode={editMode} | ||||
| createMode={createMode} | |||||
| /> | /> | ||||
| </Box> | </Box> | ||||
| </Grid> | </Grid> | ||||
| @@ -358,6 +384,7 @@ const UserMaintainPage = () => { | |||||
| isCollectData={isCollectData} | isCollectData={isCollectData} | ||||
| isNewRecord={isNewRecord} | isNewRecord={isNewRecord} | ||||
| editMode={editMode} | editMode={editMode} | ||||
| createMode={createMode} | |||||
| /> | /> | ||||
| </Box> | </Box> | ||||
| </Grid> | </Grid> | ||||