Closed JessicaLoers closed 1 month ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
capstone-new-shopping-buddy | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Sep 10, 2024 0:49am |
Concept of editing an item and reusing the form.
The key idea is to use a single form for both "adding" and "editing" shopping items, controlled by the mode state.
Mode Control: The mode state toggles between "add" and "edit". When in "edit" mode, the form is pre-filled with the item's data, and in "add" mode, it's blank for new entries.
Reusable Form: The same Form component is used for both actions. Depending on the mode, it either triggers
onAddItem
oronEditItem
, and the submit button label dynamically changes between "ADD" and "UPDATE".