Skip to content

Commit e6de163

Browse files
committed
Feat: final fixes
1 parent 94bfb77 commit e6de163

File tree

12 files changed

+222
-115
lines changed

12 files changed

+222
-115
lines changed

client/src/App.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import { Admin } from "./components/admin/Admin";
1212
import { EditBooking } from "./components/bookings/EditBooking";
1313
import { CatchAll } from "./components/CatchAll";
14+
import { NotFound } from "./components/NotFound";
1415
import { Dashboard } from "./components/dashboard/Dashboard";
1516
import { ForgotPassword } from "./components/forgotpassword/ForgotPassword";
1617
import { ForgotPasswordSent } from "./components/forgotpassword/ForgotPasswordSent";
@@ -241,6 +242,10 @@ const App = () => {
241242
/>
242243
}
243244
/>
245+
<Route
246+
path="/404"
247+
element={<NotFound />}
248+
/>
244249
<Route
245250
path="*"
246251
element={
@@ -269,14 +274,14 @@ const App = () => {
269274
}
270275
/>
271276

272-
{/* <Route
277+
<Route
273278
path="/pdftest"
274279
element={
275280
<ProtectedRoute
276281
element={<TestPDFViewer id={45} />}
277282
/>
278283
}
279-
/> */}
284+
/>
280285
</Routes>
281286
</Router>
282287
</RoleProvider>

client/src/components/NotFound.jsx

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import React from "react";
2+
import { useNavigate } from "react-router-dom";
3+
import { Box, Button, Text, VStack } from "@chakra-ui/react";
4+
5+
export const NotFound = () => {
6+
const navigate = useNavigate();
7+
8+
const handleGoBack = () => {
9+
navigate(-2);
10+
};
11+
12+
return (
13+
<Box
14+
minHeight="100vh"
15+
display="flex"
16+
alignItems="center"
17+
justifyContent="center"
18+
background="linear-gradient(135deg, rgba(255, 207, 113, 0.3) 10.44%, rgba(145, 162, 167, 0.28) 55.22%, rgba(35, 118, 221, 0.25) 100%), #fff"
19+
>
20+
<VStack spacing={8} textAlign="center" maxWidth="500px" padding="32px">
21+
{/* 404 Number */}
22+
<Text
23+
fontSize="120px"
24+
fontWeight="700"
25+
color="#2D3748"
26+
fontFamily="Inter"
27+
lineHeight="1"
28+
marginBottom="16px"
29+
>
30+
404
31+
</Text>
32+
33+
{/* Error Message */}
34+
<VStack spacing={4}>
35+
<Text
36+
fontSize="32px"
37+
fontWeight="700"
38+
color="#2D3748"
39+
fontFamily="Inter"
40+
lineHeight="normal"
41+
>
42+
Page Not Found
43+
</Text>
44+
45+
<Text
46+
fontSize="16px"
47+
fontWeight="500"
48+
color="#4A5568"
49+
fontFamily="Inter"
50+
lineHeight="normal"
51+
letterSpacing="0.08px"
52+
maxWidth="400px"
53+
>
54+
The page you're looking for doesn't exist or has been moved.
55+
</Text>
56+
</VStack>
57+
58+
{/* Go Back Button */}
59+
<Button
60+
height="40px"
61+
padding="0px 16px"
62+
justifyContent="center"
63+
alignItems="center"
64+
gap="4px"
65+
borderRadius="6px"
66+
backgroundColor="#4441C8"
67+
color="white"
68+
fontFamily="Inter"
69+
fontSize="14px"
70+
fontStyle="normal"
71+
fontWeight="700"
72+
lineHeight="normal"
73+
letterSpacing="0.07px"
74+
_hover={{
75+
backgroundColor: "#312E8A",
76+
}}
77+
onClick={handleGoBack}
78+
>
79+
Go Back
80+
</Button>
81+
</VStack>
82+
</Box>
83+
);
84+
};

client/src/components/invoices/EditInvoice.jsx

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { useSessionStore } from "../../stores/useSessionStore";
4141
import { useInvoiceSessions } from "../../contexts/hooks/useInvoiceSessions";
4242
import { useDeletedIdsStore } from "../../stores/useDeletedIdsStore";
4343
import { useSummaryStore } from "../../stores/useSummaryStore";
44+
import { getPastDue } from "../../utils/pastDueCalc";
4445

4546
const InvoiceNavBar = ({
4647
onBack,
@@ -226,32 +227,34 @@ export const EditInvoice = () => {
226227
setEditedSubtotal(subtotalResponse.data.total);
227228

228229
// get the unpaid/remaining invoices
229-
const unpaidInvoicesResponse = await backend.get(
230-
"/events/remaining/" + invoice.data[0]["eventId"]
231-
);
232-
233-
// calculate sum of unpaid/remaining invoices
234-
const unpaidTotals = await Promise.all(
235-
unpaidInvoicesResponse.data.map((invoice) =>
236-
backend.get(`/invoices/total/${invoice.id}`)
237-
)
238-
);
239-
const partiallyPaidTotals = await Promise.all(
240-
unpaidInvoicesResponse.data.map((invoice) =>
241-
backend.get(`/invoices/paid/${invoice.id}`)
242-
)
243-
);
244-
const unpaidTotal = unpaidTotals.reduce(
245-
(sum, res) => sum + res.data.total,
246-
0
247-
);
248-
const unpaidPartiallyPaidTotal = partiallyPaidTotals.reduce(
249-
(sum, res) => {
250-
return sum + Number(res.data.total);
251-
},
252-
0
253-
);
254-
const remainingBalance = unpaidTotal - unpaidPartiallyPaidTotal;
230+
// const unpaidInvoicesResponse = await backend.get(
231+
// "/events/remaining/" + invoice.data[0]["eventId"]
232+
// );
233+
234+
// // calculate sum of unpaid/remaining invoices
235+
// const unpaidTotals = await Promise.all(
236+
// unpaidInvoicesResponse.data.map((invoice) =>
237+
// backend.get(`/invoices/total/${invoice.id}`)
238+
// )
239+
// );
240+
// const partiallyPaidTotals = await Promise.all(
241+
// unpaidInvoicesResponse.data.map((invoice) =>
242+
// backend.get(`/invoices/paid/${invoice.id}`)
243+
// )
244+
// );
245+
// const unpaidTotal = unpaidTotals.reduce(
246+
// (sum, res) => sum + res.data.total,
247+
// 0
248+
// );
249+
// const unpaidPartiallyPaidTotal = partiallyPaidTotals.reduce(
250+
// (sum, res) => {
251+
// return sum + Number(res.data.total);
252+
// },
253+
// 0
254+
// );
255+
// const remainingBalance = unpaidTotal - unpaidPartiallyPaidTotal;
256+
257+
const remainingBalance = await getPastDue(backend, id);
255258

256259
setPastDue(remainingBalance);
257260

client/src/components/invoices/InvoiceComponents.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ const InvoiceStats = ({
261261
fontSize="14px"
262262
fontWeight="500"
263263
>
264-
{amountDue ? `$${Number(amountDue).toFixed(2)}` : "N/A"}
264+
{amountDue ? `$${Number(amountDue).toFixed(2)}` : "$0.00"}
265265
</Text>
266266
</Box>
267267

@@ -1292,12 +1292,12 @@ function InvoicesTable({ filteredInvoices, isPaidColor, seasonColor, sortKey, so
12921292
<Th paddingRight="8px">
12931293
<Text>SEASON</Text>
12941294
</Th>
1295-
<Th
1295+
{/* <Th
12961296
paddingLeft="8px"
12971297
paddingRight="8px"
12981298
>
12991299
<Text>DOWNLOADS</Text>
1300-
</Th>
1300+
</Th> */}
13011301
<Th>{/* Blank for edit button dropdown */}</Th>
13021302
</Tr>
13031303
</Thead>
@@ -1389,11 +1389,11 @@ function InvoicesTable({ filteredInvoices, isPaidColor, seasonColor, sortKey, so
13891389
{invoice.season}
13901390
</Tag>
13911391
</Td>
1392-
<Td>
1392+
{/* <Td>
13931393
<Flex ml="18px">
13941394
<PDFButtonInvoice onlyIcon={true} id={invoice.id} invoiceMonth={invoice.month} invoiceYear={invoice.year} programName={invoice.eventName} />
13951395
</Flex>
1396-
</Td>
1396+
</Td> */}
13971397
<td>
13981398
<Flex
13991399
width="100%"

client/src/components/invoices/InvoicePDFDocument.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ const EditInvoiceTitle = ({ sessions }) => {
104104
INVOICE
105105
</Text>
106106
<Text style={{ color: "#718096", fontSize: "12px" }}>
107-
Generated on {getGeneratedDate(sessions, true)}
107+
Generated on {(new Date()).toLocaleDateString("en-US", {
108+
month: "long",
109+
day: "numeric",
110+
year: "numeric",
111+
})}
108112
</Text>
109113
</View>
110114

client/src/components/invoices/PDFButtonInvoice.jsx

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ import { useBackendContext } from "../../contexts/hooks/useBackendContext";
2121
import { InvoicePDFDocument } from "./InvoicePDFDocument";
2222
import { useInvoiceSessions } from "../../contexts/hooks/useInvoiceSessions";
2323
import { useSessionStore } from "../../stores/useSessionStore";
24+
import { getPastDue } from "../../utils/pastDueCalc"
2425

2526
const PDFButtonInvoice = ({
2627
id,
2728
onlyIcon = false,
28-
hasUnsavedChanges,
29-
handleOtherButtonClick,
29+
hasUnsavedChanges = null,
30+
handleOtherButtonClick = null,
3031
}) => {
3132
const [loading, setLoading] = useState(false);
3233
const [invoice, setInvoice] = useState(null);
@@ -57,31 +58,34 @@ const PDFButtonInvoice = ({
5758
backend.get(`/comments/invoice/summary/${id}`)
5859
]);
5960

60-
const unpaidTotals = await Promise.all(
61-
unpaidInvoicesResponse.data.map((invoice) =>
62-
backend.get(`/invoices/total/${invoice.id}`)
63-
)
64-
);
65-
const partiallyPaidTotals = await Promise.all(
66-
unpaidInvoicesResponse.data.map((invoice) =>
67-
backend.get(`/invoices/paid/${invoice.id}`)
68-
)
69-
);
70-
71-
const unpaidTotal = unpaidTotals.reduce(
72-
(sum, res) => sum + res.data.total,
73-
0
74-
);
75-
const unpaidPartiallyPaidTotal = partiallyPaidTotals.reduce((sum, res) => {
76-
return res.data.total ? sum + Number(res.data.total) : sum;
77-
}, 0);
61+
// const unpaidTotals = await Promise.all(
62+
// unpaidInvoicesResponse.data.map((invoice) =>
63+
// backend.get(`/invoices/total/${invoice.id}`)
64+
// )
65+
// );
66+
// const partiallyPaidTotals = await Promise.all(
67+
// unpaidInvoicesResponse.data.map((invoice) =>
68+
// backend.get(`/invoices/paid/${invoice.id}`)
69+
// )
70+
// );
71+
72+
// const unpaidTotal = unpaidTotals.reduce(
73+
// (sum, res) => sum + res.data.total,
74+
// 0
75+
// );
76+
// const unpaidPartiallyPaidTotal = partiallyPaidTotals.reduce((sum, res) => {
77+
// return res.data.total ? sum + Number(res.data.total) : sum;
78+
// }, 0);
7879

7980
const totalCustomRow = summaryResponse.data[0]?.total?.reduce((acc, total) => {
8081
return acc + Number(total.value);
8182
}, 0);
8283

8384

84-
const remainingBalance = unpaidTotal - unpaidPartiallyPaidTotal + totalCustomRow;
85+
// const remainingBalance = unpaidTotal - unpaidPartiallyPaidTotal + totalCustomRow;
86+
87+
const remainingBalance = await getPastDue(backend, id);
88+
8589

8690
return {
8791
instructors: instructorResponse.data,

client/src/components/invoices/SavedEditsInvoice.jsx

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { useBackendContext } from "../../contexts/hooks/useBackendContext";
2424
import { EmailSidebar } from "../email/EmailSidebar.jsx";
2525
import Navbar from "../navbar/Navbar";
2626
import { InvoiceView } from "./InvoiceView";
27+
import { getPastDue } from "../../utils/pastDueCalc";
2728

2829
const SavedInvoiceNavBar = ({ onBack, id, invoice, payees, programName }) => {
2930
const { isOpen, onOpen, onClose } = useDisclosure();
@@ -160,32 +161,33 @@ export const SavedEdit = () => {
160161
// setSubtotal(subtotalResponse.data.total);
161162

162163
// ==== PAST DUE CALCULATION ====
163-
const unpaidInvoicesResponse = await backend.get(
164-
"/events/remaining/" + currentInvoiceResponse.data[0]["eventId"]
165-
);
166-
167-
// calculate sum of unpaid/remaining invoices
168-
const unpaidTotals = await Promise.all(
169-
unpaidInvoicesResponse.data.map((invoice) =>
170-
backend.get(`/invoices/total/${invoice.id}`)
171-
)
172-
);
173-
const partiallyPaidTotals = await Promise.all(
174-
unpaidInvoicesResponse.data.map((invoice) =>
175-
backend.get(`/invoices/paid/${invoice.id}`)
176-
)
177-
);
178-
const unpaidTotal = unpaidTotals.reduce(
179-
(sum, res) => sum + res.data.total,
180-
0
181-
);
182-
const unpaidPartiallyPaidTotal = partiallyPaidTotals.reduce(
183-
(sum, res) => {
184-
return sum + Number(res.data.total); // Had to change to number because was causing NaN
185-
},
186-
0
187-
);
188-
const remainingBalance = unpaidTotal - unpaidPartiallyPaidTotal;
164+
// const unpaidInvoicesResponse = await backend.get(
165+
// "/events/remaining/" + currentInvoiceResponse.data[0]["eventId"]
166+
// );
167+
168+
// // calculate sum of unpaid/remaining invoices
169+
// const unpaidTotals = await Promise.all(
170+
// unpaidInvoicesResponse.data.map((invoice) =>
171+
// backend.get(`/invoices/total/${invoice.id}`)
172+
// )
173+
// );
174+
// const partiallyPaidTotals = await Promise.all(
175+
// unpaidInvoicesResponse.data.map((invoice) =>
176+
// backend.get(`/invoices/paid/${invoice.id}`)
177+
// )
178+
// );
179+
// const unpaidTotal = unpaidTotals.reduce(
180+
// (sum, res) => sum + res.data.total,
181+
// 0
182+
// );
183+
// const unpaidPartiallyPaidTotal = partiallyPaidTotals.reduce(
184+
// (sum, res) => {
185+
// return sum + Number(res.data.total); // Had to change to number because was causing NaN
186+
// },
187+
// 0
188+
// );
189+
// const remainingBalance = unpaidTotal - unpaidPartiallyPaidTotal;
190+
const remainingBalance = await getPastDue(backend, id);
189191
setPastDue(remainingBalance);
190192

191193
// ==== END OF PAST DUE CALCULATION ====

0 commit comments

Comments
 (0)