feat(#29): Remove checkout button when not signed in

This commit is contained in:
Josh Creek
2024-09-21 20:51:00 +01:00
parent 05891ad510
commit a4764c547e
+30 -22
View File
@@ -3,6 +3,10 @@
import { basket, type Basket, type Item } from '$lib/stores/basket.js'; import { basket, type Basket, type Item } from '$lib/stores/basket.js';
import BasketItem from '$lib/components/checkout/BasketItem.svelte'; import BasketItem from '$lib/components/checkout/BasketItem.svelte';
export let data;
let { supabase, session, url } = data;
$: ({ supabase, session, url } = data);
let localBasket: Basket; let localBasket: Basket;
const unsubscribe = basket.subscribe((value) => { const unsubscribe = basket.subscribe((value) => {
localBasket = value; localBasket = value;
@@ -101,28 +105,32 @@
/> />
</svg> </svg>
</a> </a>
<button {#if session?.user !== undefined}
type="submit" <button
class="btn btn-primary" type="submit"
disabled={localBasket.items && localBasket.items.length === 0} class="btn btn-primary"
>Continue to Payment disabled={localBasket.items && localBasket.items.length === 0}
<svg >Continue to Payment
class="ml-2" <svg
xmlns="http://www.w3.org/2000/svg" class="ml-2"
width="23" xmlns="http://www.w3.org/2000/svg"
height="22" width="23"
viewBox="0 0 23 22" height="22"
fill="none" viewBox="0 0 23 22"
> fill="none"
<path >
d="M8.75324 5.49609L14.2535 10.9963L8.75 16.4998" <path
stroke="white" d="M8.75324 5.49609L14.2535 10.9963L8.75 16.4998"
stroke-width="1.6" stroke="white"
stroke-linecap="round" stroke-width="1.6"
stroke-linejoin="round" stroke-linecap="round"
/> stroke-linejoin="round"
</svg> />
</button> </svg>
</button>
{:else}
<p>You must sign in to checkout</p>
{/if}
</div> </div>
</form> </form>
</div> </div>