Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter by pf only and changed interfaces and forms. still has checkbo… #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/components/EventsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Typography,
Upload,
} from 'antd';
import Checkbox from 'antd/lib/checkbox/Checkbox';
import { Moment } from 'moment';
import React from 'react';
import { Helmet } from 'react-helmet';
Expand Down Expand Up @@ -47,6 +48,7 @@ export interface EventsForm {
price: number;
description: string;
location: string;
forPFOnly: boolean
}

export interface EventsFormData extends EventsForm {
Expand Down Expand Up @@ -177,6 +179,13 @@ const EventsForm: React.FC<EventsFormProps> = ({
<TextArea rows={3} placeholder="Description" />
</Form.Item>

<Form.Item
name="forPFOnly"
valuePropName="checked"
>
<Checkbox defaultChecked={false}>For Participating Families Only?</Checkbox>
</Form.Item>

{/* TODO: come back to this in a second PR because it requires backend changes too :)
<Form.Item label="Meeting Link" name="meetingLink">
<Input placeholder="Meeting Link" />
Expand Down
20 changes: 9 additions & 11 deletions src/components/event-details/EventDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ const StyledTitle = styled(Title)`
margin-top: 15px;
`;

const Time = styled.div`
margin-bottom: 0.5em;
`;

const SeatsRemaining = styled.div`
const EventInfo = styled.div`
margin-bottom: 0.5em;
`;

Expand Down Expand Up @@ -81,6 +77,7 @@ const EventDetails: React.FC<EventDetailsProps> = ({
id,
title,
details,
forPFOnly,
privilegeLevel,
announcements,
hasRegistered,
Expand All @@ -101,15 +98,15 @@ const EventDetails: React.FC<EventDetailsProps> = ({
const endTime = dateFormat(end, 'shortTime');
return startDate === endDate ? (
<>
<Time>{startDate}</Time>
<Time>
<EventInfo>{startDate}</EventInfo>
<EventInfo>
{startTime} - {endTime}
</Time>
</EventInfo>
</>
) : (
<Time>
<EventInfo>
{startDate}, {startTime} - {endDate}, {endTime}
</Time>
</EventInfo>
);
};

Expand All @@ -133,7 +130,8 @@ const EventDetails: React.FC<EventDetailsProps> = ({
</EventsTag>
)}
{computeDateString()}
<SeatsRemaining>Seats Remaining: {spotsAvailable}</SeatsRemaining>
<EventInfo>Seats Remaining: {spotsAvailable}</EventInfo>
{forPFOnly && <EventInfo>Participating Families Only</EventInfo> }
<Location>Location: {location}</Location>
<GreenButton
onClick={() => {
Expand Down
1 change: 1 addition & 0 deletions src/containers/createEvent/ducks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export interface NewEventInformation {
start: Date;
end: Date;
};
forPFOnly: boolean;
}
1 change: 1 addition & 0 deletions src/containers/createEvent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const CreateEventContainer: React.FC = () => {
start: data.start,
end: data.end,
},
forPFOnly: data.forPFOnly
});
setCreateEventRequest(AsyncRequestCompleted(response));
} catch (err) {
Expand Down
2 changes: 2 additions & 0 deletions src/containers/editEvent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const EditEventContainer: React.FC = () => {
start: data.start,
end: data.end,
},
forPFOnly: data.forPFOnly,
});
setEditEventRequest(AsyncRequestCompleted(response));
} catch (err) {
Expand All @@ -97,6 +98,7 @@ const EditEventContainer: React.FC = () => {
location: info.details.location,
start: moment(info.details.start),
end: moment(info.details.end),
forPFOnly: info.forPFOnly,
};
};

Expand Down
1 change: 1 addition & 0 deletions src/containers/upcoming-events/ducks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ export interface EventInformation {
};
price: number;
ticketCount?: number;
forPFOnly: boolean;
}
20 changes: 15 additions & 5 deletions src/containers/upcoming-events/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { Radio, Typography } from 'antd';
import React, { useEffect, useState } from 'react';
import { Helmet } from 'react-helmet';
import { connect, useDispatch } from 'react-redux';
import { connect, useDispatch, useSelector } from 'react-redux';
import styled from 'styled-components';
import { getPrivilegeLevel } from '../../auth/ducks/selectors';
import { PrivilegeLevel } from '../../auth/ducks/types';
import { ChungusContentContainer } from '../../components';
import Calendar from '../../components/Calendar';
import EventsList from '../../components/events-list/EventsList';
import { C4CState } from '../../store';
import { asyncRequestIsComplete } from '../../utils/asyncRequest';
import { getUpcomingEvents } from './ducks/thunks';
import { EventsReducerState } from './ducks/types';
import { EventInformation, EventsReducerState } from './ducks/types';
const { Title } = Typography;

const Content = styled.div`
Expand Down Expand Up @@ -45,6 +47,10 @@ const UpcomingEvents: React.FC<UpcomingEventsProps> = ({ events }) => {

const [view, setView] = useState<EventView>(EventView.List);

const privilegeLevel: PrivilegeLevel = useSelector((state: C4CState) => {
return getPrivilegeLevel(state.authenticationState.tokens);
});

return (
<>
<Helmet>
Expand Down Expand Up @@ -72,9 +78,13 @@ const UpcomingEvents: React.FC<UpcomingEventsProps> = ({ events }) => {

{asyncRequestIsComplete(events) &&
(view === EventView.List ? (
<EventsList events={events.result} />
<EventsList events={(privilegeLevel === PrivilegeLevel.ADMIN) || (privilegeLevel === PrivilegeLevel.PF) ?
events.result :
events.result.filter((e: EventInformation) => !e.forPFOnly)} />
) : (
<Calendar events={events.result} />
<Calendar events={(privilegeLevel === PrivilegeLevel.ADMIN) || (privilegeLevel === PrivilegeLevel.PF) ?
events.result :
events.result.filter((e: EventInformation) => !e.forPFOnly)} />
))}
</ChungusContentContainer>
</>
Expand All @@ -83,7 +93,7 @@ const UpcomingEvents: React.FC<UpcomingEventsProps> = ({ events }) => {

const mapStateToProps = (state: C4CState): UpcomingEventsProps => {
return {
events: state.eventsState.upcomingEvents,
events: state.eventsState.upcomingEvents
};
};

Expand Down