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.
 
 

207 line
7.9 KiB

  1. // material-ui
  2. import {
  3. Dialog, DialogTitle, DialogContent,
  4. Link, Button, Card, Box, Grid
  5. } from '@mui/material';
  6. import Typography from '@mui/material/Typography';
  7. import iAmSmartICon from 'assets/images/icons/icon_iAmSmart.png';
  8. import banner from 'assets/images/bg_ml.jpg';
  9. import { Stack } from '../../../node_modules/@mui/material/index';
  10. import { iAmSmartPath, clientId, getBowserType, isAppBowser, iAmSmartCallbackPath} from 'auth/utils'
  11. import * as React from 'react';
  12. import {FormattedMessage, useIntl} from "react-intl";
  13. // ================================|| LOGIN ||================================ //
  14. const RegisterCustom = () => {
  15. const [isPopUp, setIsPopUp] = React.useState(false);
  16. const intl = useIntl();
  17. const { locale } = intl;
  18. const registerWithIAmSmart = () => {
  19. setIsPopUp(true);
  20. }
  21. const getQRWithIAmSmart = () => {
  22. if ((isAppBowser())) {
  23. openApp();
  24. } else {
  25. openQR();
  26. }
  27. }
  28. const openQR =()=>{
  29. let callbackUrl = "https://"+iAmSmartCallbackPath()+"/iamsmart/registrycallback";
  30. let url = iAmSmartPath + "/api/v1/auth/getQR"
  31. + "?clientID=" + clientId
  32. + "&responseType=code"
  33. +"&source=" + getBowserType()
  34. +"&redirectURI="+encodeURIComponent(callbackUrl)
  35. +"&scope="+encodeURIComponent("eidapi_auth eidapi_profiles")
  36. +"&lang="+(locale === 'en' ?"en-US":locale === 'zh-HK' ?"zh-HK":"zh-CN")
  37. //+"&state="
  38. +"&brokerPage=false"
  39. window.location.assign(url);
  40. }
  41. const openApp = () => {
  42. let callbackUrl = "https://"+iAmSmartCallbackPath()+"/iamsmart/registrycallback";
  43. let url = iAmSmartPath + "/api/v1/auth/getQR"
  44. + "?clientID=" + clientId
  45. + "&responseType=code"
  46. +"&source=" + getBowserType()
  47. +"&redirectURI="+encodeURIComponent(callbackUrl)
  48. +"&scope="+encodeURIComponent("eidapi_auth eidapi_profiles")
  49. +"&lang="+(locale === 'en' ?"en-US":locale === 'zh-HK' ?"zh-HK":"zh-CN")
  50. //+"&state="
  51. +"&brokerPage=true"
  52. window.location.assign(url);
  53. }
  54. return (
  55. <Stack justifyContent="center" sx={{ minHeight: '100vh', bgcolor: 'backgroundColor.default' }}>
  56. <img src={banner} alt="banner" width="100%" height="200px" />
  57. <center>
  58. <Card
  59. sx={{
  60. maxWidth: { xs: 1, lg: 1000 },
  61. margin: { xs: 2.5, md: 3 },
  62. '& > *': {
  63. flexGrow: 1,
  64. flexBasis: '50%'
  65. },
  66. backgroundColor: "secondary"
  67. }}
  68. >
  69. <Box alignItems="center">
  70. <Grid container>
  71. <Grid item xs={12} md={12}>
  72. <Typography mt={4} variant="h3">
  73. <FormattedMessage id="registerTitle1"/>
  74. <strong style={{ color: '#FF5733' }}>
  75. {" " + intl.formatMessage({id: 'registerTitle2'}) + " "}
  76. </strong>
  77. <FormattedMessage id="registerTitle3"/>
  78. </Typography>
  79. <Typography variant="body1">
  80. {intl.formatMessage({id: 'registerSubTitle'})}
  81. </Typography>
  82. </Grid>
  83. </Grid>
  84. <Box mt={3} mb={3}>
  85. <Grid container >
  86. <Grid item xs={12} md={6} sx={{ borderRight: 1, borderColor: 'grey.500' }}>
  87. <Typography mb={4} variant="h3">
  88. <FormattedMessage id="personalUser"/>
  89. </Typography>
  90. <Button variant="outlined" color="iAmSmart" sx={{textTransform: 'none'}} onClick={registerWithIAmSmart} startIcon={<img src={iAmSmartICon} alt="iAM Smart" width="30" />}>
  91. <Typography variant="h5">
  92. <FormattedMessage id="continueWithIAmSmart"/>
  93. </Typography>
  94. </Button>
  95. <Box mt={4} ml={2} mr={2} bgcolor="grey.100" p={1.5} >
  96. <Typography textAlign='justify' variant="body1" display="block" gutterBottom>
  97. <div dangerouslySetInnerHTML={{ __html: intl.formatMessage({id: 'MSG.registerIAmSmart'}) }} />
  98. </Typography>
  99. <Link href="https://www.iamsmart.gov.hk/tc/">
  100. <FormattedMessage id="learnMore"/>
  101. </Link>
  102. </Box>
  103. <Typography m={5}>
  104. <FormattedMessage id="or"/>
  105. </Typography>
  106. <Button href="/registerFrom" variant="contained"><Typography variant="h5">
  107. <FormattedMessage id="registerNewPersonalUser"/>
  108. </Typography></Button>
  109. <Typography ml={4} mr={4} mt={4} variant="body1" display="block" sx={{ fontWeight: 'bold' }} gutterBottom>
  110. <div dangerouslySetInnerHTML={{ __html: intl.formatMessage({id: 'MSG.registerPersonal'}) }} />
  111. </Typography>
  112. </Grid>
  113. <Grid item xs={12} md={6} sx={{ borderLeft: 1, borderColor: 'grey.500' }}>
  114. <Typography mb={4} variant="h3">
  115. <FormattedMessage id="businessUser"/>
  116. </Typography>
  117. <Button href="/registerFromOrganization" variant="contained" sx={{ mt: 0.5 }}><Typography variant="h5">
  118. <FormattedMessage id="registerNewBusinessUser"/>
  119. </Typography></Button>
  120. <Typography ml={4} mr={4} mt={4} variant="body1" display="block" sx={{ fontWeight: 'bold' }} gutterBottom>
  121. <div dangerouslySetInnerHTML={{ __html: intl.formatMessage({id: 'MSG.registerOrg'}) }} />
  122. </Typography>
  123. </Grid>
  124. </Grid>
  125. </Box>
  126. </Box>
  127. </Card >
  128. </center>
  129. <Dialog
  130. open={isPopUp}
  131. onClose={() => setIsPopUp(false)}
  132. PaperProps={{
  133. sx: {
  134. minWidth: '40vw',
  135. maxWidth: { xs: '90vw', s: '90vw', m: '70vw', lg: '70vw' },
  136. maxHeight: { xs: '90vh', s: '70vh', m: '70vh', lg: '60vh' }
  137. }
  138. }}
  139. >
  140. <DialogTitle></DialogTitle>
  141. <DialogContent>
  142. <Typography variant="h3" >
  143. <FormattedMessage id="authorizeIAmSmartForInfo"/>
  144. </Typography>
  145. <Typography variant="h5" style={{ padding: '4px' }}>
  146. <FormattedMessage id="iAmSmartSubTitle"/>
  147. </Typography>
  148. </DialogContent>
  149. <DialogContent >
  150. <Grid container style={{ paddingLeft: '16px' }}>
  151. <Grid item xs={6} >
  152. <Typography style={{ padding: '4px' }}>
  153. {"- " + intl.formatMessage({id: 'userChineseName'})}
  154. </Typography>
  155. <Typography style={{ padding: '4px' }}>
  156. {"- " + intl.formatMessage({id: 'userEnglishName'})}
  157. </Typography>
  158. <Typography style={{ padding: '4px' }}>
  159. {"- " + intl.formatMessage({id: 'userIDNo'})}
  160. </Typography>
  161. </Grid>
  162. <Grid item xs={6} >
  163. <Typography style={{ padding: '4px' }}>
  164. {"- " + intl.formatMessage({id: 'userEmailAddress'})}
  165. </Typography>
  166. <Typography style={{ padding: '4px' }}>
  167. {"- " + intl.formatMessage({id: 'userPhoneNumber'})}
  168. </Typography>
  169. <Typography style={{ padding: '4px' }}>
  170. {"- " + intl.formatMessage({id: 'userAddress'})}
  171. </Typography>
  172. </Grid>
  173. </Grid>
  174. </DialogContent>
  175. <DialogContent align="right">
  176. <Button variant="outlined" onClick={getQRWithIAmSmart} startIcon={<img src={iAmSmartICon} alt="iAM Smart" width="30" />}><Typography variant="h5">
  177. <FormattedMessage id="iAmSmartAutoFillIn"/>
  178. </Typography></Button>
  179. <br/>
  180. <Link href="https://www.iamsmart.gov.hk/tc/">
  181. <FormattedMessage id="learnMore"/>
  182. </Link>
  183. </DialogContent>
  184. </Dialog>
  185. </Stack>
  186. );
  187. };
  188. export default RegisterCustom;