Add loading state to dashboard
This commit is contained in:
parent
495b60935d
commit
962b30edf0
@ -72,7 +72,7 @@ const alignRight = {
|
|||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
height: '60px',
|
height: '60px',
|
||||||
alignSelf: 'right'
|
marginLeft: 'auto'
|
||||||
};
|
};
|
||||||
|
|
||||||
const slimText = {
|
const slimText = {
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Panel, Divider, List, Icon, FlexboxGrid } from 'rsuite';
|
import { Panel, Placeholder, Loader } from 'rsuite';
|
||||||
|
|
||||||
import { NavBar, MeetingList } from '../components';
|
import { NavBar, MeetingList } from '../components';
|
||||||
|
|
||||||
import './styles/layout.less';
|
import './styles/layout.less';
|
||||||
import { backend } from '../helpers/http-common';
|
import { backend } from '../helpers/http-common';
|
||||||
|
|
||||||
|
const { Paragraph } = Placeholder;
|
||||||
|
|
||||||
export default function Dashboard({ currentUser }) {
|
export default function Dashboard({ currentUser }) {
|
||||||
const [meetings, setMeetings] = useState([]);
|
const [meetings, setMeetings] = useState([]);
|
||||||
const [confirmed, setConfirmed] = useState();
|
const [confirmed, setConfirmed] = useState();
|
||||||
const [unconfirmed, setUnconfirmed] = useState();
|
const [unconfirmed, setUnconfirmed] = useState();
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
backend
|
backend
|
||||||
@ -27,6 +30,7 @@ export default function Dashboard({ currentUser }) {
|
|||||||
setConfirmed(confirmed);
|
setConfirmed(confirmed);
|
||||||
setUnconfirmed(unconfirmed);
|
setUnconfirmed(unconfirmed);
|
||||||
setMeetings(allMeetings);
|
setMeetings(allMeetings);
|
||||||
|
setLoading(false);
|
||||||
})
|
})
|
||||||
.catch((error) => console.log(error));
|
.catch((error) => console.log(error));
|
||||||
}, []);
|
}, []);
|
||||||
@ -34,16 +38,36 @@ export default function Dashboard({ currentUser }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<NavBar title='Dashboard' />
|
<NavBar title='Dashboard' />
|
||||||
|
{loading ? (
|
||||||
|
<Panel className={'app-container'}>
|
||||||
|
<h2>Invitations</h2>
|
||||||
|
<h4>Confirmed</h4>
|
||||||
|
<Paragraph style={{ marginTop: 30 }} graph='square'>
|
||||||
|
<Loader backdrop content='loading...' vertical />
|
||||||
|
</Paragraph>
|
||||||
|
<h4>To confirm</h4>
|
||||||
|
<Paragraph style={{ marginTop: 30 }} graph='square'>
|
||||||
|
<Loader backdrop content='loading...' vertical />
|
||||||
|
</Paragraph>
|
||||||
|
</Panel>
|
||||||
|
) : (
|
||||||
<Panel className={'app-container'}>
|
<Panel className={'app-container'}>
|
||||||
<h2>Invitations</h2>
|
<h2>Invitations</h2>
|
||||||
{meetings.length === 0 && <p>You have no meetings.</p>}
|
|
||||||
{confirmed && (
|
{confirmed && (
|
||||||
<MeetingList meetings={confirmed} status={'Confirmed'} />
|
<MeetingList
|
||||||
|
meetings={confirmed}
|
||||||
|
status={'Confirmed'}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
{unconfirmed && (
|
{unconfirmed && (
|
||||||
<MeetingList meetings={unconfirmed} status={'To confirm'} />
|
<MeetingList
|
||||||
|
meetings={unconfirmed}
|
||||||
|
status={'To confirm'}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
|
{meetings.length === 0 && <p>You have no meetings.</p>}
|
||||||
</Panel>
|
</Panel>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user