Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

280 righe
11 KiB

  1. // File: src/pages/userGuide/UserMenuPub1.jsx
  2. // Notes:
  3. // - No new libraries.
  4. // - Fixes: target="_blank", rel="noopener noreferrer"
  5. // - Adds aria-label for icon-only download links (WCAG 2.4.4 / 1.1.1 friendly)
  6. // - Fixes invalid HTML: no <p> wrapping <table>
  7. // - Adds <thead>/<tbody>, scope, and React keys
  8. import { Grid, Typography, Stack } from "@mui/material";
  9. import { useState, useEffect, lazy } from "react";
  10. import Loadable from "components/Loadable";
  11. import { useIntl, FormattedMessage } from "react-intl";
  12. import usePageTitle from "components/usePageTitle";
  13. import DownloadIcon from "@mui/icons-material/Download";
  14. import titleBackgroundImg from "assets/images/dashboard/gazette-bar.png";
  15. const LoadingComponent = Loadable(lazy(() => import("pages/extra-pages/LoadingComponent")));
  16. const BackgroundHead = {
  17. backgroundImage: `url(${titleBackgroundImg})`,
  18. width: "auto",
  19. height: "auto",
  20. backgroundSize: "contain",
  21. backgroundRepeat: "no-repeat",
  22. backgroundColor: "#0c489e",
  23. backgroundPosition: "right",
  24. };
  25. const tableStyle = {
  26. fontFamily: "arial, sans-serif",
  27. borderCollapse: "collapse",
  28. width: "100%",
  29. };
  30. const cellStyle = {
  31. border: "1px solid #dddddd",
  32. textAlign: "left",
  33. padding: "8px",
  34. };
  35. const UserMenuPub1 = () => {
  36. const intl = useIntl();
  37. const { locale } = intl;
  38. const [onReady, setOnReady] = useState(false);
  39. // Localized document title/meta for /userGuidePub
  40. usePageTitle("userGuide");
  41. useEffect(() => {
  42. setOnReady(true);
  43. }, [locale]);
  44. const pnspsurl = `https://${window.location.hostname}`;
  45. const pickByLocale = (en, zhHK, zhCN) => (locale === "zh-HK" ? zhHK : locale === "en" ? en : zhCN);
  46. // If you already created downloadPdfAria in i18n, keep it.
  47. // Example en: "Download {guide} PDF ({userType})"
  48. const buildAria = (guideId, userTypeId) => {
  49. const guideTitle = intl.formatMessage({ id: guideId });
  50. const userType = intl.formatMessage({ id: userTypeId });
  51. return intl.formatMessage(
  52. { id: "downloadPdfAria", defaultMessage: "Download {guide} PDF ({userType})" },
  53. { guide: guideTitle, userType }
  54. );
  55. };
  56. const rows = [
  57. {
  58. id: "userGuide1",
  59. org: {
  60. en: `${pnspsurl}/user-guide-pub-1/eng/01 - Create account - c 1.pdf`,
  61. zhHK: `${pnspsurl}/user-guide-pub-1/cht/01c - Create account - c 1.pdf`,
  62. zhCN: `${pnspsurl}/user-guide-pub-1/chs/01sc - Create account - c 1.pdf`,
  63. },
  64. ind: {
  65. en: `${pnspsurl}/user-guide-pub-1/eng/01 - Create account - p 1.pdf`,
  66. zhHK: `${pnspsurl}/user-guide-pub-1/cht/01c - Create account - p 1.pdf`,
  67. zhCN: `${pnspsurl}/user-guide-pub-1/chs/01sc - Create account - p 1.pdf`,
  68. },
  69. },
  70. {
  71. id: "userGuide2",
  72. org: {
  73. en: `${pnspsurl}/user-guide-pub-1/eng/02 - Login - c 1.pdf`,
  74. zhHK: `${pnspsurl}/user-guide-pub-1/cht/02c - Login - c 1.pdf`,
  75. zhCN: `${pnspsurl}/user-guide-pub-1/chs/02sc - Login - c 1.pdf`,
  76. },
  77. ind: {
  78. en: `${pnspsurl}/user-guide-pub-1/eng/02 - Login - p 1.pdf`,
  79. zhHK: `${pnspsurl}/user-guide-pub-1/cht/02c - Login - p 1.pdf`,
  80. zhCN: `${pnspsurl}/user-guide-pub-1/chs/02sc - Login - p 1.pdf`,
  81. },
  82. },
  83. {
  84. id: "userGuide3", // UPDATED TO v2
  85. org: {
  86. en: `${pnspsurl}/user-guide-pub-1/eng/03 - Application for publishing a Public Notice in the Gazette - c 2.pdf`,
  87. zhHK: `${pnspsurl}/user-guide-pub-1/cht/03c - Application for publishing a Public Notice in the Gazette - c 2.pdf`,
  88. zhCN: `${pnspsurl}/user-guide-pub-1/chs/03sc - Application for publishing a Public Notice in the Gazette - c 2.pdf`,
  89. },
  90. ind: {
  91. en: `${pnspsurl}/user-guide-pub-1/eng/03 - Application for publishing a Public Notice in the Gazette - p 2.pdf`,
  92. zhHK: `${pnspsurl}/user-guide-pub-1/cht/03c - Application for publishing a Public Notice in the Gazette - p 2.pdf`,
  93. zhCN: `${pnspsurl}/user-guide-pub-1/chs/03sc - Application for publishing a Public Notice in the Gazette - p 2.pdf`,
  94. },
  95. },
  96. {
  97. id: "userGuide4",
  98. org: {
  99. en: `${pnspsurl}/user-guide-pub-1/eng/04 - Proofreading reply (with correction) - c 2.pdf`,
  100. zhHK: `${pnspsurl}/user-guide-pub-1/cht/04c - Proofreading reply (with correction) - c 2.pdf`,
  101. zhCN: `${pnspsurl}/user-guide-pub-1/chs/04sc - Proofreading reply (with correction) - c 2.pdf`,
  102. },
  103. ind: {
  104. en: `${pnspsurl}/user-guide-pub-1/eng/04 - Proofreading reply (with correction) - p 2.pdf`,
  105. zhHK: `${pnspsurl}/user-guide-pub-1/cht/04c - Proofreading reply (with correction) - p 2.pdf`,
  106. zhCN: `${pnspsurl}/user-guide-pub-1/chs/04sc - Proofreading reply (with correction) - p 2.pdf`,
  107. },
  108. },
  109. {
  110. id: "userGuide5",
  111. org: {
  112. en: `${pnspsurl}/user-guide-pub-1/eng/05 - Proofreading reply (pass for printing) - c 2.pdf`,
  113. zhHK: `${pnspsurl}/user-guide-pub-1/cht/05c - Proofreading reply (pass for printing) - c 2.pdf`,
  114. zhCN: `${pnspsurl}/user-guide-pub-1/chs/05sc - Proofreading reply (pass for printing) - c 2.pdf`,
  115. },
  116. ind: {
  117. en: `${pnspsurl}/user-guide-pub-1/eng/05 - Proofreading reply (pass for printing) - p 2.pdf`,
  118. zhHK: `${pnspsurl}/user-guide-pub-1/cht/05c - Proofreading reply (pass for printing) - p 2.pdf`,
  119. zhCN: `${pnspsurl}/user-guide-pub-1/chs/05sc - Proofreading reply (pass for printing) - p 2.pdf`,
  120. },
  121. },
  122. {
  123. id: "userGuide6",
  124. org: {
  125. en: `${pnspsurl}/user-guide-pub-1/eng/06 - Cancellation of application for publishing a Public Notice in the Gazette - c 1.pdf`,
  126. zhHK: `${pnspsurl}/user-guide-pub-1/cht/06c - Cancellation of application for publishing a Public Notice in the Gazette - c 1.pdf`,
  127. zhCN: `${pnspsurl}/user-guide-pub-1/chs/06sc - Cancellation of application for publishing a Public Notice in the Gazette - c 1.pdf`,
  128. },
  129. ind: {
  130. en: `${pnspsurl}/user-guide-pub-1/eng/06 - Cancellation of application for publishing a Public Notice in the Gazette - p 1.pdf`,
  131. zhHK: `${pnspsurl}/user-guide-pub-1/cht/06c - Cancellation of application for publishing a Public Notice in the Gazette - p 1.pdf`,
  132. zhCN: `${pnspsurl}/user-guide-pub-1/chs/06sc - Cancellation of application for publishing a Public Notice in the Gazette - p 1.pdf`,
  133. },
  134. },
  135. {
  136. id: "userGuide7",
  137. org: {
  138. en: `${pnspsurl}/user-guide-pub-1/eng/07 - Forgot password - c 1.pdf`,
  139. zhHK: `${pnspsurl}/user-guide-pub-1/cht/07c - Forgot password - c 1.pdf`,
  140. zhCN: `${pnspsurl}/user-guide-pub-1/chs/07sc - Forgot password - c 1.pdf`,
  141. },
  142. ind: {
  143. en: `${pnspsurl}/user-guide-pub-1/eng/07 - Forgot password - p 1.pdf`,
  144. zhHK: `${pnspsurl}/user-guide-pub-1/cht/07c - Forgot password - p 1.pdf`,
  145. zhCN: `${pnspsurl}/user-guide-pub-1/chs/07sc - Forgot password - p 1.pdf`,
  146. },
  147. },
  148. {
  149. id: "userGuide8",
  150. org: {
  151. en: `${pnspsurl}/user-guide-pub-1/eng/08 - Change password - c 1.pdf`,
  152. zhHK: `${pnspsurl}/user-guide-pub-1/cht/08c - Change password - c 1.pdf`,
  153. zhCN: `${pnspsurl}/user-guide-pub-1/chs/08sc - Change password - c 1.pdf`,
  154. },
  155. ind: {
  156. en: `${pnspsurl}/user-guide-pub-1/eng/08 - Change password - p 1.pdf`,
  157. zhHK: `${pnspsurl}/user-guide-pub-1/cht/08c - Change password - p 1.pdf`,
  158. zhCN: `${pnspsurl}/user-guide-pub-1/chs/08sc - Change password - p 1.pdf`,
  159. },
  160. },
  161. {
  162. id: "userGuide9",
  163. org: {
  164. en: `${pnspsurl}/user-guide-pub-1/eng/09 - Language of email notification - c 1.pdf`,
  165. zhHK: `${pnspsurl}/user-guide-pub-1/cht/09c - Language of email notification - c 1.pdf`,
  166. zhCN: `${pnspsurl}/user-guide-pub-1/chs/09sc - Language of email notification - c 1.pdf`,
  167. },
  168. ind: {
  169. en: `${pnspsurl}/user-guide-pub-1/eng/09 - Language of email notification - p 1.pdf`,
  170. zhHK: `${pnspsurl}/user-guide-pub-1/cht/09c - Language of email notification - p 1.pdf`,
  171. zhCN: `${pnspsurl}/user-guide-pub-1/chs/09sc - Language of email notification - p 1.pdf`,
  172. },
  173. },
  174. {
  175. id: "userGuidePub10",
  176. org: {
  177. en: `${pnspsurl}/user-guide-pub-1/eng/10-Payment-c1.pdf`,
  178. zhHK: `${pnspsurl}/user-guide-pub-1/cht/10c-Payment-c1.pdf`,
  179. zhCN: `${pnspsurl}/user-guide-pub-1/chs/10sc-Payment-c1.pdf`,
  180. },
  181. ind: {
  182. en: `${pnspsurl}/user-guide-pub-1/eng/10-Payment-p1.pdf`,
  183. zhHK: `${pnspsurl}/user-guide-pub-1/cht/10c-Payment-p1.pdf`,
  184. zhCN: `${pnspsurl}/user-guide-pub-1/chs/10sc-Payment-p1.pdf`,
  185. },
  186. },
  187. ];
  188. const renderDownloadLink = (href, ariaLabel) => (
  189. <a href={href} target="_blank" rel="noopener noreferrer" aria-label={ariaLabel}>
  190. <DownloadIcon aria-hidden="true" focusable="false" />
  191. </a>
  192. );
  193. if (!onReady) {
  194. return (
  195. <Grid container sx={{ minHeight: "87vh", mb: 3 }} direction="column" justifyContent="center" alignItems="center">
  196. <Grid item>
  197. <LoadingComponent />
  198. </Grid>
  199. </Grid>
  200. );
  201. }
  202. return (
  203. <Grid container sx={{ minHeight: "87vh", mb: 3 }} direction="column" alignItems="center">
  204. <Grid item xs={12} md={12} width="100%">
  205. <div style={BackgroundHead}>
  206. <Stack direction="row" height="70px" justifyContent="flex-start" alignItems="center">
  207. <Typography component="h1" ml={15} color="#FFF" variant="h4" sx={{ display: { xs: "none", sm: "none", md: "block" } }}>
  208. <FormattedMessage id="userGuide" />
  209. </Typography>
  210. </Stack>
  211. </div>
  212. </Grid>
  213. <Grid container justifyContent="center" alignItems="center">
  214. <Grid item xs={10} md={8} lg={6}>
  215. <div style={{ textAlign: "justify", textJustify: "interWord", fontStyle: "normal" }}>
  216. <table style={tableStyle}>
  217. <thead>
  218. <tr>
  219. <th style={cellStyle} width="70%" scope="col"></th>
  220. <th style={cellStyle} width="15%" scope="col">
  221. <FormattedMessage id="forOrgUser" />
  222. </th>
  223. <th style={cellStyle} width="15%" scope="col">
  224. <FormattedMessage id="forIndUser" />
  225. </th>
  226. </tr>
  227. </thead>
  228. <tbody>
  229. {rows.map((r) => {
  230. const orgHref = pickByLocale(r.org.en, r.org.zhHK, r.org.zhCN);
  231. const indHref = pickByLocale(r.ind.en, r.ind.zhHK, r.ind.zhCN);
  232. const guideTitle = intl.formatMessage({ id: r.id });
  233. return (
  234. <tr key={r.id}>
  235. <td style={cellStyle}>{guideTitle}</td>
  236. <td style={cellStyle}>
  237. {renderDownloadLink(orgHref, buildAria(r.id, "forOrgUser"))}
  238. </td>
  239. <td style={cellStyle}>
  240. {renderDownloadLink(indHref, buildAria(r.id, "forIndUser"))}
  241. </td>
  242. </tr>
  243. );
  244. })}
  245. </tbody>
  246. </table>
  247. <p style={{ marginTop: 12 }}>
  248. <FormattedMessage id="userGuidePubNote" />
  249. </p>
  250. </div>
  251. </Grid>
  252. </Grid>
  253. </Grid>
  254. );
  255. };
  256. export default UserMenuPub1;