feat: add sidebar and product categories #89

Merged
davide merged 3 commits from feat/sidebar-and-product-categories into main 2026-07-14 16:54:23 +00:00
Owner
No description provided.
feat: add sidebar and product categories
Some checks failed
check-commitizen.yaml / Check the PR title (pull_request) Successful in 2s
check-formatter.yaml / Checks with formatters (pull_request) Successful in 11s
check-linter.yaml / Checks with linters (pull_request) Failing after 15s
check-syntax.yaml / Checks with static tools (pull_request) Failing after 21s
check-yamllint.yaml / Lint yaml files (pull_request) Successful in 2s
check-build.yaml / Check that project builds (pull_request) Successful in 1m9s
forgejo-agent / LLM Bot response generation (pull_request) Successful in 2s
6807cd5c53
feat: improve columns layout
All checks were successful
check-formatter.yaml / Checks with formatters (pull_request) Successful in 11s
check-linter.yaml / Checks with linters (pull_request) Successful in 27s
check-syntax.yaml / Checks with static tools (pull_request) Successful in 22s
check-yamllint.yaml / Lint yaml files (pull_request) Successful in 2s
check-build.yaml / Check that project builds (pull_request) Successful in 1m9s
e0238aabce
davide requested review from llm-bot 2026-07-14 15:49:00 +00:00
chore: fix cron jobs enabling
All checks were successful
check-build.yaml / Check that project builds (pull_request) Successful in 1m5s
check-formatter.yaml / Checks with formatters (pull_request) Successful in 11s
check-linter.yaml / Checks with linters (pull_request) Successful in 27s
check-syntax.yaml / Checks with static tools (pull_request) Successful in 22s
check-yamllint.yaml / Lint yaml files (pull_request) Successful in 2s
8facff32b0
llm-bot left a comment

PR Review: feat: add sidebar and product categories

This is a substantial PR (69 files, +1772/-250 lines) introducing two major features: a sidebar layout and product categories. Here are my findings:


🔴 Bug Found

PageWithSidebar.sveltebind:open callback checks wrong condition

<Dialog
  bind:open={() => sidebarOpen && !isMdWidth.current, (v) => {
      if (!isMdWidth) {    // ← BUG: should be !isMdWidth.current
        sidebarOpen = v;
      }
    }}
>

The condition !isMdWidth checks the MediaQuery object itself, which is always truthy. This should be !isMdWidth.current. As a result, when the Dialog opens/closes, sidebarOpen will never update because the condition is always false. This affects mobile sidebar toggle behavior.


⚠️ Observations

  1. Breaking database migration: The migration adds categoryId as a NOT NULL column with a foreign key to productCategory. Existing products in the database would cause this migration to fail unless a default category exists or products are pre-populated. Consider whether a migration script to assign existing products to a default category is needed.

  2. Placeholder UI in list components: The popovers in CategoriesList.svelte, ProductsList.svelte, ProductOptionsList.svelte, and PrintersList.svelte have hardcoded placeholder text ("Modify order", "Edit", "Delete") that isn't wired up. These should either be implemented or removed before merge.

  3. Dead admin link: The sidebar references /admin/receipts ("Comande e scontrini") but this route doesn't exist yet.

  4. Commented-out code: In [productId]/+page.svelte, the AddProductOptionDialog is commented out with <!-- <AddProductOptionDialog>... -->. Consider removing this dead code or implementing the feature.

  5. signOutForm fire-and-forget: The sign-out form is not awaited (<Form form={signOutForm}> instead of <Form form={$derived(signOutForm)}>). This works for fire-and-forget but may cause issues if the Form component expects an awaited form.


Positive Changes

  • Naming consistency: Entity classes renamed from User/Product/Printer to UserClient/ProductClient/PrinterClient — much clearer distinction between server and client entities.
  • Dialog refactoring: Moving Dialog.svelte to the root of #components/ and using the dialog-centered utility class everywhere is a nice cleanup.
  • Category-based product access: Products are now accessed through categories, which is a logical data model improvement.
  • Batch API improvements: The fromId batch queries now properly return 404 errors for missing items instead of null.
  • Type checking: svelte-check passes with 0 errors and 0 warnings.
  • Formatting: All files pass Prettier checks.

