Fix: Make registration functional in MyE&P after changes in store api

This commit is contained in:
Björn Fromme
2023-03-09 13:39:33 +01:00
parent 6d5246c3aa
commit 49030ba5a7
2 changed files with 10 additions and 8 deletions
@@ -3,7 +3,7 @@
<h1 class="mb-4"> <h1 class="mb-4">
Registrierung MyE&amp;P Registrierung MyE&amp;P
</h1> </h1>
<form @submit.prevent="register()"> <form @submit.prevent="performRegistration()">
<div class="grid grid-cols-1 md:grid-cols-2 gap-x-4 mb-4"> <div class="grid grid-cols-1 md:grid-cols-2 gap-x-4 mb-4">
<form-group label="Vorname" :error="formErrors.firstName"> <form-group label="Vorname" :error="formErrors.firstName">
<input type="text" v-model="userData.firstName" class="border-zinc-400 focus:border-zinc-800 ring-0 focus:ring-0 mt-1 w-full"> <input type="text" v-model="userData.firstName" class="border-zinc-400 focus:border-zinc-800 ring-0 focus:ring-0 mt-1 w-full">
@@ -33,9 +33,9 @@
</form> </form>
</div> </div>
</template> </template>
w
<script> <script>
import { mapState, mapMutations } from 'vuex' import { mapState, mapActions, mapMutations } from 'vuex'
import FormGroup from './components/FormGroup' import FormGroup from './components/FormGroup'
export default { export default {
@@ -55,12 +55,13 @@
}, },
methods: { methods: {
...mapMutations(['alert']), ...mapMutations(['alert']),
register () { ...mapActions(['register']),
performRegistration () {
this.message = ''; this.message = '';
this.formErrors = {}; this.formErrors = {};
this.$store.dispatch('register', this.userData) this.register(this.userData)
.then(response => { .then(response => {
if (response.data.success) { if (response.success) {
this.alert({ this.alert({
message: 'Du erhältst in Kürze eine E-Mail mit einem Link zum (Zurück)setzen deines Passworts.', message: 'Du erhältst in Kürze eine E-Mail mit einem Link zum (Zurück)setzen deines Passworts.',
success: true, success: true,
@@ -79,11 +80,11 @@
}); });
} }
}).catch(error => { }).catch(error => {
const violations = error.response.data.violations; const violations = error.response.violations;
for (let violation of violations) { for (let violation of violations) {
this.$set(this.formErrors, violation.property_path, violation.message); this.$set(this.formErrors, violation.property_path, violation.message);
} }
}); })
} }
}, },
computed: { computed: {
@@ -199,6 +199,7 @@ export default new Vuex.Store({
message: 'Es ist ein Fehler aufgetreten: ' + error.message, message: 'Es ist ein Fehler aufgetreten: ' + error.message,
success: false, success: false,
}) })
throw error
}) })
.finally(() => { .finally(() => {
commit('endLoading') commit('endLoading')