Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

489 rader
28 KiB

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