Skip to content

Connected CSV frontend to backend#25

Merged
njbizzle merged 13 commits intomainfrom
feature/csv-merge
Apr 4, 2026
Merged

Connected CSV frontend to backend#25
njbizzle merged 13 commits intomainfrom
feature/csv-merge

Conversation

@njbizzle
Copy link
Copy Markdown
Member

@njbizzle njbizzle commented Feb 24, 2026

Tracking Info

Relates to #12
Resolves #18

Changes

Merged the CSV processing backend with the frontend display.

Testing

Tested with the following CSV files.

one.csv

First,Last,Email,Phone,New 
john,johnson,john@gmail.com,1231231234,N

many.csv

First,Last,Email,Phone,New
john,johnson,john_new_email@gmail.com,1231231234,N
johnithy,johnsonamy,johnthesecond@gmail.com,3213213211,R
jimmerson,jimarino,jimjim@jimjimmy.jim,9999999999, N
joel,johnjimmyjohn,joel.jimmy.john.john@yahoo.com,1431239999, R

bad_formatting.csv

First,Last,Email
john,johnson,john@gmail.com

bad_phone.csv

First,Last,Email,Phone,New
john,johnson,john@gmail.com,123123,N

bad_email.csv

First,Last,Email,Phone,New
john,johnson,john@@gmail.com,1231231234,N

Confirmation of Change

Tested with one.csv and many.csv

csv-merge-fullTest.webm

Tested fail cases with bad_formatting.csv, bad_phone.csv, and bad_email.csv

csv-merge-failTest.webm

Possible Improvements (either future or now, let me know)

  • More fail info when uploading file (rather than just "unsupported file upload").
  • The "Detailed Changes" screen could display added or removed tags. In this case that would only display if the "new"/"returning" tag was changed.
  • "new" / "returning" is currently stored as part of thestring[] tag member of a volunteer in the database. It should likely be stored as a boolean to prevent volunteers from being both "new" and "returning", but that goes out of the scope of this branch.

@njbizzle njbizzle closed this Feb 24, 2026
@njbizzle njbizzle reopened this Feb 24, 2026
@njbizzle njbizzle changed the base branch from main to feature/volunteer-table-final February 24, 2026 22:56
@njbizzle njbizzle changed the base branch from feature/volunteer-table-final to main February 24, 2026 22:56
@njbizzle njbizzle marked this pull request as ready for review February 25, 2026 21:04
@njbizzle njbizzle requested a review from navyaa31 as a code owner February 25, 2026 21:04
@navyaa31 navyaa31 requested review from siwenshao and wmiq84 February 25, 2026 23:10
Copy link
Copy Markdown
Contributor

@wmiq84 wmiq84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes worked, LGTM

Copy link
Copy Markdown
Collaborator

@navyaa31 navyaa31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I upload the bad_phone and bad_email csvs, I get this error. However, this isn't there for the frontend only code so do you know what might be causing this?

Image

Also, could you resolve merge conflicts with main? Since there have been some changes to the schema, the tags are rendering incorrectly on this branch so we should make sure that doesn't happen before merging this PR

Image

);

