Implementation of the Community in the backend.

This commit is contained in:
elweyn 2021-10-01 12:58:47 +02:00
parent c4840fc83d
commit b66e0243ed
3 changed files with 90 additions and 42 deletions

View File

@ -104,3 +104,26 @@ export const checkEmailQuery = gql`
} }
} }
` `
export const serverInformation = gql`
query {
serverInformation {
community {
name
description
}
}
}
`
export const communities = gql`
query {
communities {
id
name
url
description
registerUrl
}
}
`

View File

@ -29,6 +29,9 @@ export const mutations = {
newsletterState: (state, newsletterState) => { newsletterState: (state, newsletterState) => {
state.newsletterState = newsletterState state.newsletterState = newsletterState
}, },
community: (state, community) => {
state.community = community
},
} }
export const actions = { export const actions = {
@ -40,6 +43,7 @@ export const actions = {
commit('lastName', data.lastName) commit('lastName', data.lastName)
commit('description', data.description) commit('description', data.description)
commit('newsletterState', data.klickTipp.newsletterState) commit('newsletterState', data.klickTipp.newsletterState)
commit('community', data.community)
}, },
logout: ({ commit, state }) => { logout: ({ commit, state }) => {
commit('token', null) commit('token', null)
@ -49,6 +53,7 @@ export const actions = {
commit('lastName', '') commit('lastName', '')
commit('description', '') commit('description', '')
commit('newsletterState', null) commit('newsletterState', null)
commit('community', null)
localStorage.clear() localStorage.clear()
}, },
} }
@ -68,12 +73,7 @@ export const store = new Vuex.Store({
description: '', description: '',
token: null, token: null,
newsletterState: null, newsletterState: null,
community: { community: null,
name: 'Gradido Entwicklung',
url: 'http://localhost:3000/vue/',
registerUrl: 'http://localhost:3000/vue/register',
description: 'Die lokale Entwicklungsumgebung von Gradido.',
},
}, },
getters: {}, getters: {},
// Syncronous mutation of the state // Syncronous mutation of the state

View File

@ -3,43 +3,45 @@
<b-container class="text-center"> <b-container class="text-center">
<div class="pb-3">{{ $t('community.current-community') }}</div> <div class="pb-3">{{ $t('community.current-community') }}</div>
<div v-for="community in communities.community" :key="community.name"> <div v-if="!pending">
<b-card <div v-for="community in communities" :key="community.name">
v-if="community.name === $store.state.community.name" <b-card
class="border-0 mb-0" v-if="community.name === $store.state.community.name"
bg-variant="primary" class="border-0 mb-0"
> bg-variant="primary"
<b>{{ community.name }}</b> >
<br /> <b>{{ community.name }}</b>
{{ $store.state.community.description }} <br />
<br /> {{ $store.state.community.description }}
<b-button variant="outline-secondary" to="/register"> <br />
{{ $t('community.continue-to-registration') }} <b-button variant="outline-secondary" to="/register">
</b-button> {{ $t('community.continue-to-registration') }}
</b-card> </b-button>
</div> </b-card>
</div>
<hr /> <hr />
<div>{{ $t('community.other-communities') }}</div> <div>{{ $t('community.other-communities') }}</div>
<div v-for="community in communities.community" :key="community.id" class="pb-3"> <div v-for="community in communities" :key="community.id" class="pb-3">
<b-card v-if="community.name != $store.state.community.name" bg-variant="secondary"> <b-card v-if="community.name != $store.state.community.name" bg-variant="secondary">
<b>{{ community.name }}</b> <b>{{ community.name }}</b>
<br /> <br />
{{ community.description }} {{ community.description }}
<br /> <br />
{{ $t('community.location') }} {{ $t('community.location') }}
<b> <b>
<small> <small>
<b-link :href="community.url">{{ community.url }}</b-link> <b-link :href="community.url">{{ community.url }}</b-link>
</small> </small>
</b> </b>
<br /> <br />
<b-button variant="outline-secondary" :href="community.url"> <b-button variant="outline-secondary" :href="community.url">
{{ $t('community.switch-to-this-community') }} {{ $t('community.switch-to-this-community') }}
</b-button> </b-button>
</b-card> </b-card>
</div>
</div> </div>
<div class="text-center py-lg-4"> <div class="text-center py-lg-4">
@ -49,15 +51,38 @@
</div> </div>
</template> </template>
<script> <script>
import MyCommunities from '../../../public/json-example/communities.json' import communities from '../../graphql/queries'
export default { export default {
name: 'registerSelectCommunity', name: 'registerSelectCommunity',
data() { data() {
return { return {
communities: MyCommunities, communities: [],
pending: true,
} }
}, },
methods: {
async getCommunities() {
const loader = this.$loading.show({
container: this.$refs.header,
})
this.$apollo
.query({
query: communities,
})
.then((response) => {
this.communities = response.data.communities
})
.catch((error) => {
this.$toasted.error(error.message)
})
loader.hide()
this.pending = false
},
},
created() {
this.getCommunities()
},
} }
</script> </script>
<style> <style>