[wip] 🔥 Integrate Swell into the shop

Create a custom and internal API for fetching and updating content to Swell Admin API (using swell-node)
This commit is contained in:
2021-11-07 11:51:01 +01:00
parent 2f043af38e
commit bd74f5612c
14 changed files with 543 additions and 148 deletions

View File

@@ -0,0 +1,49 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
export let item: any
// console.log(item)
const dispatch = createEventDispatcher()
// When changing item quantity
const updateQuantity = ({ target: { value }}: any) => {
dispatch('updatedQuantity', {
id: item.id,
quantity: Number(value)
})
}
// When removing item
const removeItem = () => {
dispatch('removed', item.id)
}
</script>
<aside class="cart-item shadow-small">
<div class="cart-item__left">
<img
src={item.product.images[0].file.url}
width={200}
height={300}
alt={item.product.name}
>
</div>
<div class="cart-item__right">
<h3>Poster</h3>
<p>{item.product.name} {item.price_total}</p>
{#if item && item.product}
<div class="select">
<select on:change={updateQuantity}>
{#each Array(5) as _, index}
<option value={index + 1} selected={item.quantity - 1 === index}>{index + 1}</option>
{/each}
</select>
</div>
{/if}
<button on:click={removeItem}>Remove</button>
</div>
</aside>

View File

@@ -1,31 +0,0 @@
<script lang="ts">
import { getContext } from 'svelte'
// Components
import Button from '$components/atoms/Button.svelte'
import Image from '$components/atoms/Image.svelte'
import Select from './Select.svelte'
const { locations, shop } = getContext('global')
</script>
<aside class="poster-cart">
<div class="poster-cart__left">
<img src="/images/issue-1.jpg" alt="">
</div>
<div class="poster-cart__right">
<h3>Poster</h3>
<p>Houses Of Melbourne 30€</p>
<Select
name="quantity" id="filter_country"
options={[
{
value: '1',
name: '1',
default: true,
selected: true,
},
]}
/>
</div>
</aside>