if (!result.ok) {
alert("Failed to upload volunteers: " + result.error);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can delete the alerts!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

@njbizzle
Copy link
Copy Markdown
Member Author

njbizzle commented Mar 4, 2026

When I upload the bad_phone and bad_email csvs, I get this error. However, this isn't there for the frontend only code so do you know what might be causing this?

Not sure if I fully understand the question, but if you're asking where the CSV headers being validated, everything should be in the backend. The one bit in the frontend to check the file extension was redundant and I just removed it.

Also I merged main back in and updated the api to use the new backend auth as well as update the csv parser to use the new tag backend. However, I wasn't able to reproduce the tag display error. I don't think I touched that section of the frontend, but maybe some of the other changes fixed it. Let me know if that error persists.

Also I'm curious how you're seeding the volunteers. If there's a new script that's compliant with the new volunteer and tag backend, let me know and I can do some more thorough testing.

Copy link
Copy Markdown
Contributor

@siwenshao siwenshao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR still includes the full backend CSV implementation in #20 PR which was merged already, and it did not reflect the most up-to-date changes that #20 made. Please split/rebase to avoid duplicating the earlier backend PR.

Overall, it looks great! I left a couple of comments about the details that we might want to look into/fix if needed.

Comment thread backend/src/middleware/auth.ts Outdated
Comment on lines 22 to 23
const token = authHeader.split("Bearer ")[1];
const token = authHeader.split("Bearer ")[1];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why do we have a duplicated const token here of the same thing? Maybe remove one.

Comment thread backend/src/routes/volunteerRoutes.ts Outdated
storage,
limits: { fileSize: 1024 * 1024 * 5 }, // 5MB limit
fileFilter: (req, file, cb) => {
if (file.mimetype !== "text/csv" || path.extname(file.originalname).toLowerCase() !== ".csv") {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As said in the review, I think this part is updated/fixed in the #20 PR but not reflected here

Comment thread frontend/src/components/ImportVolunteerModal.tsx
Comment on lines +19 to +20
tags: string[];
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this is not matching what is in frontend/src/app/api/volunteer.ts:tags?: string[]

@njbizzle njbizzle force-pushed the feature/csv-merge branch from 9a4e7e0 to 138689d Compare March 4, 2026 20:00
@njbizzle njbizzle requested review from navyaa31 and siwenshao March 5, 2026 23:01
Copy link
Copy Markdown
Collaborator

@navyaa31 navyaa31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks mostly good to me, just left one comment. I also was not able to get the tags to be added to the new volunteers when I upload them, could you let me know if you have the same issue? Image shows no tags but I checked the database as well, and no tags were there either

Image

Comment thread frontend/src/app/api/tag/route.ts Outdated
Copy link
Copy Markdown
Collaborator

@navyaa31 navyaa31 Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have the frontend call the backend endpoints directly and remove these proxy routes? This would make the code easier to maintain. We're going to do this in the rest of the codebase as well soon

Copy link
Copy Markdown
Member Author

@njbizzle njbizzle Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The csv only contained data about new/returning, which I thought that was no longer stored as a tag. If we should still have the volunteer status display as a tag I can do that.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh you are right about the new/returning, ignore my comment about that, thanks for the reminder

Copy link
Copy Markdown
Contributor

@siwenshao siwenshao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the fixes! It looks good to me!

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 3, 2026

Visit the preview URL for this PR (updated for commit 73e05e9):

https://home-start-80e0a--pr25-feature-csv-merge-jm5hr1wk.web.app

(expires Fri, 10 Apr 2026 19:48:33 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 2d310071333235bae3893f27fc89786faff3470f

@njbizzle njbizzle requested a review from navyaa31 April 3, 2026 18:34
Copy link
Copy Markdown
Collaborator

@navyaa31 navyaa31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks for removing the extra proxy! I just left comments about some minor code quality changes

<p className={styles.title}>Are you sure you want to log out?</p>
<button className={styles.close} onClick={onClose} aria-label="Close">
<Image src={icCloseLarge} alt="" />
<img src={icCloseLarge} alt="" />
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use use next’s Image component instead of img tags? (just undoing the changes in this file should be good)

Comment thread backend/src/routes/volunteerRoutes.ts Outdated
);

router.post("/upload-csv", upload.single("csv"), volunteer.createVolunteersCsv);
// router.post("/upload-csv", upload.single("csv"), volunteer.createVolunteersCsv);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we delete this code instead of commenting it out

Comment thread frontend/src/app/api/volunteer.ts Outdated
const headers = await getAuthHeaders();

let response: Response;
console.log(headers);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we delete these logs

import { useState } from "react";
import { Volunteer } from "../types/volunteer";
import styles from "./VolunteerTable.module.css";
import { useState, useEffect } from "react";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if useEffect is never used, can we delete its import

@njbizzle njbizzle requested a review from navyaa31 April 3, 2026 19:47
Copy link
Copy Markdown
Collaborator

@navyaa31 navyaa31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@njbizzle njbizzle merged commit 5badea1 into main Apr 4, 2026
3 checks passed
@njbizzle njbizzle deleted the feature/csv-merge branch April 4, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrating Upload CSV Frontend and Backend

4 participants