Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main Catalog Page (Frontend) and Integrate w/ Backend #20

Merged
merged 9 commits into from
Jan 21, 2024
2 changes: 2 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ForgotPassword from './components/Authentication/ForgotPassword';
import EmailAction from './components/Authentication/EmailAction';
import AUTH_ROLES from './utils/auth_config';
import ProtectedRoute from './utils/ProtectedRoute';
import Catalog from './pages/Catalog/Catalog';

const { ADMIN_ROLE, USER_ROLE } = AUTH_ROLES.AUTH_ROLES;

Expand Down Expand Up @@ -39,6 +40,7 @@ const App = () => {
/>
}
/>
<Route exact path="/catalog" element={<Catalog />} />
</Routes>
</Router>
</CookiesProvider>
Expand Down
45 changes: 45 additions & 0 deletions src/pages/Catalog/Catalog.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Table, Thead, Tbody, Tr, Th, Td, TableContainer } from '@chakra-ui/react';
import { useState, useEffect } from 'react';
import { NPOBackend } from '../../utils/auth_utils';

export default function Catalog() {
const [tableData, setTableData] = useState([]);

useEffect(() => {
const fetchCatalogData = async () => {
const response = await NPOBackend.get('/catalog');
setTableData(response.data);
};

fetchCatalogData().catch(console.error);
}, []);

return (
<TableContainer>
<Table variant="simple">
<Thead>
<Tr>
<Th>Title</Th>
<Th>Host</Th>
<Th>Cohort Type</Th>
<Th>Event Type</Th>
<Th>Subject</Th>
<Th>Description</Th>
</Tr>
</Thead>
<Tbody>
{tableData.map(({ id, host, title, eventType, subject, description, year }) => (
<Tr key={id}>
<Td>{title}</Td>
<Td>{host}</Td>
<Td>{year}</Td>
<Td>{eventType}</Td>
<Td>{subject}</Td>
<Td>{description}</Td>
</Tr>
))}
</Tbody>
</Table>
</TableContainer>
);
}
Loading