You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

222 line
10 KiB

  1. // material-ui
  2. import {
  3. Grid,
  4. Typography,
  5. Button,
  6. // RadioGroup,
  7. Dialog, DialogTitle, DialogContent, DialogActions,
  8. Stack,
  9. InputLabel,
  10. // OutlinedInput,
  11. FormHelperText,
  12. TextField,
  13. // Box
  14. } from '@mui/material';
  15. import { useFormik } from 'formik';
  16. import * as yup from 'yup';
  17. import * as React from "react";
  18. import * as HttpUtils from "utils/HttpUtils";
  19. import * as UrlUtils from "utils/ApiPathConst";
  20. // import * as FieldUtils from "utils/FieldUtils";
  21. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  22. import ForwardIcon from '@mui/icons-material/Forward';
  23. import MainCard from 'components/MainCard';
  24. import { useNavigate } from "react-router-dom";
  25. // import { notifyActionSuccess } from 'utils/CommonFunction';
  26. import {PNSPS_LONG_BUTTON_THEME} from "themes/buttonConst";
  27. import {ThemeProvider} from "@emotion/react";
  28. import {FormattedMessage, useIntl} from "react-intl";
  29. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  30. const ForgotUsernameApplyForm = () => {
  31. const [isWarningPopUp, setIsWarningPopUp] = React.useState(false);
  32. // const [warningText, setWarningText] = React.useState("");s
  33. // const [attachment, setAttachment] = React.useState({});
  34. const intl = useIntl();
  35. // const [issueId, setIssueId] = React.useState(loadedData.issueId);
  36. const navigate = useNavigate();
  37. const BackgroundHead = {
  38. backgroundImage: `url(${titleBackgroundImg})`,
  39. width: 'auto',
  40. height: 'auto',
  41. backgroundSize: 'contain',
  42. backgroundRepeat: 'no-repeat',
  43. backgroundColor: '#0C489E',
  44. backgroundPosition: 'right'
  45. }
  46. const formik = useFormik({
  47. enableReinitialize: true,
  48. initialValues: {
  49. // username: '',
  50. emailAddress: '',
  51. },
  52. validationSchema: yup.object().shape({
  53. // username: yup.string().required(intl.formatMessage({id: 'requireUsername'})),
  54. emailAddress: yup.string().email(intl.formatMessage({id: 'validEmailFormat'})).max(255).required(intl.formatMessage({id: 'requireEmail'})),
  55. }),
  56. onSubmit: values => {
  57. console.log(values)
  58. HttpUtils.post({
  59. url: UrlUtils.POST_FORGOT_USERNAME_EMAIL,
  60. params: {
  61. emailAddress: values.emailAddress,
  62. },
  63. // files: [attachment],
  64. onSuccess: function () {
  65. // notifyActionSuccess(intl.formatMessage({id: 'submissionSuccess'}) + '!')
  66. navigate('/forgot/password/sent');
  67. // location.reload();
  68. },
  69. onError:function () {
  70. navigate('/forgot/password/sent');
  71. }
  72. });
  73. }
  74. });
  75. return (
  76. <Grid container sx={{ minHeight: '95vh', mb: 3 }} direction="column" alignItems="center">
  77. <Grid item xs={12} md={12} width="100%" >
  78. <div style={BackgroundHead}>
  79. <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center">
  80. <Typography ml={15} color='#FFF' variant="h4" sx={{display: { xs: 'none', sm: 'none', md: 'block' }}}>
  81. <FormattedMessage id="forgotUserPassword"/>
  82. </Typography>
  83. </Stack>
  84. </div>
  85. </Grid>
  86. <Grid item xs={12} width={{xs:"90%", sm:"90%", md:"60%", lg:"60%"}}>
  87. <Button
  88. aria-label={intl.formatMessage({id: 'back'})}
  89. title={intl.formatMessage({id: 'back'})}
  90. sx={{ ml: 0, mt: 2.5 }} style={{ border: '2px solid' }} variant="outlined" onClick={() => { navigate(-1) }}
  91. >
  92. <ForwardIcon style={{ height: 30, width: 50, transform: "rotate(180deg)" }} />
  93. </Button>
  94. </Grid>
  95. {/* <Grid item xs={12}>
  96. <Typography variant="pnspsFormParagraphBold">申請公共啟事</Typography>
  97. </Grid> */}
  98. <Grid item xs={12} md={12} width={{ md: "60%", xs: "90%" }}>
  99. <MainCard
  100. sx={{
  101. maxWidth: { xs: 400, sm:600, md:800, lg: 1000 },
  102. margin: { sm: 2.5, md: 3 },
  103. '& > *': {
  104. flexGrow: 1,
  105. flexBasis: '50%'
  106. }
  107. }}
  108. content={false}
  109. border={false}
  110. boxShadow
  111. >
  112. <form onSubmit={formik.handleSubmit}>
  113. <Grid container spacing={2} sx={{ minHeight: '40vh' }} direction="column" justifyContent="flex-start" alignItems="center">
  114. <Grid item xs={12} md={12} lg={12} sx={{ mb: 1, mt:5, display: { xs: 'none', sm: 'none', md: 'block' } }}>
  115. <InputLabel htmlFor="email-login-title">
  116. <Typography variant="h5" >
  117. <FormattedMessage id="forgotUsernameSubTitle"/>
  118. </Typography>
  119. </InputLabel>
  120. </Grid>
  121. <Grid item xs={12} md={12} lg={12} sx={{ mb: 1, mt:5, display: { md: 'none', xl: 'none', lg: 'none' } }}>
  122. <InputLabel htmlFor="email-login-subtitle">
  123. <Typography variant="h6" >
  124. <FormattedMessage id="forgotUsernameSubTitle1"/>
  125. </Typography>
  126. <Typography variant="h6" >
  127. <FormattedMessage id="forgotPasswordSubTitle2"/>
  128. </Typography>
  129. </InputLabel>
  130. </Grid>
  131. <Grid item xs={12} md={12} lg={12} width={{xs:"70%", sm:"60%",md:"50%", lg:"50%"}}>
  132. <Grid container direction="row" justifyContent="flex-start">
  133. <Grid item xs={12} md={12} lg={12} sx={{ mb: 3}} >
  134. <TextField
  135. fullWidth
  136. onChange={formik.handleChange}
  137. id="emailAddress"
  138. name="emailAddress"
  139. placeholder={intl.formatMessage({id: 'userContactEmail'})}
  140. label={intl.formatMessage({id: 'userContactEmail'}) + ":"}
  141. defaultValue={formik.values.emailAddress}
  142. value={formik.values.emailAddress}
  143. error={Boolean(formik.touched.emailAddress && formik.errors.emailAddress)}
  144. onBlur={formik.handleBlur}
  145. inputProps={{
  146. maxLength: 50,
  147. onKeyDown: (e) => {
  148. if (e.key === 'Enter') {
  149. e.preventDefault();
  150. }
  151. },
  152. }}
  153. InputLabelProps={{
  154. shrink: true
  155. }}
  156. />
  157. </Grid>
  158. {formik.touched.emailAddress && formik.errors.emailAddress && (
  159. <FormHelperText error id="standard-weight-helper-text-emailAddress-login">
  160. {formik.errors.emailAddress}
  161. </FormHelperText>
  162. )}
  163. </Grid>
  164. </Grid>
  165. <Grid item xs={12} md={12} lg={12} mt={1}>
  166. <ThemeProvider theme={PNSPS_LONG_BUTTON_THEME}>
  167. <Button
  168. aria-label={intl.formatMessage({id: 'continue'})}
  169. variant="contained"
  170. type="submit"
  171. >
  172. <FormattedMessage id="continue"/>
  173. </Button>
  174. </ThemeProvider>
  175. </Grid>
  176. </Grid>
  177. </form>
  178. </MainCard>
  179. </Grid>
  180. <div>
  181. <Dialog
  182. open={isWarningPopUp}
  183. onClose={() => setIsWarningPopUp(false)}
  184. PaperProps={{
  185. sx: {
  186. minWidth: '40vw',
  187. maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '70vw' },
  188. maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '60vh' }
  189. }
  190. }}
  191. >
  192. <DialogTitle>
  193. <FormattedMessage id="attention"/>
  194. </DialogTitle>
  195. <DialogContent style={{ display: 'flex', }}>
  196. {/* <Typography variant="h3" style={{ padding: '16px' }}>{warningText}</Typography> */}
  197. </DialogContent>
  198. <DialogActions>
  199. <Button
  200. aria-label={intl.formatMessage({id: 'ok'})}
  201. onClick={() => setIsWarningPopUp(false)}
  202. >
  203. <FormattedMessage id="ok" />
  204. </Button>
  205. </DialogActions>
  206. </Dialog>
  207. </div>
  208. </Grid>
  209. );
  210. };
  211. export default ForgotUsernameApplyForm;