Skip to content

Commit 01c09dc

Browse files
authored
Fix/eid app onboarding UX issues (#419)
* fix: app-issueS * fix: repeat pin button validation * fix: input pin component * fix: btn variants * fix: conflicts * fix: format * fix: lint * fix: reset-pin * fix: format and lint
1 parent 5982c51 commit 01c09dc

4 files changed

Lines changed: 63 additions & 14 deletions

File tree

infrastructure/eid-wallet/src/lib/ui/InputPin/InputPin.svelte

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ $effect(() => {
4343
pin = calcPin(pins);
4444
});
4545
46+
$effect(() => {
47+
if (pin === "") {
48+
for (const key of Object.keys(pins)) {
49+
pins[+key] = "";
50+
}
51+
}
52+
});
53+
4654
const calcPin = (pins: { [key: number]: string }) => {
4755
return Object.values(pins).join("") || "";
4856
};

infrastructure/eid-wallet/src/routes/(app)/settings/pin/+page.svelte

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script lang="ts">
2+
import { goto } from "$app/navigation";
23
import type { GlobalState } from "$lib/global";
34
import { runtime } from "$lib/global/runtime.svelte";
45
import { ButtonAction, Drawer, InputPin } from "$lib/ui";
@@ -16,6 +17,7 @@ let showDrawer = $state(false);
1617
const handleClose = async () => {
1718
// close functionality goes here.
1819
showDrawer = false;
20+
goto("/settings");
1921
};
2022
2123
const handleChangePIN = async () => {
@@ -30,7 +32,11 @@ const handleChangePIN = async () => {
3032
}
3133
3234
try {
33-
await globalState?.securityController.updatePin(currentPin, newPin);
35+
await globalState?.securityController.updatePin(
36+
newPin,
37+
repeatPin,
38+
currentPin,
39+
);
3440
isError = false;
3541
showDrawer = true;
3642
} catch (err) {

infrastructure/eid-wallet/src/routes/(auth)/login/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ onMount(async () => {
4848
}
4949
5050
clearPin = async () => {
51-
await globalState?.securityController.clearPin();
52-
goto("/");
51+
pin = "";
52+
isError = false;
5353
};
5454
5555
handlePinInput = async (pin: string) => {

infrastructure/eid-wallet/src/routes/(auth)/register/+page.svelte

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ let isBiometricsAvailable = $state(false);
1616
let isBiometricScreen = $state(false);
1717
let isBiometricsAdded = $state(false);
1818
let isError = $state(false);
19+
let btnVariant = $state<"soft" | "solid">("soft");
1920
2021
let globalState: GlobalState | undefined = $state(undefined);
2122
2223
const handleFirstStep = async () => {
23-
if (pin.length === 4) firstStep = false;
24+
if (pin.length === 4) {
25+
firstStep = false;
26+
btnVariant = "solid";
27+
}
2428
};
2529
2630
let handleConfirm: () => Promise<void> = $state(async () => {});
@@ -51,6 +55,21 @@ $effect(() => {
5155
isError = false;
5256
});
5357
58+
$effect(() => {
59+
// First step button
60+
if (firstStep) {
61+
btnVariant = pin.length === 4 ? "solid" : "soft";
62+
} else {
63+
// Second step button
64+
if (repeatPin.length === 4 && pin === repeatPin) {
65+
btnVariant = "solid";
66+
isError = false;
67+
} else {
68+
btnVariant = "soft";
69+
}
70+
}
71+
});
72+
5473
onMount(async () => {
5574
globalState = getContext<() => GlobalState>("globalState")();
5675
if (!globalState) throw new Error("Global state is not defined");
@@ -59,17 +78,27 @@ onMount(async () => {
5978
console.log("isBiometricsAvailable", isBiometricsAvailable);
6079
6180
handleConfirm = async () => {
62-
//confirm pin logic goes here
63-
if (repeatPin && repeatPin.length === 4 && pin !== repeatPin) {
64-
firstStep = true;
81+
if (repeatPin.length < 4) {
6582
isError = true;
66-
} else {
67-
isError = false;
68-
showDrawer = true;
69-
await globalState?.securityController.updatePin(pin, repeatPin);
7083
return;
7184
}
85+
86+
if (pin !== repeatPin) {
87+
isError = true;
88+
firstStep = true;
89+
return;
90+
}
91+
92+
isError = false;
93+
try {
94+
await globalState?.securityController.updatePin(pin, repeatPin);
95+
showDrawer = true;
96+
} catch (error) {
97+
console.error("Failed to update PIN:", error);
98+
isError = true;
99+
}
72100
};
101+
73102
handleSetupBiometrics = async () => {
74103
if (!globalState)
75104
throw new Error(
@@ -107,7 +136,11 @@ onMount(async () => {
107136
Your PIN does not match, try again.
108137
</p>
109138
</section>
110-
<ButtonAction class="w-full" variant="soft" callback={handleFirstStep}>
139+
<ButtonAction
140+
class="w-full"
141+
variant={btnVariant}
142+
callback={handleFirstStep}
143+
>
111144
Confirm
112145
</ButtonAction>
113146
</main>
@@ -123,8 +156,10 @@ onMount(async () => {
123156
</Hero>
124157
<InputPin bind:pin={repeatPin} />
125158
</section>
126-
<ButtonAction class="w-full" callback={handleConfirm}
127-
>Confirm</ButtonAction
159+
<ButtonAction
160+
variant={btnVariant}
161+
class="w-full"
162+
callback={handleConfirm}>Confirm</ButtonAction
128163
>
129164
</main>
130165
{/if}

0 commit comments

Comments
 (0)