選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

GazetteDetailCard.js 17 KiB

1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
2年前
2年前
1年前
1年前
2年前
2年前
1年前
1年前
2年前
2年前
1年前
1年前
2年前
2年前
1年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. // material-ui
  2. import {
  3. FormControl,
  4. Button,
  5. Grid,
  6. Stack,
  7. Typography, FormLabel,
  8. OutlinedInput,
  9. Dialog, DialogTitle, DialogContent, DialogActions,
  10. } from '@mui/material';
  11. import MainCard from "../../../components/MainCard";
  12. import { useForm } from "react-hook-form";
  13. import {
  14. useEffect,
  15. useState,
  16. lazy
  17. } from "react";
  18. import Loadable from 'components/Loadable';
  19. const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent')));
  20. import * as DateUtils from "utils/DateUtils";
  21. import EditNoteIcon from '@mui/icons-material/EditNote';
  22. import { isGrantedAny } from "auth/utils";
  23. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  24. const GazetteDetailCard = (
  25. { applicationDetailData,
  26. setStatus
  27. }
  28. ) => {
  29. const [onReady, setOnReady] = useState(false);
  30. const [issueNum, setIssueNum] = useState("");
  31. const [issueDate, setIssueDate] = useState("");
  32. const [gazetteCode, setGazetteCode] = useState("");
  33. const [groupTitle, setGroupTitle] = useState("");
  34. const [verified, setVerified] = useState(null);
  35. const [currentStatus, setCurrentStatus] = useState({});
  36. const [sysType, setSysType] = useState(null);
  37. const [careOf, setCareOf] = useState("");
  38. const [mode, setMode] = useState("");
  39. const [isWarningPopUp, setIsWarningPopUp] = useState(false);
  40. const [warningText, setWarningText] = useState("");
  41. const { register,
  42. // getValues
  43. } = useForm()
  44. useEffect(() => {
  45. if (Object.keys(applicationDetailData).length > 0) {
  46. setCurrentStatus(applicationDetailData.data.status);
  47. setVerified(applicationDetailData.userData.verifiedBy ? true : false);
  48. setIssueNum(applicationDetailData.gazetteIssueDetail.volume + "/" + applicationDetailData.gazetteIssueDetail.issueYear
  49. + " No. " + applicationDetailData.gazetteIssueDetail.issueNo);
  50. setIssueDate(DateUtils.dateFormat(applicationDetailData.gazetteIssueDetail.issueDate, "D MMM YYYY (ddd)"));
  51. setGazetteCode(applicationDetailData.data.groupNo)
  52. // console.log(applicationDetailData)
  53. setSysType(applicationDetailData.userData.sysType)
  54. setCareOf(applicationDetailData.data.careOf)
  55. setGroupTitle(applicationDetailData.data.groupTitle)
  56. if (applicationDetailData.data.mode != null){
  57. setMode(applicationDetailData.data.mode);
  58. }
  59. }
  60. }, [applicationDetailData]);
  61. useEffect(() => {
  62. //if state data are ready and assign to different field
  63. // console.log(currentApplicationDetailData)
  64. if (issueNum.length > 0) {
  65. setOnReady(true);
  66. }
  67. }, [issueNum]);
  68. const groupDetailClick = () => () => {
  69. if (gazetteCode == null) {
  70. setStatus("genGazetteCode");
  71. return;
  72. }
  73. setWarningText("Gazette Code is already generated, are you sure to re-generate?");
  74. setIsWarningPopUp(true);
  75. };
  76. const callback = () => {
  77. setIsWarningPopUp(false);
  78. setStatus("genGazetteCode");
  79. }
  80. return (
  81. !onReady ?
  82. <LoadingComponent />
  83. :
  84. <MainCard elevation={0}
  85. border={false}
  86. content={false}
  87. >
  88. {verified && currentStatus != "notAccepted" ?
  89. isGrantedAny("MAINTAIN_APPLICATION") ?
  90. <Grid container spacing={4} direction="row">
  91. <Grid item xs={12} md={4} >
  92. <Stack
  93. direction="row"
  94. justifyContent="space-between"
  95. alignItems="center"
  96. spacing={2}
  97. mb={2}
  98. >
  99. {mode != "offline"?
  100. <Button
  101. // size="large"
  102. variant="contained"
  103. onClick={groupDetailClick()}
  104. disabled={applicationDetailData.data.status != "submitted" && applicationDetailData.data.status != "reviewed"}
  105. sx={{
  106. textTransform: 'capitalize',
  107. alignItems: 'end'
  108. }}>
  109. <EditNoteIcon />
  110. <Typography variant="h5" ml={1}> Gen Gazette Code</Typography>
  111. </Button>
  112. :null
  113. }
  114. </Stack>
  115. </Grid>
  116. </Grid>
  117. : null
  118. : null
  119. }
  120. <Typography variant="h5" sx={{ mb: 2, borderBottom: "1px solid black" }}>
  121. Gazette Details
  122. </Typography>
  123. <form>
  124. <Grid container direction="column">
  125. <Grid item xs={12} md={12}>
  126. <Grid container direction="row" justifyContent="space-between"
  127. alignItems="center">
  128. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1 }}>
  129. <Grid container alignItems={"center"}>
  130. <Grid item xs={12} md={4} lg={4}
  131. sx={{ display: 'flex', alignItems: 'center' }}>
  132. <FormLabel><Typography variant="h5">Issue Number:</Typography></FormLabel>
  133. </Grid>
  134. <Grid item xs={12} md={8} lg={8}>
  135. <FormControl variant="outlined" fullWidth disabled >
  136. <OutlinedInput
  137. fullWidth
  138. size="small"
  139. {...register("issueNum",
  140. {
  141. value: issueNum,
  142. })}
  143. value={issueNum}
  144. id='issueNum'
  145. sx={{
  146. "& .MuiInputBase-input.Mui-disabled": {
  147. WebkitTextFillColor: "#000000",
  148. background: "#f8f8f8",
  149. },
  150. }}
  151. />
  152. </FormControl>
  153. </Grid>
  154. </Grid>
  155. </Grid>
  156. <Grid item xs={12} md={5.5} lg={5.5} sx={{ mb: 1, ml: 1 }}>
  157. <Grid container alignItems={"center"}>
  158. <Grid item xs={12} md={4} lg={4}
  159. sx={{ display: 'flex', alignItems: 'center' }}>
  160. <FormLabel><Typography variant="h5">Gazette Code:</Typography></FormLabel>
  161. </Grid>
  162. <Grid item xs={12} md={8} lg={8}>
  163. <FormControl variant="outlined" fullWidth disabled >
  164. <OutlinedInput
  165. fullWidth
  166. size="small"
  167. {...register("gazetteCode",
  168. {
  169. value: gazetteCode,
  170. })}
  171. value={gazetteCode}
  172. id='gazetteCode'
  173. sx={{
  174. "& .MuiInputBase-input.Mui-disabled": {
  175. WebkitTextFillColor: "#000000",
  176. background: "#f8f8f8",
  177. },
  178. }}
  179. />
  180. </FormControl>
  181. </Grid>
  182. </Grid>
  183. </Grid>
  184. </Grid>
  185. <Grid container direction="row" justifyContent="space-between"
  186. alignItems="center" >
  187. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1 }}>
  188. <Grid container alignItems={"center"}>
  189. <Grid item xs={12} md={4} lg={4}
  190. sx={{ display: 'flex', alignItems: 'center' }}>
  191. <FormLabel><Typography variant="h5">Issue Date:</Typography></FormLabel>
  192. </Grid>
  193. <Grid item xs={12} md={8} lg={8}>
  194. <FormControl variant="outlined" fullWidth disabled >
  195. <OutlinedInput
  196. fullWidth
  197. size="small"
  198. {...register("issueDate",
  199. {
  200. value: issueDate,
  201. })}
  202. value={issueDate}
  203. id='issueDate'
  204. sx={{
  205. "& .MuiInputBase-input.Mui-disabled": {
  206. WebkitTextFillColor: "#000000",
  207. background: "#f8f8f8",
  208. },
  209. }}
  210. />
  211. </FormControl>
  212. </Grid>
  213. </Grid>
  214. </Grid>
  215. <Grid item xs={12} md={5.5} lg={5.5} sx={{ mb: 1, ml: 1 }}>
  216. <Grid container alignItems={"center"}>
  217. <Grid item xs={12} md={4} lg={4}
  218. sx={{ display: 'flex', alignItems: 'center' }}>
  219. <FormLabel><Typography variant="h5">Group Title:</Typography></FormLabel>
  220. </Grid>
  221. <Grid item xs={12} md={8} lg={8}>
  222. <FormControl variant="outlined" fullWidth disabled >
  223. <OutlinedInput
  224. fullWidth
  225. size="small"
  226. {...register("groupTitle",
  227. {
  228. value: groupTitle,
  229. })}
  230. value={groupTitle}
  231. id='groupTitle'
  232. sx={{
  233. "& .MuiInputBase-input.Mui-disabled": {
  234. WebkitTextFillColor: "#000000",
  235. background: "#f8f8f8",
  236. },
  237. }}
  238. />
  239. </FormControl>
  240. </Grid>
  241. </Grid>
  242. </Grid>
  243. </Grid>
  244. {
  245. sysType != null && sysType == "dummy"?
  246. <Grid container direction="row" justifyContent="space-between" alignItems="center" sx={{ mb: { lg: -3 } }}>
  247. <Grid item xs={12} md={12} lg={12} sx={{ mb: 1 }}>
  248. <Grid container alignItems={"center"}>
  249. <Grid item xs={12} md={2} lg={2}
  250. sx={{ display: 'flex', alignItems: 'center' }}>
  251. <FormLabel>
  252. <Typography variant="h5">Customer&apos;s Client/ Case No:</Typography>
  253. </FormLabel>
  254. </Grid>
  255. <Grid item xs={12} md={10} lg={10}>
  256. <FormControl variant="outlined" fullWidth disabled >
  257. <OutlinedInput
  258. fullWidth
  259. size="small"
  260. {...register("careOf",
  261. {
  262. value: careOf,
  263. })}
  264. value={careOf}
  265. id='careOf'
  266. sx={{
  267. "& .MuiInputBase-input.Mui-disabled": {
  268. WebkitTextFillColor: "#000000",
  269. background: "#f8f8f8",
  270. },
  271. }}
  272. />
  273. </FormControl>
  274. </Grid>
  275. </Grid>
  276. </Grid>
  277. </Grid>
  278. : null
  279. }
  280. </Grid>
  281. </Grid>
  282. </form>
  283. <div>
  284. <Dialog
  285. open={isWarningPopUp}
  286. onClose={() => setIsWarningPopUp(false)}
  287. PaperProps={{
  288. sx: {
  289. minWidth: '40vw',
  290. maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '70vw' },
  291. maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '60vh' }
  292. }
  293. }}>
  294. <DialogTitle><Typography variant="h3">Warning</Typography></DialogTitle>
  295. <DialogContent style={{ display: 'flex', }}>
  296. <Typography variant="h4" style={{ padding: '16px' }}>{warningText}</Typography>
  297. </DialogContent>
  298. <DialogActions>
  299. <Button onClick={() => setIsWarningPopUp(false)}><Typography variant="h5">No</Typography></Button>
  300. <Button color="success" onClick={() => callback()}><Typography variant="h5">Yes</Typography></Button>
  301. </DialogActions>
  302. </Dialog>
  303. </div>
  304. </MainCard>
  305. );
  306. };
  307. export default GazetteDetailCard;