u
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { http, httpBinary, httpGetBinary } from './http.js';
|
import { http, httpBinary, httpGetBinary } from './http.js';
|
||||||
|
|
||||||
export const category = {
|
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
|
// #region GET /api/category/tree — getTree
|
||||||
getTree() {
|
getTree() {
|
||||||
return http('/api/category/tree');
|
return http('/api/category/tree');
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ import {
|
|||||||
* @property {string|null} languageId
|
* @property {string|null} languageId
|
||||||
* @property {Record<string,object>|null} categories id → node map
|
* @property {Record<string,object>|null} categories id → node map
|
||||||
* @property {number|string|null} rootCategoryId
|
* @property {number|string|null} rootCategoryId
|
||||||
|
* @property {number} articleCount Total parent articles in tree
|
||||||
* @property {boolean} renameMode
|
* @property {boolean} renameMode
|
||||||
* @property {'idle'|'loading'|'succeeded'|'failed'} treeStatus
|
* @property {'idle'|'loading'|'succeeded'|'failed'} treeStatus
|
||||||
* @property {string|null} error
|
* @property {string|null} error
|
||||||
@@ -66,6 +67,7 @@ const initialState = {
|
|||||||
languageId: null,
|
languageId: null,
|
||||||
categories: null,
|
categories: null,
|
||||||
rootCategoryId: null,
|
rootCategoryId: null,
|
||||||
|
articleCount: 0,
|
||||||
renameMode: false,
|
renameMode: false,
|
||||||
treeStatus: 'idle',
|
treeStatus: 'idle',
|
||||||
error: null,
|
error: null,
|
||||||
@@ -87,6 +89,8 @@ export function getCategoryState() {
|
|||||||
return { categories: state.categories, rootCategoryId: state.rootCategoryId };
|
return { categories: state.categories, rootCategoryId: state.rootCategoryId };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const selectCategoryTreeArticleCount = () => categoryAutomat.state.articleCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves once the category tree has loaded.
|
* Resolves once the category tree has loaded.
|
||||||
*
|
*
|
||||||
@@ -123,6 +127,7 @@ const actions = {
|
|||||||
languageId: parsed.languageId,
|
languageId: parsed.languageId,
|
||||||
categories: parsed.categories,
|
categories: parsed.categories,
|
||||||
rootCategoryId: parsed.rootCategoryId,
|
rootCategoryId: parsed.rootCategoryId,
|
||||||
|
articleCount: parsed.articleCount,
|
||||||
error: null,
|
error: null,
|
||||||
viewsLoading: true,
|
viewsLoading: true,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -106,8 +106,10 @@ export const selectCompanyId = () => companyAutomat.state.current?.id ?? null;
|
|||||||
export const selectCompanyStatus = () => companyAutomat.state.status;
|
export const selectCompanyStatus = () => companyAutomat.state.status;
|
||||||
export const selectCompanyName = () => companyAutomat.state.current?.name;
|
export const selectCompanyName = () => companyAutomat.state.current?.name;
|
||||||
export const selectCompanyIso639 = () => companyAutomat.state.current?.iso639;
|
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 selectCompanyTaxrate = () => companyAutomat.state.current?.taxrate ?? null;
|
||||||
export const selectCompanyReducedTaxrate = () => companyAutomat.state.current?.reducedtaxrate ?? 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 const selectCompanyRootCategoryId = () => companyAutomat.state.current?.rootCategoryId ?? null;
|
||||||
|
|
||||||
export default companyAutomat;
|
export default companyAutomat;
|
||||||
|
|||||||
@@ -104,8 +104,10 @@ export {
|
|||||||
selectCompanyStatus,
|
selectCompanyStatus,
|
||||||
selectCompanyName,
|
selectCompanyName,
|
||||||
selectCompanyIso639,
|
selectCompanyIso639,
|
||||||
|
selectCompanyLanguageId,
|
||||||
selectCompanyTaxrate,
|
selectCompanyTaxrate,
|
||||||
selectCompanyReducedTaxrate,
|
selectCompanyReducedTaxrate,
|
||||||
|
selectCompanyTaxfreerate,
|
||||||
selectCompanyRootCategoryId,
|
selectCompanyRootCategoryId,
|
||||||
} from './companyAutomat';
|
} from './companyAutomat';
|
||||||
|
|
||||||
@@ -133,6 +135,7 @@ export {
|
|||||||
normalizeCategoryMap,
|
normalizeCategoryMap,
|
||||||
getCategoryState,
|
getCategoryState,
|
||||||
whenCategoryTreeReady,
|
whenCategoryTreeReady,
|
||||||
|
selectCategoryTreeArticleCount,
|
||||||
} from './categoryAutomat';
|
} from './categoryAutomat';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export function parseCategoryTreeResponse(data, companyRootCategoryId) {
|
|||||||
rootCategoryId,
|
rootCategoryId,
|
||||||
categories,
|
categories,
|
||||||
languageId: data.languageId,
|
languageId: data.languageId,
|
||||||
|
articleCount: typeof data.articleCount === 'number' ? data.articleCount : 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export function normalizeCompany(raw, overrides = {}) {
|
|||||||
id: raw.id,
|
id: raw.id,
|
||||||
name: overrides.name !== undefined ? overrides.name : raw.name,
|
name: overrides.name !== undefined ? overrides.name : raw.name,
|
||||||
iso639: overrides.iso639 !== undefined ? overrides.iso639 : raw.iso639,
|
iso639: overrides.iso639 !== undefined ? overrides.iso639 : raw.iso639,
|
||||||
|
languageId: overrides.languageId !== undefined ? overrides.languageId : raw.languageId,
|
||||||
taxrate: overrides.taxrate !== undefined ? overrides.taxrate : raw.taxrate,
|
taxrate: overrides.taxrate !== undefined ? overrides.taxrate : raw.taxrate,
|
||||||
reducedtaxrate: overrides.reducedtaxrate !== undefined ? overrides.reducedtaxrate : raw.reducedtaxrate,
|
reducedtaxrate: overrides.reducedtaxrate !== undefined ? overrides.reducedtaxrate : raw.reducedtaxrate,
|
||||||
taxfreerate: overrides.taxfreerate !== undefined ? overrides.taxfreerate : raw.taxfreerate,
|
taxfreerate: overrides.taxfreerate !== undefined ? overrides.taxfreerate : raw.taxfreerate,
|
||||||
|
|||||||
Reference in New Issue
Block a user