generated from ctc-uci/npo-frontend-vite-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
ThatMegamind
merged 9 commits into
dev
from
9-main-catalog-page-and-integrate-backend-dev
Jan 21, 2024
+47
−0
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
817d29f
ChakraUI table setup
Philip-Jian 033fbfd
populate table with catalog
Philip-Jian 7950445
Merge branch '9-main-catalog-page-and-integrate-backend' of https://g…
seancfong fa501a3
Add catalog component to router
seancfong af58be6
Refactor code in Catalog component
seancfong d983ce9
Remove ChakraProvider context in main
seancfong 843f161
edited backend call
michellelin1 0b4be37
removed comments
michellelin1 29367bf
Merge branch 'dev' into 9-main-catalog-page-and-integrate-backend-dev
ThatMegamind File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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> | ||
); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could have been a prettier change on my end to fix the formatting; should I revert this?