|
5 | 5 | import { E } from "@agoric/eventual-send";
|
6 | 6 | import BoardId from "./BoardId.svelte";
|
7 | 7 | import { purses } from './store';
|
| 8 | +import Button from "smelte/src/components/Button/Button.svelte"; |
| 9 | +import Select from "smelte/src/components/Select/Select.svelte"; |
8 | 10 |
|
9 | 11 | export let item;
|
10 | 12 | export let summary = true;
|
| 13 | + export let summaryLine = 0; |
11 | 14 | export let details = true;
|
12 | 15 |
|
13 |
| - let destination; |
| 16 | + let destination = null; |
14 | 17 |
|
15 | 18 | $: deposit = () => {
|
16 | 19 | // console.log('deposit to', destination);
|
17 |
| - return E(item.actions).deposit(destination); |
| 20 | + return E(item.actions).deposit(destination ? destination.purse : undefined); |
18 | 21 | };
|
| 22 | +
|
| 23 | + $: purseItems = [{ value: null, text: 'Automatic' }, ...( |
| 24 | + $purses ? $purses.filter(({ brand }) => brand === item.brand).map(p => ({ value: p, text: p.text })) : [] |
| 25 | + )]; |
| 26 | + // $: console.log('purseItems', purseItems); |
19 | 27 | </script>
|
20 | 28 |
|
21 | 29 | <section>
|
|
26 | 34 | {/if}
|
27 | 35 | {:else if item.issuer}
|
28 | 36 | {#if summary}
|
| 37 | + {#if !summaryLine || summaryLine === 1} |
29 | 38 | Payment amount
|
30 |
| - {#if item.lastAmount} |
| 39 | + {/if} |
| 40 | + {#if item.lastAmount && (!summaryLine || summaryLine === 2)} |
31 | 41 | <Amount amount={item.displayPayment.lastAmount} />
|
32 | 42 | {/if}
|
33 | 43 | {/if}
|
34 | 44 |
|
35 | 45 | {#if details}
|
36 |
| - <button on:click={() => E(item.actions).getAmountOf()}>Refresh Amount</button> |
37 |
| - <button on:click={deposit}>Deposit to</button> |
38 | 46 | {#if $purses}
|
39 |
| - <select bind:value={destination}> |
40 |
| - <option value={undefined}>Automatic</option> |
41 |
| - {#each $purses as p} |
42 |
| - {#if p.brand === item.brand} |
43 |
| - <option>{p.pursePetname}</option> |
44 |
| - {/if} |
45 |
| - {/each} |
46 |
| - </select> |
| 47 | + <Select bind:value={destination} items={purseItems} label="Deposit to" /> |
47 | 48 | {/if}
|
| 49 | + <div> |
| 50 | + <Button on:click={() => E(item.actions).getAmountOf()}>Refresh</Button> |
| 51 | + <Button on:click={deposit}>Deposit</Button> |
| 52 | + </div> |
48 | 53 | {/if}
|
49 | 54 | {:else}
|
50 |
| - {#if summary} |
| 55 | + {#if summary && (!summaryLine || summaryLine === 1)} |
51 | 56 | Unknown brand. This payment cannot be verified.
|
52 | 57 | {/if}
|
53 | 58 | {/if}
|
|
0 commit comments