Skip to content

Connected CSV frontend to backend#25

Open
njbizzle wants to merge 10 commits intomainfrom
feature/csv-merge
Open

Connected CSV frontend to backend#25
njbizzle wants to merge 10 commits intomainfrom
feature/csv-merge

Conversation

@njbizzle
Copy link
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
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
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
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
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
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
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 on lines 22 to 23
const token = authHeader.split("Bearer ")[1];
const token = authHeader.split("Bearer ")[1];
Copy link
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.

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
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 on lines +19 to +20
tags: string[];
};
Copy link
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
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

Copy link
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
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
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
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!

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