aboutsummaryrefslogtreecommitdiff
path: root/src/containers/BsuFantomSection/BsuFantomSection.tsx
blob: 6420402279837f6a039f748e1edb235ae80af8fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React from 'react';
import { ContentSection } from 'react-benzin';
import { Grid, Link } from '@material-ui/core';
import EventCard from '../../components/EventCard/EventCard';
import { useEvents } from '../../hooks/APIClient';
import EventForm from './EventForm';
import LoginForm from './LoginForm';
import { useAuth } from '../../hooks/useAuth';


const BsuFantomSection: React.FC = () => {
  const { data: events, mutate } = useEvents();
  const { isAuthenticated } = useAuth();

  return (
    <ContentSection sectionName="bsu-fantom" level={1}>
      <p>
        Schedule your offline <Link href="https://edufpmi.bsu.by">EDUFPMI</Link> conference attendance
      </p>
      {
        isAuthenticated
        ? (
          <>
            <ContentSection sectionName="Schedule an event" level={2}>
              <EventForm mutate={mutate} />
            </ContentSection>
            <ContentSection sectionName="Upcoming events" level={2}>
              <Grid container spacing={2}>
                {events?.map((event, index) => (
                  <Grid item lg={3} md={4} sm={6} xs={12}>
                    <EventCard event={event} mutate={mutate} />
                  </Grid>
                ))}
              </Grid>
            </ContentSection>
          </>
        ) : (
          <ContentSection sectionName="Login" level={2}>
            <p>
              In order to use <b>bsu-fantom</b> you must log in
              using your <Link href="https://edufpmi.bsu.by">EDUFPMI</Link> credentials:
            </p>
            <LoginForm />
          </ContentSection>
        )
      }
    </ContentSection>
  );
};

export default BsuFantomSection;