Add Shop module at end of Location page
With linked poster if existing, otherwise with all products
This commit is contained in:
@@ -20,10 +20,14 @@
|
||||
import House from '$components/molecules/House.svelte'
|
||||
import Pagination from '$components/molecules/Pagination.svelte'
|
||||
import NewsletterModule from '$components/organisms/NewsletterModule.svelte'
|
||||
import ShopModule from '$components/organisms/ShopModule.svelte'
|
||||
|
||||
export let location: any
|
||||
export let photos: any[]
|
||||
export let totalPhotos: number
|
||||
export let product: any
|
||||
|
||||
console.log(product)
|
||||
|
||||
dayjs.extend(relativeTime)
|
||||
|
||||
@@ -285,25 +289,41 @@
|
||||
{/each}
|
||||
</section>
|
||||
|
||||
<section class="location-page__next">
|
||||
<div class="container">
|
||||
<Pagination
|
||||
ended={ended}
|
||||
current={currentPhotosAmount}
|
||||
total={totalPhotos}
|
||||
on:click={!ended && loadMorePhotos}
|
||||
>
|
||||
{#if !ended}
|
||||
<p class="more">See more photos</p>
|
||||
{:else}
|
||||
<p>You've seen it all!</p>
|
||||
{/if}
|
||||
</Pagination>
|
||||
|
||||
{#if ended}
|
||||
<NewsletterModule theme="light" />
|
||||
<section class="location-page__next container">
|
||||
<Pagination
|
||||
ended={ended}
|
||||
current={currentPhotosAmount}
|
||||
total={totalPhotos}
|
||||
on:click={!ended && loadMorePhotos}
|
||||
>
|
||||
{#if !ended}
|
||||
<p class="more">See more photos</p>
|
||||
{:else}
|
||||
<p>You've seen it all!</p>
|
||||
{/if}
|
||||
</div>
|
||||
</Pagination>
|
||||
|
||||
{#if ended}
|
||||
<div class="grid-modules">
|
||||
<div class="container grid">
|
||||
<div class="wrap">
|
||||
{#if location.has_poster}
|
||||
<ShopModule
|
||||
title="Poster available"
|
||||
text="Houses of {location.name} is available as a poster on our shop."
|
||||
images={product.photos_product}
|
||||
textBottom={null}
|
||||
buttonText="Buy"
|
||||
url="/shop/poster-{location.slug}"
|
||||
/>
|
||||
{:else}
|
||||
<ShopModule />
|
||||
{/if}
|
||||
<NewsletterModule theme="light" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
{:else}
|
||||
<div class="location-page__message">
|
||||
|
||||
@@ -63,9 +63,18 @@ export async function GET ({ params }: RequestEvent): Promise<RequestHandlerOutp
|
||||
total_published: photo_aggregated (filter: { location: { slug: { _eq: "${slug}" }}}) {
|
||||
count { location }
|
||||
}
|
||||
|
||||
# Shop product
|
||||
product (filter: { location: { slug: { _eq: "${slug}" }}}) {
|
||||
photos_product {
|
||||
directus_files_id {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`)
|
||||
const { data: { location: location, photos, total_published }} = res
|
||||
const { data: { location: location, photos, total_published, product }} = res
|
||||
|
||||
if (params.country !== location[0].country.slug || !location.length) {
|
||||
return { status: 404 }
|
||||
@@ -74,8 +83,9 @@ export async function GET ({ params }: RequestEvent): Promise<RequestHandlerOutp
|
||||
return {
|
||||
body: {
|
||||
location: location[0],
|
||||
photos: photos,
|
||||
photos,
|
||||
totalPhotos: photos.length ? total_published[0].count.location : 0,
|
||||
product: product[0],
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user