Skip to content

Commit 3c9482a

Browse files
committed
chore: move user data to stores
1 parent cc975a5 commit 3c9482a

File tree

3 files changed

+26
-24
lines changed

3 files changed

+26
-24
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ import {
2424
status,
2525
verifStep,
2626
verificaitonId,
27+
verificationPerson,
28+
verificationDocument,
29+
verificationWebsocketData,
2730
} from "./store";
2831
2932
type Document = {
@@ -164,6 +167,10 @@ function watchEventStream(id: string) {
164167
person = data.person;
165168
document = data.document;
166169
websocketData = data; // Store the full websocket data
170+
// Also store in writable stores for selfie page
171+
verificationPerson.set(data.person);
172+
verificationDocument.set(data.document);
173+
verificationWebsocketData.set(data);
167174
if (data.status === "resubmission_requested") {
168175
DocFront.set(null);
169176
DocBack.set(null);

infrastructure/eid-wallet/src/routes/(auth)/verify/steps/selfie.svelte

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import axios from "axios";
88
import { getContext, onMount } from "svelte";
99
import { Shadow } from "svelte-loading-spinners";
1010
import { writable } from "svelte/store";
11-
import { Selfie, permissionGranted, verifStep, verificaitonId, status, reason } from "../store";
11+
import { Selfie, permissionGranted, verifStep, verificaitonId, status, reason, verificationPerson, verificationDocument, verificationWebsocketData } from "../store";
1212
import type { GlobalState } from "$lib/global";
1313
import { capitalize } from "$lib/utils";
1414
import { v4 as uuidv4 } from "uuid";
@@ -23,11 +23,6 @@ let showResults = $state(false);
2323
let loading = $state(false);
2424
let globalState: GlobalState | undefined = $state(undefined);
2525
26-
// Store websocket data
27-
let person: any = $state(null);
28-
let document: any = $state(null);
29-
let websocketData: { w3id?: string } | null = $state(null);
30-
3126
async function requestCameraPermission() {
3227
try {
3328
stream = await navigator.mediaDevices.getUserMedia({
@@ -54,13 +49,6 @@ function stopCamera() {
5449
$effect(() => {
5550
if ($status && $verifStep === 3) {
5651
showResults = true;
57-
// Get person/document data from context if needed
58-
const verifyContext = getContext<any>("verifyData");
59-
if (verifyContext) {
60-
person = verifyContext.person;
61-
document = verifyContext.document;
62-
websocketData = verifyContext.websocketData;
63-
}
6452
}
6553
});
6654
@@ -120,33 +108,37 @@ async function handleContinue() {
120108
return verifStep.set(0);
121109
}
122110
if (!globalState) throw new Error("Global state is not defined");
111+
if (!$verificationPerson || !$verificationDocument) {
112+
console.error("Missing verification data");
113+
return;
114+
}
123115
124116
loading = true;
125117
126118
try {
127119
globalState.userController.user = {
128120
name: capitalize(
129-
`${person.firstName.value} ${person.lastName.value ?? ""}`,
121+
`${$verificationPerson.firstName.value} ${$verificationPerson.lastName.value ?? ""}`,
130122
),
131-
"Date of Birth": new Date(person.dateOfBirth.value).toDateString(),
123+
"Date of Birth": new Date($verificationPerson.dateOfBirth.value).toDateString(),
132124
"ID submitted":
133-
document.type.value === "passport"
134-
? `Passport - ${document.country.value}`
135-
: document.type.value === "drivers_license"
136-
? `Driving License - ${document.country.value}`
137-
: `ID Card - ${document.country.value}`,
138-
"Document Number": document.number.value,
125+
$verificationDocument.type.value === "passport"
126+
? `Passport - ${$verificationDocument.country.value}`
127+
: $verificationDocument.type.value === "drivers_license"
128+
? `Driving License - ${$verificationDocument.country.value}`
129+
: `ID Card - ${$verificationDocument.country.value}`,
130+
"Document Number": $verificationDocument.number.value,
139131
};
140132
globalState.userController.document = {
141-
"Valid From": new Date(document.validFrom.value).toDateString(),
142-
"Valid Until": new Date(document.validUntil.value).toDateString(),
133+
"Valid From": new Date($verificationDocument.validFrom.value).toDateString(),
134+
"Valid Until": new Date($verificationDocument.validUntil.value).toDateString(),
143135
"Verified On": new Date().toDateString(),
144136
};
145137
globalState.userController.isFake = false;
146138
147139
if ($status === "duplicate") {
148140
// For duplicate case, skip provision and resolve the existing eVault URI
149-
const existingW3id = websocketData?.w3id;
141+
const existingW3id = $verificationWebsocketData?.w3id;
150142
if (!existingW3id) {
151143
throw new Error("No w3id provided for duplicate eVault");
152144
}

infrastructure/eid-wallet/src/routes/(auth)/verify/store.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ export const reason = writable<string>();
1111
export const documentType = writable<
1212
"passport" | "id" | "permit" | "dl" | null
1313
>(null);
14+
export const verificationPerson = writable<any>(null);
15+
export const verificationDocument = writable<any>(null);
16+
export const verificationWebsocketData = writable<{ w3id?: string } | null>(null);

0 commit comments

Comments
 (0)