Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
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
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
<script lang="ts">
import * as Button from "$lib/ui/Button";
import { cn } from "$lib/utils";
import {
CheckmarkBadge02Icon,
Upload03Icon,
ViewIcon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/svelte";
import type { HTMLAttributes } from "svelte/elements";
import * as Button from "$lib/ui/Button";
import { cn } from "$lib/utils";
import {
CheckmarkBadge02Icon,
Upload03Icon,
ViewIcon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/svelte";
import type { HTMLAttributes } from "svelte/elements";

interface userData {
[fieldName: string]: string;
}
interface IIdentityCard extends HTMLAttributes<HTMLElement> {
variant?: "eName" | "ePassport" | "eVault";
userId?: string;
viewBtn?: () => void;
shareBtn?: () => void;
userData?: userData;
totalStorage?: number;
usedStorage?: number;
}
interface userData {
[fieldName: string]: string;
}
interface IIdentityCard extends HTMLAttributes<HTMLElement> {
variant?: "eName" | "ePassport" | "eVault";
userId?: string;
viewBtn?: () => void;
shareBtn?: () => void;
userData?: userData;
totalStorage?: number;
usedStorage?: number;
}

const {
variant = "eName",
userId,
viewBtn,
shareBtn,
userData,
totalStorage = 0,
usedStorage = 0,
...restProps
}: IIdentityCard = $props();
const state = $state({
progressWidth: "0%",
});
const {
variant = "eName",
userId,
viewBtn,
shareBtn,
userData,
totalStorage = 0,
usedStorage = 0,
...restProps
}: IIdentityCard = $props();
const state = $state({
progressWidth: "0%",
});

$effect(() => {
state.progressWidth =
usedStorage > 0 ? `${(usedStorage / totalStorage) * 100}%` : "0%";
});
$effect(() => {
state.progressWidth =
usedStorage > 0 ? `${(usedStorage / totalStorage) * 100}%` : "0%";
});

const baseClasses = `relative ${variant === "eName" ? "bg-black-900" : variant === "ePassport" ? "bg-primary" : "bg-gray"} rounded-3xl w-full min-h-[150px] text-white overflow-hidden`;
const baseClasses = `relative ${variant === "eName" ? "bg-black-900" : variant === "ePassport" ? "bg-primary" : "bg-gray"} rounded-3xl w-full min-h-[150px] text-white overflow-hidden`;
</script>

<div {...restProps} class={cn(baseClasses, restProps.class)}>
Expand Down
34 changes: 17 additions & 17 deletions infrastructure/eid-wallet/src/routes/(app)/ePassport/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<script lang="ts">
import { AppNav, IdentityCard } from "$lib/fragments";
import type { GlobalState } from "$lib/global";
import * as Button from "$lib/ui/Button";
import { Share05Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/svelte";
import { getContext, onMount } from "svelte";
import { AppNav, IdentityCard } from "$lib/fragments";
import type { GlobalState } from "$lib/global";
import * as Button from "$lib/ui/Button";
import { Share05Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/svelte";
import { getContext, onMount } from "svelte";

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

function shareEPassport() {
alert("EPassport Code shared!");
}
function shareEPassport() {
alert("EPassport Code shared!");
}

let userData: Record<string, unknown>;
let docData: Record<string, unknown> = {};
let userData: Record<string, unknown>;
let docData: Record<string, unknown> = {};

onMount(async () => {
userData = await globalState.userController.user;
docData = await globalState.userController.document;
console.log(userData);
});
onMount(async () => {
userData = await globalState.userController.user;
docData = await globalState.userController.document;
console.log(userData);
});
</script>

<AppNav title="ePassport" class="mb-8" />
Expand Down
58 changes: 29 additions & 29 deletions infrastructure/eid-wallet/src/routes/(app)/main/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
<script lang="ts">
import { goto } from "$app/navigation";
import { Hero, IdentityCard } from "$lib/fragments";
import type { GlobalState } from "$lib/global";
import { Drawer } from "$lib/ui";
import * as Button from "$lib/ui/Button";
import { QrCodeIcon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/svelte";
import { getContext, onMount, type Snippet } from "svelte";
import { goto } from "$app/navigation";
import { Hero, IdentityCard } from "$lib/fragments";
import type { GlobalState } from "$lib/global";
import { Drawer } from "$lib/ui";
import * as Button from "$lib/ui/Button";
import { QrCodeIcon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/svelte";
import { getContext, onMount, type Snippet } from "svelte";

let userData: Record<string, unknown> = $state();
let greeting = $state();
let ename = $state();
let userData: Record<string, unknown> = $state();
let greeting = $state();
let ename = $state();

let shareQRdrawerOpen = $state(false);
let shareQRdrawerOpen = $state(false);

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

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

onMount(async () => {
userData = await globalState.userController.user;
const vaultData = await globalState.vaultController.vault;
ename = vaultData.ename;
onMount(async () => {
userData = await globalState.userController.user;
const vaultData = await globalState.vaultController.vault;
ename = vaultData.ename;

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

<Hero
Expand Down
174 changes: 87 additions & 87 deletions infrastructure/eid-wallet/src/routes/(app)/scan-qr/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,97 +1,97 @@
<script lang="ts">
import AppNav from "$lib/fragments/AppNav/AppNav.svelte";
import { Drawer } from "$lib/ui";
import * as Button from "$lib/ui/Button";
import {
FlashlightIcon,
Image02Icon,
QrCodeIcon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/svelte";
import {
Format,
type PermissionState,
type Scanned,
cancel,
checkPermissions,
requestPermissions,
scan,
} from "@tauri-apps/plugin-barcode-scanner";
import { onDestroy, onMount } from "svelte";
import type { SVGAttributes } from "svelte/elements";
const pathProps: SVGAttributes<SVGPathElement> = {
stroke: "white",
"stroke-width": 7,
"stroke-linecap": "round",
"stroke-linejoin": "round",
};
let codeScannedDrawerOpen = $state(false);
let loggedInDrawerOpen = $state(false);
let flashlightOn = $state(false);
let scannedData: Scanned | undefined = $state(undefined);
let scanning = false;
let loading = false;
let permissions_nullable: PermissionState | null;
async function startScan() {
let permissions = await checkPermissions()
.then((permissions) => {
return permissions;
import AppNav from "$lib/fragments/AppNav/AppNav.svelte";
import { Drawer } from "$lib/ui";
import * as Button from "$lib/ui/Button";
import {
FlashlightIcon,
Image02Icon,
QrCodeIcon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/svelte";
import {
Format,
type PermissionState,
type Scanned,
cancel,
checkPermissions,
requestPermissions,
scan,
} from "@tauri-apps/plugin-barcode-scanner";
import { onDestroy, onMount } from "svelte";
import type { SVGAttributes } from "svelte/elements";
const pathProps: SVGAttributes<SVGPathElement> = {
stroke: "white",
"stroke-width": 7,
"stroke-linecap": "round",
"stroke-linejoin": "round",
};
let codeScannedDrawerOpen = $state(false);
let loggedInDrawerOpen = $state(false);
let flashlightOn = $state(false);
let scannedData: Scanned | undefined = $state(undefined);
let scanning = false;
let loading = false;
let permissions_nullable: PermissionState | null;
async function startScan() {
let permissions = await checkPermissions()
.then((permissions) => {
return permissions;
})
.catch(() => {
return null; // possibly return "denied"? or does that imply that the check has been successful, but was actively denied?
});
// TODO: handle receiving "prompt-with-rationale" (issue: https://github.com/tauri-apps/plugins-workspace/issues/979)
if (permissions === "prompt") {
permissions = await requestPermissions(); // handle in more detail?
}
permissions_nullable = permissions;
if (permissions === "granted") {
// Scanning parameters
const formats = [Format.QRCode];
const windowed = true;
if (scanning) return;
scanning = true;
scan({ formats, windowed })
.then((res) => {
console.log("Scan result:", res);
scannedData = res;
codeScannedDrawerOpen = true;
})
.catch(() => {
return null; // possibly return "denied"? or does that imply that the check has been successful, but was actively denied?
.catch((error) => {
// TODO: display error to user
console.error("Scan error:", error);
})
.finally(() => {
scanning = false;
});
// TODO: handle receiving "prompt-with-rationale" (issue: https://github.com/tauri-apps/plugins-workspace/issues/979)
if (permissions === "prompt") {
permissions = await requestPermissions(); // handle in more detail?
}
permissions_nullable = permissions;
if (permissions === "granted") {
// Scanning parameters
const formats = [Format.QRCode];
const windowed = true;
if (scanning) return;
scanning = true;
scan({ formats, windowed })
.then((res) => {
console.log("Scan result:", res);
scannedData = res;
codeScannedDrawerOpen = true;
})
.catch((error) => {
// TODO: display error to user
console.error("Scan error:", error);
})
.finally(() => {
scanning = false;
});
}
console.error("Permission denied or not granted");
// TODO: consider handling GUI for permission denied
}
async function cancelScan() {
await cancel();
scanning = false;
}
console.error("Permission denied or not granted");
// TODO: consider handling GUI for permission denied
}
async function cancelScan() {
await cancel();
scanning = false;
}
onMount(async () => {
startScan();
});
onMount(async () => {
startScan();
});
onDestroy(async () => {
await cancelScan();
});
onDestroy(async () => {
await cancelScan();
});
</script>

<AppNav title="Scan QR Code" titleClasses="text-white" iconColor="white" />
Expand Down
Loading
Loading