debugfest/mern-book-tracker
Feature Request: Implement Add Book Form with Validation
开放
#3 创建于 2025年10月11日
enhancementgood first issuehacktoberfest
仓库指标
- 星标
- (0 个星标)
- PR 合并指标
- (PR 指标待抓取)
描述
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.