app

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

ListingReview.svelte (4301B)


      1 <script lang="ts">
      2   import Notice from './Notice.svelte';
      3   import {
      4     editorReviewSnapshot,
      5     type EditorReview
      6   } from '../publishing/editor-workflow.ts';
      7   let {
      8     review,
      9     onedit,
     10     onpublish,
     11     publishing = false,
     12     captured = false
     13   }: {
     14     review: EditorReview;
     15     onedit: () => void;
     16     onpublish?: () => void;
     17     publishing?: boolean;
     18     captured?: boolean;
     19   } = $props();
     20   const preview = $derived(editorReviewSnapshot(review));
     21   function tag(name: string) {
     22     return (
     23       preview?.tags
     24         .find((value) => value[0] === name)
     25         ?.slice(1)
     26         .join(' ') ?? ''
     27     );
     28   }
     29 </script>
     30 
     31 {#if preview}
     32   <section class="stack" aria-label="Public listing review">
     33     <h2 id="listing-review-heading" tabindex="-1">Public review</h2>
     34     {#if preview.withdrawal}
     35       <h3>Removal request</h3>
     36       <p>This public request cannot erase all other copies.</p>
     37       <dl>
     38         <dt>Listing coordinate</dt>
     39         <dd class="key">{preview.withdrawal.coordinate}</dd>
     40         <dt>Exact retained event</dt>
     41         <dd class="key">{preview.withdrawal.eventId}</dd>
     42         <dt>Public author</dt>
     43         <dd class="key">{preview.owner}</dd>
     44         <dt>Request time</dt>
     45         <dd>{preview.createdAtSeconds}</dd>
     46         <dt>Request kind</dt>
     47         <dd>5</dd>
     48         <dt>Exact request ID</dt>
     49         <dd class="key">{preview.expectedHash}</dd>
     50         <dt>Public reason</dt>
     51         <dd>No public reason text.</dd>
     52         <dt>Public references</dt>
     53         <dd class="key">{tag('e')} {tag('a')} {tag('k')}</dd>
     54         <dt>Public destinations</dt>
     55         <dd>
     56           <ul>
     57             {#each preview.targets as target (target)}<li class="key">
     58                 {target}
     59               </li>{/each}
     60           </ul>
     61         </dd>
     62       </dl>
     63     {:else}
     64       <p>
     65         Check the complete public listing before any signing or publication.
     66       </p>
     67       <h3>{tag('title')}</h3>
     68       <p class="description" id="listing-review-content">{preview.content}</p>
     69       <dl>
     70         <dt>Derived summary</dt>
     71         <dd>{preview.summary}</dd>
     72         <dt>Public area</dt>
     73         <dd>{tag('location')}</dd>
     74         <dt>Price</dt>
     75         <dd>{tag('price')} per {tag('radroots:price_unit')}</dd>
     76         {#if tag('radroots:quantity')}<dt>Advertised quantity</dt>
     77           <dd>{tag('radroots:quantity')}</dd>{/if}
     78         <dt>Publisher</dt>
     79         <dd class="key">{preview.owner}</dd>
     80         {#if preview.revision}
     81           <dt>Unchanged listing coordinate</dt>
     82           <dd class="key">{preview.revision.coordinate}</dd>
     83           <dt>Original publication time</dt>
     84           <dd>{preview.revision.publishedAtSeconds}</dd>
     85           <dt>Proposed availability</dt>
     86           <dd>{preview.revision.status === 'sold' ? 'Sold' : 'Available'}</dd>
     87         {/if}
     88         <dt>Public destinations</dt>
     89         <dd>
     90           <ul>
     91             {#each preview.targets as target (target)}<li class="key">
     92                 {target}
     93               </li>{/each}
     94           </ul>
     95         </dd>
     96       </dl>
     97       {#if !preview.revision}<p>Messages: ready to receive replies</p>{/if}
     98       {#if !captured && !publishing}<p>
     99           This review has not requested a signature or published the listing.
    100         </p>{/if}
    101       {#if preview.revision?.status === 'sold'}<p>
    102           This is a public availability update, not a payment or stock
    103           reservation receipt.
    104         </p>{/if}
    105     {/if}
    106     {#if (preview.revision || preview.withdrawal) && onpublish && !captured}
    107       <button
    108         type="button"
    109         class="button button--primary"
    110         onclick={onpublish}
    111         disabled={publishing}
    112         >{preview.withdrawal
    113           ? publishing
    114             ? 'Publishing removal request'
    115             : 'Publish removal request'
    116           : publishing
    117             ? 'Publishing update'
    118             : preview.revision?.status === 'sold'
    119               ? 'Publish sold update'
    120               : 'Publish changes'}</button
    121       >
    122     {/if}
    123     <button type="button" onclick={onedit} disabled={publishing || captured}
    124       >Edit details</button
    125     >
    126   </section>
    127 {:else}
    128   <Notice
    129     tone="warning"
    130     text="This review is no longer current. Return to the current listing values."
    131   />
    132   <button type="button" onclick={onedit}>Edit details</button>
    133 {/if}