Skip to content

Commit

Permalink
Show new subevent in frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasSJacobsen committed Oct 6, 2020
1 parent 299f826 commit 9f9c85e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
21 changes: 16 additions & 5 deletions src/Frontend/Mainscreen/Event.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import * as SolidIcons from '@fortawesome/free-solid-svg-icons';
import IconLabel from './IconLabel';
import { AppContext } from '../App';
import { eventTimeComparator, selectField, selectTime, selectGroups } from '../utils';
import Posts from "./Posts";
import './event.scss';

/****************************/
/**** SubEvent component ****/
/****************************/
/***********************************/
/**** Gammel SubEvent component ****/
/***********************************/
const SubEvent = ({ event, event: { google_maps }, lang }) => {
const showUrl = google_maps && google_maps.startsWith('https');

Expand All @@ -26,8 +27,9 @@ const SubEvent = ({ event, event: { google_maps }, lang }) => {
/*****************************/
/****** Event component ******/
/*****************************/
const Event = ({ data }) => {
const Event = ({ data, group }) => {
const event = data;
const posts = data.posts
const [ open, setOpen ] = useState(true);
const [ state ] = useContext(AppContext);
const lang = state.lang;
Expand All @@ -41,7 +43,7 @@ const Event = ({ data }) => {
const link = data.link;
const linkText = selectField(event, 'linkText', lang);
const chevron = open ? SolidIcons["faChevronUp"] : SolidIcons["faChevronDown"];

return (
<div className="event-wrapper">
<div className="event">
Expand All @@ -52,12 +54,21 @@ const Event = ({ data }) => {
{ open && from && <IconLabel icon="faComment" label={from} /> }
{ open && link && linkText && <IconLabel icon="faLink" label={linkText} link={link}/> }
{ open && description && <p className="event-description"> { description } </p> }
{/***********************************/
/**** Gammel SubEvent component ****/}
{ open && event.subEvents && event.subEvents.length > 0 && (
<div className="sub-event-wrapper">
{ event.subEvents
.sort(eventTimeComparator)
.map(e => <SubEvent key={`${e.parent_event_id}-${e.title_NO}`} event={e} lang={lang}/>) }
</div>
)}
{/***********************************/}

{ open && posts && (
<div className="sub-event-wrapper">
{ event.posts.map( e => <Posts key={e.id} post={e} lang={lang}/>) }
</div>
)}
<div className="event-chevron" onClick={() => setOpen(!open)}>
<FontAwesomeIcon icon={chevron} />
Expand Down
2 changes: 1 addition & 1 deletion src/Frontend/Mainscreen/MainScreen.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const MainScreen = ({ group, events, removeGroup }) => {
.filter((e) => translateDayIdx(e.day_NO) === day)
.filter((e) => eventForGroupFilter(e, group))
.sort(eventTimeComparator)
.map((e) => <Event key={e.id} data={e} />)
.map((e) => <Event key={e.id} data={e} group={group}/>)
) : (
<>
{" "}
Expand Down

0 comments on commit 9f9c85e

Please sign in to comment.