mirror of
https://github.com/aljazceru/hypergolic.git
synced 2025-12-18 22:14:21 +01:00
problem: can't use product groups
This commit is contained in:
@@ -1,57 +1,25 @@
|
||||
<script lang="ts">
|
||||
import * as Card from '$lib/components/ui/card/index.js';
|
||||
import type { NDKEvent } from '@nostr-dev-kit/ndk';
|
||||
import { Product, Rocket } from '@/event_helpers/rockets';
|
||||
import AddProductToRocket from './AddProductToRocket.svelte';
|
||||
import PayNow from './PayNow.svelte';
|
||||
import { Rocket } from '@/event_helpers/rockets';
|
||||
|
||||
export let product: NDKEvent;
|
||||
export let rocket: NDKEvent;
|
||||
//$page.url.searchParams.get("tab")
|
||||
|
||||
function validate(event: NDKEvent): boolean {
|
||||
let test = 0;
|
||||
if (
|
||||
event.getMatchingTags('name') &&
|
||||
event.getMatchingTags('name')[0] &&
|
||||
event.getMatchingTags('name')[0][1]
|
||||
) {
|
||||
test++;
|
||||
}
|
||||
if (
|
||||
event.getMatchingTags('description') &&
|
||||
event.getMatchingTags('description')[0] &&
|
||||
event.getMatchingTags('description')[0][1]
|
||||
) {
|
||||
test++;
|
||||
}
|
||||
if (
|
||||
event.getMatchingTags('cover') &&
|
||||
event.getMatchingTags('cover')[0] &&
|
||||
event.getMatchingTags('cover')[0][1]
|
||||
) {
|
||||
test++;
|
||||
}
|
||||
return test == 3;
|
||||
}
|
||||
|
||||
function includedInRocket(rocket:Rocket, product:NDKEvent): boolean {
|
||||
return Boolean(rocket.Products().get(product.id))
|
||||
}
|
||||
export let product: Product;
|
||||
export let rocket: Rocket;
|
||||
</script>
|
||||
|
||||
{#if validate(product)}
|
||||
{#if product.Validate()}
|
||||
<Card.Root>
|
||||
<Card.Header>
|
||||
<Card.Title>{product.getMatchingTags('name')[0][1]}</Card.Title>
|
||||
<Card.Description>{product.getMatchingTags('description')[0][1]}</Card.Description>
|
||||
<Card.Title>{product.Group()} {#if product.Option().length > 0}(variant: {product.Option()}){/if}</Card.Title>
|
||||
<Card.Description>{product.Description()}</Card.Description>
|
||||
</Card.Header>
|
||||
|
||||
{#if $$slots.default}
|
||||
<Card.Content>
|
||||
<div class="flex flex-col items-center justify-center gap-2 md:flex-row">
|
||||
<img
|
||||
src={product.getMatchingTags('cover')[0][1]}
|
||||
src={product.CoverImage()}
|
||||
alt="cover"
|
||||
class="aspect-square w-[300px] object-cover"
|
||||
/>
|
||||
@@ -59,17 +27,13 @@
|
||||
</div>
|
||||
</Card.Content>
|
||||
{:else}
|
||||
<img
|
||||
src={product.getMatchingTags('cover')[0][1]}
|
||||
alt="cover"
|
||||
class="aspect-square object-cover"
|
||||
/>
|
||||
<img src={product.CoverImage()} alt="cover" class="aspect-square object-cover" />
|
||||
{/if}
|
||||
<Card.Footer class="flex justify-center pt-2">
|
||||
{#if !includedInRocket(new Rocket(rocket), product)}
|
||||
{#if !rocket.Products().get(product.ID())}
|
||||
<AddProductToRocket {product} {rocket} />
|
||||
{:else}
|
||||
<PayNow {product} rocketProduct={new Rocket(rocket).Products().get(product.id)} {rocket} />
|
||||
<PayNow {product} rocketProduct={rocket.Products().get(product.ID())} {rocket} />
|
||||
{/if}
|
||||
</Card.Footer>
|
||||
</Card.Root>
|
||||
|
||||
Reference in New Issue
Block a user