Add per-business modules and home chart slots.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-08-08 10:40:57 +03:30
co-authored by Cursor
parent 0632f67bda
commit 9ca6e2306f
7 changed files with 201 additions and 12 deletions
@@ -10,6 +10,8 @@ import { BusinessSettings } from './business-settings.types';
import {
mergeBusinessSettings,
normalizeBusinessSettings,
normalizeEnabledBusinessModules,
normalizeHomeCharts,
toPrismaJson,
} from './business-settings.util';
import { UpdateBusinessSettingsDto } from './dto/update-business-settings.dto';
@@ -49,6 +51,14 @@ export class BusinessSettingsService {
const businessId = BigInt(businessIdRaw);
await this.assertPermission(businessId, actor.id, 'business.update');
if (dto.modules !== undefined) {
if (!(await this.permissions.isSuperAdmin(actor.id))) {
throw new ForbiddenException(
'Only super admins can change business modules',
);
}
}
const business = await this.prisma.business.findUnique({
where: { id: businessId },
select: { id: true, settings: true },
@@ -98,6 +108,19 @@ export class BusinessSettingsService {
};
}
if (dto.modules) {
patch.modules = {
enabled:
dto.modules.enabled !== undefined
? normalizeEnabledBusinessModules(dto.modules.enabled)
: current.modules.enabled,
charts:
dto.modules.charts !== undefined
? normalizeHomeCharts(dto.modules.charts)
: current.modules.charts,
};
}
const next = mergeBusinessSettings(current, patch);
const updated = await this.prisma.business.update({