|
| 1 | +import { Box, Button } from '@rocket.chat/fuselage'; |
| 2 | +import colors from '@rocket.chat/fuselage-tokens/colors.json'; |
| 3 | +import type { ReactElement } from 'react'; |
| 4 | +import { Trans, useTranslation } from 'react-i18next'; |
| 5 | + |
| 6 | +import BackgroundLayer from '../../common/BackgroundLayer'; |
| 7 | +import { OnboardingLogo } from '../../common/OnboardingLogo'; |
| 8 | + |
| 9 | +type OauthAuthorizationPageProps = { |
| 10 | + clientName?: string; |
| 11 | + onClickAuthorizeOAuth: () => void; |
| 12 | + error: { |
| 13 | + message?: string; |
| 14 | + onGoBack?: () => void; |
| 15 | + }; |
| 16 | +}; |
| 17 | + |
| 18 | +const OauthAuthorizationPage = ({ |
| 19 | + clientName, |
| 20 | + onClickAuthorizeOAuth, |
| 21 | + error, |
| 22 | +}: OauthAuthorizationPageProps): ReactElement => { |
| 23 | + const { t } = useTranslation(); |
| 24 | + |
| 25 | + const name = clientName || '...loading...'; |
| 26 | + |
| 27 | + return ( |
| 28 | + <BackgroundLayer> |
| 29 | + <Box |
| 30 | + display='flex' |
| 31 | + flexDirection='column' |
| 32 | + alignItems='center' |
| 33 | + textAlign='center' |
| 34 | + width='100%' |
| 35 | + maxWidth={576} |
| 36 | + paddingBlock={32} |
| 37 | + paddingInline={16} |
| 38 | + > |
| 39 | + <OnboardingLogo /> |
| 40 | + <Box |
| 41 | + fontWeight={500} |
| 42 | + width='100%' |
| 43 | + mbs='x24' |
| 44 | + mbe='x36' |
| 45 | + fontSize='x57' |
| 46 | + lineHeight='x62' |
| 47 | + fontFamily='sans' |
| 48 | + > |
| 49 | + {t('page.oauthAuthorizationPage.title')} |
| 50 | + </Box> |
| 51 | + <Box width='full' backgroundColor='white'> |
| 52 | + <Box fontScale='p1' p='x40' textAlign='start' color={colors.n900}> |
| 53 | + {error.message ? ( |
| 54 | + <> |
| 55 | + <Box fontScale='h1' mbe='x18'> |
| 56 | + Error |
| 57 | + </Box> |
| 58 | + {error.message} |
| 59 | + <Box mbs='x24'> |
| 60 | + <Button onClick={error.onGoBack} primary> |
| 61 | + {t('page.oauthAuthorizationPage.buttons.goBack')} |
| 62 | + </Button> |
| 63 | + </Box> |
| 64 | + </> |
| 65 | + ) : ( |
| 66 | + <> |
| 67 | + <Trans |
| 68 | + i18nKey='page.oauthAuthorizationPage.allowLogin' |
| 69 | + name={name} |
| 70 | + > |
| 71 | + Do you wish to allow |
| 72 | + <strong>{{ name }}</strong> |
| 73 | + to login with your Rocket.Chat Cloud Account? |
| 74 | + </Trans> |
| 75 | + |
| 76 | + <Box mbs='x24'> |
| 77 | + <Button onClick={onClickAuthorizeOAuth} primary> |
| 78 | + {t('page.oauthAuthorizationPage.buttons.authorize')} |
| 79 | + </Button> |
| 80 | + </Box> |
| 81 | + </> |
| 82 | + )} |
| 83 | + </Box> |
| 84 | + </Box> |
| 85 | + </Box> |
| 86 | + </BackgroundLayer> |
| 87 | + ); |
| 88 | +}; |
| 89 | + |
| 90 | +export default OauthAuthorizationPage; |
0 commit comments