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

ApplicationDetailCard.js 28 KiB

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