aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Account.svelte
blob: 47deadcd300b5d23745ce8c6a3831ac6502040d1 (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
<script>
  import { account as acc } from "$lib/store";
  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="border rounded-xl shadow p-4 space-y-5">
    <div class="flex">
      <Balance {balance} {user} {rate} />
      <a href={`/account/${id}`} class="contents">
        <button class="ml-auto flex gap-1 mb-auto pb-2 pl-2">
          <div class="my-auto text-secondary">{name}</div>
          <Icon icon="settings" style="w-8 my-auto" />
        </button>
      </a>
    </div>

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

      <a href={`/invoice?account=${id}`} class="contents" on:click={setAccount}>
        <button
          class="rounded-2xl border py-5 px-6 font-bold hover:opacity-80 flex bg-primary grow"
        >
          <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>
    </div>
  </div>
</a>