import React from 'react'; import { Card, CardHeader, CardContent, CardActions, Button } from '@material-ui/core'; import { Event } from '../../types'; import { patch } from '../../requests'; interface PropTypes { event: Event; mutate: () => void; } const EventCard: React.FC = ({ event, mutate }) => { const { data: { name, date, participants, conferenceId, attendanceId } } = event; const handleJoin = () => { // TODO: add your username to participants list const update = { data: { participants: [...participants, Math.random()] }} return patch(`/events/${event._id}`, update).then(() => mutate()); }; return ( {conferenceId &&
ConferenceID: {conferenceId}
} {attendanceId &&
AttendanceID: {attendanceId}
}
Participants ({participants?.length || 0} / 3)
    {participants?.map(username => (
  • {username}
  • ))}
{(participants?.length || 0) < 3 && ( )}
); }; export default EventCard;