Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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