Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

127 řádky
4.7 KiB

  1. // material-ui
  2. import {
  3. Grid,
  4. Typography,
  5. Stack,
  6. Button,
  7. } from '@mui/material';
  8. import * as React from "react";
  9. import * as HttpUtils from "utils/HttpUtils";
  10. import * as UrlUtils from "utils/ApiPathConst";
  11. import * as DateUtils from "utils/DateUtils";
  12. import { useParams, useNavigate } from "react-router-dom";
  13. import Loadable from 'components/Loadable';
  14. const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
  15. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  16. import { FormattedMessage } from "react-intl";
  17. import usePageTitle from 'components/usePageTitle';
  18. import { PRIMARY_CONTAINED_BUTTON_SX } from 'themes/colorConst';
  19. const BackgroundHead = {
  20. backgroundImage: `url(${titleBackgroundImg})`,
  21. width: '100%',
  22. height: '100%',
  23. backgroundSize: 'contain',
  24. backgroundRepeat: 'no-repeat',
  25. backgroundColor: '#0C489E',
  26. backgroundPosition: 'right'
  27. }
  28. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  29. const Index = () => {
  30. usePageTitle("msgDetails");
  31. const params = useParams();
  32. const navigate = useNavigate()
  33. const [record, setRecord] = React.useState();
  34. const [onReady, setOnReady] = React.useState(false);
  35. React.useEffect(() => {
  36. loadForm();
  37. }, []);
  38. React.useEffect(() => {
  39. setOnReady(true);
  40. }, [record]);
  41. const loadForm = () => {
  42. if (params.id > 0) {
  43. HttpUtils.get({
  44. url: UrlUtils.GET_MSG_DETAILS + "/" + params.id,
  45. onSuccess: (responseData) => {
  46. if (!responseData?.sentDate) {
  47. navigate("/");
  48. }
  49. setRecord(responseData);
  50. }
  51. });
  52. }
  53. }
  54. return (
  55. !onReady ?
  56. <Grid container sx={{ minHeight: '87vh', mb: 3 }} direction="column" justifyContent="center" alignItems="center">
  57. <Grid item>
  58. <LoadingComponent />
  59. </Grid>
  60. </Grid>
  61. :
  62. (
  63. <Grid container sx={{ minHeight: '110vh', backgroundColor: '#fff' }} direction="column" justifyContent="flex-start" alignItems="center" >
  64. <Grid item xs={12} width="100%">
  65. <div style={BackgroundHead} width="100%">
  66. <Stack direction="row" height='70px'>
  67. <Typography component="h1" ml={15} color='#FFF' variant="h4" sx={{ pt: 2 }}>
  68. <FormattedMessage id="msgDetails" />
  69. </Typography>
  70. </Stack>
  71. </div>
  72. </Grid>
  73. {/*row 1*/}
  74. <Grid item xs={12} md={12} >
  75. <Grid container justifyContent="flex-start" alignItems="center" >
  76. <center>
  77. <Grid item xs={12} md={12} sx={{p:2}} >
  78. <Typography component="h2" variant="h3" sx={{ textAlign: "left", borderBottom: "1px solid black" }}>
  79. {record?.subject}
  80. </Typography>
  81. <Typography sx={{p:1}} align="justify">{DateUtils.datetimeStr(record?.sentDate)}</Typography>
  82. <Typography component="div" variant="body1" sx={{ p: 4, textAlign: "left", bgcolor: "#f8f8f8" }} align="justify">
  83. <div dangerouslySetInnerHTML={{ __html: record?.content }} />
  84. </Typography>
  85. <Typography component="h3" variant="h4" sx={{ ml: 8, mt: 4, mr: 8, textAlign: "center" }}>
  86. <Button
  87. component="span"
  88. variant="contained"
  89. size="large"
  90. sx={{ m: 4, ...PRIMARY_CONTAINED_BUTTON_SX }}
  91. onClick={() => {
  92. navigate(-1);
  93. }}
  94. >
  95. <FormattedMessage id="back" />
  96. </Button>
  97. </Typography>
  98. </Grid>
  99. </center>
  100. </Grid>
  101. </Grid>
  102. {/*row 2*/}
  103. </Grid >
  104. )
  105. );
  106. };
  107. export default Index;