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/username/sent');
  67. // location.reload();
  68. },
  69. onError:function () {
  70. navigate('/forgot/username/sent');
  71. }
  72. });
  73. }
  74. });
  75. return (
  76. <Grid container sx={{ minHeight: '87vh', 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="forgotUsername"/>
  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} md={12} width={{ md: "60%", xs: "90%" }}>
  96. <MainCard
  97. sx={{
  98. maxWidth: { xs: 400, sm:600, md:800, lg: 1000 },
  99. margin: { sm: 2.5, md: 3 },
  100. '& > *': {
  101. flexGrow: 1,
  102. flexBasis: '50%'
  103. }
  104. }}
  105. content={false}
  106. border={false}
  107. boxShadow
  108. >
  109. <form onSubmit={formik.handleSubmit}>
  110. <Grid container spacing={2} sx={{ minHeight: '40vh' }} direction="column" justifyContent="flex-start" alignItems="center">
  111. <Grid item xs={12} md={12} lg={12} sx={{ mb: 1, mt:5, display: { xs: 'none', sm: 'none', md: 'block' } }}>
  112. <InputLabel htmlFor="email-login-title">
  113. <Typography variant="h5" >
  114. <FormattedMessage id="forgotUsernameSubTitle"/>
  115. </Typography>
  116. </InputLabel>
  117. </Grid>
  118. <Grid item xs={12} md={12} lg={12} sx={{ mb: 1, mt:5, display: { md: 'none', xl: 'none', lg: 'none' } }}>
  119. <InputLabel htmlFor="email-login-subtitle">
  120. <Typography variant="h6" >
  121. <FormattedMessage id="forgotUsernameSubTitle1"/>
  122. </Typography>
  123. <Typography variant="h6" >
  124. <FormattedMessage id="forgotPasswordSubTitle2"/>
  125. </Typography>
  126. </InputLabel>
  127. </Grid>
  128. <Grid item xs={12} md={12} lg={12} width={{xs:"70%", sm:"60%",md:"50%", lg:"50%"}}>
  129. <Grid container direction="row" justifyContent="flex-start">
  130. <Grid item xs={12} md={12} lg={12} sx={{ mb: 3}} >
  131. <TextField
  132. fullWidth
  133. autoFocus
  134. onChange={formik.handleChange}
  135. id="emailAddress"
  136. name="emailAddress"
  137. placeholder={intl.formatMessage({id: 'userContactEmail'})}
  138. label={intl.formatMessage({id: 'userContactEmail'}) + ":"}
  139. defaultValue={formik.values.emailAddress}
  140. value={formik.values.emailAddress}
  141. error={Boolean(formik.touched.emailAddress && formik.errors.emailAddress)}
  142. onBlur={formik.handleBlur}
  143. inputProps={{
  144. "aria-describedby" : 'standard-weight-helper-text-emailAddress-login',
  145. "aria-label": intl.formatMessage({id: 'userContactEmail'}),
  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="h5" style={{ padding: '16px' }}>{warningText}</Typography> */}
  197. </DialogContent>
  198. <DialogActions>
  199. <Button
  200. aria-label={intl.formatMessage({id: 'close'})}
  201. onClick={() => setIsWarningPopUp(false)}
  202. >
  203. <FormattedMessage id="close" />
  204. </Button>
  205. </DialogActions>
  206. </Dialog>
  207. </div>
  208. </Grid>
  209. );
  210. };
  211. export default ForgotUsernameApplyForm;