Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

217 righe
6.7 KiB

  1. import {
  2. useEffect,
  3. useState
  4. } from "react";
  5. // material-ui
  6. import {
  7. Button,
  8. // Link,
  9. Stack,
  10. Typography,
  11. Dialog,
  12. DialogActions,
  13. DialogContent,
  14. DialogContentText,
  15. DialogTitle,
  16. FormLabel,
  17. Autocomplete,
  18. TextField
  19. } from '@mui/material';
  20. import { Grid } from "../../../../node_modules/@mui/material/index";
  21. import * as ComboData from "utils/ComboData";
  22. import { useFormik, FormikProvider } from 'formik';
  23. import * as yup from 'yup';
  24. const StatusChangeDialog = (props) => {
  25. const [content, setContent] = useState();
  26. const [dialogTitle, setDialogTitle] = useState("Confirm");
  27. const [prositiveBtnText, setPrositiveBtnText] = useState("Confirm");
  28. const [remarks, setRemarks] = useState("");
  29. const [helperText, setHelperText] = useState("");
  30. const [comboInputValue, setComboInputValue] = useState({});
  31. const groupTitleComboList = ComboData.groupTitle;
  32. useEffect(() => {
  33. setComboInputValue({});
  34. if (props.getStatus == "genGazetteCode") {
  35. setDialogTitle("Gen Gazette Code");
  36. setPrositiveBtnText("Submit");
  37. return getGazetteCodeContent()
  38. } else if (props.getStatus == "notAccepted") {
  39. setDialogTitle("Not Accept Reason");
  40. setPrositiveBtnText("Mark Not Accept");
  41. return getNotAcceptedContent();
  42. }if (props.getStatus == "resubmit") {
  43. setDialogTitle("Re-Submit Reason");
  44. setPrositiveBtnText("Mark Re-Submit");
  45. return getNotAcceptedContent();
  46. } else {
  47. setDialogTitle("Action Confirm");
  48. setPrositiveBtnText("Confirm");
  49. let str = "Are you sure you want to " + props.getStatus + " this application?"
  50. return getConfirmContent(str);
  51. }
  52. }, [props.getStatus]);
  53. const acceptedHandle = () => () => {
  54. const getStatus = props.getStatus.status;
  55. if (getStatus == "notAccepted") {
  56. if (!remarks || remarks == "")
  57. setHelperText("Please enter reason");
  58. }
  59. if (!helperText) {
  60. props.setReason({ "reason": remarks });
  61. if (remarks != null && remarks != "") {
  62. console.log(remarks)
  63. // props.setStatusWindowAccepted(true);
  64. }
  65. }
  66. if (getStatus != "notAccepted") {
  67. props.setStatusWindowAccepted(true);
  68. }
  69. };
  70. const formik = useFormik({
  71. initialValues: ({
  72. username: '',
  73. }),
  74. validationSchema: yup.object().shape({
  75. }),
  76. });
  77. const getConfirmContent = (text) => {
  78. setContent(<Grid container direction="row" justifyContent="center" alignItems="center">
  79. <FormLabel sx={{ fontSize: "20px", color: "#000000", textAlign: "center" }}>
  80. <Typography variant="h5">{text}</Typography>
  81. </FormLabel>
  82. </Grid>);
  83. }
  84. const getNotAcceptedContent = () => {
  85. setContent(<Grid container direction="row" justifyContent="center" alignItems="center">
  86. <Grid item xs={12} md={12} lg={12}>
  87. <TextField
  88. multiline
  89. fullWidth
  90. rows={6}
  91. placeholder="Please enter reason"
  92. helperText={helperText}
  93. onChange={(newValues) => {
  94. setRemarks(newValues.target.value);
  95. setHelperText("");
  96. }}
  97. variant="outlined"
  98. InputProps={
  99. {
  100. style: { minHeight: '42.5px', maxHeight: '50vh', height: 'auto' },
  101. }
  102. }
  103. />
  104. </Grid>
  105. </Grid>
  106. );
  107. }
  108. const getGazetteCodeContent = () => {
  109. setContent(<Grid container direction="row" justifyContent="center" alignItems="center">
  110. <Grid item xs={12} md={8} lg={8} sx={{ mb: 1, }}>
  111. <Grid container alignItems={"center"}>
  112. <Grid item xs={12} md={2} lg={3}
  113. sx={{ display: 'flex', alignItems: 'center' }}>
  114. <Typography variant="h5">Target Issue:</Typography>
  115. </Grid>
  116. <Grid item xs={12} md={9} lg={9}>
  117. <FormLabel>
  118. <Typography variant="h5">{props.gazetteIssue + ", "}{props.issueNum + ", "}{props.issueDate}</Typography>
  119. </FormLabel>
  120. </Grid>
  121. </Grid>
  122. </Grid>
  123. <Grid item xs={12} md={8} lg={8} sx={{ mb: 1, height: "180px" }}>
  124. <Grid container alignItems={"center"}>
  125. <Grid item xs={12} md={3} lg={3}
  126. sx={{ display: 'flex', alignItems: 'center' }}>
  127. <Typography variant="h5">Gazette Group:</Typography>
  128. </Grid>
  129. <Grid item xs={12} md={9} lg={9}>
  130. <Autocomplete
  131. disablePortal
  132. id="gazetteGroup"
  133. options={groupTitleComboList}
  134. filterOptions={(options) => options}
  135. inputValue={comboInputValue.label}
  136. onChange={(event, newValue) => {
  137. if (newValue != null && newValue != {}) {
  138. console.log(comboInputValue)
  139. props.setSelectedGazetteGroupInputType(newValue.label);
  140. setComboInputValue(newValue);
  141. props.setSelectedGazetteGroup(newValue);
  142. formik.setFieldValue("", "")
  143. } else {
  144. gazetteGroup
  145. props.setSelectedGazetteGroupInputType("");
  146. }
  147. }}
  148. // sx={{"& .MuiInputBase-root": { height: "41px" },"#idDocType":{padding: "0px 0px 0px 0px"}, "& .MuiAutocomplete-endAdornment": { top: "auto" },}}
  149. renderInput={(params) => <TextField {...params} placeholder="" />}
  150. />
  151. </Grid>
  152. </Grid>
  153. </Grid>
  154. </Grid>
  155. );
  156. }
  157. return (
  158. <Dialog
  159. open={props.open}
  160. onClose={props.handleClose}
  161. fullWidth={true}
  162. maxWidth={'md'}
  163. >
  164. <DialogTitle >
  165. <Grid container>
  166. <Grid item>
  167. <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center">
  168. <Typography variant="h4">
  169. {dialogTitle}
  170. </Typography>
  171. </Stack>
  172. </Grid>
  173. </Grid>
  174. </DialogTitle>
  175. <FormikProvider value={formik}>
  176. <form>
  177. <DialogContent>
  178. <DialogContentText>
  179. {content}
  180. </DialogContentText>
  181. </DialogContent>
  182. </form>
  183. </FormikProvider>
  184. <Stack direction="row" justifyContent="space-around">
  185. <DialogActions>
  186. <Button variant="contained" onClick={props.handleClose} autoFocus >
  187. <Typography variant="h5">
  188. Cancel
  189. </Typography>
  190. </Button>
  191. </DialogActions>
  192. <DialogActions>
  193. <Button variant="contained" color="success" onClick={acceptedHandle()} autoFocus disabled={Object.keys(props.selectedGazetteGroup).length === 0 && props.getStatus === "genGazetteCode"}>
  194. <Typography variant="h5">
  195. {prositiveBtnText}
  196. </Typography>
  197. </Button>
  198. </DialogActions>
  199. </Stack>
  200. </Dialog>
  201. );
  202. };
  203. export default StatusChangeDialog;