25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

226 lines
7.1 KiB

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