aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/InvoiceData.svelte
blob: b511c599794218b36e78a6dad1e0cc55782e62fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<script>
  import { btc, f, sat, s, sats } from "$lib/utils";
  let {
    showQr,
    src,
    link,
    txt,
    invoice,
    amount,
    amountFiat,
    currency,
    tip,
    rate,
  } = $props();
</script>

{#if showQr}
  <div>
    <a href={link}>
      <img
        {src}
        class="mx-auto z-10 max-w-[360px] border-4 border-white"
        alt={txt}
      />
    </a>
  </div>
{/if}

{#if !showQr || txt.length <= 120}
  <div class="break-all text-center text-secondary text-xl">
    {txt}
  </div>
{/if}

{#each invoice.items as i}
  <div class="grid grid-cols-12 text-xl">
    <div class="col-span-1 my-auto">{i.quantity}</div>
    <div class="mr-auto grow col-span-7 my-auto">
      {i.name}
    </div>
    <div class="col-span-2 font-semibold text-right my-auto">
      {f(i.price * i.quantity, currency)}
    </div>
    <div class="col-span-2 text-secondary text-right text-lg my-auto">
      {sat(btc(i.price * i.quantity, rate))}
    </div>
  </div>
{/each}

{#if amount > 0}
  <div class="text-center font-bold text-2xl">
    <div class="flex justify-center items-end gap-2">
      <div>{f(amountFiat, currency)}</div>

      {#if tip}
        <div class="text-base flex items-center gap-1">
          <div>+</div>
          <div>{f(tip * (rate / sats), currency)}</div>
        </div>
      {/if}
    </div>
    <div class="flex justify-center items-end text-secondary font-normal text-xl gap-2">
      <div class="flex items-center">
        <iconify-icon icon="ph:lightning-fill" class="text-yellow-300"
        ></iconify-icon>
        <div>
          {`${s(amount)}`}
        </div>
      </div>
      {#if tip}
        <div class="text-base flex items-center">
          <div>+</div>
          <iconify-icon icon="ph:lightning-fill" class="text-yellow-300"
          ></iconify-icon>
          <div>{s(tip)}</div>
        </div>
      {/if}
    </div>
  </div>
{/if}