You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

61 lines
1.5 KiB

<template>
<v-card>
<v-card-title class="headline">
{{ $t('add_wish_header') }}
</v-card-title>
<v-card-subtitle>
<NuxtLink to='/'>{{ $t("add_wish_back") }}</NuxtLink>
</v-card-subtitle>
<v-card-text>
<v-form ref='addform'>
<v-text-field
v-model="wish"
:label="$t('add_wish_placeholder')"
required
:rules="[rules.required]"
></v-text-field>
<v-btn class='mt-4' v-on:click='submitWish' color='primary'>
<v-icon>mdi-plus</v-icon> {{ $t("add_wish_button") }}
</v-btn>
</v-form>
</v-card-text>
</v-card>
</template>
<script>
import { BASE_API_URL, getAxiosConfig } from '@/constants'
export default {
name: 'addwish',
data () {
return {
wish: "",
rules: {
required: value => !!value || 'Bitte einen Wunsch eingeben!',
}
}
},
methods: {
submitWish() {
if(!this.$refs.addform.validate()) {
return
}
this.$axios.post(BASE_API_URL + "/wishes/create", {
wish: this.wish,
}, getAxiosConfig(localStorage.getItem("token"))).then(async response => {
await this.$store.dispatch("wishes/fetchPersonal")
await this.$refs.addform.reset()
await this.$router.push('/')
}).catch(error => {
this.$swal("Fehler", "Überprüfe deine Eingaben und versuchs nochmal. Fehler:<br />" + JSON.stringify(error.response.data), "error")
})
}
}
}
</script>
<style scoped>
</style>