Enhance supervisor office validation in falukantService: Update error handling to provide clearer messages when no supervisor position exists or when the position is vacant. This change improves user feedback during application processes by ensuring users understand the requirements for supervisor office fulfillment.

This commit is contained in:
Torsten Schulz (local)
2026-01-31 00:23:20 +01:00
parent 067273d428
commit 4bf1bc35ae

View File

@@ -5583,7 +5583,7 @@ ORDER BY r.id`,
{
model: ChurchOfficeType,
as: 'type',
attributes: ['hierarchyLevel']
attributes: ['id', 'name', 'hierarchyLevel']
},
{
model: FalukantCharacter,
@@ -5597,8 +5597,12 @@ ORDER BY r.id`,
limit: 1
});
if (!supervisorOffice || !supervisorOffice.holder) {
throw new Error('No supervisor found for this position');
if (!supervisorOffice) {
throw new Error('No supervisor position exists in this region. Higher church offices must be filled before you can apply.');
}
if (!supervisorOffice.holder) {
const officeName = supervisorOffice.type?.name || 'higher';
throw new Error(`The ${officeName} position in this region is vacant. It must be filled before you can apply.`);
}
supervisorId = supervisorOffice.holder.id;
} else {