Add per-business modules and home chart slots.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
0632f67bda
commit
9ca6e2306f
@@ -25,8 +25,18 @@ import { normalizeBusinessPrimaryColorId } from '../business-settings/business-p
|
||||
import type { BusinessPrimaryColorId } from '../business-settings/business-primary-colors';
|
||||
import {
|
||||
normalizeDashboardLocale,
|
||||
normalizeEnabledBusinessModules,
|
||||
normalizeHomeCharts,
|
||||
} from '../business-settings/business-settings.util';
|
||||
import type { DashboardLocale } from '../business-settings/business-settings.types';
|
||||
import type {
|
||||
BusinessModuleId,
|
||||
DashboardLocale,
|
||||
HomeChartId,
|
||||
} from '../business-settings/business-settings.types';
|
||||
import {
|
||||
DEFAULT_ENABLED_BUSINESS_MODULES,
|
||||
DEFAULT_HOME_CHARTS,
|
||||
} from '../business-settings/business-settings.types';
|
||||
|
||||
type BusinessRow = {
|
||||
id: bigint;
|
||||
@@ -46,6 +56,8 @@ type BusinessRow = {
|
||||
ownerCellNumber: string | null;
|
||||
primaryColor: string | null;
|
||||
defaultLocale: string | null;
|
||||
enabledModules: unknown;
|
||||
homeCharts: unknown;
|
||||
};
|
||||
|
||||
function slugify(value: string) {
|
||||
@@ -121,7 +133,9 @@ export class BusinessAdminService {
|
||||
own."ownerNameEn" AS "ownerNameEn",
|
||||
own."ownerCellNumber" AS "ownerCellNumber",
|
||||
b.settings->'branding'->>'primaryColor' AS "primaryColor",
|
||||
b.settings->'branding'->>'defaultLocale' AS "defaultLocale"
|
||||
b.settings->'branding'->>'defaultLocale' AS "defaultLocale",
|
||||
b.settings->'modules'->'enabled' AS "enabledModules",
|
||||
b.settings->'modules'->'charts' AS "homeCharts"
|
||||
FROM businesses b
|
||||
LEFT JOIN LATERAL (
|
||||
SELECT d.id, d.host, d.ssl_enabled
|
||||
@@ -153,15 +167,34 @@ export class BusinessAdminService {
|
||||
]);
|
||||
|
||||
return {
|
||||
items: items.map((item) => ({
|
||||
...item,
|
||||
primaryColor: normalizeBusinessPrimaryColorId(
|
||||
item.primaryColor,
|
||||
) as BusinessPrimaryColorId,
|
||||
defaultLocale: normalizeDashboardLocale(
|
||||
item.defaultLocale,
|
||||
) as DashboardLocale,
|
||||
})),
|
||||
items: items.map((item) => {
|
||||
const {
|
||||
enabledModules: rawEnabledModules,
|
||||
homeCharts: rawHomeCharts,
|
||||
...rest
|
||||
} = item;
|
||||
const enabledModules: BusinessModuleId[] =
|
||||
rawEnabledModules == null
|
||||
? [...DEFAULT_ENABLED_BUSINESS_MODULES]
|
||||
: normalizeEnabledBusinessModules(rawEnabledModules);
|
||||
const homeCharts: [HomeChartId, HomeChartId] =
|
||||
rawHomeCharts == null
|
||||
? [...DEFAULT_HOME_CHARTS]
|
||||
: normalizeHomeCharts(rawHomeCharts);
|
||||
|
||||
return {
|
||||
...rest,
|
||||
primaryColor: normalizeBusinessPrimaryColorId(
|
||||
item.primaryColor,
|
||||
) as BusinessPrimaryColorId,
|
||||
defaultLocale: normalizeDashboardLocale(
|
||||
item.defaultLocale,
|
||||
) as DashboardLocale,
|
||||
enabledModules,
|
||||
moduleCount: enabledModules.length,
|
||||
homeCharts,
|
||||
};
|
||||
}),
|
||||
total: totalRow[0]?.total ?? 0,
|
||||
page,
|
||||
pageSize,
|
||||
|
||||
Reference in New Issue
Block a user