From e96bfb062407a258ac7c738ef9278007b7c38a13 Mon Sep 17 00:00:00 2001 From: seb Date: Sun, 2 Aug 2026 19:02:10 +0200 Subject: [PATCH] u --- README.md | 10 +++++----- src/sql/category.js | 1 + src/store/category/createUnderParent.js | 1 + src/store/category/rename.js | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 48230b3..a3ed70f 100644 --- a/README.md +++ b/README.md @@ -186,10 +186,10 @@ Company-scoped brands. Auth via `resolveCompanyAccess`. | Method | Signature | Returns | | --- | --- | --- | -| `createUnderParent` | `({ googleAuthId, parentId, name })` | `{ id, parentId, sort, name }` | -| `rename` | `({ googleAuthId, id, name })` | `{ id, name }` | +| `createUnderParent` | `({ googleAuthId, parentId, name })` | `{ id, parentId, sort, name, slug }` | +| `rename` | `({ googleAuthId, id, name })` | `{ id, name, slug }` | | `delete` | `({ googleAuthId, id })` | `void` — blocked by FK if `categoryarticle` or child categories remain | -| `getTreeForCompany` | `(googleAuthId, companyId)` | `{ languageId, tree, articles }` | +| `getTreeForCompany` | `(googleAuthId, companyId)` | `{ languageId, tree, articles }` — tree rows carry `name` + `slug` | | `getCategoryArticles` | `(googleAuthId, categoryId)` | `{ id, sku, name, slug, net, taxRate, optionsCount, articleListCount, childCount, fatherArticleId, fatherSku, fullHash, thumbW, thumbH, thumbHash }[]` | ### `createUnderParent` (transaction) @@ -197,11 +197,11 @@ Company-scoped brands. Auth via `resolveCompanyAccess`. 1. `parentId` exists, else `Parent not found` 2. Walk ancestors to root; find `company` with `root_category_id` = root 3. `companyuser` for `(googleAuthId, companyId)`, else `Not authorized` -4. Insert `category` (next sibling `sort`) + `categorytext` (`name`, slugified `slug`, company default language) +4. Insert `category` (next sibling `sort`) + `categorytext` (`name`, slugified `slug`, company default language); returns `{ id, parentId, sort, name, slug }` `getTreeForCompany` throws `Not authorized` if `googleAuthId` is not a `companyuser` of `companyId`, and `Company not found` if the company is missing, has no `root_category_id`, or no `default_language_id`. -`rename` updates the `categorytext` name (and re-slugifies `slug`) for the category in the company default language. Empty name → `Name required`. Auth via `resolveCategoryAccess` on the category (`Parent not found` / `Not authorized`). Missing text row → `Category not found`. Returns `{ id, name }`. For `PATCH /api/category/:id`. +`rename` updates the `categorytext` name (and re-slugifies `slug`) for the category in the company default language. Empty name → `Name required`. Auth via `resolveCategoryAccess` on the category (`Parent not found` / `Not authorized`). Missing text row → `Category not found`. Returns `{ id, name, slug }`. For `PATCH /api/category/:id`. --- diff --git a/src/sql/category.js b/src/sql/category.js index 478f2f6..b1ca810 100644 --- a/src/sql/category.js +++ b/src/sql/category.js @@ -15,6 +15,7 @@ SELECT t.parent_id AS parentId, t.sort, ct.name, + ct.slug, p.thumbw AS thumbW, p.thumbh AS thumbH, p.thumbhash AS thumbHash diff --git a/src/store/category/createUnderParent.js b/src/store/category/createUnderParent.js index f5864f3..7ea1bde 100644 --- a/src/store/category/createUnderParent.js +++ b/src/store/category/createUnderParent.js @@ -54,6 +54,7 @@ export default function createUnderParent(pool) { parentId: resolvedParentId, sort, name, + slug, }; } catch (err) { try { diff --git a/src/store/category/rename.js b/src/store/category/rename.js index e161bd8..37c6ca9 100644 --- a/src/store/category/rename.js +++ b/src/store/category/rename.js @@ -36,6 +36,6 @@ export default function rename(pool) { throw new Error('Category not found'); } - return { id, name: cleaned }; + return { id, name: cleaned, slug }; }; }