@@ -12,17 +12,15 @@ import {
12
12
Icon ,
13
13
} from "@chakra-ui/react"
14
14
15
- import { trackCustomEvent } from "../../utils/matomo"
16
- import { ButtonLink } from "../Buttons"
17
- import InlineLink from "../Link"
18
- import OldHeading from "../OldHeading"
19
- import Text from "../OldText"
20
- import Translation from "../Translation"
15
+ import type { CommunityEvent } from "@/lib/interfaces"
21
16
22
- import {
23
- type Event as EventType ,
24
- useCommunityEvents ,
25
- } from "./useCommunityEvents"
17
+ import { ButtonLink } from "@/components/Buttons"
18
+ import InlineLink from "@/components/Link"
19
+ import OldHeading from "@/components/OldHeading"
20
+ import Text from "@/components/OldText"
21
+ import Translation from "@/components/Translation"
22
+
23
+ import { trackCustomEvent } from "@/lib/utils/matomo"
26
24
27
25
const matomoEvent = ( buttonType : string ) => {
28
26
trackCustomEvent ( {
@@ -48,7 +46,7 @@ const renderEventDateTime = (
48
46
}
49
47
50
48
interface EventProps {
51
- event : EventType
49
+ event : CommunityEvent
52
50
language : string
53
51
type : "upcoming" | "past"
54
52
}
@@ -77,11 +75,17 @@ const Event = ({ event, language, type }: EventProps) => {
77
75
)
78
76
}
79
77
80
- const CommunityEvents = ( ) => {
78
+ type CommunityEventsProps = {
79
+ events : {
80
+ pastEventData : CommunityEvent [ ]
81
+ upcomingEventData : CommunityEvent [ ]
82
+ }
83
+ }
84
+
85
+ const CommunityEvents = ( { events } : CommunityEventsProps ) => {
81
86
const { locale } = useRouter ( )
82
87
const { t } = useTranslation ( "page-index" )
83
- const { pastEventData, upcomingEventData, loading, hasError } =
84
- useCommunityEvents ( )
88
+ const { pastEventData, upcomingEventData } = events
85
89
86
90
return (
87
91
< Flex
@@ -96,13 +100,13 @@ const CommunityEvents = () => {
96
100
< Center w = { { base : "100%" , lg : "40%" } } >
97
101
< Box pe = { 8 } ps = { { base : 8 , lg : 0 } } >
98
102
< OldHeading >
99
- < Translation id = " community-events-content-heading" />
103
+ { t ( "page-index: community-events-content-heading") }
100
104
</ OldHeading >
101
105
< Text >
102
- < Translation id = "community-events-content-1" />
106
+ < Translation id = "page-index: community-events-content-1" />
103
107
</ Text >
104
108
< Text >
105
- < Translation id = " community-events-content-2" />
109
+ { t ( "page-index: community-events-content-2") }
106
110
</ Text >
107
111
</ Box >
108
112
</ Center >
@@ -118,54 +122,44 @@ const CommunityEvents = () => {
118
122
textAlign = "center"
119
123
flexDir = "column"
120
124
>
121
- { loading ? (
122
- < Text >
123
- < Translation id = "loading" />
124
- </ Text >
125
- ) : (
126
- < Flex direction = "column" h = "full" gap = { 8 } >
127
- { hasError ? (
128
- < Text color = "error.base" >
129
- < Translation id = "loading-error-try-again-later" />
125
+ < Flex direction = "column" h = "full" gap = { 8 } >
126
+ { upcomingEventData . length ? (
127
+ < Box flex = { 1 } >
128
+ < Text fontSize = "3xl" fontWeight = "bold" lineHeight = { 1.4 } >
129
+ { upcomingEventData [ 0 ] . title }
130
130
</ Text >
131
- ) : upcomingEventData . length ? (
132
- < Box flex = { 1 } >
133
- < Text fontSize = "3xl" fontWeight = "bold" lineHeight = { 1.4 } >
134
- { upcomingEventData [ 0 ] . title }
135
- </ Text >
136
- < Text m = { 0 } fontSize = "xl" >
137
- { renderEventDateTime ( upcomingEventData [ 0 ] . date , locale ! ) }
138
- </ Text >
139
- < Text color = "body.medium" fontSize = "md" >
140
- ({ Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone } )
141
- </ Text >
142
- </ Box >
143
- ) : (
144
- < Text fontSize = "3xl" fontWeight = "bold" mb = { 8 } >
145
- < Translation id = "community-events-no-events-planned" />
131
+ < Text m = { 0 } fontSize = "xl" >
132
+ { renderEventDateTime ( upcomingEventData [ 0 ] . date , locale ! ) }
146
133
</ Text >
147
- ) }
148
- < Flex flexDirection = "column" gap = { 2 } >
149
- < ButtonLink
150
- to = "/discord/"
151
- gap = { 2 }
152
- onClick = { ( ) => matomoEvent ( "discord" ) }
134
+ < Text color = "body.medium" fontSize = "md" >
135
+ ({ Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone } )
136
+ </ Text >
137
+ </ Box >
138
+ ) : (
139
+ < Text fontSize = "3xl" fontWeight = "bold" mb = { 8 } >
140
+ { t ( "page-index:community-events-no-events-planned" ) }
141
+ </ Text >
142
+ ) }
143
+ < Flex flexDirection = "column" gap = { 2 } >
144
+ < ButtonLink
145
+ to = "/discord/"
146
+ gap = { 2 }
147
+ onClick = { ( ) => matomoEvent ( "discord" ) }
148
+ >
149
+ < Icon as = { FaDiscord } fontSize = { 25 } />
150
+ Join Discord
151
+ </ ButtonLink >
152
+ { upcomingEventData [ 0 ] && (
153
+ < InlineLink
154
+ to = { upcomingEventData [ 0 ] . calendarLink }
155
+ onClick = { ( ) => matomoEvent ( "Add to calendar" ) }
156
+ fontWeight = { 700 }
153
157
>
154
- < Icon as = { FaDiscord } fontSize = { 25 } />
155
- Join Discord
156
- </ ButtonLink >
157
- { upcomingEventData [ 0 ] && (
158
- < InlineLink
159
- to = { upcomingEventData [ 0 ] . calendarLink }
160
- onClick = { ( ) => matomoEvent ( "Add to calendar" ) }
161
- fontWeight = { 700 }
162
- >
163
- { t ( "community-events-add-to-calendar" ) }
164
- </ InlineLink >
165
- ) }
166
- </ Flex >
158
+ { t ( "community-events-add-to-calendar" ) }
159
+ </ InlineLink >
160
+ ) }
167
161
</ Flex >
168
- ) }
162
+ </ Flex >
169
163
</ Flex >
170
164
< Flex
171
165
w = { { base : "100%" , lg : "50%" } }
@@ -174,54 +168,38 @@ const CommunityEvents = () => {
174
168
flexDir = "column"
175
169
>
176
170
< Text fontSize = "lg" fontWeight = "bold" mb = { 2 } >
177
- < Translation id = " community-events-upcoming-calls" />
171
+ { t ( "page-index: community-events-upcoming-calls") }
178
172
</ Text >
179
173
< Divider mb = { 4 } />
180
- { loading ? (
181
- < Text >
182
- < Translation id = "loading" />
183
- </ Text >
184
- ) : hasError ? (
185
- < Text color = "error.base" >
186
- < Translation id = "loading-error-try-again-later" />
187
- </ Text >
188
- ) : upcomingEventData . slice ( 1 ) . length ? (
174
+ { upcomingEventData . slice ( 1 ) . length ? (
189
175
upcomingEventData . slice ( 1 ) . map ( ( item , idx ) => {
190
176
return (
191
177
< Event
192
178
key = { idx }
193
179
event = { item }
194
- language = { language }
180
+ language = { locale ! }
195
181
type = "upcoming"
196
182
/>
197
183
)
198
184
} )
199
185
) : (
200
186
< Text mx = "auto" >
201
- < Translation id = " community-events-no-upcoming-calls" />
187
+ { t ( "page-index: community-events-no-upcoming-calls") }
202
188
</ Text >
203
189
) }
204
190
< Text fontSize = "lg" fontWeight = "bold" mb = { 2 } mt = { 4 } >
205
- < Translation id = " community-events-previous-calls" />
191
+ { t ( "page-index: community-events-previous-calls") }
206
192
</ Text >
207
193
< Divider mb = { 4 } />
208
- { loading ? (
209
- < Text >
210
- < Translation id = "loading" />
211
- </ Text >
212
- ) : hasError ? (
213
- < Text color = "error.base" >
214
- < Translation id = "loading-error-try-again-later" />
215
- </ Text >
216
- ) : pastEventData . length ? (
194
+ { pastEventData . length ? (
217
195
pastEventData . map ( ( item , idx ) => {
218
196
return (
219
- < Event key = { idx } event = { item } language = { language } type = "past" />
197
+ < Event key = { idx } event = { item } language = { locale ! } type = "past" />
220
198
)
221
199
} )
222
200
) : (
223
201
< Text mx = "auto" >
224
- < Translation id = " community-events-there-are-no-past-calls" />
202
+ { t ( "page-index: community-events-there-are-no-past-calls") }
225
203
</ Text >
226
204
) }
227
205
</ Flex >
0 commit comments