Skip to content

Let users edit, unpublish and delete their own foods - #10

Merged
YarinQuapi merged 1 commit into
masterfrom
scanner-feedback-loop
Nov 15, 2026
Merged

YarinQuapi merged 1 commit into
masterfrom
scanner-feedback-loop

Conversation

@YarinQuapi

Copy link
Copy Markdown
Owner

What changed

Managing your own foods (web + mobile)

  • API: new DELETE /api/foods/:id, owner only, behind a new foods:delete permission (on by default for users, listed in the admin Permissions screen).
  • Web: the catalog's food detail now has Stop sharing / Publish and Delete next to Edit. The edit form is titled "Edit food" instead of "New food", has a delete button, and returns to the catalog after saving.
  • Mobile: the catalog detail sheet now has Edit, Stop sharing / Publish and Delete. FoodScreen takes an optional food and edits it with PUT (previously mobile could not edit a food at all).
  • Deleting asks for confirmation first on both platforms, since it cannot be undone.

Stale auth error (web + mobile)

  • An error such as "That email is already registered" stayed on screen while the fields were edited. On web the browser blocks submitting a too-short password itself, so pressing Sign up left the old message next to a different email. Editing any sign-up or login field now clears it.

Why

Foods a user created could be edited on web only, unpublished only from the web edit form, and never deleted.

Reviewer notes

  • The barcode stays fixed when editing: the update route does not accept it.
  • Diary entries hold their own copy of the name and nutrients and foodId is onDelete: SetNull, so past days should be unaffected by a delete. That path was not exercised end to end.
  • No migration: foods:delete falls back to the in-code default like the other operations.
  • New strings exist in English and Hebrew on both platforms.

Testing

  • API tests pass (49/49; the RBAC operation count was updated to 20), web and API typecheck, flutter analyze shows only the 7 existing infos, Flutter tests pass.
  • Create, edit, publish, unpublish and delete were exercised against a local API with curl; a second delete returns 404.
  • Not done: the new web and mobile screens were not clicked through in a browser or simulator.

🤖 Generated with Claude Code

Foods a user created could be edited on web only, unpublished only from
the web edit form, and never deleted.

- API: add DELETE /api/foods/:id for the owner, behind a new
  foods:delete permission (on by default for users).
- Web: the catalog detail gains Stop sharing and Delete next to Edit;
  the edit form is titled "Edit food", can delete, and returns to the
  catalog after saving.
- Mobile: the catalog detail sheet gains Edit, Stop sharing and Delete;
  the food screen now also edits an existing food.

Deleting asks for confirmation first, as it cannot be undone.

Also clear a stale auth error (such as "email already registered") as
soon as a sign-up or login field is edited, on web and mobile. The
browser blocks submitting a too-short password itself, so the old
message used to stay next to a different email.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@YarinQuapi
YarinQuapi merged commit 2ffbb93 into master Nov 15, 2026
3 checks passed
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.

1 participant