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>
|
<script>
|
||||||
import InputPassword from '../../components/Inputs/InputPassword'
|
import InputPassword from '../../components/Inputs/InputPassword'
|
||||||
import InputEmail from '../../components/Inputs/InputEmail'
|
import InputEmail from '../../components/Inputs/InputEmail'
|
||||||
import { login, communityInfo } from '../../graphql/queries'
|
import { login } from '../../graphql/queries'
|
||||||
|
import { getCommunityInfo } from '../../mixin/getCommunityInfo'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'login',
|
name: 'login',
|
||||||
@ -70,6 +71,7 @@ export default {
|
|||||||
InputPassword,
|
InputPassword,
|
||||||
InputEmail,
|
InputEmail,
|
||||||
},
|
},
|
||||||
|
mixins: [getCommunityInfo],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
form: {
|
form: {
|
||||||
@ -107,21 +109,6 @@ export default {
|
|||||||
this.$toasted.error(this.$t('error.no-account'))
|
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>
|
</script>
|
||||||
|
|||||||
@ -161,11 +161,12 @@ import InputEmail from '../../components/Inputs/InputEmail.vue'
|
|||||||
import InputPasswordConfirmation from '../../components/Inputs/InputPasswordConfirmation.vue'
|
import InputPasswordConfirmation from '../../components/Inputs/InputPasswordConfirmation.vue'
|
||||||
import LanguageSwitchSelect from '../../components/LanguageSwitchSelect.vue'
|
import LanguageSwitchSelect from '../../components/LanguageSwitchSelect.vue'
|
||||||
import { registerUser } from '../../graphql/mutations'
|
import { registerUser } from '../../graphql/mutations'
|
||||||
import { communityInfo } from '../../graphql/queries'
|
import { getCommunityInfo } from '../../mixin/getCommunityInfo'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { InputPasswordConfirmation, InputEmail, LanguageSwitchSelect },
|
components: { InputPasswordConfirmation, InputEmail, LanguageSwitchSelect },
|
||||||
name: 'register',
|
name: 'register',
|
||||||
|
mixins: [getCommunityInfo],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
form: {
|
form: {
|
||||||
@ -229,20 +230,6 @@ export default {
|
|||||||
this.form.password.passwordRepeat = ''
|
this.form.password.passwordRepeat = ''
|
||||||
this.language = ''
|
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: {
|
computed: {
|
||||||
namesFilled() {
|
namesFilled() {
|
||||||
@ -257,9 +244,6 @@ export default {
|
|||||||
return this.form.email !== ''
|
return this.form.email !== ''
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
|
||||||
this.onCreated()
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style></style>
|
<style></style>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user