@@ -5,24 +5,14 @@ import Translation from "@/components/Translation"
5
5
6
6
import { trackCustomEvent } from "@/lib/utils/matomo"
7
7
8
- import events from "../data/community-events.json "
8
+ import CommunityEvents , { CommunityEvent } from "../data/community-events"
9
9
10
10
import { Button } from "./Buttons"
11
11
import EventCard from "./EventCard"
12
12
import InfoBanner from "./InfoBanner"
13
13
import InlineLink from "./Link"
14
14
15
- interface ICommunityEventData {
16
- title : string
17
- to : string
18
- sponsor : string | null
19
- location : string
20
- description : string
21
- startDate : string
22
- endDate : string
23
- }
24
-
25
- interface IOrderedUpcomingEventType extends ICommunityEventData {
15
+ interface IOrderedUpcomingEventType extends CommunityEvent {
26
16
date : string
27
17
formattedDetails : string
28
18
}
@@ -33,7 +23,6 @@ const UpcomingEventsList: React.FC = () => {
33
23
Array < IOrderedUpcomingEventType >
34
24
> ( [ ] )
35
25
const [ maxRange , setMaxRange ] = useState < number > ( eventsPerLoad )
36
- const [ isVisible , setIsVisible ] = useState < boolean > ( true )
37
26
38
27
// Create Date object from each YYYY-MM-DD JSON date string
39
28
const dateParse = ( dateString : string ) : Date => {
@@ -46,7 +35,7 @@ const UpcomingEventsList: React.FC = () => {
46
35
}
47
36
48
37
useEffect ( ( ) => {
49
- const eventsList : Array < ICommunityEventData > = [ ...events ]
38
+ const eventsList : CommunityEvent [ ] = [ ...CommunityEvents ]
50
39
const yesterday = new Date ( )
51
40
yesterday . setDate ( yesterday . getDate ( ) - 1 )
52
41
@@ -70,9 +59,7 @@ const UpcomingEventsList: React.FC = () => {
70
59
event . endDate
71
60
) . toLocaleDateString ( ) } `
72
61
73
- const details = `${ event . sponsor ? "(" + event . sponsor + ")" : "" } ${
74
- event . description
75
- } `
62
+ const details = `${ event . description } `
76
63
77
64
return {
78
65
...event ,
@@ -86,7 +73,6 @@ const UpcomingEventsList: React.FC = () => {
86
73
87
74
const loadMoreEvents = ( ) => {
88
75
setMaxRange ( ( counter ) => counter + eventsPerLoad )
89
- setIsVisible ( maxRange + eventsPerLoad <= orderedUpcomingEvents . length )
90
76
trackCustomEvent ( {
91
77
eventCategory : "more events button" ,
92
78
eventAction : "click" ,
@@ -151,7 +137,7 @@ const UpcomingEventsList: React.FC = () => {
151
137
maxWidth = "620px"
152
138
marginTop = "5"
153
139
>
154
- { isVisible && (
140
+ { maxRange <= orderedUpcomingEvents . length && (
155
141
< Button onClick = { loadMoreEvents } >
156
142
< Translation id = "page-community:page-community-upcoming-events-load-more" />
157
143
</ Button >
0 commit comments