refactor: get rid of page data types

This commit is contained in:
2023-05-26 23:47:08 +02:00
parent 422727586e
commit 685d4fd244
28 changed files with 44 additions and 72 deletions

View File

@@ -1,10 +1,9 @@
import { error } from '@sveltejs/kit'
import type { LayoutServerLoad } from './$types'
import { fetchAPI } from '$utils/api'
import { fetchSwell } from '$utils/functions/shopServer'
export const load = (async () => {
export const load = async () => {
try {
// Get content from API
const res = await fetchAPI(`query {
@@ -76,4 +75,4 @@ export const load = (async () => {
} catch (err) {
throw error(500, err.message)
}
}) satisfies LayoutServerLoad
}

View File

@@ -3,14 +3,13 @@
</style>
<script lang="ts">
import type { PageData } from './$types'
import { setContext } from 'svelte'
import { cartNotifications } from '$utils/stores/shop'
// Components
import Cart from '$components/organisms/Cart.svelte'
import NotificationCart from '$components/molecules/NotificationCart.svelte'
export let data: PageData
export let data
const { shop, locations, posters, shopProducts, settings } = data

View File

@@ -1,11 +1,10 @@
import { error } from '@sveltejs/kit'
import type { PageServerLoad } from './$types'
import { fetchAPI } from '$utils/api'
import { getRandomItem } from 'utils/array'
import { fetchSwell } from '$utils/functions/shopServer'
export const load = (async ({ setHeaders }) => {
export const load = async ({ setHeaders }) => {
try {
// Get content from API
const data = await fetchAPI(`query {
@@ -54,4 +53,4 @@ export const load = (async ({ setHeaders }) => {
} catch (err) {
throw error(500, err.message)
}
}) satisfies PageServerLoad
}

View File

@@ -1,5 +1,4 @@
<script lang="ts">
import type { PageData } from './$types'
import { getContext } from 'svelte'
import { getAssetUrlKey } from '$utils/api'
import { shopCurrentProductSlug } from '$utils/stores/shop'
@@ -10,7 +9,7 @@
import ShopHeader from '$components/organisms/ShopBanner.svelte'
import PosterLayout from '$components/layouts/PosterLayout.svelte'
export let data: PageData
export let data
const { product, shopProduct }: { product: any, shopProduct: any } = data
const { posters, settings }: any = getContext('shop')

View File

@@ -1,10 +1,9 @@
import { error } from '@sveltejs/kit'
import type { PageServerLoad } from './$types'
import { fetchAPI } from '$utils/api'
import { fetchSwell } from '$utils/functions/shopServer'
export const load = (async ({ params, setHeaders }) => {
export const load = async ({ params, setHeaders }) => {
try {
// Get content from API
const data = await fetchAPI(`query {
@@ -51,4 +50,4 @@ export const load = (async ({ params, setHeaders }) => {
} catch (err) {
throw error(404)
}
}) satisfies PageServerLoad
}

View File

@@ -1,5 +1,4 @@
<script lang="ts">
import type { PageData } from './$types'
import { getContext } from 'svelte'
import { getAssetUrlKey } from '$utils/api'
import { shopCurrentProductSlug } from '$utils/stores/shop'
@@ -11,7 +10,7 @@
import PostersGrid from '$components/organisms/PostersGrid.svelte'
import PosterLayout from '$components/layouts/PosterLayout.svelte'
export let data: PageData
export let data
const { posters }: any = getContext('shop')