Add MeetingList and Dashboard
This commit is contained in:
@@ -1,20 +1,48 @@
|
||||
import React from 'react';
|
||||
import { Panel } from 'rsuite';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Panel, Divider, List, Icon, FlexboxGrid } from 'rsuite';
|
||||
|
||||
import { useAuth } from '../helpers/authContext';
|
||||
import { NavBar } from '../components';
|
||||
import { NavBar, MeetingList } from '../components';
|
||||
|
||||
export default function Dashboard() {
|
||||
const { authToken, isAuthenticated, currentUser } = useAuth();
|
||||
import './styles/layout.less';
|
||||
import { backend } from '../helpers/http-common';
|
||||
|
||||
export default function Dashboard({ currentUser }) {
|
||||
const [meetings, setMeetings] = useState([]);
|
||||
const [confirmed, setConfirmed] = useState();
|
||||
const [unconfirmed, setUnconfirmed] = useState();
|
||||
|
||||
useEffect(() => {
|
||||
backend
|
||||
.get(`/accounts/${currentUser.id}/meetings`)
|
||||
.then((response) => {
|
||||
const allMeetings = response.data;
|
||||
|
||||
const confirmed = allMeetings.filter(
|
||||
(meeting) => meeting.start_time,
|
||||
);
|
||||
const unconfirmed = allMeetings.filter(
|
||||
(meeting) => !meeting.start_time,
|
||||
);
|
||||
|
||||
setConfirmed(confirmed);
|
||||
setUnconfirmed(unconfirmed);
|
||||
setMeetings(allMeetings);
|
||||
})
|
||||
.catch((error) => console.log(error));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<NavBar title='Meeting Planner' />
|
||||
<Panel header={<h3>Dashboard</h3>} bordered>
|
||||
<p>This is just experimenting with stuff.</p>
|
||||
<p>{authToken}</p>
|
||||
<p>Authenticated: {isAuthenticated.toString()}</p>
|
||||
<p>Current user: {currentUser.username}</p>
|
||||
<NavBar title='Dashboard' />
|
||||
<Panel className={'app-container'}>
|
||||
<h2>Invitations</h2>
|
||||
{meetings.length === 0 && <p>You have no meetings.</p>}
|
||||
{confirmed && (
|
||||
<MeetingList meetings={confirmed} status={'Confirmed'} />
|
||||
)}
|
||||
{unconfirmed && (
|
||||
<MeetingList meetings={unconfirmed} status={'To confirm'} />
|
||||
)}
|
||||
</Panel>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -53,7 +53,7 @@ export default function Login() {
|
||||
};
|
||||
|
||||
if (isAuthenticated) {
|
||||
return <Redirect to='/schedule' />;
|
||||
return <Redirect to='/dashboard' />;
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user