You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

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