refactored showrooms page

This commit is contained in:
2022-09-19 15:58:11 +02:00
parent e5c6b871db
commit 9f20d34f42
23 changed files with 378 additions and 65 deletions

View File

@ -1,7 +1,11 @@
// import JSONAPI from 'vuejs/api/json-axios'
import REST from 'vuejs/api/rest-axios'
// import REST from 'vuejs/api/rest-axios'
// import MA from 'vuejs/api/ma-axios'
// import qs from 'querystring-es3'
import MGQ from 'vuejs/api/graphql-axios'
import { print } from 'graphql/language/printer'
import gql from 'graphql-tag'
import ShowroomFields from 'vuejs/api/gql/showroom.fragment.gql'
export default {
namespaced: true,
@ -20,7 +24,7 @@ export default {
setItems (state, items) {
state.items = items
items.forEach((item, i) => {
state.showrooms_by_tid[item.tid] = item
state.showrooms_by_tid[item.id] = item
})
// console.log('Showroom setitems', state.showrooms_by_tid)
}
@ -28,14 +32,30 @@ export default {
// actions
actions: {
getItems ({ dispatch, commit, state }) {
REST.get('/showrooms_rest?_format=json', {})
.then(({ data }) => {
console.log('showrooms REST: data', data)
commit('setItems', data)
getShowrooms ({ dispatch, commit, state }) {
// REST.get('/showrooms_rest?_format=json', {})
// .then(({ data }) => {
// console.log('showrooms REST: data', data)
// commit('setItems', data)
// })
// .catch((error) => {
// console.warn('Issue with showrooms', error)
// Promise.reject(error)
// })
const ast = gql`{
allshowrooms(lang: "${drupalDecoupled.lang_code}") {
...ShowroomFields
}
}
${ShowroomFields}
`
MGQ.post('', { query: print(ast) })
.then(({ data: { data: { allshowrooms } } }) => {
console.log('loadshowrooms showrooms loaded', allshowrooms)
commit('setItems', allshowrooms)
})
.catch((error) => {
console.warn('Issue with showrooms', error)
.catch(error => {
console.warn('Issue with getShowrooms', error)
Promise.reject(error)
})
}