mirror of
https://git.meshkee.com/Meshkee/backend.git
synced 2026-08-11 22:30:59 +04:30
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
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user