Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

23 new donated item form #33

Merged
merged 9 commits into from
Oct 7, 2024
Merged

23 new donated item form #33

merged 9 commits into from
Oct 7, 2024

Conversation

truffer11
Copy link
Collaborator

**Fixes Issue #23 **

What was changed?

  • Added a new form for newly donated items in client-app/src/components.

Why was it changed?

  • Allows for a user friendly and efficient way to add newly donated items to the database.
    • Note: This code is not yet connected to the database, however it will be connected in the future.
    • The form is way easier to understand and fill out compared to directly entering this data into the database.

How was it changed?

  • There is a new file, NewItemForm.tsx where the code should live eventually.
  • For now, just so I wasn't creating the form blind, the code is in DonorForm.tsx as well. The original code for DonorForm.tsx is commented out below. This will all be fixed as soon as I do not need to see the New Item Form.
  • On the foundational level, this code is similar to the code used in the Donor Form. I decided to do this to keep consistency among the forms, keeping the same style and color formatting.
    • The rest of the code has been changed to allow for different fields, dropdowns, dates, and file uploads.
    • As it relates to error handling, there have been a few modifications, including field specific errors and new item exclusive checks.
  • It should be important to note that this code is not yet set up with the database, however that will be done at a later time.
  • Images are stored in an array as base64 strings instead of their file names.

Screenshots that show the changes (if applicable):

  • Before:
    • Crickets
  • After:
    • image_2024-09-30_153213489
    • Screenshot 2024-09-30 153103

);
};

export default NewItemForm;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is same as donor form, this NewItemForm file should be imported in the home, or else both donor form and donated item from should be integrated. Separate routes should be created.

Copy link
Collaborator

@miabu-pashh miabu-pashh left a comment

Choose a reason for hiding this comment

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

Overall, two separate tsx files should be written for donor form and donated item form, and image upload option should be implemented in the backend option as well. as multiple images are being uploaded, we need to use an array of objects. The file handling function looks fine and form validators with error messages are neat. The donor should be able to have more options to donate.

client-app/src/Components/DonorForm.tsx Outdated Show resolved Hide resolved
@@ -0,0 +1,285 @@

Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a new button Donated Item in the navbar beside the Donor Form. And then create a new route path /addDonatedItem and route it to this newly added component NewItemForm

client-app/src/Components/DonorForm.tsx Outdated Show resolved Hide resolved
if (validateForm()) {
try {
const response = await axios.post(
`${process.env.REACT_APP_BACKEND_API_BASE_URL}donor`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

update the donor endpoint with donatedItem

@@ -0,0 +1,286 @@
import React, { useState, ChangeEvent, FormEvent } from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

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

@truffer11 rename the file to DonatedItemForm.tsx

@Anjali0407-git Anjali0407-git merged commit 9301a6a into main Oct 7, 2024
2 checks passed
@Anjali0407-git Anjali0407-git deleted the 23-new-donated-item-form branch October 7, 2024 14:12
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.

Create a form for adding new Donated item
3 participants