Skip to content

Commit d4290f9

Browse files
authored
Merge pull request #12000 from ethereum/add2024Events
Add 2024 community events and refactor to typescript
2 parents fa6b431 + bcd8c14 commit d4290f9

File tree

4 files changed

+422
-419
lines changed

4 files changed

+422
-419
lines changed

src/components/UpcomingEventsList.tsx

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,30 @@
11
import { useEffect, useState } from "react"
2+
import { useTranslation } from "next-i18next"
23
import { Box } from "@chakra-ui/react"
34

4-
import Translation from "@/components/Translation"
5+
import type { CommunityConference } from "@/lib/types"
6+
7+
import { Button } from "@/components/Buttons"
8+
import EventCard from "@/components/EventCard"
9+
import InfoBanner from "@/components/InfoBanner"
10+
import InlineLink from "@/components/Link"
511

612
import { trackCustomEvent } from "@/lib/utils/matomo"
713

8-
import events from "../data/community-events.json"
9-
10-
import { Button } from "./Buttons"
11-
import EventCard from "./EventCard"
12-
import InfoBanner from "./InfoBanner"
13-
import InlineLink from "./Link"
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-
}
14+
import communityConferences from "@/data/community-events"
2415

25-
interface IOrderedUpcomingEventType extends ICommunityEventData {
16+
type OrderedUpcomingEvent = CommunityConference & {
2617
date: string
2718
formattedDetails: string
2819
}
2920

30-
const UpcomingEventsList: React.FC = () => {
21+
const UpcomingEventsList = () => {
22+
const { t } = useTranslation("page-community")
3123
const eventsPerLoad = 10
3224
const [orderedUpcomingEvents, setOrderedUpcomingEvents] = useState<
33-
Array<IOrderedUpcomingEventType>
25+
OrderedUpcomingEvent[]
3426
>([])
3527
const [maxRange, setMaxRange] = useState<number>(eventsPerLoad)
36-
const [isVisible, setIsVisible] = useState<boolean>(true)
3728

3829
// Create Date object from each YYYY-MM-DD JSON date string
3930
const dateParse = (dateString: string): Date => {
@@ -46,7 +37,7 @@ const UpcomingEventsList: React.FC = () => {
4637
}
4738

4839
useEffect(() => {
49-
const eventsList: Array<ICommunityEventData> = [...events]
40+
const eventsList: CommunityConference[] = [...communityConferences]
5041
const yesterday = new Date()
5142
yesterday.setDate(yesterday.getDate() - 1)
5243

@@ -70,9 +61,7 @@ const UpcomingEventsList: React.FC = () => {
7061
event.endDate
7162
).toLocaleDateString()}`
7263

73-
const details = `${event.sponsor ? "(" + event.sponsor + ")" : ""} ${
74-
event.description
75-
}`
64+
const details = `${event.description}`
7665

7766
return {
7867
...event,
@@ -86,7 +75,6 @@ const UpcomingEventsList: React.FC = () => {
8675

8776
const loadMoreEvents = () => {
8877
setMaxRange((counter) => counter + eventsPerLoad)
89-
setIsVisible(maxRange + eventsPerLoad <= orderedUpcomingEvents.length)
9078
trackCustomEvent({
9179
eventCategory: "more events button",
9280
eventAction: "click",
@@ -97,9 +85,9 @@ const UpcomingEventsList: React.FC = () => {
9785
if (orderedUpcomingEvents.length === 0) {
9886
return (
9987
<InfoBanner emoji=":information_source:">
100-
<Translation id="page-community-upcoming-events-no-events" />{" "}
88+
{t("page-community-upcoming-events-no-events")}{" "}
10189
<InlineLink to="https://github.com/ethereum/ethereum-org-website/blob/dev/src/data/community-events.json">
102-
<Translation id="page-community:page-community-please-add-to-page" />
90+
{t("page-community-please-add-to-page")}
10391
</InlineLink>
10492
</InfoBanner>
10593
)
@@ -151,9 +139,9 @@ const UpcomingEventsList: React.FC = () => {
151139
maxWidth="620px"
152140
marginTop="5"
153141
>
154-
{isVisible && (
142+
{maxRange <= orderedUpcomingEvents.length && (
155143
<Button onClick={loadMoreEvents}>
156-
<Translation id="page-community:page-community-upcoming-events-load-more" />
144+
{t("page-community-upcoming-events-load-more")}
157145
</Button>
158146
)}
159147
</Box>

0 commit comments

Comments
 (0)