u
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -54,6 +54,7 @@ import {
|
||||
* @property {string|null} languageId
|
||||
* @property {Record<string,object>|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,
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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';
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,6 +36,7 @@ export function parseCategoryTreeResponse(data, companyRootCategoryId) {
|
||||
rootCategoryId,
|
||||
categories,
|
||||
languageId: data.languageId,
|
||||
articleCount: typeof data.articleCount === 'number' ? data.articleCount : 0,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user