aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Balance.svelte
blob: 0cc27068ec14845a5cb8c121d63c068ec0f0a103 (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
<script>
  import Icon from "$comp/Icon.svelte";
  import Pin from "$comp/Pin.svelte";
  import { f, s, sat, sats } from "$lib/utils";
  import { pin } from "$lib/store";
  import { t } from "$lib/translations";

  let show;
  export let user, rate, balance;
</script>

{#if show && user.haspin && $pin?.length !== 6}
  <Pin cancel={() => (show = false)} />
{/if}

<div>
  {#if user.haspin && !$pin}
    <button
      on:click|preventDefault={() => (show = true)}
      class="flex gap-2 text-xl"
    >
      <Icon icon="eye-off" style="w-8 my-auto" />
      <div class="my-auto">{$t("user.showBalance")}</div>
    </button>
  {:else}
    <div class="text-4xl font-bold tabular-nums">
      {#if isNaN(rate)}
        <div class="text-gray-200">&mdash;</div>
      {:else}
        {f((balance * rate) / sats, user.currency)}
      {/if}
    </div>

    <div class="text-secondary text-xl">
      ⚡️{s(balance)}
    </div>
  {/if}
</div>