From 6b0839639d794e223fc879f9ef6609def662486c Mon Sep 17 00:00:00 2001 From: seb Date: Mon, 12 Oct 2026 18:41:53 +0200 Subject: [PATCH] u --- src/api/category.js | 2 +- src/automats/categoryAutomat.js | 5 +++++ src/automats/companyAutomat.js | 2 ++ src/automats/index.js | 3 +++ src/utils/categoryUtils.js | 1 + src/utils/companyForm.js | 1 + 6 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/api/category.js b/src/api/category.js index 57c0fcb..f33e119 100644 --- a/src/api/category.js +++ b/src/api/category.js @@ -1,7 +1,7 @@ import { http, httpBinary, httpGetBinary } from './http.js'; export const category = { - /** GET /api/category/tree → { languageId, tree, articles } (company from session) */ + /** GET /api/category/tree → { languageId, tree, articleCount } (company from session) */ // #region GET /api/category/tree — getTree getTree() { return http('/api/category/tree'); diff --git a/src/automats/categoryAutomat.js b/src/automats/categoryAutomat.js index 17ea138..1844670 100644 --- a/src/automats/categoryAutomat.js +++ b/src/automats/categoryAutomat.js @@ -54,6 +54,7 @@ import { * @property {string|null} languageId * @property {Record|null} categories id → node map * @property {number|string|null} rootCategoryId + * @property {number} articleCount Total parent articles in tree * @property {boolean} renameMode * @property {'idle'|'loading'|'succeeded'|'failed'} treeStatus * @property {string|null} error @@ -66,6 +67,7 @@ const initialState = { languageId: null, categories: null, rootCategoryId: null, + articleCount: 0, renameMode: false, treeStatus: 'idle', error: null, @@ -87,6 +89,8 @@ export function getCategoryState() { return { categories: state.categories, rootCategoryId: state.rootCategoryId }; } +export const selectCategoryTreeArticleCount = () => categoryAutomat.state.articleCount; + /** * Resolves once the category tree has loaded. * @@ -123,6 +127,7 @@ const actions = { languageId: parsed.languageId, categories: parsed.categories, rootCategoryId: parsed.rootCategoryId, + articleCount: parsed.articleCount, error: null, viewsLoading: true, }); diff --git a/src/automats/companyAutomat.js b/src/automats/companyAutomat.js index 2ffa587..2436095 100644 --- a/src/automats/companyAutomat.js +++ b/src/automats/companyAutomat.js @@ -106,8 +106,10 @@ export const selectCompanyId = () => companyAutomat.state.current?.id ?? null; export const selectCompanyStatus = () => companyAutomat.state.status; export const selectCompanyName = () => companyAutomat.state.current?.name; export const selectCompanyIso639 = () => companyAutomat.state.current?.iso639; +export const selectCompanyLanguageId = () => companyAutomat.state.current?.languageId ?? null; export const selectCompanyTaxrate = () => companyAutomat.state.current?.taxrate ?? null; export const selectCompanyReducedTaxrate = () => companyAutomat.state.current?.reducedtaxrate ?? null; +export const selectCompanyTaxfreerate = () => companyAutomat.state.current?.taxfreerate ?? null; export const selectCompanyRootCategoryId = () => companyAutomat.state.current?.rootCategoryId ?? null; export default companyAutomat; diff --git a/src/automats/index.js b/src/automats/index.js index 3d47402..fab1ef1 100644 --- a/src/automats/index.js +++ b/src/automats/index.js @@ -104,8 +104,10 @@ export { selectCompanyStatus, selectCompanyName, selectCompanyIso639, + selectCompanyLanguageId, selectCompanyTaxrate, selectCompanyReducedTaxrate, + selectCompanyTaxfreerate, selectCompanyRootCategoryId, } from './companyAutomat'; @@ -133,6 +135,7 @@ export { normalizeCategoryMap, getCategoryState, whenCategoryTreeReady, + selectCategoryTreeArticleCount, } from './categoryAutomat'; /** diff --git a/src/utils/categoryUtils.js b/src/utils/categoryUtils.js index be25186..0051213 100644 --- a/src/utils/categoryUtils.js +++ b/src/utils/categoryUtils.js @@ -36,6 +36,7 @@ export function parseCategoryTreeResponse(data, companyRootCategoryId) { rootCategoryId, categories, languageId: data.languageId, + articleCount: typeof data.articleCount === 'number' ? data.articleCount : 0, }; } diff --git a/src/utils/companyForm.js b/src/utils/companyForm.js index 0a75d12..23b1696 100644 --- a/src/utils/companyForm.js +++ b/src/utils/companyForm.js @@ -17,6 +17,7 @@ export function normalizeCompany(raw, overrides = {}) { id: raw.id, name: overrides.name !== undefined ? overrides.name : raw.name, iso639: overrides.iso639 !== undefined ? overrides.iso639 : raw.iso639, + languageId: overrides.languageId !== undefined ? overrides.languageId : raw.languageId, taxrate: overrides.taxrate !== undefined ? overrides.taxrate : raw.taxrate, reducedtaxrate: overrides.reducedtaxrate !== undefined ? overrides.reducedtaxrate : raw.reducedtaxrate, taxfreerate: overrides.taxfreerate !== undefined ? overrides.taxfreerate : raw.taxfreerate,