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

582 行
33 KiB

  1. // material-ui
  2. import {
  3. FormControl,
  4. Button,
  5. Grid,
  6. Typography, FormLabel,
  7. OutlinedInput,
  8. Stack,
  9. Dialog, DialogTitle, DialogContent, DialogActions, InputAdornment,
  10. } from '@mui/material';
  11. import {delBugMode} from "auth/utils";
  12. const MainCard = Loadable(lazy(() => import('components/MainCard')));
  13. import { useForm } from "react-hook-form";
  14. import {
  15. useEffect,
  16. useState
  17. } from "react";
  18. import Loadable from 'components/Loadable';
  19. import { lazy } from 'react';
  20. const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent')));
  21. import * as HttpUtils from "utils/HttpUtils"
  22. import * as DateUtils from "utils/DateUtils"
  23. import * as UrlUtils from "utils/ApiPathConst"
  24. import * as StatusUtils from "utils/statusUtils/PublicNoteStatusUtils";
  25. import DoneIcon from '@mui/icons-material/Done';
  26. import CloseIcon from '@mui/icons-material/Close';
  27. import EditNoteIcon from '@mui/icons-material/EditNote';
  28. import DownloadIcon from '@mui/icons-material/Download';
  29. import ReplayIcon from '@mui/icons-material/Replay';
  30. import { notifyDownloadSuccess } from 'utils/CommonFunction';
  31. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  32. const ApplicationDetailCard = (
  33. { applicationDetailData,
  34. setStatus,
  35. setUploadStatus
  36. }
  37. ) => {
  38. const [currentApplicationDetailData, setCurrentApplicationDetailData] = useState({});
  39. const [companyName, setCompanyName] = useState({});
  40. const [verified, setVerified] = useState(null);
  41. const [fileDetail, setfileDetail] = useState({});
  42. const [onReady, setOnReady] = useState(false);
  43. const { register } = useForm()
  44. const [isWarningPopUp, setIsWarningPopUp] = useState(false);
  45. const [warningText, setWarningText] = useState("");
  46. useEffect(() => {
  47. //if user data from parent are not null
  48. // console.log(applicationDetailData)
  49. if (Object.keys(applicationDetailData).length > 0) {
  50. loadApplicationDetail()
  51. }
  52. }, [applicationDetailData]);
  53. useEffect(() => {
  54. //if state data are ready and assign to different field
  55. // console.log(currentApplicationDetailData)
  56. if (Object.keys(currentApplicationDetailData).length > 0) {
  57. setOnReady(true);
  58. }
  59. }, [currentApplicationDetailData]);
  60. const loadApplicationDetail = () => {
  61. setCurrentApplicationDetailData(applicationDetailData.data);
  62. setCompanyName(applicationDetailData.companyName);
  63. setVerified(applicationDetailData.userData.verifiedBy ? true : false)
  64. setfileDetail(applicationDetailData.fileDetail);
  65. // setReload(false)
  66. }
  67. const onDownloadClick = () => () => {
  68. HttpUtils.fileDownload({
  69. fileId: fileDetail?.id,
  70. skey: fileDetail?.skey,
  71. filename: fileDetail?.filename,
  72. });
  73. notifyDownloadSuccess()
  74. setUploadStatus(true)
  75. };
  76. const reSubmitClick = () => () => {
  77. setStatus("resubmit")
  78. };
  79. const notAcceptedClick = () => () => {
  80. setStatus("notAccepted")
  81. };
  82. const setCompleteDisable=()=>{
  83. if(delBugMode) return false;
  84. return (new Date()).getTime() < DateUtils.convertToDate(applicationDetailData.gazetteIssueDetail.issueDate).getTime();
  85. }
  86. const complatedClick = () => () => {
  87. let issueDate = DateUtils.convertToDate(applicationDetailData.gazetteIssueDetail.issueDate);
  88. let current = new Date();
  89. if(delBugMode){
  90. setStatus("complete")
  91. }else if(current.getTime() >= issueDate.getTime()){
  92. setStatus("complete")
  93. }
  94. };
  95. const withdrawnClick = () => () => {
  96. setStatus("withdraw")
  97. };
  98. const doPublish =()=>()=>{
  99. setStatus("publish")
  100. }
  101. const onProofClick = () => {
  102. if (applicationDetailData.data.groupNo) {
  103. HttpUtils.get({
  104. url: UrlUtils.CHECK_CREATE_PROOF + "/" + currentApplicationDetailData.id,
  105. onSuccess: function (responeData) {
  106. if (responeData.success == true) {
  107. window.open("/proof/create/" + currentApplicationDetailData.id, "_blank", "noreferrer");
  108. window.addEventListener("focus", onFocus)
  109. } else {
  110. let msg = responeData.msg;
  111. if (msg === "haveActiveProof") {
  112. msg = "Action Failed: There is already a pending payment and proofreading record for client review."
  113. } else if (msg === "haveProofed") {
  114. msg = "Action Failed: Already proofed."
  115. }
  116. setWarningText(msg);
  117. setIsWarningPopUp(true);
  118. }
  119. }
  120. });
  121. } else {
  122. setWarningText("Please generate Gazette Code before Create Proof.");
  123. setIsWarningPopUp(true);
  124. }
  125. }
  126. const onFocus = () => {
  127. location.reload();
  128. window.removeEventListener("focus", onFocus)
  129. }
  130. return (
  131. !onReady ?
  132. <LoadingComponent />
  133. :
  134. <MainCard elevation={0}
  135. border={false}
  136. content={false}
  137. >
  138. {verified && currentApplicationDetailData.status !== "notAccepted" ?
  139. <Grid container spacing={4} direction="row">
  140. <Grid item xs={12} md={4} >
  141. <Stack
  142. direction="row"
  143. justifyContent="flex-start"
  144. alignItems="center"
  145. spacing={2}
  146. mb={2}
  147. >
  148. {currentApplicationDetailData.status === "reviewed" ?
  149. <Button
  150. // size="large"
  151. variant="contained"
  152. onClick={() => { onProofClick() }}
  153. sx={{
  154. textTransform: 'capitalize',
  155. alignItems: 'end'
  156. }}>
  157. <EditNoteIcon />
  158. <Typography ml={1} variant="h5"> Create Proof</Typography>
  159. </Button> :
  160. null
  161. }
  162. </Stack>
  163. </Grid>
  164. <Grid item xs={12} md={8} >
  165. <Stack
  166. direction="row"
  167. justifyContent="flex-start"
  168. alignItems="center"
  169. spacing={2}
  170. mb={2}
  171. >
  172. {currentApplicationDetailData.status === "submitted" || currentApplicationDetailData.status == "reviewed" ?
  173. <>
  174. <Button
  175. // size="large"
  176. variant="contained"
  177. onClick={reSubmitClick()}
  178. color="orange"
  179. >
  180. <ReplayIcon />
  181. <Typography ml={1} variant="h5"> Re-Submit</Typography>
  182. </Button>
  183. <Button
  184. // size="large"
  185. variant="contained"
  186. onClick={notAcceptedClick()}
  187. color="error"
  188. sx={{
  189. textTransform: 'capitalize',
  190. alignItems: 'end',
  191. }}>
  192. <CloseIcon />
  193. <Typography ml={1} variant="h5">Not Accept</Typography>
  194. </Button>
  195. </> :
  196. (currentApplicationDetailData.status == "confirmed" && currentApplicationDetailData.creditor == 1) ?
  197. <>
  198. <Button
  199. // size="large"
  200. variant="contained"
  201. onClick={doPublish()}
  202. disabled={setCompleteDisable()}
  203. sx={{
  204. textTransform: 'capitalize',
  205. alignItems: 'end',
  206. backgroundColor: '#52b202'
  207. }}>
  208. <DoneIcon />
  209. <Typography ml={1} variant="h5">Publish</Typography>
  210. </Button>
  211. </>
  212. :
  213. (currentApplicationDetailData.status == "paid" && currentApplicationDetailData.creditor == 0) ?
  214. <>
  215. <Button
  216. // size="large"
  217. variant="contained"
  218. onClick={complatedClick()}
  219. disabled={setCompleteDisable()}
  220. sx={{
  221. textTransform: 'capitalize',
  222. alignItems: 'end',
  223. backgroundColor: '#52b202'
  224. }}>
  225. <DoneIcon />
  226. <Typography ml={1} variant="h5">Publish</Typography>
  227. </Button>
  228. <Button
  229. // size="large"
  230. variant="contained"
  231. onClick={withdrawnClick()}
  232. sx={{
  233. textTransform: 'capitalize',
  234. alignItems: 'end',
  235. backgroundColor: '#ffa733'
  236. }}>
  237. <CloseIcon />
  238. <Typography ml={1} variant="h5">Withdraw</Typography>
  239. </Button>
  240. </> : null
  241. }
  242. </Stack>
  243. </Grid>
  244. </Grid> : null
  245. }
  246. <Typography variant="h4" xs={12} md={12} sx={{ mb: 2, borderBottom: "1px solid black" }}>
  247. Application Details
  248. </Typography>
  249. <form>
  250. <Grid container direction="column">
  251. <Grid item xs={12} md={12}>
  252. <Grid container direction="row" justifyContent="flex-start"
  253. alignItems="center">
  254. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1 }}>
  255. <Grid container alignItems={"center"}>
  256. <Grid item xs={12} md={4} lg={4}
  257. sx={{ display: 'flex', alignItems: 'center' }}>
  258. <FormLabel><Typography variant="h5">Application No:</Typography></FormLabel>
  259. </Grid>
  260. <Grid item xs={12} md={8} lg={8}>
  261. <FormControl variant="outlined" fullWidth disabled >
  262. <OutlinedInput
  263. fullWidth
  264. size="small"
  265. {...register("appNo",
  266. {
  267. value: currentApplicationDetailData.appNo,
  268. })}
  269. id='appNo'
  270. sx={{
  271. "& .MuiInputBase-input.Mui-disabled": {
  272. WebkitTextFillColor: "#000000",
  273. background: "#f8f8f8",
  274. },
  275. }}
  276. />
  277. </FormControl>
  278. </Grid>
  279. </Grid>
  280. </Grid>
  281. <Grid item xs={12} sm={12} md={5.5} lg={5.5} sx={{ mb: 1, ml: { md: 1, lg: 3 } }}>
  282. <Grid container alignItems={"center"}>
  283. <Grid item xs={12} md={4} lg={4}
  284. sx={{ display: 'flex', alignItems: 'center' }}>
  285. <FormLabel><Typography variant="h5">Status:</Typography></FormLabel>
  286. </Grid>
  287. <Grid item xs={12} md={8} lg={8}>
  288. <FormControl variant="outlined">
  289. {StatusUtils.getStatusByTextEng(currentApplicationDetailData.status)}
  290. </FormControl>
  291. </Grid>
  292. </Grid>
  293. </Grid>
  294. </Grid>
  295. <Grid container direction="row" justifyContent="flex-start"
  296. alignItems="center">
  297. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1 }}>
  298. <Grid container alignItems={"center"}>
  299. <Grid item xs={12} md={4} lg={4}
  300. sx={{ display: 'flex', alignItems: 'center' }}>
  301. <FormLabel><Typography variant="h5">Applicant:</Typography></FormLabel>
  302. </Grid>
  303. <Grid item xs={12} md={8} lg={8}>
  304. <FormControl variant="outlined" fullWidth disabled >
  305. {currentApplicationDetailData.orgId === null ?
  306. <OutlinedInput
  307. fullWidth
  308. size="small"
  309. {...register("contactPerson",
  310. {
  311. value: currentApplicationDetailData.contactPerson,
  312. })}
  313. id='contactPerson'
  314. sx={{
  315. "& .MuiInputBase-input.Mui-disabled": {
  316. WebkitTextFillColor: "#000000",
  317. background: "#f8f8f8",
  318. },
  319. }}
  320. /> :
  321. <OutlinedInput
  322. fullWidth
  323. size="small"
  324. {...register("companyName",
  325. {
  326. value: companyName.enCompanyName,
  327. })}
  328. id='companyName'
  329. sx={{
  330. "& .MuiInputBase-input.Mui-disabled": {
  331. WebkitTextFillColor: "#000000",
  332. background: "#f8f8f8",
  333. },
  334. }}
  335. />
  336. }
  337. </FormControl>
  338. </Grid>
  339. </Grid>
  340. </Grid>
  341. <Grid item xs={12} md={5.5} lg={5.5} sx={{ mb: 1, ml: { md: 1, lg: 3 } }}>
  342. <Grid container alignItems={"center"}>
  343. <Grid item xs={12} md={4} lg={4}
  344. sx={{ display: 'flex', alignItems: 'center' }}>
  345. <FormLabel><Typography variant="h5">Contact Phone:</Typography></FormLabel>
  346. </Grid>
  347. <Grid item xs={12} md={8} lg={8}>
  348. <Stack direction="row">
  349. <FormControl variant="outlined" sx={{ width: '25%', minWidth: 100, }} disabled >
  350. <OutlinedInput
  351. size="small"
  352. {...register("contactTelNo.countryCode",
  353. {
  354. value: currentApplicationDetailData.contactTelNo.countryCode,
  355. })}
  356. id='countryCode'
  357. sx={{
  358. "& .MuiInputBase-input.Mui-disabled": {
  359. WebkitTextFillColor: "#000000",
  360. background: "#f8f8f8",
  361. },
  362. mr: 1
  363. }}
  364. inputProps={{
  365. maxLength: 3,
  366. }}
  367. endAdornment={<InputAdornment position="end">-</InputAdornment>}
  368. />
  369. </FormControl>
  370. <FormControl variant="outlined" sx={{ width: '75%' }} disabled >
  371. <OutlinedInput
  372. size="small"
  373. type="tel"
  374. {...register("contactTelNo.phoneNumber",
  375. {
  376. value: currentApplicationDetailData.contactTelNo.phoneNumber,
  377. })}
  378. id='phoneNumber'
  379. sx={{
  380. "& .MuiInputBase-input.Mui-disabled": {
  381. WebkitTextFillColor: "#000000",
  382. background: "#f8f8f8",
  383. },
  384. }}
  385. inputProps={{
  386. maxLength: 11,
  387. }}
  388. />
  389. </FormControl>
  390. </Stack>
  391. </Grid>
  392. </Grid>
  393. </Grid>
  394. </Grid>
  395. <Grid container direction="row" justifyContent="flex-start"
  396. alignItems="center">
  397. <Grid item xs={12} md={6} lg={6} sx={{ mb: 1 }}>
  398. <Grid container alignItems={"center"}>
  399. <Grid item xs={12} md={4} lg={4}
  400. sx={{ display: 'flex', alignItems: 'center' }}>
  401. <FormLabel><Typography variant="h5">Contact Person:</Typography></FormLabel>
  402. </Grid>
  403. <Grid item xs={12} md={8} lg={8}>
  404. <FormControl variant="outlined" fullWidth disabled>
  405. <OutlinedInput
  406. fullWidth
  407. size="small"
  408. {...register("contactPerson",
  409. {
  410. value: currentApplicationDetailData.contactPerson,
  411. })}
  412. id='contactPerson'
  413. sx={{
  414. "& .MuiInputBase-input.Mui-disabled": {
  415. WebkitTextFillColor: "#000000",
  416. background: "#f8f8f8",
  417. },
  418. }}
  419. />
  420. </FormControl>
  421. </Grid>
  422. </Grid>
  423. </Grid>
  424. <Grid item xs={12} md={5.5} lg={5.5} sx={{ mb: 1, ml: { md: 1, lg: 3 } }}>
  425. <Grid container alignItems={"center"}>
  426. <Grid item xs={12} md={4} lg={4}
  427. sx={{ display: 'flex', alignItems: 'center' }}>
  428. <FormLabel><Typography variant="h5">Contact Fax:</Typography></FormLabel>
  429. </Grid>
  430. <Grid item xs={12} md={8} lg={8}>
  431. <Stack direction="row">
  432. <FormControl variant="outlined" sx={{ width: '25%', minWidth: 100, }} disabled>
  433. <OutlinedInput
  434. size="small"
  435. {...register("contactFaxNo.countryCode",
  436. {
  437. value: currentApplicationDetailData.contactFaxNo.countryCode,
  438. })}
  439. id='countryCode'
  440. sx={{
  441. "& .MuiInputBase-input.Mui-disabled": {
  442. WebkitTextFillColor: "#000000",
  443. background: "#f8f8f8",
  444. },
  445. mr: 1,
  446. }}
  447. inputProps={{
  448. maxLength: 3,
  449. type: "tel"
  450. }}
  451. endAdornment={<InputAdornment position="end">-</InputAdornment>}
  452. />
  453. </FormControl>
  454. <FormControl variant="outlined" sx={{ width: '75%' }} disabled>
  455. <OutlinedInput
  456. size="small"
  457. type="tel"
  458. {...register("contactFaxNo.faxNumber",
  459. {
  460. value: currentApplicationDetailData.contactFaxNo.faxNumber,
  461. })}
  462. id='faxNumber'
  463. sx={{
  464. "& .MuiInputBase-input.Mui-disabled": {
  465. WebkitTextFillColor: "#000000",
  466. background: "#f8f8f8",
  467. },
  468. }}
  469. inputProps={{
  470. maxLength: 8,
  471. }}
  472. />
  473. </FormControl>
  474. </Stack>
  475. </Grid>
  476. </Grid>
  477. </Grid>
  478. </Grid>
  479. <Grid container direction="row" justifyContent="flex-start"
  480. alignItems="center">
  481. <Grid item xs={12} md={12} lg={12} mt={1} >
  482. <Grid container alignItems={"center"}>
  483. <Grid item xs={12} md={12} lg={12}>
  484. <Grid container direction="row">
  485. <Grid item xs={12} md={2} lg={2}
  486. sx={{ display: 'flex', alignItems: 'center' }}>
  487. <FormLabel><Typography variant="h5" >Manuscript File:</Typography></FormLabel>
  488. </Grid>
  489. <Grid item xs={12} md={8} lg={8} sx={{ display: 'flex', alignItems: 'center' }}>
  490. <Grid container direction="row" justifyContent="flex-start">
  491. <Grid item xs={10} md={8} lg={8} sx={{ display: 'flex', alignItems: 'center' }}>
  492. <FormControl variant="outlined" fullWidth >
  493. <Typography
  494. // fullWidth
  495. id='fileName'
  496. variant="h5"
  497. sx={{ wordBreak: 'break-word' }}
  498. >
  499. {fileDetail?.filename}
  500. </Typography>
  501. </FormControl>
  502. </Grid>
  503. <Grid item md={2} lg={2}>
  504. <Button
  505. size="small"
  506. variant="contained"
  507. onClick={onDownloadClick()}
  508. disabled={!fileDetail?.filename}
  509. sx={{
  510. textTransform: 'capitalize',
  511. alignItems: 'end',
  512. }}>
  513. <DownloadIcon />
  514. </Button>
  515. </Grid>
  516. </Grid>
  517. </Grid>
  518. </Grid>
  519. </Grid>
  520. </Grid>
  521. </Grid>
  522. </Grid>
  523. </Grid>
  524. </Grid>
  525. </form>
  526. <div>
  527. <Dialog
  528. open={isWarningPopUp}
  529. onClose={() => setIsWarningPopUp(false)}
  530. PaperProps={{
  531. sx: {
  532. minWidth: '40vw',
  533. maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '70vw' },
  534. maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '60vh' }
  535. }
  536. }}
  537. >
  538. <DialogTitle><Typography variant="h3">Warning</Typography></DialogTitle>
  539. <DialogContent style={{ display: 'flex', }}>
  540. <Typography variant="h4" style={{ padding: '16px' }}>{warningText}</Typography>
  541. </DialogContent>
  542. <DialogActions>
  543. <Button onClick={() => setIsWarningPopUp(false)}><Typography variant="h5">OK</Typography></Button>
  544. </DialogActions>
  545. </Dialog>
  546. </div>
  547. </MainCard>
  548. );
  549. };
  550. export default ApplicationDetailCard;