From d422fc48943cf01891768c34a10f972637e1319b Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 15 Nov 2020 00:16:27 +0300 Subject: feat: add EventCard --- src/components/EventCard/EventCard.tsx | 59 ++++++++++++++++++++++ .../BsuFantomSection/BsuFantomSection.tsx | 10 +++- src/types.ts | 10 +++- 3 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 src/components/EventCard/EventCard.tsx (limited to 'src') diff --git a/src/components/EventCard/EventCard.tsx b/src/components/EventCard/EventCard.tsx new file mode 100644 index 0000000..88984ff --- /dev/null +++ b/src/components/EventCard/EventCard.tsx @@ -0,0 +1,59 @@ +import React from 'react'; +import { makeStyles } from '@material-ui/core/styles'; +import { + Card, + CardHeader, + CardContent, + CardActions, + Button +} from '@material-ui/core'; +import { Event } from '../../types'; + +interface PropTypes { + event: Event; +} + +const useStyles = makeStyles(theme => ({ + root: { + margin: theme.spacing(1), + maxWidth: theme.spacing(60) + } +})); + +const EventCard: React.FC = ({ event }) => { + const classes = useStyles(); + const { data: { + name, + date, + participants, + conferenceId, + attendanceId + }} = event; + + return ( + + + + {conferenceId &&
ConferenceID: {conferenceId}
} + {attendanceId &&
AttendanceID: {attendanceId}
} +
+ Participants ({participants?.length || 0} / 3) +
    + {participants?.map(username => ( +
  • {username}
  • + ))} +
+
+
+ {(participants?.length || 0) < 3 && ( + + + + )} +
+ ); +}; + +export default EventCard; diff --git a/src/containers/BsuFantomSection/BsuFantomSection.tsx b/src/containers/BsuFantomSection/BsuFantomSection.tsx index 119b2ae..90632d7 100644 --- a/src/containers/BsuFantomSection/BsuFantomSection.tsx +++ b/src/containers/BsuFantomSection/BsuFantomSection.tsx @@ -1,12 +1,20 @@ import React from 'react'; import { ContentSection } from 'react-benzin'; import { Link } from '@material-ui/core'; +import EventCard from '../../components/EventCard/EventCard'; +import { useEvents } from '../../hooks/APIClient'; const BsuFantomSection: React.FC = () => { + const { data: events } = useEvents(); return ( - Schedule your offline EDUFPMI conference attendance +

+ Schedule your offline EDUFPMI conference attendance +

+ + {events?.map(event => )} +
); }; diff --git a/src/types.ts b/src/types.ts index dc429a4..d385d2a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -8,5 +8,13 @@ export interface User extends Base { username: string; } -export interface Event extends Base {} +export interface Event extends Base { + data: { + name: string; + participants: string[]; + date: string; + conferenceId: string; + attendanceId: string; + } +} -- cgit v1.2.3