Skip to content

Commit 49c31ae

Browse files
committed
fix: error when removing mobile filters and remove the call to fetch header and footer in layout for error page
1 parent 07bd0c9 commit 49c31ae

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

layouts/default.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import { provideTheme } from '@/composables/provideTheme'
55
provideTheme()
66
77
const { enabled, state } = usePreviewMode()
8+
const isApiLocked = computed(() => {
9+
const host = useRuntimeConfig().public.craftGraphqlURL
10+
return host.includes('test')
11+
})
812
const layoutCustomProps = useAttrs()
913
const globalStore = useGlobalStore()
1014
@@ -28,7 +32,12 @@ onMounted(async () => {
2832
2933
if (!import.meta.dev && layoutCustomProps['is-error']) {
3034
// console.log('In SSG refresh layout data as state is not maintained after an error response')
31-
await $layoutData()
35+
if (isApiLocked.value) {
36+
console.log('API is locked, not fetching layout data')
37+
} else {
38+
// Fetch layout data only if the API is not locked
39+
await $layoutData()
40+
}
3241
}
3342
3443
classes.value.push({ 'has-scrolled': globalStore.sTop })

pages/search.vue

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -368,17 +368,28 @@ function updateCountInFilters(desktopOptions: Option[]): string[] {
368368
.map(option => `${option.value} (${option.count})`)
369369
}
370370
function handleFilterUpdate(updatedFilters) {
371-
selectedGroupNameFilters.value = updatedFilters
372-
console.log('Filters updated:', selectedGroupNameFilters.value)
371+
console.log('Filters :', JSON.stringify(userFilterSelection.value), updatedFilters)
372+
userFilterSelection.value = updatedFilters
373+
console.log('Filters updated:', JSON.stringify(userFilterSelection.value))
373374
}
374375
375376
function applyChangesToSearch() {
376-
console.log('applyChangesToSearch called')
377+
console.log('applyChangesToSearch called', JSON.stringify(userFilterSelection.value))
378+
const newFilter = { 'groupName.keyword': userFilterSelection.value['groupName.keyword'] || [] }
379+
// Extract valid option values from desktopOptions (without counts)
380+
const validOptions = resetSearchFilters.desktopOptions.map(option => option.value)
381+
console.log('validOptions:', validOptions)
377382
378-
const newFilterString = selectedGroupNameFilters['groupName.keyword'] && selectedGroupNameFilters['groupName.keyword'].length > 0
379-
? `groupName.keyword:(${selectedGroupNameFilters['groupName.keyword'].join(',')})`
383+
newFilter['groupName.keyword'] = (newFilter['groupName.keyword'] || []).map((item) => {
384+
const match = validOptions.find(valid => item.trim().startsWith(valid))
385+
return match || null
386+
}).filter(Boolean)
387+
const newFilterString = newFilter['groupName.keyword'].length > 0
388+
? `groupName.keyword:(${newFilter['groupName.keyword'].join(',')})`
380389
: ''
381390
391+
console.log('newFilter after processing:', newFilter)
392+
console.log('newFilterString:', newFilterString)
382393
useRouter().push({
383394
path: route.path,
384395
query: {
@@ -513,8 +524,8 @@ function applyChangesToSearch() {
513524
/>
514525
</span>
515526
<section-remove-search-filter
516-
v-if="isMobile && Object.keys(selectedGroupNameFilters).length > 0"
517-
:filters="selectedGroupNameFilters"
527+
v-if="isMobile && Object.keys(userFilterSelection).length > 0"
528+
:filters="userFilterSelection"
518529
class="remove-filters"
519530
@update:filters="handleFilterUpdate"
520531
@remove-selected="applyChangesToSearch"

0 commit comments

Comments
 (0)