2
2
3
3
import Sidebar from './_components/sidebar' ;
4
4
import { GlobalStoreProvider } from '@/src/providers/global-store-provider' ;
5
- import { buttonVariants } from '@/src/components/shadcn-ui/button' ;
5
+ import { Button } from '@/src/components/shadcn-ui/button' ;
6
6
import { SpinnerGap } from '@phosphor-icons/react' ;
7
7
import Link from 'next/link' ;
8
8
import { platform } from '@/src/lib/trpc' ;
@@ -18,7 +18,10 @@ export default function Layout({
18
18
data : storeData ,
19
19
isLoading : storeDataLoading ,
20
20
error : storeError
21
- } = platform . org . store . getStoreData . useQuery ( { orgShortcode } ) ;
21
+ } = platform . org . store . getStoreData . useQuery (
22
+ { orgShortcode } ,
23
+ { retry : 3 , retryDelay : ( attemptIndex ) => attemptIndex * 5000 }
24
+ ) ;
22
25
23
26
const { data : hasEmailIdentity } =
24
27
platform . org . mail . emailIdentities . userHasEmailIdentities . useQuery ( {
@@ -29,28 +32,39 @@ export default function Layout({
29
32
return (
30
33
< div className = "flex h-full w-full flex-col items-center justify-center gap-2" >
31
34
< SpinnerGap className = "text-base-11 h-20 w-20 animate-spin" />
35
+ < span className = "text-slate-11 font-bold" >
36
+ < span className = "font-display text-slate-12 text-bold" > UnInbox</ span > { ' ' }
37
+ is Loading...
38
+ </ span >
32
39
</ div >
33
40
) ;
34
41
}
35
42
36
- if ( storeError && ! storeDataLoading ) {
43
+ if ( storeError ) {
37
44
return (
38
45
< div className = "flex h-full w-full flex-col items-center justify-center gap-2" >
39
46
< h1 className = "text-red-11 text-2xl font-bold" > An Error Occurred!</ h1 >
40
47
< span className = "text-red-11 whitespace-pre font-mono text-xl" >
41
48
{ storeError . message }
42
49
</ span >
43
-
44
- < Link
45
- className = { buttonVariants ( { variant : 'outline' } ) }
46
- href = "/" >
47
- Go Back Home
48
- </ Link >
50
+ < div className = "flex gap-2" >
51
+ < Button
52
+ variant = "outline"
53
+ className = "flex-1"
54
+ asChild >
55
+ < Link href = "/" > Go Back</ Link >
56
+ </ Button >
57
+ < Button
58
+ className = "flex-1"
59
+ onClick = { ( ) => window . location . reload ( ) } >
60
+ Retry
61
+ </ Button >
62
+ </ div >
49
63
</ div >
50
64
) ;
51
65
}
52
66
53
- if ( ! storeDataLoading && ! storeData ?. currentOrg ) {
67
+ if ( ! storeData ?. currentOrg ) {
54
68
return (
55
69
< div className = "flex h-full w-full flex-col items-center justify-center gap-2" >
56
70
< h1 className = "text-red-11 text-2xl font-bold" > Invalid Org</ h1 >
@@ -61,32 +75,30 @@ export default function Layout({
61
75
does not exists or you are not part of that org!
62
76
</ span >
63
77
64
- < Link
65
- className = { buttonVariants ( { variant : 'outline' } ) }
66
- href = "/" >
67
- Go Back Home
68
- </ Link >
78
+ < Button
79
+ variant = "outline"
80
+ className = "flex-1"
81
+ asChild >
82
+ < Link href = "/" > Go Back</ Link >
83
+ </ Button >
69
84
</ div >
70
85
) ;
71
86
}
72
87
73
- if ( storeData ) {
74
- return (
75
- < GlobalStoreProvider initialState = { storeData } >
76
- < div className = "bg-base-1 max-w-svh flex h-full max-h-svh w-full flex-row gap-0 overflow-hidden p-0" >
77
- < div className = "h-full max-h-full w-fit" >
78
- < Sidebar />
79
- </ div >
80
- < div className = "flex h-full w-full flex-row p-0" >
81
- < RealtimeProvider > { children } </ RealtimeProvider >
82
- </ div >
83
-
84
- < NewConvoSheet />
85
- { hasEmailIdentity && ! hasEmailIdentity . hasIdentity && (
86
- < ClaimEmailIdentity />
87
- ) }
88
+ return (
89
+ < GlobalStoreProvider initialState = { storeData } >
90
+ < div className = "bg-base-1 max-w-svh flex h-full max-h-svh w-full flex-row gap-0 overflow-hidden p-0" >
91
+ < div className = "h-full max-h-full w-fit" >
92
+ < Sidebar />
88
93
</ div >
89
- </ GlobalStoreProvider >
90
- ) ;
91
- }
94
+ < div className = "flex h-full w-full flex-row p-0" >
95
+ < RealtimeProvider > { children } </ RealtimeProvider >
96
+ </ div >
97
+ < NewConvoSheet />
98
+ { hasEmailIdentity && ! hasEmailIdentity . hasIdentity && (
99
+ < ClaimEmailIdentity />
100
+ ) }
101
+ </ div >
102
+ </ GlobalStoreProvider >
103
+ ) ;
92
104
}
0 commit comments