feat(admin): implement region renaming functionality and update UI components
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user