Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 95 additions & 92 deletions infrastructure/eid-wallet/src/routes/(app)/main/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
<script lang="ts">
import { goto } from "$app/navigation";
import { Hero, IdentityCard } from "$lib/fragments";
import type { GlobalState } from "$lib/global";
import { Drawer, Toast } from "$lib/ui";
import * as Button from "$lib/ui/Button";
import {
CircleArrowDataTransferDiagonalFreeIcons,
QrCodeIcon,
Settings02Icon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/svelte";
import { type Snippet, getContext, onMount } from "svelte";
import { onDestroy } from "svelte";
import { Shadow } from "svelte-loading-spinners";
import QrCode from "svelte-qrcode";

let userData: Record<string, unknown> | undefined = $state(undefined);
let greeting: string | undefined = $state(undefined);
let ename: string | undefined = $state(undefined);
let profileCreationStatus: "idle" | "loading" | "success" | "failed" =
$state("idle");

let shareQRdrawerOpen = $state(false);
let statusInterval: ReturnType<typeof setInterval> | undefined =
$state(undefined);
let showToast = $state(false);
let toastMessage = $state("");

function shareQR() {
alert("QR Code shared!");
shareQRdrawerOpen = false;
}

async function copyEName() {
if (!ename) return;
try {
await navigator.clipboard.writeText(ename);
toastMessage = "eName copied to clipboard!";
showToast = true;
} catch (error) {
console.error("Failed to copy eName:", error);
toastMessage = "Failed to copy eName";
showToast = true;
import { goto } from "$app/navigation";
import { Hero, IdentityCard } from "$lib/fragments";
import type { GlobalState } from "$lib/global";
import { Drawer, Toast } from "$lib/ui";
import * as Button from "$lib/ui/Button";
import {
CircleArrowDataTransferDiagonalFreeIcons,
QrCodeIcon,
Settings02Icon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/svelte";
import { type Snippet, getContext, onMount } from "svelte";
import { onDestroy } from "svelte";
import { Shadow } from "svelte-loading-spinners";
import QrCode from "svelte-qrcode";

let userData: Record<string, unknown> | undefined = $state(undefined);
let greeting: string | undefined = $state(undefined);
let ename: string | undefined = $state(undefined);
let profileCreationStatus: "idle" | "loading" | "success" | "failed" =
$state("idle");

let shareQRdrawerOpen = $state(false);
let statusInterval: ReturnType<typeof setInterval> | undefined =
$state(undefined);
let showToast = $state(false);
let toastMessage = $state("");

function shareQR() {
alert("QR Code shared!");
shareQRdrawerOpen = false;
}
}

function handleToastClose() {
showToast = false;
}
async function copyEName() {
if (!ename) return;
try {
await navigator.clipboard.writeText(ename);
toastMessage = "eName copied to clipboard!";
showToast = true;
} catch (error) {
console.error("Failed to copy eName:", error);
toastMessage = "Failed to copy eName";
showToast = true;
}
}

function handleToastClose() {
showToast = false;
}

async function retryProfileCreation() {
try {
await globalState.vaultController.retryProfileCreation();
} catch (error) {
console.error("Retry failed:", error);
async function retryProfileCreation() {
try {
await globalState.vaultController.retryProfileCreation();
} catch (error) {
console.error("Retry failed:", error);
}
}
}

const globalState = getContext<() => GlobalState>("globalState")();
const globalState = getContext<() => GlobalState>("globalState")();

onMount(() => {
// Load initial data
(async () => {
const userInfo = await globalState.userController.user;
const isFake = await globalState.userController.isFake;
userData = { ...userInfo, isFake };
const vaultData = await globalState.vaultController.vault;
ename = vaultData?.ename;
})();
onMount(() => {
// Load initial data
(async () => {
const userInfo = await globalState.userController.user;
const isFake = await globalState.userController.isFake;
userData = { ...userInfo, isFake };
const vaultData = await globalState.vaultController.vault;
ename = vaultData?.ename;
})();

// Get initial profile creation status
// Get initial profile creation status
profileCreationStatus = globalState.vaultController.profileCreationStatus;
console.log("status current", profileCreationStatus);

// Set up a watcher for profile creation status changes
const checkStatus = () => {
profileCreationStatus =
globalState.vaultController.profileCreationStatus;
};

// Check status periodically
statusInterval = setInterval(checkStatus, 1000);

const currentHour = new Date().getHours();
greeting =
currentHour > 17
? "Good Evening"
: currentHour > 12
? "Good Afternoon"
: "Good Morning";
});

onDestroy(() => {
if (statusInterval) {
clearInterval(statusInterval);
}
});
console.log("status current", profileCreationStatus);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

// Set up a watcher for profile creation status changes
const checkStatus = () => {
profileCreationStatus =
globalState.vaultController.profileCreationStatus;
};

// Check status periodically
statusInterval = setInterval(checkStatus, 1000);

const currentHour = new Date().getHours();
greeting =
currentHour > 17
? "Good Evening"
: currentHour > 12
? "Good Afternoon"
: "Good Morning";
});

onDestroy(() => {
if (statusInterval) {
clearInterval(statusInterval);
}
});
</script>

{#if profileCreationStatus === "loading"}
Expand Down Expand Up @@ -198,12 +198,15 @@ onDestroy(() => {
</div>
</Drawer>

<Button.Nav href="/scan-qr">
<Button.Nav
href="/scan-qr"
class="fixed bottom-12 left-1/2 -translate-x-1/2"
>
<Button.Action
variant="solid"
size="sm"
size="md"
onclick={() => alert("Action button clicked!")}
class="mx-auto text-nowrap flex gap-8 fixed bottom-5 left-1/2 -translate-x-1/2 z-10"
class="mx-auto text-nowrap flex gap-8"
>
<HugeiconsIcon
size={32}
Expand Down
100 changes: 50 additions & 50 deletions infrastructure/eid-wallet/src/routes/(app)/settings/pin/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
<script lang="ts">
import { goto } from "$app/navigation";
import type { GlobalState } from "$lib/global";
import { runtime } from "$lib/global/runtime.svelte";
import { ButtonAction, Drawer, InputPin } from "$lib/ui";
import { CircleLock01Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/svelte";
import { getContext, onMount } from "svelte";
import { goto } from "$app/navigation";
import type { GlobalState } from "$lib/global";
import { runtime } from "$lib/global/runtime.svelte";
import { ButtonAction, Drawer, InputPin } from "$lib/ui";
import { CircleLock01Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/svelte";
import { getContext, onMount } from "svelte";

let globalState: GlobalState | undefined = $state(undefined);
let currentPin = $state("");
let newPin = $state("");
let repeatPin = $state("");
let isError = $state(false);
let showDrawer = $state(false);
let globalState: GlobalState | undefined = $state(undefined);
let currentPin = $state("");
let newPin = $state("");
let repeatPin = $state("");
let isError = $state(false);
let showDrawer = $state(false);

const handleClose = async () => {
// close functionality goes here.
showDrawer = false;
goto("/settings");
};
const handleClose = async () => {
// close functionality goes here.
showDrawer = false;
goto("/settings");
};

const handleChangePIN = async () => {
const handleChangePIN = async () => {
if (newPin.length < 4 || repeatPin.length < 4 || currentPin.length < 4) {
isError = true;
return;
}
isError = true;
return;
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

if (newPin !== repeatPin) {
isError = true;
return;
}
if (newPin !== repeatPin) {
isError = true;
return;
}

try {
await globalState?.securityController.updatePin(
newPin,
repeatPin,
currentPin,
);
isError = false;
showDrawer = true;
} catch (err) {
console.error("Failed to update PIN:", err);
isError = true;
}
};
try {
await globalState?.securityController.updatePin(
newPin,
repeatPin,
currentPin,
);
isError = false;
showDrawer = true;
} catch (err) {
console.error("Failed to update PIN:", err);
isError = true;
}
};

$effect(() => {
runtime.header.title = "Change PIN";
if (repeatPin.length === 4 && newPin === repeatPin) isError = false;
});
$effect(() => {
runtime.header.title = "Change PIN";
if (repeatPin.length === 4 && newPin === repeatPin) isError = false;
});

onMount(() => {
globalState = getContext<() => GlobalState>("globalState")();
if (!globalState) throw new Error("Global state is not defined");
});
onMount(() => {
globalState = getContext<() => GlobalState>("globalState")();
if (!globalState) throw new Error("Global state is not defined");
});
</script>

<main
class="h-[85vh] pt-[4svh] px-[5vw] pb-[4.5svh] flex flex-col justify-between"
class="h-[85vh] pt-[4svh] px-[5vw] pb-[8svh] flex flex-col justify-between"
>
<section>
<div>
Expand All @@ -83,9 +83,9 @@ onMount(() => {

<Drawer bind:isPaneOpen={showDrawer}>
<div
class="relative bg-gray w-[72px] h-[72px] rounded-[24px] flex justify-center items-center mb-[2.3svh]"
class="relative bg-gray w-18 h-18 rounded-3xl flex justify-center items-center mb-[2.3svh]"
>
<span class="relative z-[1]">
<span class="relative z-1">
<HugeiconsIcon
icon={CircleLock01Icon}
color="var(--color-primary)"
Expand Down
Loading
Loading