debugfest/mern-book-tracker
Feature Request: Implement Add Book Form with Validation
オープン
#3 opened on 2025/10/11
enhancementgood first issuehacktoberfest
Repository metrics
- Stars
- (0 個のスター)
- PR merge metrics
- (PR metrics pending)
説明
Users should be able to add new books to the tracker with details like title, author, genre, year, and status. The form must include input validation and display clear error messages for invalid fields.
🎯 Proposed Solution
- Create
AddBook.tsxcomponent and/addroute. - Fields:
title,author,genre,year,status. - Validate:
- All fields are required.
yearmust be numeric.
- POST to
/api/booksupon submission. - Display success toast and redirect to book list.
✅ Expected Behavior
- Invalid inputs show inline error messages.
- Valid submissions create a new book in the database.
- User sees confirmation and redirection to book list.
💻 Technical Notes
- Use controlled inputs with React hooks.
- Utilize form libraries like React Hook Form (optional).
- Validation logic runs both client-side and server-side.
🧪 Test Steps
- Open
/addpage. - Try submitting with empty fields → error messages appear.
- Add valid book → redirect and verify entry in list.