25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

157 satır
6.4 KiB

  1. // material-ui
  2. import {
  3. Grid,
  4. Typography,
  5. Stack,
  6. Box,
  7. Button
  8. } from '@mui/material';
  9. import * as UrlUtils from "utils/ApiPathConst";
  10. import * as React from "react";
  11. import * as HttpUtils from "utils/HttpUtils";
  12. import * as DateUtils from "utils/DateUtils";
  13. import * as FormatUtils from "utils/FormatUtils"
  14. import { useParams } from "react-router-dom";
  15. import { useNavigate } from "react-router-dom";
  16. import ForwardIcon from '@mui/icons-material/Forward';
  17. import Loadable from 'components/Loadable';
  18. const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
  19. const ApplicationDetails = Loadable(React.lazy(() => import('./ApplicationDetails')));
  20. const ProofForm = Loadable(React.lazy(() => import('./ProofForm')));
  21. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  22. const BackgroundHead = {
  23. backgroundImage: `url(${titleBackgroundImg})`,
  24. width: '100%',
  25. height: '100%',
  26. backgroundSize: 'contain',
  27. backgroundRepeat: 'no-repeat',
  28. backgroundColor: '#0C489E',
  29. backgroundPosition: 'right'
  30. }
  31. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  32. const Index = () => {
  33. const params = useParams();
  34. const navigate = useNavigate()
  35. const [record, setRecord] = React.useState();
  36. const [onReady, setOnReady] = React.useState(false);
  37. React.useLayoutEffect(() => {
  38. loadForm();
  39. }, []);
  40. React.useLayoutEffect(() => {
  41. setOnReady(true);
  42. }, [record]);
  43. const loadForm = () => {
  44. if (params.id > 0) {
  45. HttpUtils.get({
  46. url: UrlUtils.GET_PROOF + "/" + params.id,
  47. onSuccess: (responseData) => {
  48. if (!responseData.data?.id) {
  49. navigate("/proof/search");
  50. }
  51. responseData.data["phoneNumber"] = JSON.parse(responseData.data.contactTelNo).phoneNumber;
  52. responseData.data["tel_countryCode"] = JSON.parse(responseData.data.contactTelNo).countryCode;
  53. responseData.data["faxNumber"] = JSON.parse(responseData.data.contactFaxNo).faxNumber;
  54. responseData.data["fax_countryCode"] = JSON.parse(responseData.data.contactFaxNo).countryCode;
  55. responseData.data["issueNoStr"] = responseData.data.issueYear
  56. + " Vol. " + FormatUtils.zeroPad(responseData.data.issueVolume, 3)
  57. + ", No. " + FormatUtils.zeroPad(responseData.data.issueNo, 2);
  58. responseData.data["issueDateStr"] = DateUtils.dateFormat(responseData.data.issueDate, "D MMM YYYY (ddd)");
  59. responseData.data["groupType"] = responseData.data.groupNo.charAt(0);
  60. responseData.data["action"] = responseData.data.replyDate ? responseData.data.action : true;
  61. setRecord(responseData.data);
  62. }
  63. });
  64. }
  65. }
  66. // calculate back button position
  67. // const applicationDetailsRef = React.useCallback(node => {
  68. // if (node === null) {
  69. // return
  70. // } else {
  71. // setBackButtonLeftPos(`${node.getBoundingClientRect()?.left}px`)
  72. // }
  73. // })
  74. // const [backButtonPos, setBackButtonPos] = React.useState()
  75. // const backButtonRef = React.useRef()
  76. // React.useLayoutEffect(()=>{
  77. // console.log(applicationDetailsRef.current?.getBoundingClientRect())
  78. // if (backButtonRef.current) backButtonRef.current.style.marginLeft = `${backButtonPos}`
  79. // },[backButtonPos])
  80. // React.useEffect(()=>{
  81. // if (backButtonRef.current) backButtonRef.current.style.marginLeft = `${backButtonLeftPos}`
  82. // }, [backButtonLeftPos])
  83. return (
  84. !onReady ?
  85. <LoadingComponent />
  86. :
  87. (
  88. <Grid container sx={{ minHeight: '110vh', backgroundColor: 'backgroundColor.default' }} direction="column" justifyContent="flex-start" alignItems="center" >
  89. <Grid item xs={12} width="100%">
  90. <div style={BackgroundHead} width="100%">
  91. <Stack direction="row" height='70px'>
  92. <Typography ml={15} color='#FFF' variant="h4" sx={{ pt: 2 }}>Proof Record</Typography>
  93. </Stack>
  94. </div>
  95. </Grid>
  96. <Grid item xs={12} width="100%">
  97. <Button sx={{ ml: 6, mt: 2.5 }} style={{ border: '2px solid' }} variant="outlined" onClick={() => { navigate("/proof/search") }}>
  98. <ForwardIcon style={{ height: 30, width: 50, transform: "rotate(180deg)" }} />
  99. </Button>
  100. </Grid>
  101. {/*row 1*/}
  102. <Grid item xs={12} md={12} >
  103. <Grid container justifyContent="flex-start" alignItems="center" direction="column">
  104. <center>
  105. <Grid item xs={12} md={12} sx={{ pt: 2, ml: 6, mr: 6, }}>
  106. <Box xs={12} md={12} sx={{ p: 4, borderRadius: '10px', backgroundColor: '#ffffff' }}>
  107. <ApplicationDetails
  108. // setBackButtonPos={setBackButtonPos}
  109. formData={record}
  110. style={{
  111. display: "flex",
  112. height: "100%",
  113. flex: 1
  114. }}
  115. />
  116. </Box>
  117. </Grid>
  118. <Grid item xs={12} md={12} sx={{ pt: 3, pb: 2, ml: 6, mr: 6, }}>
  119. <Box xs={12} md={12} sx={{ p: 4, borderRadius: '10px', backgroundColor: '#ffffff' }}>
  120. <ProofForm
  121. formData={record}
  122. />
  123. </Box>
  124. </Grid>
  125. </center>
  126. </Grid>
  127. </Grid>
  128. {/*row 2*/}
  129. </Grid >
  130. )
  131. );
  132. };
  133. export default Index;