Implement age validation for political applications in FalukantService: Added MIN_AGE_POLITICS_DAYS constant and logic to check user age before allowing applications. Updated PoliticsView to reflect age eligibility and display appropriate hints. Enhanced error handling for age-related restrictions.
This commit is contained in:
@@ -1030,8 +1030,10 @@
|
||||
"date": "Datum",
|
||||
"candidacy": "Kandidatur",
|
||||
"none": "Keine offenen Positionen.",
|
||||
"apply": "Für ausgewählte Positionen kandidieren"
|
||||
"apply": "Für ausgewählte Positionen kandidieren",
|
||||
"minAgeHint": "Kandidatur erst ab 16 Jahren möglich."
|
||||
},
|
||||
"too_young": "Dein Charakter ist noch zu jung. Eine Bewerbung ist erst ab 16 Jahren möglich.",
|
||||
"upcoming": {
|
||||
"office": "Amt",
|
||||
"region": "Region",
|
||||
|
||||
@@ -364,8 +364,10 @@
|
||||
"date": "Date",
|
||||
"candidacy": "Candidacy",
|
||||
"none": "No open positions.",
|
||||
"apply": "Apply for selected positions"
|
||||
"apply": "Apply for selected positions",
|
||||
"minAgeHint": "Candidacy is only possible from age 16."
|
||||
},
|
||||
"too_young": "Your character is too young. Applications are only possible from age 16.",
|
||||
"upcoming": {
|
||||
"office": "Office",
|
||||
"region": "Region",
|
||||
|
||||
@@ -74,13 +74,13 @@
|
||||
<td>{{ e.region.name }}</td>
|
||||
<td>{{ formatDate(e.date) }}</td>
|
||||
<!-- Checkbox ganz am Ende -->
|
||||
<td>
|
||||
<td :title="e.canApplyByAge === false ? $t('falukant.politics.open.minAgeHint') : null">
|
||||
<input
|
||||
type="checkbox"
|
||||
:id="`apply-${e.id}`"
|
||||
v-model="selectedApplications"
|
||||
:value="e.id"
|
||||
:disabled="e.alreadyApplied"
|
||||
:disabled="e.alreadyApplied || e.canApplyByAge === false"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -389,6 +389,10 @@ export default {
|
||||
.map(e => e.id);
|
||||
} catch (err) {
|
||||
console.error('Error submitting applications', err);
|
||||
const msg = err?.response?.data?.error === 'too_young'
|
||||
? this.$t('falukant.politics.too_young')
|
||||
: (err?.response?.data?.error || err?.message || this.$t('falukant.politics.applyError'));
|
||||
this.$root.$refs?.messageDialog?.open?.(msg, this.$t('falukant.politics.title'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user