Skip to content

Commit

Permalink
Showing 5 changed files with 49 additions and 82 deletions.
18 changes: 12 additions & 6 deletions components/FooterSliceZone.vue
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
<footer class="footer" role="contentinfo">
<div class="footer__left">
<div
v-for="(slice, index) in usedMainFooter.data.body"
v-for="(slice, index) in usedMainFooter"
:key="`footer-slice-left-${index}`"
>
<template v-if="slice.slice_type === 'logos_zone'">
@@ -42,33 +42,39 @@
</template>

<script>
import { mapState } from 'vuex'
import { keyBy } from '~/services/key-by'
import { documentFetcher, documents } from '~/services/document-fetcher'
export default {
name: 'FooterSliceZone',
data() {
return {
socialMediasHoverMap: {},
mainFooters: null,
}
},
async fetch() {
this.mainFooters = await documentFetcher(
this.$prismic,
this.$i18n
).findByType(documents.mainFooter)
},
computed: {
isPixPro() {
return process.env.isPixPro
},
...mapState(['mainFooters']),
usedMainFooter() {
const mainFooterBySite = keyBy(
this.mainFooters,
(mainFooter) => mainFooter?.data?.footer_for
)
if (this.isPixPro && mainFooterBySite['pix-pro']) {
return mainFooterBySite['pix-pro']
return mainFooterBySite['pix-pro'].data.body
}
return mainFooterBySite['pix-site']
return mainFooterBySite['pix-site'].data.body
},
navigationGroups() {
return this.usedMainFooter.data.body.filter(
return this.usedMainFooter.filter(
(slice) => slice.slice_type === 'navigation_group'
)
},
11 changes: 9 additions & 2 deletions components/HotNewsBanner.vue
Original file line number Diff line number Diff line change
@@ -11,16 +11,23 @@
</template>

<script>
import { mapState } from 'vuex'
import { documentFetcher, documents } from '~/services/document-fetcher'
export default {
name: 'HotNewsBanner',
data() {
return {
isOpen: true,
hotNews: null,
}
},
computed: mapState(['hotNews']),
async fetch() {
const hotNews = await documentFetcher(this.$prismic, this.$i18n).findByType(
documents.hotNews
)
this.hotNews = hotNews?.data?.description
},
methods: {
closeBanner() {
this.isOpen = false
14 changes: 12 additions & 2 deletions components/NavigationSliceZone.vue
Original file line number Diff line number Diff line change
@@ -29,16 +29,26 @@
</template>

<script>
import { mapState } from 'vuex'
import { keyBy } from '~/services/key-by'
import { documentFetcher, documents } from '~/services/document-fetcher'
export default {
name: 'NavigationSliceZone',
data() {
return {
mainNavigations: [],
}
},
async fetch() {
this.mainNavigations = await documentFetcher(
this.$prismic,
this.$i18n
).findByType(documents.mainNavigation)
},
computed: {
isPixPro() {
return process.env.isPixPro
},
...mapState(['mainNavigations']),
usedMainNavigation() {
const mainNavBySite = keyBy(
47 changes: 0 additions & 47 deletions store/index.js

This file was deleted.

41 changes: 16 additions & 25 deletions tests/components/slices/NavigationSliceZone.test.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ jest.mock('~/services/document-fetcher')

describe('NavigationSliceZone', () => {
let component
let store
const stubs = {
'client-only': true,
'slide-menu': true,
@@ -66,19 +65,16 @@ describe('NavigationSliceZone', () => {

describe('#usedMainNavigation', () => {
describe('When we are in pix-site and we have the site navigation', () => {
beforeEach(() => {
store = {
state: {
mainNavigations: [expectedSiteNavigation, expectedProNavigation],
},
}
})

it('should return the site navigation', () => {
// given
component = shallowMount(NavigationSliceZone, {
mocks: {
$store: store,
data() {
return {
mainNavigations: [
expectedSiteNavigation,
expectedProNavigation,
],
}
},
stubs,
})
@@ -96,18 +92,18 @@ describe('NavigationSliceZone', () => {
process.env = {
isPixPro: true,
}
store = {
state: {
mainNavigations: [expectedSiteNavigation, expectedProNavigation],
},
}
})

it('should return the pro navigation', () => {
// given
component = shallowMount(NavigationSliceZone, {
mocks: {
$store: store,
data() {
return {
mainNavigations: [
expectedSiteNavigation,
expectedProNavigation,
],
}
},
stubs,
})
@@ -125,18 +121,13 @@ describe('NavigationSliceZone', () => {
process.env = {
isPixPro: true,
}
store = {
state: {
mainNavigations: [expectedSiteNavigation],
},
}
})

it('should return the site navigation', () => {
// given
component = shallowMount(NavigationSliceZone, {
mocks: {
$store: store,
data() {
return { mainNavigations: [expectedSiteNavigation] }
},
stubs,
})

0 comments on commit de3d094

Please sign in to comment.