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

Internal View: Add Category Modal #64

Open
19 tasks
idil-bit opened this issue Dec 19, 2024 · 0 comments
Open
19 tasks

Internal View: Add Category Modal #64

idil-bit opened this issue Dec 19, 2024 · 0 comments

Comments

@idil-bit
Copy link
Collaborator

idil-bit commented Dec 19, 2024

### DUE JAN 31

Purpose

Implement the functionality for the "Add Category" button in categories/page.tsx to display a modal for creating a new category. Users should be able to input a category name and submit it to the backend API to store the new category.

To Do

  • Move this ticket to the In Progress column
  • Get updated with the codebase (git checkout dev, git pull, create a new branch by git checkout -b [branchname] as per README, npm install to update your dependencies, npm build dev)
  • Modal Implementation
    • When the "Add Category" button is clicked, a modal should appear containing:
      • A text input field for the category name.
      • Two buttons: "Cancel" and "Save".
  • State Management
    • Use React's useState hook to manage:
      • Modal Visibility State: To show/hide the modal.
      • Input Field Value: To store the user’s input for the category name.
  • Input Field
    • Bind the input field to a categoryName state.
    • Add input validation:
      • Ensure the category name is not empty before submission.
      • Display a validation error if the field is empty.
    • Cancel Button
      • Close the modal without making any changes.
  • API Integration
    • Use the existing API structure to POST the new category to the categories endpoint.
      • API Path: app/api/categories/route.ts
      • Request Body will be a JSON object with the name set to the value in the input text field, the itemName being "" and units being [ ] (empty list)
      • Example can be found in app/volunteer-add-pages/[[...volunteer-add-pages]]/page.tsx (search for fetch in that file)
      • Response Handling
        • On success, log the response and close the modal.
        • On failure, display an error message in the modal.
  • create a PR for this ticket
    • add yourselves as assignees and Jiyoon as the reviewer to the PR
  • Move this ticket to the Ready for Review column

Pictures

Image

Image

@idil-bit idil-bit converted this from a draft issue Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: drafts
Development

No branches or pull requests

1 participant