feat(admin): implement region renaming functionality and update UI components

This commit is contained in:
Torsten Schulz (local)
2026-08-14 13:50:49 +02:00
parent a6a1ce7726
commit edb40c9785
6 changed files with 244 additions and 0 deletions

View File

@@ -934,6 +934,30 @@ class AdminService {
return region;
}
async updateFalukantRegion(userId, regionId, { name } = {}) {
if (!(await this.hasUserAccess(userId, 'falukantusers'))) {
throw new Error('noaccess');
}
const regionName = String(name || '').trim();
if (!regionName) {
throw new Error('missingName');
}
const region = await RegionData.findByPk(regionId);
if (!region) {
throw new Error('regionNotFound');
}
region.name = regionName;
await region.save();
return RegionData.findByPk(region.id, {
attributes: ['id', 'name', 'map', 'regionTypeId', 'parentId'],
include: [{ model: RegionType, as: 'regionType', attributes: ['id', 'labelTr', 'parentId'] }],
});
}
async deleteFalukantRegion(userId, regionId) {
if (!(await this.hasUserAccess(userId, 'falukantusers'))) {
throw new Error('noaccess');