mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Withdrew duplicate code and wrote a mixin for it.
This commit is contained in:
parent
183d25dde4
commit
c0fc927c23
18
frontend/src/mixin/getCommunityInfo.js
Normal file
18
frontend/src/mixin/getCommunityInfo.js
Normal file
@ -0,0 +1,18 @@
|
||||
import { communityInfo } from '../graphql/queries'
|
||||
|
||||
export const getCommunityInfo = {
|
||||
created() {
|
||||
if (!this.$store.state.community) {
|
||||
this.$apollo
|
||||
.query({
|
||||
query: communityInfo,
|
||||
})
|
||||
.then((result) => {
|
||||
this.$store.commit('community', result.data.getCommunityInfo)
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$toasted.error(error.message)
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
@ -62,7 +62,8 @@
|
||||
<script>
|
||||
import InputPassword from '../../components/Inputs/InputPassword'
|
||||
import InputEmail from '../../components/Inputs/InputEmail'
|
||||
import { login, communityInfo } from '../../graphql/queries'
|
||||
import { login } from '../../graphql/queries'
|
||||
import { getCommunityInfo } from '../../mixin/getCommunityInfo'
|
||||
|
||||
export default {
|
||||
name: 'login',
|
||||
@ -70,6 +71,7 @@ export default {
|
||||
InputPassword,
|
||||
InputEmail,
|
||||
},
|
||||
mixins: [getCommunityInfo],
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
@ -107,21 +109,6 @@ export default {
|
||||
this.$toasted.error(this.$t('error.no-account'))
|
||||
})
|
||||
},
|
||||
async onCreated() {
|
||||
this.$apollo
|
||||
.query({
|
||||
query: communityInfo,
|
||||
})
|
||||
.then((result) => {
|
||||
this.$store.commit('community', result.data.getCommunityInfo)
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$toasted.error(error.message)
|
||||
})
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.onCreated()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -161,11 +161,12 @@ import InputEmail from '../../components/Inputs/InputEmail.vue'
|
||||
import InputPasswordConfirmation from '../../components/Inputs/InputPasswordConfirmation.vue'
|
||||
import LanguageSwitchSelect from '../../components/LanguageSwitchSelect.vue'
|
||||
import { registerUser } from '../../graphql/mutations'
|
||||
import { communityInfo } from '../../graphql/queries'
|
||||
import { getCommunityInfo } from '../../mixin/getCommunityInfo'
|
||||
|
||||
export default {
|
||||
components: { InputPasswordConfirmation, InputEmail, LanguageSwitchSelect },
|
||||
name: 'register',
|
||||
mixins: [getCommunityInfo],
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
@ -229,20 +230,6 @@ export default {
|
||||
this.form.password.passwordRepeat = ''
|
||||
this.language = ''
|
||||
},
|
||||
async onCreated() {
|
||||
if (!this.$state.store.community) {
|
||||
this.$apollo
|
||||
.query({
|
||||
query: communityInfo,
|
||||
})
|
||||
.then((result) => {
|
||||
this.$store.commit('community', result.data.getCommunityInfo)
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$toasted.error(error.message)
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
namesFilled() {
|
||||
@ -257,9 +244,6 @@ export default {
|
||||
return this.form.email !== ''
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.onCreated()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style></style>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user