Füge Funktion zum Abbrechen der Werbung hinzu: Implementiere cancelWooing in FalukantService und FalukantController, aktualisiere FamilyView für die Benutzeroberfläche und verbessere die Fehlermeldungen bei vorzeitigen Abbrüchen.

This commit is contained in:
Torsten Schulz (local)
2026-01-28 11:53:34 +01:00
parent 16f3d1a320
commit cbff7c130c
8 changed files with 119 additions and 7 deletions

View File

@@ -82,9 +82,9 @@
</tr>
</tbody>
</table>
<div>
<button @click="sendGift" class="button">{{ $t('falukant.family.spouse.wooing.sendGift')
}}</button>
<div class="wooing-actions">
<button @click="sendGift" class="button">{{ $t('falukant.family.spouse.wooing.sendGift') }}</button>
<button @click="cancelWooing" class="button button-secondary">{{ $t('falukant.family.spouse.wooing.cancel') }}</button>
</div>
</div>
</div>
@@ -341,6 +341,24 @@ export default {
}
},
async cancelWooing() {
try {
await apiClient.post('/api/falukant/family/cancel-wooing');
await this.loadFamilyData();
this.$root.$refs.messageDialog?.open('tr:falukant.family.spouse.wooing.cancelSuccess');
} catch (error) {
console.error('Error cancelling wooing:', error);
if (error?.response?.status === 412) {
const retryAtIso = error.response?.data?.retryAt;
const retryStr = retryAtIso ? new Date(retryAtIso).toLocaleString(navigator.language, { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }) : '';
const msg = this.$t('falukant.family.spouse.wooing.cancelTooSoon');
this.$root.$refs.errorDialog?.open(retryStr ? `${msg}${this.$t('falukant.family.sendgift.nextGiftAt')}: ${retryStr}` : msg);
} else {
this.$root.$refs.errorDialog?.open('tr:falukant.family.spouse.wooing.cancelError');
}
}
},
async sendGift() {
if (!this.selectedGiftId) {
this.$root.$refs.errorDialog.open(`tr:falukant.family.sendgift.error.nogiftselected`);