Skip to content

Commit 2e572a3

Browse files
committed
#1182 - add adminToolTable, move form into page
1 parent 7a418f2 commit 2e572a3

5 files changed

Lines changed: 180 additions & 212 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Paper, Table, TableBody, TableCell, TableContainer, TableHead } from '@mui/material';
2+
3+
interface AdminToolTableProps {
4+
columns: {
5+
name: string;
6+
width?: string;
7+
}[];
8+
rows: JSX.Element[];
9+
}
10+
11+
const AdminToolTable = ({ columns, rows }: AdminToolTableProps) => {
12+
return (
13+
<TableContainer component={Paper}>
14+
<Table>
15+
<TableHead>
16+
{columns.map((column, idx) => (
17+
<TableCell
18+
key={`${column.name}-${idx}`}
19+
align="left"
20+
sx={{ fontSize: '16px', fontWeight: 600, border: '2px solid black' }}
21+
width={column.width}
22+
>
23+
{column.name}
24+
</TableCell>
25+
))}
26+
</TableHead>
27+
<TableBody>{rows}</TableBody>
28+
</Table>
29+
</TableContainer>
30+
);
31+
};
32+
33+
export default AdminToolTable;

src/frontend/src/pages/AdminToolsPage/CreateTeamModal.tsx

Lines changed: 0 additions & 122 deletions
This file was deleted.

src/frontend/src/pages/AdminToolsPage/FinanceConfig/AccountCodesTable.tsx

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TableRow, TableCell, Paper, Table, TableBody, TableContainer, TableHead, Typography, Box } from '@mui/material';
1+
import { TableRow, TableCell, Typography, Box } from '@mui/material';
22
import LoadingIndicator from '../../../components/LoadingIndicator';
33
import { useGetAllExpenseTypes } from '../../../hooks/finance.hooks';
44
import ErrorPage from '../../ErrorPage';
@@ -7,6 +7,7 @@ import { useState } from 'react';
77
import { ExpenseType } from 'shared';
88
import CreateAccountCodeModal from './CreateAccountCodeModal';
99
import EditAccountCodeModal from './EditAccountCodeModal';
10+
import AdminToolTable from '../AdminToolTable';
1011

1112
const AccountCodesTable = () => {
1213
const {
@@ -59,37 +60,14 @@ const AccountCodesTable = () => {
5960
<Typography variant="subtitle1" textAlign="left">
6061
Account Codes
6162
</Typography>
62-
<TableContainer component={Paper}>
63-
<Table>
64-
<TableHead>
65-
<TableCell
66-
align="left"
67-
sx={{ fontSize: '16px', fontWeight: 600, border: '2px solid black' }}
68-
itemType="date"
69-
width="50%"
70-
>
71-
Account Name
72-
</TableCell>
73-
<TableCell
74-
align="left"
75-
sx={{ fontSize: '16px', fontWeight: 600, border: '2px solid black' }}
76-
itemType="date"
77-
width="30%"
78-
>
79-
Account Code
80-
</TableCell>
81-
<TableCell
82-
align="center"
83-
sx={{ fontSize: '16px', fontWeight: 600, border: '2px solid black' }}
84-
itemType="date"
85-
width="20%"
86-
>
87-
Allowed
88-
</TableCell>
89-
</TableHead>
90-
<TableBody>{accountCodesTableRows}</TableBody>
91-
</Table>
92-
</TableContainer>
63+
<AdminToolTable
64+
columns={[
65+
{ name: 'Account Name', width: '50%' },
66+
{ name: 'Account Code', width: '30%' },
67+
{ name: 'Allowed', width: '20%' }
68+
]}
69+
rows={accountCodesTableRows}
70+
/>
9371
<Box sx={{ display: 'flex', justifyContent: 'right', marginTop: '10px' }}>
9472
<NERButton
9573
variant="contained"

src/frontend/src/pages/AdminToolsPage/FinanceConfig/VendorsTable.tsx

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { TableRow, TableCell, Paper, Table, TableBody, TableContainer, TableHead, Typography, Box } from '@mui/material';
1+
import { TableRow, TableCell, Typography, Box } from '@mui/material';
22
import LoadingIndicator from '../../../components/LoadingIndicator';
33
import { useGetAllVendors } from '../../../hooks/finance.hooks';
44
import { datePipe } from '../../../utils/pipes';
55
import ErrorPage from '../../ErrorPage';
66
import { NERButton } from '../../../components/NERButton';
77
import { useState } from 'react';
88
import CreateVendorModal from './CreateVendorModal';
9+
import AdminToolTable from '../AdminToolTable';
910

1011
const VendorsTable = () => {
1112
const { data: vendors, isLoading: vendorIsLoading, isError: vendorIsError, error: vendorError } = useGetAllVendors();
@@ -20,7 +21,7 @@ const VendorsTable = () => {
2021

2122
const vendorTableRows = vendors.map((vendor) => (
2223
<TableRow>
23-
<TableCell align="center" sx={{ border: '2px solid black' }}>
24+
<TableCell align="left" sx={{ border: '2px solid black' }}>
2425
{datePipe(vendor.dateCreated)}
2526
</TableCell>
2627
<TableCell sx={{ border: '2px solid black' }}>{vendor.name}</TableCell>
@@ -31,30 +32,7 @@ const VendorsTable = () => {
3132
<Box>
3233
<CreateVendorModal showModal={createModalShow} handleClose={() => setCreateModalShow(false)} />
3334
<Typography variant="subtitle1">Registered Vendors</Typography>
34-
<TableContainer component={Paper}>
35-
<Table sx={{ border: '2px solid black' }}>
36-
<TableHead>
37-
<TableRow>
38-
<TableCell
39-
align="center"
40-
sx={{
41-
fontSize: '16px',
42-
fontWeight: 600,
43-
width: '25%',
44-
border: '2px solid black'
45-
}}
46-
itemType="date"
47-
>
48-
Date Registered
49-
</TableCell>
50-
<TableCell align="left" sx={{ fontSize: '16px', fontWeight: 600 }}>
51-
Vendor Name
52-
</TableCell>
53-
</TableRow>
54-
</TableHead>
55-
<TableBody>{vendorTableRows}</TableBody>
56-
</Table>
57-
</TableContainer>
35+
<AdminToolTable columns={[{ name: 'Date Registered' }, { name: 'Vendor Name' }]} rows={vendorTableRows} />
5836
<Box sx={{ display: 'flex', justifyContent: 'right', marginTop: '10px' }}>
5937
<NERButton
6038
variant="contained"

0 commit comments

Comments
 (0)