From 4c0152ae0f03048a26ba7ef31cc47eba35b474a4 Mon Sep 17 00:00:00 2001 From: F4ilji Date: Mon, 6 Jul 2026 17:57:28 +0500 Subject: [PATCH] fix(ssr): polyfill localStorage/sessionStorage, guard BasicListBadge filters prop, remove this. from template --- resources/js/Pages/Client/Programs/Index.vue | 2 +- resources/js/Pages/Client/Schedules/Index.vue | 2 +- .../shared/badge/BasicListBadge.vue | 1 + resources/js/ssr.js | 18 ++++++++++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/resources/js/Pages/Client/Programs/Index.vue b/resources/js/Pages/Client/Programs/Index.vue index dac93bf..91c0d0d 100755 --- a/resources/js/Pages/Client/Programs/Index.vue +++ b/resources/js/Pages/Client/Programs/Index.vue @@ -103,7 +103,7 @@ export default {
- +
diff --git a/resources/js/Pages/Client/Schedules/Index.vue b/resources/js/Pages/Client/Schedules/Index.vue index 764c2f8..819031c 100755 --- a/resources/js/Pages/Client/Schedules/Index.vue +++ b/resources/js/Pages/Client/Schedules/Index.vue @@ -21,7 +21,7 @@ export default { name: "Index", data() { return { - favoriteGroups: JSON.parse(localStorage.getItem('favoriteGroups')), + favoriteGroups: typeof window !== 'undefined' ? JSON.parse(localStorage.getItem('favoriteGroups') || '[]') : [], showFavorites: false, loading: false, currentPageLoaded: this.schedules_paginator.current_page, diff --git a/resources/js/componentss/shared/badge/BasicListBadge.vue b/resources/js/componentss/shared/badge/BasicListBadge.vue index 777cbee..717d711 100755 --- a/resources/js/componentss/shared/badge/BasicListBadge.vue +++ b/resources/js/componentss/shared/badge/BasicListBadge.vue @@ -48,6 +48,7 @@ export default { props: { filters: { type: Object, + default: () => ({}), }, }, } diff --git a/resources/js/ssr.js b/resources/js/ssr.js index 889442d..9cca6db 100755 --- a/resources/js/ssr.js +++ b/resources/js/ssr.js @@ -7,6 +7,24 @@ if (typeof globalThis.IntersectionObserver === 'undefined') { }; } +if (typeof globalThis.localStorage === 'undefined') { + const noop = () => ''; + globalThis.localStorage = { getItem: noop, setItem: noop, removeItem: noop, clear: noop, get length() { return 0; }, key: noop }; +} + +if (typeof globalThis.sessionStorage === 'undefined') { + const noop = () => ''; + globalThis.sessionStorage = { getItem: noop, setItem: noop, removeItem: noop, clear: noop, get length() { return 0; }, key: noop }; +} + +if (typeof globalThis.window === 'undefined') { + globalThis.window = globalThis; +} + +if (typeof globalThis.document === 'undefined') { + globalThis.document = { createElement: () => ({ style: {} }), querySelector: () => null, head: { appendChild: () => {} }, body: { appendChild: () => {} } }; +} + import '../css/app.css'; import { createInertiaApp } from '@inertiajs/vue3' import createServer from '@inertiajs/vue3/server'