ConflictNotice.svelte (3458B)
1 <script lang="ts"> 2 /* global setInterval, clearInterval */ 3 import { onMount } from 'svelte'; 4 import Notice from './Notice.svelte'; 5 import { 6 ownedEditSourceSnapshot, 7 type OwnedEditSource 8 } from '../publishing/edit-source.ts'; 9 import type { PublicDraftForm } from '../contracts/local-records.ts'; 10 let { 11 source, 12 proposed 13 }: { source: OwnedEditSource; proposed?: PublicDraftForm } = $props(); 14 let observed = $derived(ownedEditSourceSnapshot(source)); 15 onMount(() => { 16 // Observe existing bounded request state; this does not open new lookups. 17 const timer = setInterval(() => { 18 observed = ownedEditSourceSnapshot(source); 19 }, 250); 20 return () => clearInterval(timer); 21 }); 22 const conflict = $derived( 23 observed?.status === 'conflict' || observed?.status === 'withdrawn' 24 ); 25 </script> 26 27 {#if observed && conflict} 28 <section class="stack" aria-label="Current and proposed listing"> 29 <Notice 30 tone="warning" 31 text="This listing changed elsewhere. Review the latest version before publishing." 32 /> 33 <p> 34 Your proposed changes remain local. These versions have not been merged. 35 </p> 36 <h2>Current listing</h2> 37 {#if observed.current} 38 <dl class="stack"> 39 <div> 40 <dt>Product name</dt> 41 <dd>{observed.current.title}</dd> 42 </div> 43 <div> 44 <dt>Full public description</dt> 45 <dd class="description">{observed.current.content}</dd> 46 </div> 47 <div> 48 <dt>Public area</dt> 49 <dd>{observed.current.location}</dd> 50 </div> 51 <div> 52 <dt>Price</dt> 53 <dd> 54 {observed.current.price.amount} 55 {observed.current.price.currency} per {observed.current.price.unit} 56 </dd> 57 </div> 58 <div> 59 <dt>Advertised quantity</dt> 60 <dd>{observed.current.quantity?.amount ?? 'Not specified'}</dd> 61 </div> 62 <div> 63 <dt>Availability</dt> 64 <dd>{observed.current.status}</dd> 65 </div> 66 </dl> 67 {:else}<p> 68 The current listing is withdrawn or unsupported. It cannot be 69 overwritten here. 70 </p>{/if} 71 {#if proposed} 72 <h2>Your proposed listing</h2> 73 <dl class="stack"> 74 <div> 75 <dt>Product name</dt> 76 <dd>{proposed.title}</dd> 77 </div> 78 <div> 79 <dt>Description</dt> 80 <dd class="description">{proposed.description}</dd> 81 </div> 82 <div> 83 <dt>Public area</dt> 84 <dd>{proposed.location}</dd> 85 </div> 86 <div> 87 <dt>Price</dt> 88 <dd>{proposed.amount} {proposed.currency} per {proposed.unit}</dd> 89 </div> 90 <div> 91 <dt>Advertised quantity</dt> 92 <dd>{proposed.quantity || 'Not specified'}</dd> 93 </div> 94 <div> 95 <dt>Public contact</dt> 96 <dd> 97 {proposed.contactType 98 ? proposed.contactType + ': ' + proposed.contactValue 99 : 'Not included'} 100 </dd> 101 </div> 102 </dl> 103 {/if} 104 </section> 105 {:else if observed && observed.status !== 'ready'} 106 <Notice 107 tone="info" 108 text={observed.status === 'checking' 109 ? 'Checking the current listing and removal requests. Your local values remain here.' 110 : 'The current listing check is incomplete. Keep your local values; this does not prove that another revision is absent.'} 111 /> 112 {/if}