generated from hack4impact-upenn/boilerplate-s2022
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into taha/piecomponent
- Loading branch information
Showing
14 changed files
with
456 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import React, { useEffect, useState, useLayoutEffect } from 'react'; | ||
import { Typography, Grid } from '@mui/material'; | ||
import Table from '@mui/material/Table'; | ||
import TableBody from '@mui/material/TableBody'; | ||
import TableCell from '@mui/material/TableCell'; | ||
import TableContainer from '@mui/material/TableContainer'; | ||
import TableHead from '@mui/material/TableHead'; | ||
import TableRow from '@mui/material/TableRow'; | ||
import Paper from '@mui/material/Paper'; | ||
import { useData } from '../util/api'; | ||
import ICity from '../util/types/city'; | ||
import Edit from '../images/editDashboard.png'; | ||
|
||
/** | ||
* M | ||
*/ | ||
|
||
function createData(name: string) { | ||
return { name }; | ||
} | ||
|
||
function CityDashboardPage() { | ||
const [cityList, setCityList] = useState<ICity[]>([]); | ||
const [rows, setRows] = useState<string[]>([]); | ||
|
||
useLayoutEffect(() => { | ||
document.body.style.backgroundColor = 'white'; | ||
}); | ||
const cityData = useData(`cities/all`); | ||
|
||
useEffect(() => { | ||
setCityList(cityData?.data); | ||
}, [cityData]); | ||
|
||
// eslint-disable-next-line no-plusplus | ||
for (let i = 0; i < cityList?.length; i++) { | ||
if (rows.length <= cityList?.length) { | ||
if (cityList[i].isAccredited === true) { | ||
rows.push(`${cityList[i].cityName} (Accredited)`); | ||
} else { | ||
rows.push(cityList[i].cityName); | ||
} | ||
} | ||
} | ||
|
||
return ( | ||
<Grid | ||
container | ||
xs={12} | ||
justifyContent="center" | ||
alignItems="center" | ||
flexDirection="column" | ||
> | ||
<Grid item> | ||
<div style={{ height: '60vh', width: '60vw' }}> | ||
<TableContainer component={Paper}> | ||
<Table sx={{ minWidth: 650 }} aria-label="simple table"> | ||
<TableHead> | ||
<TableRow> | ||
<TableCell>City Name</TableCell> | ||
<TableCell align="right">Edit</TableCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{rows.map((row) => ( | ||
<TableRow | ||
key={row} | ||
sx={{ '&:last-child td, &:last-child th': { border: 0 } }} | ||
> | ||
<TableCell component="th" scope="row"> | ||
{row} | ||
</TableCell> | ||
<TableCell align="right"> | ||
<img | ||
src={Edit} | ||
alt="edit button" | ||
width="25" | ||
height="25" | ||
/> | ||
</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
</div> | ||
</Grid> | ||
</Grid> | ||
); | ||
} | ||
|
||
export default CityDashboardPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React, { useLayoutEffect } from 'react'; | ||
import { Typography, Grid } from '@mui/material'; | ||
import ScreenGrid from '../components/ScreenGrid'; | ||
import UserTable from './UserTable'; | ||
import InviteUserButton from '../components/buttons/InviteUserButton'; | ||
|
||
/** | ||
* A page only accessible to admins that displays all users in a table and allows | ||
* Admin to delete users from admin and promote users to admin. | ||
*/ | ||
function UserDashboardPage() { | ||
useLayoutEffect(() => { | ||
document.body.style.backgroundColor = 'white'; | ||
}); | ||
|
||
return ( | ||
<Grid | ||
container | ||
xs={12} | ||
justifyContent="center" | ||
alignItems="center" | ||
flexDirection="column" | ||
> | ||
<Grid item container width="60vw" justifyContent="flex-end"> | ||
<InviteUserButton /> | ||
</Grid> | ||
<Grid item> | ||
<div style={{ height: '60vh', width: '60vw' }}> | ||
<UserTable /> | ||
</div> | ||
</Grid> | ||
</Grid> | ||
); | ||
} | ||
|
||
export default UserDashboardPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
client/src/components/indicatorComponents/HighSchoolGradsPercent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { Toolbar } from '@mui/material'; | ||
import Box from '@mui/material/Box'; | ||
import Paper from '@mui/material/Paper'; | ||
import Typography from '@mui/material/Typography'; | ||
import { useData } from '../../util/api'; | ||
import ICity from '../../util/types/city'; | ||
import COLORS from '../../assets/colors'; | ||
|
||
type RevenueWidgetProps = { | ||
city: string; | ||
}; | ||
|
||
function HighSchoolGradsPercent({ city }: RevenueWidgetProps) { | ||
const cityData = useData(`cities/${city}`); | ||
|
||
if (cityData) { | ||
const hsGraduateList: { [key: number]: number } = | ||
cityData?.data.indicators.high_school_graduates; | ||
|
||
const HSGraduateValue = | ||
Object.values(hsGraduateList)[Object.values(hsGraduateList).length - 1]; | ||
|
||
return ( | ||
<Paper elevation={0} key={-1} sx={{ overflow: 'hidden' }}> | ||
<Box sx={{ p: 3 }}> | ||
<Typography variant="h6" sx={{ fontWeight: 700 }}> | ||
High School Graduates | ||
</Typography> | ||
<Typography variant="subtitle2" sx={{ color: COLORS.gray, mb: 1 }}> | ||
High school graduate or higher, percent of persons age 25+ | ||
</Typography> | ||
<Typography | ||
variant="h4" | ||
sx={{ color: COLORS.primaryBlue }} | ||
align="center" | ||
> | ||
{Intl.NumberFormat('en-US', { | ||
notation: 'compact', | ||
maximumFractionDigits: 1, | ||
}).format(HSGraduateValue)} | ||
</Typography> | ||
</Box> | ||
</Paper> | ||
); | ||
} | ||
|
||
return <Paper elevation={0} key={-1} sx={{ overflow: 'hidden' }} />; | ||
} | ||
|
||
export default HighSchoolGradsPercent; |
Oops, something went wrong.