Skip to content

Commit f9961c1

Browse files
committed
added more css, added buttons for modify and returned on items
1 parent 61e8d67 commit f9961c1

5 files changed

Lines changed: 123 additions & 13 deletions

File tree

client/src/components/ui/button_quick_actions.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import Link from "next/link";
44
import React from "react";
55

6+
// tmr night, wed night, friday night, sat mornign and sun morning
7+
68
const Quick_Actions = () => {
79
return (
810
<div className="quick-actions-card">
@@ -12,8 +14,16 @@ const Quick_Actions = () => {
1214
{/* 2. RIGHT COLUMN: Quick Actions */}
1315
<aside className="actions-panel">
1416
{/* This is where the Quick_Actions component will go */}
15-
{/* Button 1: Add Product */}
16-
<Link href="/organization_add_product">
17+
{/* Button 1: Add Product, this is to pass some mode to the add page to tell what mode and data to do*/}
18+
<Link
19+
href={{
20+
pathname: "/organization_add_product",
21+
query: {
22+
mode: "add",
23+
data: null,
24+
},
25+
}}
26+
>
1727
<button className="action-button primary">
1828
<span className="icon-plus">+</span>
1929
Add Product

client/src/components/ui/card_organization_inventory_details_modal.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Key components
1515
3. The overlay component itself
1616
*/
1717

18+
import Link from "next/link";
1819
import React from "react";
1920

2021
// Define the shape of the data this modal expects
@@ -75,6 +76,35 @@ const Inventory_Details_Modal: React.FC<Inventory_Details_Modal_Interface> = ({
7576
<p>Due On: {itemData.dueOn}</p>
7677
<p>Expiry Date: {itemData.expiryDate}</p>
7778
</div>
79+
80+
{/* NEW ACTION BUTTONS */}
81+
<div className="modal-actions">
82+
<Link
83+
href={{
84+
pathname: "/organization_add_product",
85+
query: {
86+
mode: "lend",
87+
data: JSON.stringify(itemData),
88+
},
89+
}}
90+
>
91+
<div className="modal-action-button secondary">
92+
Returned? <br /> Click me
93+
</div>
94+
</Link>
95+
96+
<Link
97+
href={{
98+
pathname: "/organization_add_product",
99+
query: {
100+
mode: "modify",
101+
data: JSON.stringify(itemData),
102+
},
103+
}}
104+
>
105+
<div className="modal-action-button secondary">Modify</div>
106+
</Link>
107+
</div>
78108
</div>
79109
</div>
80110
);

client/src/helpers/helper_functions.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,12 @@ export const calcTime = (dateString: string | undefined): string => {
3232
return "invalid date: " + error;
3333
}
3434
};
35+
36+
export const formatDateForInput = (dateString: string | undefined): string => {
37+
if (!dateString) return "";
38+
const d = new Date(dateString);
39+
if (isNaN(d.getTime())) return "";
40+
41+
// This extracts the "2026-01-07" part of an ISO string
42+
return d.toISOString().split("T")[0];
43+
};

client/src/pages/organization_add_product.tsx

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@ import { useSWRConfig } from "swr/_internal";
55

66
import { Inventory_Details_Interface } from "@/components/ui/card_organization_inventory_details_modal";
77
import Header from "@/components/ui/navbar_organization";
8+
import { formatDateForInput } from "@/helpers/helper_functions";
89
import { BASE_URL } from "@/hooks/organization_call_backend";
910
import { createNewItemClean } from "@/hooks/organization_clean_backend_calls";
1011
// import { createItem } from '../hooks/organization_call_backend';
1112

1213
const Organization_Add_Product = () => {
14+
// get the query from the other buttons
15+
const { mode, data } = useRouter().query;
16+
17+
// covnert the data back from json
18+
const parsedData: Inventory_Details_Interface | null = data
19+
? JSON.parse(data as string)
20+
: null;
21+
1322
// it creates a page stack that we can use to navigate
1423
// when to use and should we replace all href with router.push?
1524
// we only use this when we want to have buttons that go back to certain pages or after finishing a task
@@ -24,21 +33,24 @@ const Organization_Add_Product = () => {
2433
>({
2534
// id is excluded because it will be auto generated by backend
2635
// id: number,
27-
name: "",
28-
details: "",
29-
categories: "",
30-
availability: "",
36+
name: mode === "add" ? "" : parsedData?.name,
37+
details: mode === "add" ? "" : parsedData?.details,
38+
categories: mode === "add" ? "" : parsedData?.categories,
39+
availability: mode === "add" ? "" : parsedData?.availability,
3140

3241
// organization is kept away because we will fix it to the name of the organization that is logged in
3342
// organization: "",
3443

35-
collectionPoint: "",
36-
borrowerName: "",
37-
borrowedOn: "",
38-
returnedOn: "",
39-
dueOn: "",
40-
expiryDate: "",
41-
dateAdded: "",
44+
collectionPoint: mode === "add" ? "" : parsedData?.collectionPoint,
45+
borrowerName: mode === "add" ? "" : parsedData?.borrowerName,
46+
borrowedOn:
47+
mode === "add" ? "" : formatDateForInput(parsedData?.borrowedOn),
48+
returnedOn:
49+
mode === "add" ? "" : formatDateForInput(parsedData?.returnedOn),
50+
dueOn: mode === "add" ? "" : formatDateForInput(parsedData?.dueOn),
51+
expiryDate:
52+
mode === "add" ? "" : formatDateForInput(parsedData?.expiryDate),
53+
dateAdded: mode === "add" ? "" : formatDateForInput(parsedData?.dateAdded),
4254
});
4355

4456
// used whenever you type in the form fields

client/src/styles/organization.css

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,55 @@ gap: 30px: adds space between the two columns
640640
text-align: center;
641641
}
642642

643+
/* src/styles/organization.css */
644+
645+
/* Container for the bottom buttons */
646+
.modal-actions {
647+
display: flex;
648+
justify-content: space-between;
649+
gap: 20px;
650+
margin-top: 30px;
651+
}
652+
653+
/* Individual large grey buttons */
654+
.modal-action-button.secondary {
655+
flex: 1; /* Makes both buttons equal width */
656+
background-color: #e0e0e0; /* The light grey from your image */
657+
border: none;
658+
border-radius: 4px; /* Slight rounding as seen in image */
659+
padding: 15px 10px;
660+
font-size: 24px; /* Large text like your screenshot */
661+
font-weight: 500;
662+
color: #000000;
663+
cursor: pointer;
664+
line-height: 1.2;
665+
transition: background-color 0.2s;
666+
}
667+
668+
.modal-action-button.secondary:hover {
669+
background-color: #d0d0d0; /* Slightly darker on hover */
670+
}
671+
672+
/* Styling the body list for better alignment */
673+
.modal-details-list {
674+
margin-top: 20px;
675+
text-align: left;
676+
}
677+
678+
.modal-details-list p {
679+
display: flex;
680+
justify-content: space-between;
681+
margin-bottom: 8px;
682+
border-bottom: 1px solid #f0f0f0;
683+
padding-bottom: 4px;
684+
}
685+
686+
.modal-title {
687+
font-size: 28px;
688+
text-align: center;
689+
margin-bottom: 10px;
690+
}
691+
643692
.returned-button {
644693
background-color: #e0e0e0;
645694
color: #333;

0 commit comments

Comments
 (0)