aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/SetAmount.svelte
blob: c339aa7de221551e83ddf75761d73f2e0a8f80e0 (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
<script lang="ts">
  import { amountPrompt } from "$lib/store";
  import Numpad from "$comp/Numpad.svelte";
  import Toggle from "$comp/Toggle.svelte";

  let submit = $state();

  let {
    currency = $bindable("USD"),
    fiat = $bindable(true),
    locale = $bindable("en-US"),
    rate = $bindable(0),
    settingAmount,
    setAmount,
    newAmount = $bindable(0),
    toggleAmount,
    element = undefined,
    t,
  }: any = $props();
</script>

{#if settingAmount}
  <div class="fixed inset-0 bg-base-100/90 overflow-y-auto h-full w-full z-50">
    <div class="relative mx-auto p-12 max-w-xl shadow-lg rounded-md bg-base-100 space-y-5">
      <form onsubmit={setAmount} class="space-y-5">
        <Numpad bind:amount={newAmount} bind:fiat {currency} {rate} {submit} {locale} />
        <div class="w-full flex flex-wrap gap-2">
          <button bind:this={submit} type="submit" onclick={setAmount} class="btn btn-accent">
            <div class="my-auto">{t("payments.ok")}</div>
          </button>
          <button type="button" class="btn" onclick={toggleAmount} onkeydown={toggleAmount}>
            <div class="my-auto">{t("payments.cancel")}</div>
          </button>
        </div>
      </form>

      <div class="flex justify-center gap-3">
        <div class="text-secondary">{t("payments.amountPrompt")}</div>
        <Toggle id="notify" bind:value={$amountPrompt} />
      </div>
    </div>
  </div>
{/if}