Skip to content

Commit

Permalink
[Clean] remplace mainNavigation by mainNavigations
Browse files Browse the repository at this point in the history
  • Loading branch information
MelanieMEB committed Oct 13, 2020
1 parent 3f8d686 commit d9dcb13
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions components/NavigationSliceZone.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ export default {
)
},
...mapState(['mainNavigation', 'organizationNavItems']),
...mapState(['mainNavigations', 'organizationNavItems']),
usedMainNavigation() {
const groupBySite = groupBy(this.mainNavigation, 'data.navigation_for')
const groupBySite = groupBy(this.mainNavigations, 'data.navigation_for')
if (this.isPixPro && groupBySite['pix-pro']) {
return groupBySite['pix-pro'][0]
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/i18n.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function ({ app: { $prismic, i18n, store } }) {
i18n.onLanguageSwitched = () => {
store.dispatch('updateNavigation', { prismic: $prismic, i18n })
store.dispatch('updateMainNavigation', { prismic: $prismic, i18n })
store.dispatch('updateMainNavigations', { prismic: $prismic, i18n })
}
}
16 changes: 8 additions & 8 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ export const state = () => ({
aboutNavItems: [],
hotNews: null,
host: null,
mainNavigation: [],
mainNavigations: [],
})
export const actions = {
async nuxtServerInit({ commit }, { app, req }) {
commit('updateNavigation', await getNavigation(app.$prismic, app.i18n))
commit(
'updateMainNavigation',
await getMainNavigation(app.$prismic, app.i18n)
'updateMainNavigations',
await getMainNavigations(app.$prismic, app.i18n)
)
commit('updateHotNews', await getHotNews(app.$prismic, app.i18n))
commit('updateHost', req)
},
async updateNavigation({ commit }, { i18n, prismic }) {
commit('updateNavigation', await getNavigation(prismic, i18n))
},
async updateMainNavigation({ commit }, { i18n, prismic }) {
commit('updateMainNavigation', await getMainNavigation(prismic, i18n))
async updateMainNavigations({ commit }, { i18n, prismic }) {
commit('updateMainNavigations', await getMainNavigation(prismic, i18n))
},
}
export const mutations = {
Expand Down Expand Up @@ -50,8 +50,8 @@ export const mutations = {
state.resourcesNavItems = navItems(navigations, 'ressources-nav')
state.aboutNavItems = navItems(navigations, 'about-nav')
},
updateMainNavigation(state, navigations) {
state.mainNavigation = navigations
updateMainNavigations(state, navigations) {
state.mainNavigations = [...navigations]
},
updateHotNews(state, hotNews) {
state.hotNews = hotNews && hotNews.data ? hotNews.data.description : null
Expand All @@ -62,7 +62,7 @@ function getNavigation(prismic, i18n) {
return documentFetcher(prismic, i18n).get(documents.navigation)
}

function getMainNavigation(prismic, i18n) {
function getMainNavigations(prismic, i18n) {
return documentFetcher(prismic, i18n).findByType(documents.mainNavigation)
}

Expand Down
10 changes: 5 additions & 5 deletions tests/components/slices/NavigationSliceZone.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('NavigationSliceZone', () => {
beforeEach(() => {
store = {
state: {
mainNavigation: [expectedSiteNavigation, expectedProNavigation],
mainNavigations: [expectedSiteNavigation, expectedProNavigation],
},
}
})
Expand Down Expand Up @@ -99,7 +99,7 @@ describe('NavigationSliceZone', () => {
}
store = {
state: {
mainNavigation: [expectedSiteNavigation, expectedProNavigation],
mainNavigations: [expectedSiteNavigation, expectedProNavigation],
},
}
})
Expand Down Expand Up @@ -128,7 +128,7 @@ describe('NavigationSliceZone', () => {
}
store = {
state: {
mainNavigation: [expectedSiteNavigation],
mainNavigations: [expectedSiteNavigation],
},
}
})
Expand Down Expand Up @@ -160,7 +160,7 @@ describe('NavigationSliceZone', () => {

store = {
state: {
mainNavigation: [expectedSiteNavigation, expectedProNavigation],
mainNavigations: [expectedSiteNavigation, expectedProNavigation],
},
}
})
Expand Down Expand Up @@ -190,7 +190,7 @@ describe('NavigationSliceZone', () => {

store = {
state: {
mainNavigation: [expectedSiteNavigation],
mainNavigations: [expectedSiteNavigation],
},
}
})
Expand Down

0 comments on commit d9dcb13

Please sign in to comment.