You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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