Skip to content

Commit bcc9590

Browse files
authored
Merge branch 'develop' into implement_checksum
2 parents 287fdc5 + 0ce22f9 commit bcc9590

File tree

15 files changed

+275
-122
lines changed

15 files changed

+275
-122
lines changed

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,20 @@ The Paso Robles Food Co-op is a non-profit organization dedicated to building a
1717

1818
### Team
1919

20-
The PRFC team consists of 13 Cal Poly students. Over the course of about 9 months, we worked as a team to deploy this web application. The team members are listed below:
20+
The PRFC team consists of 12 Cal Poly students. Over the course of about 9 months, we worked as a team to deploy this web application. The team members are listed below:
2121

22+
- [Ivan Alvarez](https://www.linkedin.com/in/ivanalvarez04/) - Tech Lead
23+
- [Amanda Chan](https://www.linkedin.com/in/achan04/) - Tech Lead
2224
- [Alexios Sideris](https://www.linkedin.com/in/alexios-sideris/) - Project Manager
2325
- [Naomi Tan](https://www.linkedin.com/) - Designer
24-
- [Kayle Le](https://www.linkedin.com/in/kayla-le-2227a61b0?trk=contact-info) - Designer
26+
- [Kayla Le](https://www.linkedin.com/in/kayla-le-2227a61b0?trk=contact-info) - Designer
2527
- [Anagha Kulkami](https://www.linkedin.com/in/anagha-kul/) - Designer
26-
- [Ivan Alvarez](https://www.linkedin.com/in/ivanalvarez04/) - Tech Lead
27-
- [Amanda Chan](https://www.linkedin.com/in/achan04/) - Tech Lead
2828
- [Vinayak Kohli](https://www.linkedin.com/) - Software Developer
2929
- [Karthik Balaji](https://www.linkedin.com/in/karthik-balaji-6529011ab/) - Software Developer
3030
- [Min Hset Hlaing](https://www.linkedin.com/in/min-hset-hlaing-37013b224/) - Software Developer
3131
- [Sue Sue](https://www.linkedin.com/in/sue-sue/) - Software Developer
3232
- [Camila Yeremin](https://www.linkedin.com/) - Software Developer
3333
- [Winnie Trinh](https://www.linkedin.com/in/winnie-trinh/) - Software Developer
34-
- [Charles Moreno](https://www.linkedin.com/) - Software Developer
3534

3635
## Getting Started And Contributing
3736

package-lock.json

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"scripts": {
66
"dev": "next dev",
7-
"build": "next build",
7+
"build": "prisma generate && next build",
88
"start": "next start",
99
"lint": "next lint",
1010
"lint:fix": "next lint --fix",
@@ -25,6 +25,7 @@
2525
"@prisma/client": "^6.4.1",
2626
"jspdf": "^3.0.1",
2727
"jspdf-autotable": "^5.0.2",
28+
"dayjs": "^1.11.13",
2829
"mongoose": "^8",
2930
"next": "^15.2.1",
3031
"nodemailer": "^6.10.0",

src/app/api/example/route.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/app/api/referral/[id]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NextRequest, NextResponse } from "next/server";
22
import prisma from "@/database/db";
33

4-
export async function PUT(req: NextRequest, context: { params: { id?: string } }) {
4+
export async function PUT(req: NextRequest, context: { params: Promise<{ id?: string }> }) {
55
try {
66
const resolvedParams = await context.params; // Await the params
77
if (!resolvedParams?.id) {

src/app/api/referral/route.ts

Lines changed: 70 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export async function POST(req: NextRequest) {
99

1010
// Destructure required parameters from the request body
1111
const { member_name, member_email, prospects, referral_code } = body;
12+
console.log(body);
1213
// Validate required fields with specific error messages
1314
if (!member_name) {
1415
return NextResponse.json({ message: "Member name is required." }, { status: 400 });
@@ -36,7 +37,7 @@ export async function POST(req: NextRequest) {
3637
}
3738
}
3839

39-
const emailSent = await sendEmail(prospects, referral_code);
40+
const emailSent = await sendEmail(prospects, referral_code, member_name);
4041
if (!emailSent) {
4142
return NextResponse.json({ message: "Failed to send email." }, { status: 500 });
4243
}
@@ -74,79 +75,80 @@ const transport = nodemailer.createTransport({
7475
},
7576
});
7677

77-
async function sendEmail(prospects: any, ref: any) {
78-
const mail = {
79-
from: process.env.FROM_EMAIL,
80-
to: prospects.map((prospect: { prospect_email: any }) => prospect.prospect_email).join(", "),
81-
subject: "You've Been Referred!",
82-
text: `Hello! -nodemailer\n`,
83-
html: `<div style="width: 100%; max-width: 600px; margin: 0 auto; font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
84-
85-
86-
<!--Header with logo image-->
87-
<div style="text-align: center;">
88-
<img src="cid:pasoLogo" alt="THE PASO FOOD CO-OP" style="max-width: 100%;">
89-
</div>
78+
async function sendEmail(prospects: any, ref: any, member: any) {
79+
let emailsSent = true;
80+
for (const prospect of prospects) {
81+
// console.log(prospect.prospect_email);
82+
const mail = {
83+
from: process.env.FROM_EMAIL,
84+
to: prospect.prospect_email,
85+
subject: "You've Been Invited!",
86+
text: `Hello! -nodemailer\n`,
87+
html: `<div style="width: 100%; max-width: 600px; margin: 0 auto; font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
9088
91-
<! Main content >
92-
<div style="padding: 20px;">
93-
<p>Hello ${prospects.prospect_name},</p>
9489
95-
<p>We're excited to let you know that your friend, <strong>${prospects.referrer_name}</strong>, thinks you'd love being a part of the Paso Robles Food Co-op!</p>
96-
97-
<p>At the Co-op, we're all about building a stronger community by connecting members to fresh, healthy, and locally-sourced food. As a member, you'll enjoy:</p>
98-
99-
<ul style="list-style-type: none; padding-left: 10px;">
100-
<li style="margin-bottom: 8px;">• Supporting local farmers and food producers 🌱</li>
101-
<li style="margin-bottom: 8px;">• A say in how the Co-op operates (yes, you're an owner!) 🗳️</li>
102-
<li style="margin-bottom: 8px;">• Exclusive discounts and special events 🎉</li>
103-
</ul>
104-
105-
<p>It's easy to join the Co-op and start making an impact in our community! Just click the link below to complete your membership registration:</p>
106-
107-
<p>
108-
<span style="font-weight: bold;">👉 <a href="https://www.pasoroblescoop.com" style="color: black; text-decoration: none;">Join Now</a></span>
109-
</p>
110-
<p>Your unique referral code is <strong>${ref}</strong>—be sure to enter it during registration.</p>
111-
112-
<p>Feel free to reach out if you have any questions or want to learn more about what makes the Paso Robles Food Co-op special.</p>
113-
114-
<p>Looking forward to welcoming you into our growing Co-op family!</p>
115-
116-
<p>Warm regards,<br>
117-
The Paso Robles Food Co-op Team</p>
118-
119-
<! Contact Info >
120-
<div style="margin-top: 20px; border-top: 1px solid #eee; padding-top: 15px;">
121-
<p style="margin: 5px 0;">
122-
📧 <a href="mailto:info@pasoroblescoop.com" style="color: #333; text-decoration: none;">info@pasoroblescoop.com</a>
123-
</p>
124-
<p style="margin: 5px 0;">
125-
📞 <span>[555-555-5555]</span>
126-
</p>
127-
<p style="margin: 5px 0;">
128-
🌐 <a href="https://www.pasoroblescoop.com" style="color: #333; text-decoration: none;">www.pasoroblescoop.com</a>
90+
<!--Header with logo image-->
91+
<div style="text-align: center;">
92+
<img src="cid:pasoLogo" alt="THE PASO FOOD CO-OP" style="max-width: 100%;">
93+
</div>
94+
95+
<! Main content >
96+
<div style="padding: 20px;">
97+
<p>Hello ${prospect.prospect_name},</p>
98+
99+
<p>We're excited to let you know that <strong>${member}</strong>, thinks you'd love being a part of the Paso Robles Food Co-op!</p>
100+
101+
<p>At the Co-op, we're all about building a stronger community by connecting members to fresh, healthy, and locally-sourced food. As a member owner, you'll enjoy:</p>
102+
103+
<ul style="padding-left: 10px;">
104+
<li style="margin-bottom: 8px;">Supporting local farmers and food producers 🌱</li>
105+
<li style="margin-bottom: 8px;">A say in how the Co-op operates (yes, you're an owner!) 🗳️</li>
106+
<li style="margin-bottom: 8px;">Exclusive discounts and special events 🎉</li>
107+
</ul>
108+
109+
<p>It's easy to join the Co-op and start making an impact in our community! Just click the link below to complete your membership registration:</p>
110+
111+
<p>
112+
<span style="font-weight: bold;">👉 <a href="https://www.pasoroblescoop.com" style="color: black; text-decoration: none;">Join Now</a></span>
129113
</p>
114+
<p>Your unique referral code is <strong>${ref}</strong>—be sure to confirm/enter it during registration.</p>
115+
116+
<p>Feel free to reach out if you have any questions or want to learn more about what makes the Paso Robles Food Co-op special. Our monthly meeting is every 4<sup>th</sup> Wednesday at 6pm. All details and info at our website: <a href="www.pasofoodcooperative.com" style="color: #333; text-decoration: underline;">www.pasofoodcooperative.com</a></p>
117+
118+
<p>Looking forward to welcoming you into our growing Co-op family!</p>
119+
120+
<p>Warm regards,<br>
121+
${member} and The Paso Robles Food Co-op Member Owners</p>
122+
123+
<! Contact Info >
124+
<div style="margin-top: 20px; border-top: 1px solid #eee; padding-top: 15px;">
125+
<p style="margin: 5px 0;">
126+
📧 <a href="mailto:info@pasofoodcooperative.com" style="color: #333; text-decoration: none;">info@pasofoodcooperative.com</a>
127+
</p>
128+
<p style="margin: 5px 0;">
129+
🌐 <a href="www.pasofoodcooperative.com" style="color: #333; text-decoration: none;">www.pasofoodcooperative.com</a>
130+
</p>
131+
</div>
130132
</div>
131-
</div>
132-
</div>`,
133-
attachments: [
134-
{
135-
filename: "paso-coop.jpeg", // Name of the file as it will appear in the email
136-
path: "public/assets/paso-coop.jpeg", // Path relative to your project root
137-
cid: "pasoLogo", // Content ID referenced in the HTML img src
138-
},
139-
],
140-
};
133+
</div>`,
134+
attachments: [
135+
{
136+
filename: "paso-coop.jpeg", // Name of the file as it will appear in the email
137+
path: "public/assets/paso-coop.jpeg", // Path relative to your project root
138+
cid: "pasoLogo", // Content ID referenced in the HTML img src
139+
},
140+
],
141+
};
141142

142-
try {
143-
const sendAttempt = await transport.sendMail(mail);
144-
console.log("Email sent successfully: ", sendAttempt.response);
145-
return true;
146-
} catch (error) {
147-
console.error("Error sending email: ", error);
148-
return false;
143+
try {
144+
const sendAttempt = await transport.sendMail(mail);
145+
console.log("Email sent successfully: ", sendAttempt.response);
146+
} catch (error) {
147+
console.error("Error sending email: ", error);
148+
return false;
149+
}
149150
}
151+
return emailsSent;
150152
}
151153

152154
// To use whenever you fetch something from the db and want to return it

src/app/page.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Header from "@/components/Header/Header";
22
import ReferralForm from "@/components/ReferralForm/ReferralForm";
33
import styles from "@/styles/page.module.css";
44
import Image from "next/image";
5+
import { Suspense } from "react";
56

67
export default function Home() {
78
return (
@@ -16,7 +17,9 @@ export default function Home() {
1617
<h2>Refer a Family Member or Friend</h2>
1718
</div>
1819
{/* Referral Form */}
19-
<ReferralForm />
20+
<Suspense fallback={<div>Loading...</div>}>
21+
<ReferralForm />
22+
</Suspense>
2023
</div>
2124
<div className={styles.heroImage}>
2225
<Image src="/produce.jpg" alt="Fresh Produce" width={600} height={600} layout="intrinsic" />

src/components/Header/Header.module.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* Header.module.css */
22
.header {
33
width: 100%;
4-
height: 80px; /* Adjust height as needed */
4+
height: 8vw; /* Adjust height as needed */
55
background-color: white;
66
display: flex;
77
align-items: center;
@@ -18,6 +18,7 @@
1818
}
1919

2020
.logo {
21-
height: 60px; /* Adjust logo size as needed */
21+
height: 4vw;
22+
min-height: 60px; /* Adjust logo size as needed */
2223
width: auto;
2324
}

src/components/Header/Header.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
import React from "react";
22
import styles from "./Header.module.css"; // Ensure this is the correct path
3+
import Image from "next/image";
34

45
const Header: React.FC = () => {
56
return (
67
<header className={styles.header}>
78
<div className={styles.logoContainer}>
8-
<img src="/logo.jpg" alt="Logo" className={styles.logo} />
9+
{/* <img src="/logo.jpg" alt="Logo" className={styles.logo} /> */}
10+
<Image
11+
src="/logo.jpg"
12+
alt="Logo"
13+
className={styles.logo}
14+
width={120} // Adjust based on your needs
15+
height={60}
16+
priority // Optional: load early for better LCP
17+
/>
918
</div>
1019
</header>
1120
);

src/components/ReferralDatabase/ReferralDataGrid.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { useState, useEffect } from "react";
1313
import Switch from "@mui/material/Switch";
1414
import jsPDF from "jspdf";
1515
import autoTable from "jspdf-autotable";
16+
import dayjs from "dayjs"; // For date
1617

1718
const CustomToolbar = ({ onExport }: { onExport: () => void }) => {
1819
return (
@@ -212,7 +213,13 @@ export default function ReferralDataGrid() {
212213
};
213214

214215
return (
215-
<div style={{ height: 572, width: "100%" }}>
216+
<div
217+
style={{
218+
height: "calc(100vh - 12rem", // Subtract the header height from the full screen height
219+
width: "100%",
220+
margin: "0 auto", //Center horizontally
221+
}}
222+
>
216223
<DataGrid
217224
rows={rows}
218225
columns={columns}
@@ -224,6 +231,7 @@ export default function ReferralDataGrid() {
224231
showQuickFilter: true,
225232
},
226233
}}
234+
getRowClassName={(params) => (params.indexRelativeToCurrentPage % 2 === 0 ? "even-row" : "odd-row")}
227235
sx={{
228236
border: "2px solid #968676",
229237
borderRadius: "12px",
@@ -239,13 +247,14 @@ export default function ReferralDataGrid() {
239247
fontWeight: "bold",
240248
textDecoration: "underline",
241249
},
250+
"& .even-row": {
251+
backgroundColor: "#ffffff",
252+
},
253+
"& .odd-row": {
254+
backgroundColor: "#D9D9D9",
255+
},
242256
"& .MuiDataGrid-row": {
243-
"&:nth-of-type(odd)": {
244-
backgroundColor: "#D9D9D9", // Odd row background color
245-
},
246-
"&:nth-of-type(even)": {
247-
backgroundColor: "#ffffff", // Even row background color
248-
},
257+
transition: "none !important",
249258
},
250259
}}
251260
/>

0 commit comments

Comments
 (0)