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

162 строки
5.4 KiB

  1. import PropTypes from 'prop-types';
  2. import { Box, Grid, Typography, Dialog, DialogContent, IconButton } from '@mui/material';
  3. import CloseIcon from '@mui/icons-material/Close';
  4. import Loadable from 'components/Loadable';
  5. import { lazy, useState } from 'react';
  6. import { FormattedMessage, useIntl } from "react-intl";
  7. import { checkSysEnv, checkPaymentSuspension } from "utils/Utils";
  8. import backbroundImg from 'assets/images/bg_ml.jpg';
  9. import lgceImg from 'assets/images/2025_lgce.jpg'; // <-- your popup image
  10. import 'assets/style/loginStyles.css';
  11. const AuthCard = Loadable(lazy(() => import('./AuthCardCustom')));
  12. const BackgroundHead = {
  13. backgroundImage: `url(${backbroundImg})`,
  14. width: '100%',
  15. height: '100%',
  16. backgroundSize: 'cover'
  17. };
  18. const AuthWrapper = ({ children }) => {
  19. const intl = useIntl();
  20. // --- Date control ---
  21. const today = new Date();
  22. const showUntil = new Date("2025-11-27T00:00:00"); // 8 Dec 2025 and onwards = hide popup
  23. const [openPopup, setOpenPopup] = useState(today < showUntil);
  24. const handleClosePopup = () => {
  25. setOpenPopup(false);
  26. };
  27. return (
  28. <Box sx={{ minHeight: '87vh' }}>
  29. <Dialog
  30. open={openPopup}
  31. onClose={handleClosePopup}
  32. aria-labelledby="election-promo-title"
  33. maxWidth="md"
  34. PaperProps={{
  35. sx: {
  36. borderRadius: 2,
  37. overflow: 'hidden',
  38. boxShadow: 6
  39. }
  40. }}
  41. >
  42. <Box sx={{ position: 'relative' }}>
  43. <IconButton
  44. aria-label="Close"
  45. onClick={handleClosePopup}
  46. sx={{
  47. position: 'absolute',
  48. top: 6,
  49. right: 6,
  50. zIndex: 1,
  51. bgcolor: 'rgba(255,255,255,0.8)',
  52. '&:hover': { bgcolor: 'rgba(255,255,255,1)' }
  53. }}
  54. >
  55. <CloseIcon />
  56. </IconButton>
  57. <DialogContent sx={{ p: 0 }}>
  58. <Box
  59. component="img"
  60. src={lgceImg}
  61. alt={intl.formatMessage({ id: 'lgce_alt', defaultMessage: '2025 Legislative Council General Election' })}
  62. title={intl.formatMessage({ id: 'lgce_title', defaultMessage: '2025 Legislative Council General Election' })}
  63. sx={{
  64. display: 'block',
  65. width: '100%',
  66. maxWidth: '720px',
  67. height: 'auto'
  68. }}
  69. />
  70. </DialogContent>
  71. </Box>
  72. </Dialog>
  73. {/* Page content */}
  74. <div style={BackgroundHead}>
  75. <Grid
  76. container
  77. direction="row"
  78. justifyContent="space-between"
  79. alignItems="center"
  80. sx={{ minHeight: '87vh' }}
  81. >
  82. <Grid item xs={12} md={8} lg={8} xl={8}>
  83. <Grid
  84. container
  85. direction="column"
  86. justifyContent="flex-start"
  87. alignItems="flex-start"
  88. sx={{ minHeight: { md: 'calc(87vh)' } }}
  89. >
  90. <Grid item xs={12} sx={{ ml: 4,}}>
  91. {checkPaymentSuspension()?
  92. <Typography style={{ color: 'red', textAlign: "flex-start" }}>
  93. <div style={{ padding: 12 }} dangerouslySetInnerHTML={{ __html: intl.formatMessage({ id: "suspensionMessageText" }) }} />
  94. </Typography>
  95. : ""}
  96. <Typography style={{ textAlign: "flex-start" }}>
  97. <div
  98. style={{ padding: 12 }}
  99. dangerouslySetInnerHTML={{ __html: intl.formatMessage({ id: "homePageHeaderMessage" }) }}
  100. />
  101. </Typography>
  102. </Grid>
  103. <Grid
  104. container
  105. direction="column"
  106. justifyContent="flex-start"
  107. alignItems="center"
  108. spacing={2}
  109. sx={{ minHeight: { md: 'calc(50vh)' } }}
  110. >
  111. <Grid item xs={12} sx={{ ml: 4, mt: 12, display: { xs: 'none', sm: 'block' } }}>
  112. <Typography style={{ textAlign: "center", fontSize: "1.8rem" }}>
  113. <FormattedMessage id="HKSARGOV" />
  114. </Typography>
  115. <Typography style={{ textAlign: "center", fontSize: "1.8rem" }}>
  116. <FormattedMessage id="Gazette" />
  117. </Typography>
  118. <Typography style={{ textAlign: "center", fontSize: "1.8rem" }}>
  119. <FormattedMessage id="PNSPS_fullname" />
  120. </Typography>
  121. {checkSysEnv() !== '' ? (
  122. <Typography style={{ color: 'red', textAlign: "center", fontSize: "1.8rem" }}>
  123. User Acceptance Test Environment
  124. </Typography>
  125. ) : (
  126. ""
  127. )}
  128. </Grid>
  129. </Grid>
  130. </Grid>
  131. </Grid>
  132. <Grid item xs={12} md={4} lg={4} xl={4}>
  133. <Grid
  134. container
  135. justifyContent="center"
  136. alignItems="center"
  137. sx={{ minHeight: { xs: 'calc(90vh - 134px)', md: 'calc(90vh - 112px)' } }}
  138. >
  139. <Grid item xs={12} md={11} lg={11} xl={11}>
  140. <AuthCard>{children}</AuthCard>
  141. </Grid>
  142. </Grid>
  143. </Grid>
  144. </Grid>
  145. </div>
  146. </Box>
  147. );
  148. };
  149. AuthWrapper.propTypes = {
  150. children: PropTypes.node
  151. };
  152. export default AuthWrapper;