📝 Recommendations

  1. Fix the isMdWidth bug before merge — this is a clear regression.
  2. Add migration safeguard for existing products (either assign to a default category or make categoryId nullable with a default).
  3. Remove or implement the placeholder popover actions in list components.
  4. Remove the dead /admin/receipts link or create the route.
  5. Consider removing the commented-out AddProductOptionDialog code.
## PR Review: feat: add sidebar and product categories This is a substantial PR (69 files, +1772/-250 lines) introducing two major features: a **sidebar layout** and **product categories**. Here are my findings: --- ### 🔴 Bug Found **`PageWithSidebar.svelte` — `bind:open` callback checks wrong condition** ```svelte <Dialog bind:open={() => sidebarOpen && !isMdWidth.current, (v) => { if (!isMdWidth) { // ← BUG: should be !isMdWidth.current sidebarOpen = v; } }} > ``` The condition `!isMdWidth` checks the `MediaQuery` object itself, which is always truthy. This should be `!isMdWidth.current`. As a result, when the Dialog opens/closes, `sidebarOpen` will never update because the condition is always `false`. This affects mobile sidebar toggle behavior. --- ### ⚠️ Observations 1. **Breaking database migration**: The migration adds `categoryId` as a `NOT NULL` column with a foreign key to `productCategory`. Existing products in the database would cause this migration to fail unless a default category exists or products are pre-populated. Consider whether a migration script to assign existing products to a default category is needed. 2. **Placeholder UI in list components**: The popovers in `CategoriesList.svelte`, `ProductsList.svelte`, `ProductOptionsList.svelte`, and `PrintersList.svelte` have hardcoded placeholder text ("Modify order", "Edit", "Delete") that isn't wired up. These should either be implemented or removed before merge. 3. **Dead admin link**: The sidebar references `/admin/receipts` ("Comande e scontrini") but this route doesn't exist yet. 4. **Commented-out code**: In `[productId]/+page.svelte`, the `AddProductOptionDialog` is commented out with `<!-- <AddProductOptionDialog>... -->`. Consider removing this dead code or implementing the feature. 5. **`signOutForm` fire-and-forget**: The sign-out form is not awaited (`<Form form={signOutForm}>` instead of `<Form form={$derived(signOutForm)}>`). This works for fire-and-forget but may cause issues if the Form component expects an awaited form. --- ### ✅ Positive Changes - **Naming consistency**: Entity classes renamed from `User`/`Product`/`Printer` to `UserClient`/`ProductClient`/`PrinterClient` — much clearer distinction between server and client entities. - **Dialog refactoring**: Moving `Dialog.svelte` to the root of `#components/` and using the `dialog-centered` utility class everywhere is a nice cleanup. - **Category-based product access**: Products are now accessed through categories, which is a logical data model improvement. - **Batch API improvements**: The `fromId` batch queries now properly return 404 errors for missing items instead of `null`. - **Type checking**: `svelte-check` passes with 0 errors and 0 warnings. - **Formatting**: All files pass Prettier checks. --- ### 📝 Recommendations 1. **Fix the `isMdWidth` bug** before merge — this is a clear regression. 2. **Add migration safeguard** for existing products (either assign to a default category or make `categoryId` nullable with a default). 3. **Remove or implement** the placeholder popover actions in list components. 4. **Remove the dead `/admin/receipts` link** or create the route. 5. Consider removing the commented-out `AddProductOptionDialog` code.
@ -0,0 +115,4 @@
<main class="h-screen w-full">
<header class="flex border-b border-slate-300 p-2 gap-4 items-center">
<Dialog
bind:open={() => sidebarOpen && !isMdWidth.current, (v) => {
Member

Bug: !isMdWidth should be !isMdWidth.current. Since MediaQuery objects are always truthy, sidebarOpen will never be updated when the Dialog opens/closes.

Bug: `!isMdWidth` should be `!isMdWidth.current`. Since `MediaQuery` objects are always truthy, `sidebarOpen` will never be updated when the Dialog opens/closes.
davide merged commit 2bd658e575 into main 2026-07-14 16:54:23 +00:00
davide deleted branch feat/sidebar-and-product-categories 2026-07-14 16:54:23 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
projects/events-cash-register!89
No description provided.