Skip to content

Commit 52fa5ad

Browse files
profile page (#178)
* basic layout for profile page * fixed alt text * merge conflict * profile page for other users implemented * fix: profile pages and logics * fixed all the pages of profile * fixed all the pages of profile * fix: format --------- Co-authored-by: gourav <[email protected]>
1 parent 26dc10f commit 52fa5ad

File tree

33 files changed

+929
-717
lines changed

33 files changed

+929
-717
lines changed

infrastructure/eid-wallet/src/lib/fragments/IdentityCard/IdentityCard.svelte

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
<script lang="ts">
2-
import * as Button from "$lib/ui/Button";
3-
import { cn } from "$lib/utils";
4-
import {
5-
CheckmarkBadge02Icon,
6-
Upload03Icon,
7-
ViewIcon,
8-
} from "@hugeicons/core-free-icons";
9-
import { HugeiconsIcon } from "@hugeicons/svelte";
10-
import type { HTMLAttributes } from "svelte/elements";
2+
import * as Button from "$lib/ui/Button";
3+
import { cn } from "$lib/utils";
4+
import {
5+
CheckmarkBadge02Icon,
6+
Upload03Icon,
7+
ViewIcon,
8+
} from "@hugeicons/core-free-icons";
9+
import { HugeiconsIcon } from "@hugeicons/svelte";
10+
import type { HTMLAttributes } from "svelte/elements";
1111
12-
interface userData {
13-
[fieldName: string]: string;
14-
}
15-
interface IIdentityCard extends HTMLAttributes<HTMLElement> {
16-
variant?: "eName" | "ePassport" | "eVault";
17-
userId?: string;
18-
viewBtn?: () => void;
19-
shareBtn?: () => void;
20-
userData?: userData;
21-
totalStorage?: number;
22-
usedStorage?: number;
23-
}
12+
interface userData {
13+
[fieldName: string]: string;
14+
}
15+
interface IIdentityCard extends HTMLAttributes<HTMLElement> {
16+
variant?: "eName" | "ePassport" | "eVault";
17+
userId?: string;
18+
viewBtn?: () => void;
19+
shareBtn?: () => void;
20+
userData?: userData;
21+
totalStorage?: number;
22+
usedStorage?: number;
23+
}
2424
25-
const {
26-
variant = "eName",
27-
userId,
28-
viewBtn,
29-
shareBtn,
30-
userData,
31-
totalStorage = 0,
32-
usedStorage = 0,
33-
...restProps
34-
}: IIdentityCard = $props();
35-
const state = $state({
36-
progressWidth: "0%",
37-
});
25+
const {
26+
variant = "eName",
27+
userId,
28+
viewBtn,
29+
shareBtn,
30+
userData,
31+
totalStorage = 0,
32+
usedStorage = 0,
33+
...restProps
34+
}: IIdentityCard = $props();
35+
const state = $state({
36+
progressWidth: "0%",
37+
});
3838
39-
$effect(() => {
40-
state.progressWidth =
41-
usedStorage > 0 ? `${(usedStorage / totalStorage) * 100}%` : "0%";
42-
});
39+
$effect(() => {
40+
state.progressWidth =
41+
usedStorage > 0 ? `${(usedStorage / totalStorage) * 100}%` : "0%";
42+
});
4343
44-
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`;
44+
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`;
4545
</script>
4646

4747
<div {...restProps} class={cn(baseClasses, restProps.class)}>

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<script lang="ts">
2-
import { AppNav, IdentityCard } from "$lib/fragments";
3-
import type { GlobalState } from "$lib/global";
4-
import * as Button from "$lib/ui/Button";
5-
import { Share05Icon } from "@hugeicons/core-free-icons";
6-
import { HugeiconsIcon } from "@hugeicons/svelte";
7-
import { getContext, onMount } from "svelte";
2+
import { AppNav, IdentityCard } from "$lib/fragments";
3+
import type { GlobalState } from "$lib/global";
4+
import * as Button from "$lib/ui/Button";
5+
import { Share05Icon } from "@hugeicons/core-free-icons";
6+
import { HugeiconsIcon } from "@hugeicons/svelte";
7+
import { getContext, onMount } from "svelte";
88
9-
const globalState = getContext<() => GlobalState>("globalState")();
9+
const globalState = getContext<() => GlobalState>("globalState")();
1010
11-
function shareEPassport() {
12-
alert("EPassport Code shared!");
13-
}
11+
function shareEPassport() {
12+
alert("EPassport Code shared!");
13+
}
1414
15-
let userData: Record<string, unknown>;
16-
let docData: Record<string, unknown> = {};
15+
let userData: Record<string, unknown>;
16+
let docData: Record<string, unknown> = {};
1717
18-
onMount(async () => {
19-
userData = await globalState.userController.user;
20-
docData = await globalState.userController.document;
21-
console.log(userData);
22-
});
18+
onMount(async () => {
19+
userData = await globalState.userController.user;
20+
docData = await globalState.userController.document;
21+
console.log(userData);
22+
});
2323
</script>
2424

2525
<AppNav title="ePassport" class="mb-8" />

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

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
<script lang="ts">
2-
import { goto } from "$app/navigation";
3-
import { Hero, IdentityCard } from "$lib/fragments";
4-
import type { GlobalState } from "$lib/global";
5-
import { Drawer } from "$lib/ui";
6-
import * as Button from "$lib/ui/Button";
7-
import { QrCodeIcon } from "@hugeicons/core-free-icons";
8-
import { HugeiconsIcon } from "@hugeicons/svelte";
9-
import { getContext, onMount, type Snippet } from "svelte";
2+
import { goto } from "$app/navigation";
3+
import { Hero, IdentityCard } from "$lib/fragments";
4+
import type { GlobalState } from "$lib/global";
5+
import { Drawer } from "$lib/ui";
6+
import * as Button from "$lib/ui/Button";
7+
import { QrCodeIcon } from "@hugeicons/core-free-icons";
8+
import { HugeiconsIcon } from "@hugeicons/svelte";
9+
import { getContext, onMount, type Snippet } from "svelte";
1010
11-
let userData: Record<string, unknown> = $state();
12-
let greeting = $state();
13-
let ename = $state();
11+
let userData: Record<string, unknown> = $state();
12+
let greeting = $state();
13+
let ename = $state();
1414
15-
let shareQRdrawerOpen = $state(false);
15+
let shareQRdrawerOpen = $state(false);
1616
17-
function shareQR() {
18-
alert("QR Code shared!");
19-
shareQRdrawerOpen = false;
20-
}
17+
function shareQR() {
18+
alert("QR Code shared!");
19+
shareQRdrawerOpen = false;
20+
}
2121
22-
const globalState = getContext<() => GlobalState>("globalState")();
22+
const globalState = getContext<() => GlobalState>("globalState")();
2323
24-
onMount(async () => {
25-
userData = await globalState.userController.user;
26-
const vaultData = await globalState.vaultController.vault;
27-
ename = vaultData.ename;
24+
onMount(async () => {
25+
userData = await globalState.userController.user;
26+
const vaultData = await globalState.vaultController.vault;
27+
ename = vaultData.ename;
2828
29-
const currentHour = new Date().getHours();
30-
greeting =
31-
currentHour > 17
32-
? "Good Evening"
33-
: currentHour > 12
34-
? "Good Afternoon"
35-
: "Good Morning";
36-
});
29+
const currentHour = new Date().getHours();
30+
greeting =
31+
currentHour > 17
32+
? "Good Evening"
33+
: currentHour > 12
34+
? "Good Afternoon"
35+
: "Good Morning";
36+
});
3737
</script>
3838

3939
<Hero

infrastructure/eid-wallet/src/routes/(app)/scan-qr/+page.svelte

Lines changed: 87 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,97 @@
11
<script lang="ts">
2-
import AppNav from "$lib/fragments/AppNav/AppNav.svelte";
3-
import { Drawer } from "$lib/ui";
4-
import * as Button from "$lib/ui/Button";
5-
import {
6-
FlashlightIcon,
7-
Image02Icon,
8-
QrCodeIcon,
9-
} from "@hugeicons/core-free-icons";
10-
import { HugeiconsIcon } from "@hugeicons/svelte";
11-
import {
12-
Format,
13-
type PermissionState,
14-
type Scanned,
15-
cancel,
16-
checkPermissions,
17-
requestPermissions,
18-
scan,
19-
} from "@tauri-apps/plugin-barcode-scanner";
20-
import { onDestroy, onMount } from "svelte";
21-
import type { SVGAttributes } from "svelte/elements";
22-
23-
const pathProps: SVGAttributes<SVGPathElement> = {
24-
stroke: "white",
25-
"stroke-width": 7,
26-
"stroke-linecap": "round",
27-
"stroke-linejoin": "round",
28-
};
29-
30-
let codeScannedDrawerOpen = $state(false);
31-
let loggedInDrawerOpen = $state(false);
32-
let flashlightOn = $state(false);
33-
34-
let scannedData: Scanned | undefined = $state(undefined);
35-
36-
let scanning = false;
37-
let loading = false;
38-
39-
let permissions_nullable: PermissionState | null;
40-
41-
async function startScan() {
42-
let permissions = await checkPermissions()
43-
.then((permissions) => {
44-
return permissions;
2+
import AppNav from "$lib/fragments/AppNav/AppNav.svelte";
3+
import { Drawer } from "$lib/ui";
4+
import * as Button from "$lib/ui/Button";
5+
import {
6+
FlashlightIcon,
7+
Image02Icon,
8+
QrCodeIcon,
9+
} from "@hugeicons/core-free-icons";
10+
import { HugeiconsIcon } from "@hugeicons/svelte";
11+
import {
12+
Format,
13+
type PermissionState,
14+
type Scanned,
15+
cancel,
16+
checkPermissions,
17+
requestPermissions,
18+
scan,
19+
} from "@tauri-apps/plugin-barcode-scanner";
20+
import { onDestroy, onMount } from "svelte";
21+
import type { SVGAttributes } from "svelte/elements";
22+
23+
const pathProps: SVGAttributes<SVGPathElement> = {
24+
stroke: "white",
25+
"stroke-width": 7,
26+
"stroke-linecap": "round",
27+
"stroke-linejoin": "round",
28+
};
29+
30+
let codeScannedDrawerOpen = $state(false);
31+
let loggedInDrawerOpen = $state(false);
32+
let flashlightOn = $state(false);
33+
34+
let scannedData: Scanned | undefined = $state(undefined);
35+
36+
let scanning = false;
37+
let loading = false;
38+
39+
let permissions_nullable: PermissionState | null;
40+
41+
async function startScan() {
42+
let permissions = await checkPermissions()
43+
.then((permissions) => {
44+
return permissions;
45+
})
46+
.catch(() => {
47+
return null; // possibly return "denied"? or does that imply that the check has been successful, but was actively denied?
48+
});
49+
50+
// TODO: handle receiving "prompt-with-rationale" (issue: https://github.com/tauri-apps/plugins-workspace/issues/979)
51+
if (permissions === "prompt") {
52+
permissions = await requestPermissions(); // handle in more detail?
53+
}
54+
55+
permissions_nullable = permissions;
56+
57+
if (permissions === "granted") {
58+
// Scanning parameters
59+
const formats = [Format.QRCode];
60+
const windowed = true;
61+
62+
if (scanning) return;
63+
scanning = true;
64+
scan({ formats, windowed })
65+
.then((res) => {
66+
console.log("Scan result:", res);
67+
scannedData = res;
68+
codeScannedDrawerOpen = true;
4569
})
46-
.catch(() => {
47-
return null; // possibly return "denied"? or does that imply that the check has been successful, but was actively denied?
70+
.catch((error) => {
71+
// TODO: display error to user
72+
console.error("Scan error:", error);
73+
})
74+
.finally(() => {
75+
scanning = false;
4876
});
49-
50-
// TODO: handle receiving "prompt-with-rationale" (issue: https://github.com/tauri-apps/plugins-workspace/issues/979)
51-
if (permissions === "prompt") {
52-
permissions = await requestPermissions(); // handle in more detail?
53-
}
54-
55-
permissions_nullable = permissions;
56-
57-
if (permissions === "granted") {
58-
// Scanning parameters
59-
const formats = [Format.QRCode];
60-
const windowed = true;
61-
62-
if (scanning) return;
63-
scanning = true;
64-
scan({ formats, windowed })
65-
.then((res) => {
66-
console.log("Scan result:", res);
67-
scannedData = res;
68-
codeScannedDrawerOpen = true;
69-
})
70-
.catch((error) => {
71-
// TODO: display error to user
72-
console.error("Scan error:", error);
73-
})
74-
.finally(() => {
75-
scanning = false;
76-
});
77-
}
78-
79-
console.error("Permission denied or not granted");
80-
// TODO: consider handling GUI for permission denied
8177
}
8278
83-
async function cancelScan() {
84-
await cancel();
85-
scanning = false;
86-
}
79+
console.error("Permission denied or not granted");
80+
// TODO: consider handling GUI for permission denied
81+
}
82+
83+
async function cancelScan() {
84+
await cancel();
85+
scanning = false;
86+
}
8787
88-
onMount(async () => {
89-
startScan();
90-
});
88+
onMount(async () => {
89+
startScan();
90+
});
9191
92-
onDestroy(async () => {
93-
await cancelScan();
94-
});
92+
onDestroy(async () => {
93+
await cancelScan();
94+
});
9595
</script>
9696

9797
<AppNav title="Scan QR Code" titleClasses="text-white" iconColor="white" />

0 commit comments

Comments
 (0)