generated from ctc-uci/npo-template-merged
-
Notifications
You must be signed in to change notification settings - Fork 1
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 create-endpoints-8
- Loading branch information
Showing
11 changed files
with
380 additions
and
8 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,9 @@ | ||
import LogoImg from "./logo.png"; | ||
|
||
// NOTE: Do not import logo.png, use Logo component instead | ||
|
||
export const Logo = () => { | ||
return ( | ||
<img src={LogoImg}></img> | ||
); | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,72 @@ | ||
import { Box, Flex, Link, Text, VStack } from "@chakra-ui/react"; | ||
|
||
export const Navbar = () => { | ||
const menuItems = [ | ||
{ name: "Home", path: "/home" }, | ||
{ name: "Events", path: "/events" }, | ||
{ name: "Invoices", path: "/invoices" }, | ||
{ name: "Settings", path: "/settings" }, | ||
{ | ||
name: "Google Calendar", | ||
path: "/calendar", | ||
external: true, | ||
}, | ||
]; | ||
|
||
return ( | ||
<Box | ||
w="64" | ||
bg="white" | ||
boxShadow="lg" | ||
h="100vh" | ||
> | ||
{/* Logo Section */} | ||
<Flex | ||
justify="center" | ||
p={6} | ||
> | ||
<Flex | ||
w="16" | ||
h="16" | ||
rounded="full" | ||
border="2px" | ||
borderColor="gray.300" | ||
align="center" | ||
justify="center" | ||
> | ||
<Text | ||
fontSize="xl" | ||
fontWeight="semibold" | ||
> | ||
LPA | ||
</Text> | ||
</Flex> | ||
</Flex> | ||
|
||
{/* Navigation Links */} | ||
<VStack | ||
spacing={2} | ||
align="stretch" | ||
px={4} | ||
> | ||
{menuItems.map((item) => ( | ||
<Link | ||
key={item.name} | ||
href={item.path} | ||
display="flex" | ||
alignItems="center" | ||
px={4} | ||
py={3} | ||
color="gray.700" | ||
_hover={{ bg: "gray.100" }} | ||
rounded="lg" | ||
> | ||
<Text>{item.name}</Text> | ||
</Link> | ||
))} | ||
</VStack> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default Navbar; |
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,105 @@ | ||
import React from 'react'; | ||
import { useState, useEffect } from 'react'; | ||
import { Document, Page, Text, View, StyleSheet } from '@react-pdf/renderer'; | ||
import { PDFDownloadLink } from '@react-pdf/renderer'; | ||
import { useBackendContext } from '../contexts/hooks/useBackendContext'; | ||
|
||
|
||
const styles = StyleSheet.create({ | ||
page: { | ||
padding: 30, | ||
backgroundColor: '#ffffff' | ||
}, | ||
section: { | ||
margin: 10, | ||
padding: 20, | ||
borderRadius: 5, | ||
backgroundColor: '#f8f9fa', | ||
borderBottom: '1px solid #eee' | ||
}, | ||
header: { | ||
fontSize: 14, | ||
fontWeight: 'bold', | ||
marginBottom: 10, | ||
color: '#2c3e50' | ||
}, | ||
row: { | ||
flexDirection: 'row', | ||
marginBottom: 8, | ||
alignItems: 'center' | ||
}, | ||
label: { | ||
width: 100, | ||
fontSize: 12, | ||
color: '#666', | ||
marginRight: 10 | ||
}, | ||
value: { | ||
flex: 1, | ||
fontSize: 12, | ||
color: '#333' | ||
}, | ||
dateTime: { | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
marginBottom: 10 | ||
}, | ||
timeBlock: { | ||
flex: 1 | ||
} | ||
}); | ||
|
||
const MyDocument = ({ bookingData }) => { | ||
return ( | ||
<Document> | ||
<Page size="A4" style={styles.page}> | ||
{bookingData && bookingData.map((element) => ( | ||
<View style={styles.section} key={element.id}> | ||
<Text>Archived: {element.archived}</Text> | ||
<Text>Date: {element.date}</Text> | ||
<Text>Event ID: {element.eventId}</Text> | ||
<Text>DB ID: {element.id}</Text> | ||
<Text>Room ID: {element.roomId}</Text> | ||
<Text>Start Time: {element.startTime}</Text> | ||
<Text>End Time: {element.endTime}</Text> | ||
</View> | ||
))} | ||
</Page> | ||
</Document> | ||
); | ||
}; | ||
|
||
const PDFButton = () => { | ||
const { backend } = useBackendContext(); | ||
const [bookingData, setBookingData] = useState(null); | ||
const [isLoading, setIsLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
const fetchData = async () => { | ||
try { | ||
const response = await backend.get("/bookings"); | ||
setBookingData(Array.isArray(response.data) ? response.data : []); | ||
} catch (err) { | ||
console.error("Error fetching bookings:", err); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
} | ||
fetchData(); | ||
}, [backend]); | ||
|
||
if (isLoading) return <div>Loading...</div>; | ||
|
||
return ( | ||
<div> | ||
<PDFDownloadLink | ||
document={<MyDocument bookingData={bookingData} />} | ||
fileName="bookingdata.pdf" | ||
> | ||
<button>Download PDF</button> | ||
</PDFDownloadLink> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PDFButton; |
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,70 @@ | ||
import express from "express"; | ||
import {db} from "../db/db-pgp"; | ||
import { keysToCamel } from "../common/utils"; | ||
|
||
const assignmentsRouter = express.Router(); | ||
assignmentsRouter.use(express.json()); | ||
|
||
assignmentsRouter.post("/", async (req, res) => { | ||
try { | ||
const { eventId, clientId, role } = req.body; | ||
|
||
console.log('Values:', { eventId, clientId, role }); // Add this line | ||
const query = { | ||
text: 'INSERT INTO assignments (event_id, client_id, role) VALUES ($1, $2, $3) RETURNING *', | ||
values: [eventId, clientId, role], | ||
}; | ||
|
||
const result = await db.query(query); | ||
console.log('Query result:', result); // Add this line | ||
res.status(201).json({id: result[0].id }); | ||
} catch (err) { | ||
res.status(500).send(err.message); | ||
} | ||
}); | ||
|
||
assignmentsRouter.get("/client/:client_id", async (req, res) => { | ||
try { | ||
const { client_id } = req.params; | ||
const data = await db.query(`SELECT * FROM assignments WHERE client_id = $1`, [client_id]); | ||
res.status(200).json(keysToCamel(data)); | ||
} catch (err) { | ||
res.status(500).send(err.message); | ||
} | ||
}) | ||
|
||
assignmentsRouter.get("/search", async (req, res) => { | ||
const {event, client} = req.query; | ||
try { | ||
const data = await db.query(`SELECT * FROM assignments WHERE event_id = $1 AND client_id = $2`, [event, client]); | ||
res.status(200).json(keysToCamel(data)); | ||
} catch (err) { | ||
res.status(500).send(err.message); | ||
} | ||
}) | ||
|
||
assignmentsRouter.put("/:id", async (req, res) => { | ||
try { | ||
const { id } = req.params; | ||
const { eventId, clientId, role } = req.body; | ||
const data = await db.query(`UPDATE assignments SET event_id = $1, client_id = $2, role = $3 WHERE id = $4 RETURNING *`, [eventId, clientId, role, id]); | ||
res.status(200).json(keysToCamel(data)); | ||
} catch (err) { | ||
res.status(500).send(err.message); | ||
} | ||
}) | ||
|
||
assignmentsRouter.delete("/:id", async (req, res) => { | ||
try { | ||
const {id} = req.params; | ||
const data = await db.query("DELETE FROM assignments WHERE id = $1", [id]); | ||
res.status(200).json({result: "success"}); | ||
} catch (err) { | ||
res.status(500).json({result: "error"}); | ||
} | ||
}); | ||
|
||
|
||
|
||
|
||
export { assignmentsRouter }; |
Oops, something went wrong.