fix: language can be changed in profile

This commit is contained in:
Moriz Wahl 2021-09-20 11:50:26 +02:00
parent e6d386c598
commit c401344193
3 changed files with 10 additions and 5 deletions

View File

@ -19,7 +19,7 @@ export const resetPassword = gql`
`
export const updateUserInfos = gql`
query(
mutation(
$email: String!
$firstName: String
$lastName: String

View File

@ -74,7 +74,7 @@ export default {
async onSubmit() {
this.$apollo
.mutate({
mutations: updateUserInfos,
mutation: updateUserInfos,
variables: {
email: this.$store.state.email,
password: this.form.password,

View File

@ -29,7 +29,7 @@
<div v-else>
<div>
<b-form @submit.stop.prevent="handleSubmit(onSubmit)">
<b-form @submit.stop.prevent="onSubmit">
<b-row class="mb-2">
<b-col class="col-12">
<small>
@ -64,6 +64,7 @@
<script>
import LanguageSwitchSelect from '../../../components/LanguageSwitchSelect.vue'
import { updateUserInfos } from '../../../graphql/mutations'
import { localeChanged } from 'vee-validate'
export default {
name: 'FormUserLanguage',
@ -87,19 +88,23 @@ export default {
cancelEdit() {
this.showLanguage = true
},
async onSubmit() {
this.$apollo
.mutate({
mutation: updateUserInfos,
variables: {
language: this.$store.state.language,
email: this.$store.state.email,
language: this.language,
},
})
.then(() => {
this.$store.commit('language', this.language)
this.$i18n.locale = this.language
localeChanged(this.language)
this.cancelEdit()
})
.catch((error) => {
this.language = this.$store.state.language
this.$toasted.error(error.message)
})
},