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:
@@ -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`);
|
||||
|
||||
Reference in New Issue
Block a user