aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Account.svelte
blob: 458f67c68ac4f41819c1d15472f594b9bc0a9cdb (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
<script>
  import Icon from "$comp/Icon.svelte";
  import Balance from "$comp/Balance.svelte";
  import { t } from "$lib/translations";

  export let user, rate, account;
  let { name, seed, balance, id } = account;
  $: type = seed ? "Savings" : "Cash";

  $: refresh(account);
  let refresh = (a) => ({ seed, balance, id } = a);

  let setAccount = () => (document.cookie = `aid=${id}; path=/; max-age=86400`);
</script>

<a href={`/payments`} class="block" on:click={setAccount}>
  <div class="py-4 px-2 space-y-5 bg-primary rounded-2xl border">
    <div class="flex">
      <Balance {balance} {user} {rate} />
      {#if seed}
      <a href={`/account/${id}`} class="contents">
        <button class="ml-auto flex gap-1 mb-auto pb-4 pl-4">
          <Icon icon="settings" style="w-8 my-auto" />
        </button>
      </a>
      {/if}
    </div>

    <div class="flex gap-1 justify-center w-full text-xl">
      <a href={`/invoice`} class="contents" on:click={setAccount}>
        <button
          class="rounded-2xl border py-5 px-4 hover:opacity-80 flex grow bg-white"
        >
          <div class="mx-auto flex gap-2">
            <Icon icon="receive" style="w-8" />
            <div class="my-auto">{$t("user.dashboard.receive")}</div>
          </div>
        </button>
      </a>

      <a href={`/scan`} class="contents" on:click={setAccount}>
        <button
          class="rounded-2xl border py-5 px-4 hover:opacity-80 flex shrink bg-white"
        >
          <div class="mx-auto flex gap-2">
            <Icon icon="camera" style="w-8" />
          </div>
        </button>
      </a>

      <a href={`/send`} class="contents grow" on:click={setAccount}>
        <button
          type="button"
          class="rounded-2xl border py-5 px-6 hover:opacity-80 flex bg-white grow"
        >
          <div class="mx-auto flex gap-1">
            <Icon icon="send" style="w-8" />
            <div class="my-auto">{$t("user.dashboard.send")}</div>
          </div>
        </button>
      </a>
    </div>
  </div>
</a>