aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Password.svelte
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-11-26 21:45:00 -0800
committerAdam Soltys <[email protected]>2024-11-26 21:45:00 -0800
commitf4eb6547d0db5edd0137fdefe461433500515040 (patch)
tree86a24ca7f263f80f322d59b2e5def5fc6b062719 /src/components/Password.svelte
parent872aa0b3b0b9a847b8afcdee7f1ad53c524ce4f0 (diff)
downloadcoinos-ui-f4eb6547d0db5edd0137fdefe461433500515040.tar.gz
coinos-ui-f4eb6547d0db5edd0137fdefe461433500515040.zip
warnings
Diffstat (limited to 'src/components/Password.svelte')
-rw-r--r--src/components/Password.svelte55
1 files changed, 13 insertions, 42 deletions
diff --git a/src/components/Password.svelte b/src/components/Password.svelte
index dc77c0d3..bc32129d 100644
--- a/src/components/Password.svelte
+++ b/src/components/Password.svelte
@@ -1,25 +1,26 @@
<script lang="ts">
import { t } from "$lib/translations";
- import { preventDefault } from "svelte/legacy";
+ import PasswordInput from "$comp/PasswordInput.svelte";
- import Icon from "$comp/Icon.svelte";
import { focus, fail, post } from "$lib/utils";
import { password as pw, passwordPrompt } from "$lib/store";
let { user } = $props();
-
let password = $state();
- let { username } = user;
- let revealPassword = $state(false);
let cancel = () => ($passwordPrompt = false);
- let submit = async () => {
+ let submit = async (e) => {
+ console.log("submitting");
+ e.preventDefault();
try {
- await post("/password", { password });
+ console.log("res?");
+ let res = await post("/password", { password });
+ console.log(res);
$passwordPrompt = false;
$pw = password;
} catch (e) {
+ console.log(e);
fail("Invalid password, try again");
}
};
@@ -34,47 +35,17 @@
<h1 class="text-center text-2xl font-semibold">
{$t("user.settings.pleaseEnterYourPassword")}
</h1>
- <form onsubmit={preventDefault(submit)} class="space-y-2">
- <label
- for="password"
- class="input flex items-center justify-center gap-2 w-full"
- >
- {#if revealPassword}
- <input
- class="clean"
- name="password"
- type="text"
- required
- bind:value={password}
- autocapitalize="none"
- use:focus
- />
- {:else}
- <input
- class="clean"
- name="password"
- type="password"
- required
- bind:value={password}
- autocapitalize="none"
- use:focus
- />
- {/if}
- <iconify-icon
- class="cursor-pointer"
- onclick={() => (revealPassword = !revealPassword)}
- icon={revealPassword ? "ph:eye-bold" : "ph:eye-slash-bold"}
- width="32"
- ></iconify-icon>
- </label>
+ <form onsubmit={submit} class="space-y-2">
+ <PasswordInput bind:value={password} {focus} />
<div class="w-full flex gap-2">
<button
type="button"
class="btn !w-auto grow"
onclick={cancel}
- onkeydown={cancel}>Cancel</button
+ onkeydown={cancel}>{$t("payments.cancel")}</button
>
- <button type="submit" class="btn btn-accent !w-auto grow">Submit</button
+ <button type="submit" class="btn btn-accent !w-auto grow"
+ >{$t("payments.submit")}</button
>
</div>
</form>