app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

ListingRow.svelte (1396B)


      1 <script lang="ts">
      2   import type { ListingView } from '../catalog/listing-view.ts';
      3   import { internalHref } from '../navigation-url.ts';
      4   import Disclosure from './primitives/Disclosure.svelte';
      5   let { listing }: { listing: ListingView } = $props();
      6   function timestamp(seconds: number): string {
      7     const milliseconds = seconds * 1000;
      8     return Number.isFinite(milliseconds) &&
      9       Math.abs(milliseconds) <= 8640000000000000
     10       ? new Date(milliseconds).toISOString()
     11       : `${seconds} seconds since the Unix epoch`;
     12   }
     13 </script>
     14 
     15 <article class="stack">
     16   <h2><a href={internalHref(listing.href)}>{listing.title}</a></h2>
     17   <p>{listing.price.currency} {listing.price.amount} / {listing.price.unit}</p>
     18   <p>{listing.publisher.label} ยท {listing.location}</p>
     19   {#if listing.quantity}<p>
     20       Advertised quantity: {listing.quantity.amount}
     21       {listing.quantity.unit}
     22     </p>{:else}<p>Advertised quantity not specified</p>{/if}
     23   <p>{listing.summary}</p>
     24   <p>Seller updated: {timestamp(listing.createdAt)}</p>
     25   {#if listing.lastKnown}<p class="notice">
     26       Last known listing. Availability has not been confirmed.
     27     </p>{/if}
     28   <Disclosure summary="Publisher details">
     29     {#if listing.publisher.assertedName}<p>
     30         This name is asserted by the publisher.
     31       </p>{/if}
     32     <p>Publisher key: <code>{listing.publisher.pubkey}</code></p>
     33   </Disclosure>
     34 </article>