Skip to content

Commit 4cdf324

Browse files
committed
refactor(admin-dashboard): replace HTML elements with MUI components
1 parent 21ff213 commit 4cdf324

File tree

1 file changed

+44
-44
lines changed
  • client/src/components/admin/dashboard

1 file changed

+44
-44
lines changed

client/src/components/admin/dashboard/index.jsx

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import React, { useEffect, useState } from 'react';
1+
import { useEffect, useState } from 'react';
2+
3+
import Box from '@mui/material/Box';
4+
import Typography from '@mui/material/Typography';
5+
26
import UpcomingEvent from '../../presentational/upcomingEvent';
37
import EventOverview from '../eventOverview';
48
import DonutChartContainer from '../donutChartContainer';
@@ -8,7 +12,7 @@ import Tab from '../../../common/tabs/tab';
812
import LocationTableReport from '../reports';
913
import '../../../sass/Dashboard.scss';
1014
import './index.scss';
11-
import { REACT_APP_CUSTOM_REQUEST_HEADER as headerToSend} from '../../../utils/globalSettings';
15+
import { REACT_APP_CUSTOM_REQUEST_HEADER as headerToSend } from '../../../utils/globalSettings';
1216

1317
const AdminDashboard = () => {
1418
const defaultChartType = 'All Events';
@@ -30,31 +34,23 @@ const AdminDashboard = () => {
3034
const [processedCheckins, setCheckins] = useState(null);
3135

3236
// Volunteers SignedIn By Event Type
33-
const [
34-
totalVolunteersByEventType,
35-
setVolunteersSignedInByEventType,
36-
] = useState({});
37-
const [
38-
totalVolunteerHoursByEventType,
39-
setVolunteeredHoursByEventType,
40-
] = useState({});
37+
const [totalVolunteersByEventType, setVolunteersSignedInByEventType] =
38+
useState({});
39+
const [totalVolunteerHoursByEventType, setVolunteeredHoursByEventType] =
40+
useState({});
4141
const [totalVolunteerAvgHoursByEventType, setAvgHoursByEventType] = useState(
42-
{}
42+
{},
4343
);
4444

4545
// Volunteers SignedIn By HackNight Property
46-
const [
47-
totalVolunteersByHackNightProp,
48-
setVolunteersSignedInByHackNightProp,
49-
] = useState({});
46+
const [totalVolunteersByHackNightProp, setVolunteersSignedInByHackNightProp] =
47+
useState({});
5048
const [
5149
totalVolunteerHoursByHackNightProp,
5250
setVolunteeredHoursByHackNightProp,
5351
] = useState({});
54-
const [
55-
totalVolunteerAvgHoursByHackNightProp,
56-
setAvgHoursByHackNightProp,
57-
] = useState({});
52+
const [totalVolunteerAvgHoursByHackNightProp, setAvgHoursByHackNightProp] =
53+
useState({});
5854

5955
// Volunteers To Chart
6056
const [totalVolunteers, setVolunteersToChart] = useState({});
@@ -72,7 +68,7 @@ const AdminDashboard = () => {
7268
'x-customrequired-header': headerToSend,
7369
},
7470
},
75-
signal
71+
signal,
7672
);
7773
const events = await eventsRes.json();
7874
const checkinsRes = await fetch(
@@ -82,7 +78,7 @@ const AdminDashboard = () => {
8278
'x-customrequired-header': headerToSend,
8379
},
8480
},
85-
signal
81+
signal,
8682
);
8783
const checkins = await checkinsRes.json();
8884
processData(events, checkins);
@@ -132,7 +128,7 @@ const AdminDashboard = () => {
132128
const capitalize = (str, lower = false) =>
133129
(lower ? str.toLowerCase() : str).replace(
134130
/(?:^|\s|["'([{])+\S/g,
135-
(match) => match.toUpperCase()
131+
(match) => match.toUpperCase(),
136132
);
137133
let type = capitalize(event[propName], true);
138134
event[propName] = type;
@@ -168,15 +164,15 @@ const AdminDashboard = () => {
168164
events,
169165
checkins,
170166
uniqueEventTypes,
171-
'eventType'
167+
'eventType',
172168
);
173169
setVolunteersSignedInByEventType(totalVolunteersByEventType);
174170

175171
let totalVolunteersByHackNightProp = extractVolunteersSignedInByProperty(
176172
events,
177173
checkins,
178174
hackNightUniqueLocations,
179-
'hacknight'
175+
'hacknight',
180176
);
181177
setVolunteersSignedInByHackNightProp(totalVolunteersByHackNightProp);
182178

@@ -185,30 +181,30 @@ const AdminDashboard = () => {
185181
events,
186182
checkins,
187183
uniqueEventTypes,
188-
'eventType'
184+
'eventType',
189185
);
190186
setVolunteeredHoursByEventType(totalVolunteerHoursByEventType);
191187

192188
let totalVolunteerHoursByHackNightProp = findTotalVolunteerHours(
193189
events,
194190
checkins,
195191
hackNightUniqueLocations,
196-
'hacknight'
192+
'hacknight',
197193
);
198194
setVolunteeredHoursByHackNightProp(totalVolunteerHoursByHackNightProp);
199195

200196
// Data for 3 chart 'total average hours'
201197
let totalVolunteerAvgHoursByEventType = findAverageVolunteerHours(
202198
totalVolunteersByEventType,
203199
totalVolunteerHoursByEventType,
204-
uniqueEventTypes
200+
uniqueEventTypes,
205201
);
206202
setAvgHoursByEventType(totalVolunteerAvgHoursByEventType);
207203

208204
let totalVolunteerAvgHoursByHackNightProp = findAverageVolunteerHours(
209205
totalVolunteersByHackNightProp,
210206
totalVolunteerHoursByHackNightProp,
211-
hackNightUniqueLocations
207+
hackNightUniqueLocations,
212208
);
213209
setAvgHoursByHackNightProp(totalVolunteerAvgHoursByHackNightProp);
214210

@@ -222,7 +218,7 @@ const AdminDashboard = () => {
222218
events,
223219
checkins,
224220
uniqueTypes,
225-
propName
221+
propName,
226222
) {
227223
let result = {};
228224
let type;
@@ -277,7 +273,7 @@ const AdminDashboard = () => {
277273
function findAverageVolunteerHours(
278274
totalVolunteers,
279275
totalVolunteerHours,
280-
uniqueTypes
276+
uniqueTypes,
281277
) {
282278
let result = {};
283279
uniqueTypes.forEach((el) => (result[el] = parseInt('0')));
@@ -377,25 +373,29 @@ const AdminDashboard = () => {
377373
return function cleanup() {
378374
abortController.abort();
379375
};
380-
// eslint-disable-next-line react-hooks/exhaustive-deps
381376
}, []);
382377

383378
return (
384-
<div className="flex-container">
385-
<div className="dashboard admin-dashboard-wrap">
386-
<div className="admin-header">
387-
<h1>Stats by Location - Volunteer Hours</h1>
388-
</div>
379+
<Box className="flex-container">
380+
<Box className="dashboard admin-dashboard-wrap">
381+
<Box className="admin-header">
382+
<Typography
383+
variant="h1"
384+
sx={{ fontFamily: '"Open Sans", sans-serif', marginBottom: '0' }}
385+
>
386+
Stats by Location - Volunteer Hours
387+
</Typography>
388+
</Box>
389389

390390
{!isLoading && nextEvent.length ? (
391-
!isCheckInReady &&
391+
!isCheckInReady && (
392392
<div className="event-header">You have 1 upcoming event:</div>
393-
) : (
394-
<div className="event-header">Current event:</div>
395393
)
396-
}
394+
) : (
395+
<div className="event-header">Current event:</div>
396+
)}
397397

398-
<div className="admin-upcoming-event">
398+
<Box className="admin-upcoming-event">
399399
{isLoading ? (
400400
<Loading />
401401
) : (
@@ -405,7 +405,7 @@ const AdminDashboard = () => {
405405
setCheckInReady={setCheckInReady}
406406
/>
407407
)}
408-
</div>
408+
</Box>
409409

410410
<TabsContainer active={0}>
411411
<Tab title="Table Report">
@@ -467,8 +467,8 @@ const AdminDashboard = () => {
467467
)}
468468
</Tab>
469469
</TabsContainer>
470-
</div>
471-
</div>
470+
</Box>
471+
</Box>
472472
);
473473
};
474474

0 commit comments

Comments
 (0)