refactor: get rid of page data types
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user