Skip to content

Commit

Permalink
refactor(events): update event organizer to use api host data (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert27 authored Nov 25, 2024
1 parent 60b685a commit 8440f7b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 118 deletions.
8 changes: 5 additions & 3 deletions rogue-thi-app/components/cards/EventsCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ export default function EventsCard() {
{calendar.slice(0, 2).map((x, i) => (
<ListGroup.Item key={i}>
<div>{x.title}</div>
<div className="text-muted">
{t('events.organizer.attribute')} {x.organizer}
</div>
{x.host?.name && (
<div className="text-muted">
{t('events.organizer.attribute')} {x.host.name}
</div>
)}
</ListGroup.Item>
))}
</ListGroup>
Expand Down
92 changes: 0 additions & 92 deletions rogue-thi-app/data/clubs.json

This file was deleted.

7 changes: 5 additions & 2 deletions rogue-thi-app/lib/backend/neuland-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,11 @@ class NeulandAPIClient {
gql`
query {
clEvents {
id
organizer
host {
name
website
instagram
}
title
location
begin
Expand Down
40 changes: 19 additions & 21 deletions rogue-thi-app/pages/events.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import SwipeableTabs, { SwipeableTab } from '../components/SwipeableTabs'
import Button from 'react-bootstrap/Button'
import Link from 'next/link'
import Modal from 'react-bootstrap/Modal'
import clubs from '../data/clubs.json'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import { useRouter } from 'next/router'
import { useTranslation } from 'next-i18next'
Expand Down Expand Up @@ -243,9 +242,6 @@ export default function Events({ initialCampusEvents, sportsEvents }) {
)}
{campusLifeEvents &&
campusLifeEvents.map((item, idx) => {
const club = clubs.find(
(club) => club.club === item.organizer
)
return (
<ListGroup.Item
key={idx}
Expand All @@ -265,29 +261,31 @@ export default function Events({ initialCampusEvents, sportsEvents }) {
)}
<div className={styles.details}>
<span className={styles.eventDetails}>
{club != null && (
{item.host != null ? (
<>
{club.website != null && (
{item.host.name != null && (
<a
href={club.website}
href={item.host.website}
className={styles.eventUrl}
target="_blank"
rel="noreferrer"
>
<Users size={16} />
{` ${club.club} `}
{` ${item.host.name} `}
</a>
)}
</>
)}
{club == null && (
<>
<Users
size={16}
className={styles.icon}
/>
{item.organizer}
</>
) : (
item.host &&
item.host.name != null && (
<>
<Users
size={16}
className={styles.icon}
/>
{item.host.name}
</>
)
)}
</span>

Expand Down Expand Up @@ -326,19 +324,19 @@ export default function Events({ initialCampusEvents, sportsEvents }) {

<span style={{ flex: 1 }}></span>
<span className={styles.socials}>
{club != null && club.website != null && (
{item.host != null && item.host.website != null && (
<a
href={club.website}
href={item.host.website}
className={styles.eventUrl}
target="_blank"
rel="noreferrer"
>
<Globe size={20} />
</a>
)}
{club != null && club.instagram != null && (
{item.host != null && item.host.instagram != null && (
<a
href={club.instagram}
href={item.host.instagram}
className={styles.eventUrl}
target="_blank"
rel="noreferrer"
Expand Down

0 comments on commit 8440f7b

Please sign in to comment.