Commit be2c9bd 1 parent fc7974e commit be2c9bd Copy full SHA for be2c9bd
File tree 5 files changed +113
-0
lines changed
5 files changed +113
-0
lines changed Original file line number Diff line number Diff line change 113
113
"sla" : " SLA: Premium" ,
114
114
"push" : " Unlimited push notifications" ,
115
115
"engagement" : " Engagement Dashboard"
116
+ },
117
+ "redirect" : {
118
+ "subtitle" : " Redirecting in {{seconds}} seconds" ,
119
+ "redirectNotWorking" : " Redirect not working? <1>Open workspace</1>"
116
120
}
117
121
},
118
122
"form" : {
Original file line number Diff line number Diff line change
1
+ import ReactDOM from 'react-dom' ;
2
+
3
+ import RedirectPage from './RedirectPage' ;
4
+
5
+ const onRedirect = jest . fn ( ) ;
6
+
7
+ it ( 'renders without crashing' , ( ) => {
8
+ const div = document . createElement ( 'div' ) ;
9
+ ReactDOM . render (
10
+ < RedirectPage title = 'Ready' countDownSeconds = { 5 } onRedirect = { onRedirect } /> ,
11
+ div
12
+ ) ;
13
+ ReactDOM . unmountComponentAtNode ( div ) ;
14
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { action } from '@storybook/addon-actions' ;
2
+ import type { Story , Meta } from '@storybook/react' ;
3
+ import type { ComponentProps } from 'react' ;
4
+
5
+ import RedirectPage from './RedirectPage' ;
6
+
7
+ type Args = ComponentProps < typeof RedirectPage > ;
8
+
9
+ export default {
10
+ title : 'pages/RedirectPage' ,
11
+ component : RedirectPage ,
12
+ parameters : {
13
+ actions : { argTypesRegex : '^on.*' } ,
14
+ layout : 'fullscreen' ,
15
+ } ,
16
+ args : {
17
+ title : 'Kapai workspace is ready! 🚀' ,
18
+ countDownSeconds : 5 ,
19
+ onRedirect : action ( 'onRedirect' ) ,
20
+ } ,
21
+ } as Meta < Args > ;
22
+
23
+ export const _RedirectPage : Story < Args > = ( args ) => < RedirectPage { ...args } /> ;
24
+ _RedirectPage . storyName = 'RedirectPage' ;
Original file line number Diff line number Diff line change
1
+ import { Box , Margins } from '@rocket.chat/fuselage' ;
2
+ import type { ReactElement } from 'react' ;
3
+ import { useEffect , useState } from 'react' ;
4
+ import { useTranslation , Trans } from 'react-i18next' ;
5
+
6
+ import ActionLink from '../../common/ActionLink' ;
7
+ import BackgroundLayer from '../../common/BackgroundLayer' ;
8
+ import { OnboardingLogo } from '../../common/OnboardingLogo' ;
9
+
10
+ type RedirectPageProps = {
11
+ title : string ;
12
+ countDownSeconds : number ;
13
+ onRedirect : ( ) => void ;
14
+ } ;
15
+
16
+ const RedirectPage = ( {
17
+ title,
18
+ countDownSeconds,
19
+ onRedirect,
20
+ } : RedirectPageProps ) : ReactElement => {
21
+ const { t } = useTranslation ( ) ;
22
+
23
+ const [ seconds , setSeconds ] = useState ( countDownSeconds ) ;
24
+
25
+ const countDown = ( ) => {
26
+ setInterval ( ( ) => {
27
+ setSeconds ( ( prev ) => ( prev === 0 ? 0 : prev - 1 ) ) ;
28
+ } , 1000 ) ;
29
+ } ;
30
+
31
+ useEffect ( ( ) => {
32
+ countDown ( ) ;
33
+ } , [ ] ) ;
34
+
35
+ useEffect ( ( ) => {
36
+ if ( seconds === 0 ) onRedirect ( ) ;
37
+ } , [ seconds ] ) ;
38
+
39
+ return (
40
+ < BackgroundLayer >
41
+ < Box
42
+ display = 'flex'
43
+ flexDirection = 'column'
44
+ alignItems = 'center'
45
+ textAlign = 'center'
46
+ width = '100%'
47
+ maxWidth = { 768 }
48
+ paddingBlock = { 32 }
49
+ paddingInline = { 16 }
50
+ >
51
+ < Margins blockEnd = { 32 } >
52
+ < OnboardingLogo />
53
+
54
+ < Box fontScale = 'hero' > { title } </ Box >
55
+
56
+ < Box fontScale = 'p1b' > { t ( 'page.redirect.subtitle' , { seconds } ) } </ Box >
57
+
58
+ < Box fontScale = 'c1' >
59
+ < Trans i18nKey = 'page.redirect.redirectNotWorking' >
60
+ Redirect not working?
61
+ < ActionLink onClick = { onRedirect } > Open workspace</ ActionLink >
62
+ </ Trans >
63
+ </ Box >
64
+ </ Margins >
65
+ </ Box >
66
+ </ BackgroundLayer >
67
+ ) ;
68
+ } ;
69
+
70
+ export default RedirectPage ;
Original file line number Diff line number Diff line change
1
+ export { default } from './RedirectPage' ;
You can’t perform that action at this time.
0 commit comments