aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/InvoiceActions.svelte
blob: e7fb57e3ce7b7e13fc9c22b7013b63ce2d359edc (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<script lang="ts">
  import { amountPrompt } from "$lib/store";
  import { types } from "$lib/utils";
  import { page } from "$app/stores";
  import { goto } from "$app/navigation";
  let {
    user,
    invoice,
    copy,
    t,
    link,
    showQr = $bindable(),
    txt,
    setAmount,
    newAmount = $bindable(),
    toggleType,
    toggleAmount,
    setType,
    toggleMemo,
  } = $props();

  let { aid, account, address_type, type } = $derived(invoice);
</script>

<div class="text-secondary space-y-2 text-xl pt-2">
  <button
    class="btn flex-nowrap"
    class:bg-base-300={type === types.ecash}
    class:text-secondary={type === types.ecash}
    class:hidden={type !== types.ecash}
    onclick={setType(types.ecash)}
  >
    <img src="/images/cash.png" class="w-8 my-auto" alt="Ecash" />
    <div class="my-auto text-lg">Ecash</div>
  </button>

  <button
    class="btn flex-nowrap"
    class:bg-base-300={type === types.liquid}
    class:text-secondary={type === types.liquid}
    class:hidden={type !== types.liquid}
    onclick={() => setType(types.liquid)}
  >
    <img src="/images/liquid.svg" class="w-8" alt="Liquid" />
    <div class="my-auto text-lg">Liquid</div>
  </button>

  <div class="flex flex-wrap gap-2 justify-around text-secondary w-full">
    {#if user?.id === invoice?.user?.id}
      <button class="btn grow !w-auto" onclick={toggleAmount}>
        <iconify-icon noobserver icon="ph:pencil-simple-bold" width="32"></iconify-icon>
        <div class="my-auto">{t("payments.setAmount")}</div>
      </button>
    {:else}
      <a href={link} class="block">
        <button class="btn grow !w-auto">
          <iconify-icon noobserver icon="ph:arrow-square-out-bold" width="32"></iconify-icon>
          <div class="my-auto">{t("payments.openLink")}</div>
        </button>
      </a>
    {/if}

    <button class="btn grow !w-auto" onclick={toggleMemo}>
      <iconify-icon noobserver icon="ph:chat-centered-text-bold" width="32"></iconify-icon>
      <div class="my-auto">{t("invoice.setMemo")}</div>
    </button>
  </div>



  <div class="flex gap-2">
    {#if aid === user.id}
      <button
        class="btn flex-nowrap !w-auto grow"
        class:bg-base-300={type === types.lightning}
        class:text-secondary={type === types.lightning}
        onclick={() => {
          $amountPrompt = false;
          newAmount = undefined;
          setType(types.lightning);
        }}
      >
        <div class="bg-black rounded-full w-8 h-8 items-center justify-center flex">
          <div class="m-auto">
            <iconify-icon noobserver icon="ph:lightning-fill" class="text-yellow-300 text-2xl"
            ></iconify-icon>
          </div>
        </div>
        <div class="my-auto text-lg">Lightning</div>
      </button>
    {/if}

    {#if !account?.seed && !(account?.pubkey && account?.fingerprint) && account?.type !== "ark"}
      <button
        class="btn flex-nowrap !w-auto grow"
        class:bg-base-300={type === types.bitcoin}
        class:text-secondary={type === types.bitcoin}
        onclick={() => setType(types.bitcoin)}
      >
        <img src="/images/bitcoin.svg" class="w-8" alt="Bitcoin" />
        <div class="my-auto text-lg">Bitcoin</div>
      </button>
    {/if}
  </div>

  {#if aid === user.id}
    <button type="button" class="btn" onclick={toggleType}>
      <img src="/images/liquid.svg" class="w-8" alt="Liquid" />
      <img src="/images/cash.png" class="w-8 my-auto" alt="Ecash" />
      <div class="my-auto">{t("payments.moreOptions")}</div>
    </button>
  {/if}
</div>