aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Account.svelte
blob: d283b393ad4ae39b76ce3ef55ef8ec982928b6d5 (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 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 space-y-2" on:click={setAccount}>
  <div class="flex">
    <Balance {balance} {user} {rate} />
    <a href={`/payments`} class="contents" on:click={setAccount}>
      <button class="ml-auto flex gap-1 mb-auto pb-4 pl-4">
        <Icon icon="clock" style="w-8 my-auto" />
      </button>
    </a>
    <a href={`/account/${id}`} class="contents">
      <button class="flex gap-1 mb-auto pb-4 pl-4">
        <Icon icon="settings" style="w-8 my-auto" />
      </button>
    </a>
  </div>

  <div class="flex justify-center w-full text-lg gap-2">
    <a href={`/invoice`} class="contents" on:click={setAccount}>
      <button
        class="py-3 px-4 hover:opacity-80 flex grow border rounded-2xl bg-primary"
      >
        <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={`/send`} class="contents grow" on:click={setAccount}>
      <button
        type="button"
        class="py-3 px-4 hover:opacity-80 flex grow border rounded-2xl bg-primary"
      >
        <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>
</a>