Skip to content

Commit

Permalink
Replace ical usage in Event listing (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoGresse committed Aug 6, 2020
1 parent 8a0c232 commit de1c2f7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/organisations/org/event/Event.js
Expand Up @@ -8,17 +8,17 @@ import Button from '@material-ui/core/Button'
import AddToCalendar from '@culturehq/add-to-calendar'
import './AddToCalendar.css'

const Event = ({ ical, event }) => {
const Event = ({ event }) => {
const date = new Date(event.startDate)

const exportedEvent = getEventForExport(ical, event)
const exportedEvent = getEventForExport(event)

return (
<>
<Grid item xs={12} sm={8}>
<Box flex={1}>
<Typography variant="h5" style={{ color: 'red' }}>
{ical && ical.name}
{event.icalName}
</Typography>
<Typography variant="h4" style={{ fontFamily: 'Roboto' }}>
{event.title}
Expand Down Expand Up @@ -93,13 +93,13 @@ const Event = ({ ical, event }) => {
)
}

const getEventForExport = (ical, event) => {
const getEventForExport = event => {
const startDate = new Date(event.startDate)
const endDate = new Date(event.endDate)

const data = {
name: `${event.title} - ${ical.name}`,
details: `${event.title} - ${ical.name}`,
name: `${event.title} - ${event.icalName}`,
details: `${event.title} - ${event.icalName}`,
startsAt: startDate.toISOString(),
endsAt: endDate.toISOString(),
}
Expand Down
8 changes: 2 additions & 6 deletions src/organisations/org/event/PassedEvents.js
Expand Up @@ -16,7 +16,7 @@ import Box from '@material-ui/core/Box'
const PassedEvents = ({ token }) => {
const [
{
selectedOrganization: { id, icals, events, eventsLoading },
selectedOrganization: { id, events, eventsLoading },
},
] = useStateValue()

Expand All @@ -40,11 +40,7 @@ const PassedEvents = ({ token }) => {
</Grid>
)}
{passedEvents.map(event => (
<Event
key={event.id}
ical={icals.filter(ical => event.icalId === ical.id)[0]}
event={event}
/>
<Event key={event.id} event={event} />
))}
{passedEvents.length === 0 && (
<Grid item>
Expand Down
8 changes: 2 additions & 6 deletions src/organisations/org/event/UpcomingEvents.js
Expand Up @@ -16,7 +16,7 @@ import CircularProgress from '@material-ui/core/CircularProgress'
const UpcomingEvents = ({ token }) => {
const [
{
selectedOrganization: { id, icals, events, eventsLoading },
selectedOrganization: { id, events, eventsLoading },
},
] = useStateValue()

Expand All @@ -40,11 +40,7 @@ const UpcomingEvents = ({ token }) => {
</Grid>
)}
{upcomingEvents.map(event => (
<Event
key={event.id}
ical={icals.filter(ical => event.icalId === ical.id)[0]}
event={event}
/>
<Event key={event.id} event={event} />
))}
{upcomingEvents.length === 0 && (
<Grid item>
Expand Down

0 comments on commit de1c2f7

Please sign in to comment.