Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

210 linhas
7.6 KiB

  1. // material-ui
  2. import {
  3. Grid,
  4. Dialog, DialogTitle, DialogContent, DialogActions,
  5. Typography,
  6. Button,
  7. Stack,
  8. TextField
  9. } from '@mui/material';
  10. import { useFormik } from 'formik';
  11. import * as React from "react";
  12. import * as yup from 'yup';
  13. import * as HttpUtils from "utils/HttpUtils";
  14. import { apiPath } from "auth/utils";
  15. import { useIntl } from "react-intl";
  16. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  17. const Mail = () => {
  18. const [isResponsPopUp, setIsResponsPopUp] = React.useState(false);
  19. const [responsText, setResponsText] = React.useState("");
  20. const intl = useIntl();
  21. function getMaxErrStr(num, fieldname) {
  22. return intl.formatMessage({ id: 'noMoreThenNWords' }, { num: num, fieldname: fieldname ? intl.formatMessage({ id: fieldname }) + ": " : "" });
  23. }
  24. const formik = useFormik({
  25. enableReinitialize: true,
  26. initialValues: { email: "" },
  27. validationSchema: yup.object().shape({
  28. email: yup.string().max(128, getMaxErrStr(128)).required(intl.formatMessage({ id: 'require' }) + 'e-Mail')
  29. }),
  30. onSubmit: values => {
  31. console.log(values);
  32. HttpUtils.post({
  33. url: apiPath + "/test/send-mail",
  34. params: {
  35. email: values.email,
  36. tempKey: values.tempKey
  37. },
  38. onSuccess: function () {
  39. setResponsText("Success");
  40. setIsResponsPopUp(true);
  41. },
  42. onFail: (response) => {
  43. setResponsText("Fail: " + response);
  44. setIsResponsPopUp(true);
  45. },
  46. onError: (error) => {
  47. setResponsText("Error: " + error);
  48. setIsResponsPopUp(true);
  49. }
  50. });
  51. }
  52. });
  53. const setReminderDate=()=>{
  54. HttpUtils.get({
  55. url: apiPath + "/demandNote/set-expect-reminder",
  56. onSuccess: function () {
  57. setResponsText("Success");
  58. setIsResponsPopUp(true);
  59. },
  60. onFail: (response) => {
  61. setResponsText("Fail: " + response);
  62. setIsResponsPopUp(true);
  63. },
  64. onError: (error) => {
  65. setResponsText("Error: " + error);
  66. setIsResponsPopUp(true);
  67. }
  68. });
  69. }
  70. const testDaily_checkDNStatus=()=>{
  71. HttpUtils.post({
  72. url: apiPath + "/test/daily_checkDNStatus",
  73. onSuccess: function () {
  74. setResponsText("Success");
  75. setIsResponsPopUp(true);
  76. },
  77. onFail: (response) => {
  78. setResponsText("Fail: " + response);
  79. setIsResponsPopUp(true);
  80. },
  81. onError: (error) => {
  82. setResponsText("Error: " + error);
  83. setIsResponsPopUp(true);
  84. }
  85. });
  86. }
  87. return (
  88. !JSON.parse(localStorage.getItem('userData')).fullenName == "2fi" ?
  89. <Grid container >
  90. <Typography variant="h1">Ooops! Seem go wrong page...</Typography>
  91. </Grid>
  92. :
  93. <Grid container spacing={1} >
  94. <Grid item xs={12}>
  95. <Typography variant="h3" style={{ padding: 8 }}>Test View</Typography>
  96. </Grid>
  97. {/*col 2*/}
  98. <form onSubmit={formik.handleSubmit} style={{ width: '100%', paddingLeft: 64 , paddingBottom: 60}}>
  99. <Grid item xs={12} mt={1} >
  100. <Typography variant="h4" style={{ padding: 8 }}>Test Send Mail</Typography>
  101. <Stack direction="row" justifyContent="flex-end" alignItems="center">
  102. <TextField
  103. fullWidth
  104. id="email"
  105. name="email"
  106. type="email"
  107. placeholder="email"
  108. label="eMail"
  109. onChange={formik.handleChange}
  110. />
  111. </Stack>
  112. <Stack direction="row" justifyContent="flex-end" alignItems="center">
  113. <TextField
  114. fullWidth
  115. id="tempKey"
  116. name="tempKey"
  117. type="tempKey"
  118. placeholder="tempKey"
  119. label="tempKey"
  120. onChange={formik.handleChange}
  121. />
  122. </Stack>
  123. </Grid>
  124. <Button
  125. variant="contained"
  126. type="submit"
  127. sx={{
  128. textTransform: 'capitalize',
  129. alignItems: 'end',
  130. width: 200
  131. }}>
  132. Send
  133. </Button>
  134. </form>
  135. <Grid item xs={12} mt={1} style={{ width: '100%', paddingLeft: 64, paddingBottom: 60 }}>
  136. <Typography variant="h4" style={{ padding: 8 }}>Set DN Reminder Expect send Date</Typography>
  137. <Button
  138. variant="contained"
  139. onClick={()=>{
  140. setReminderDate();
  141. }}
  142. sx={{
  143. textTransform: 'capitalize',
  144. alignItems: 'end',
  145. width: 200
  146. }}>
  147. Set Expect Date
  148. </Button>
  149. </Grid>
  150. <Grid item xs={12} mt={1} style={{ width: '100%', paddingLeft: 64, paddingBottom: 60 }}>
  151. <Typography variant="h4" style={{ padding: 8 }}>Set DN Reminder Expect send Date</Typography>
  152. <Button
  153. variant="contained"
  154. onClick={()=>{
  155. testDaily_checkDNStatus();
  156. }}
  157. sx={{
  158. textTransform: 'capitalize',
  159. alignItems: 'end',
  160. width: 250
  161. }}>
  162. Test daily_checkDNStatus
  163. </Button>
  164. </Grid>
  165. <div>
  166. <Dialog
  167. open={isResponsPopUp}
  168. onClose={() => setIsResponsPopUp(false)}
  169. PaperProps={{
  170. sx: {
  171. minWidth: '40vw',
  172. maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '70vw' },
  173. maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '60vh' }
  174. }
  175. }}
  176. >
  177. <DialogTitle>Respons</DialogTitle>
  178. <DialogContent style={{ display: 'flex', }}>
  179. <Typography variant="h5" style={{ padding: '16px' }}>{responsText}</Typography>
  180. </DialogContent>
  181. <DialogActions>
  182. <Button onClick={() => setIsResponsPopUp(false)}>OK</Button>
  183. </DialogActions>
  184. </Dialog>
  185. </div>
  186. </Grid>
  187. );
  188. };
  189. export default Mail;