|
1 | 1 | <script lang="ts"> |
2 | | -import { goto } from "$app/navigation"; |
3 | | -import { Hero } from "$lib/fragments"; |
4 | | -import { GlobalState } from "$lib/global"; |
5 | | -import { ButtonAction } from "$lib/ui"; |
6 | | -import { getContext, onMount } from "svelte"; |
| 2 | + import { goto } from "$app/navigation"; |
| 3 | + import { Hero } from "$lib/fragments"; |
| 4 | + import { GlobalState } from "$lib/global"; |
| 5 | + import { ButtonAction } from "$lib/ui"; |
| 6 | + import { getContext, onMount } from "svelte"; |
| 7 | + import Drawer from "$lib/ui/Drawer/Drawer.svelte"; |
| 8 | + import axios from "axios"; |
| 9 | + import { PUBLIC_PROVISIONER_URL } from "$env/static/public"; |
| 10 | + import { verifStep } from "./store"; |
| 11 | + import Passport from "./steps/passport.svelte"; |
| 12 | + import Selfie from "./steps/selfie.svelte"; |
7 | 13 |
|
8 | | -let globalState: GlobalState | undefined = $state(undefined); |
| 14 | + let globalState: GlobalState | undefined = $state(undefined); |
| 15 | + let showVeriffModal = $state(false); |
9 | 16 |
|
10 | | -let handleVerification: () => Promise<void>; |
| 17 | + async function handleVerification() { |
| 18 | + const { data } = await axios.post( |
| 19 | + new URL("/idv", PUBLIC_PROVISIONER_URL).toString(), |
| 20 | + ); |
| 21 | + console.log(data); |
| 22 | + showVeriffModal = true; |
| 23 | + } |
11 | 24 |
|
12 | | -onMount(() => { |
13 | | - globalState = getContext<() => GlobalState>("globalState")(); |
14 | | - // handle verification logic + set user data in the store |
15 | | - handleVerification = async () => { |
16 | | - if (!globalState) throw new Error("Global state is not defined"); |
17 | | - globalState.userController.user = { |
18 | | - name: "John Doe", |
19 | | - "Date of Birth": "01/01/2000", |
20 | | - "ID submitted": "American Passport", |
21 | | - "Passport Number": "1234567-US", |
22 | | - }; |
23 | | - await goto("/register"); |
24 | | - }; |
25 | | -}); |
| 25 | + onMount(() => { |
| 26 | + globalState = getContext<() => GlobalState>("globalState")(); |
| 27 | + // handle verification logic + set user data in the store |
| 28 | +
|
| 29 | + // handleVerification = async () => { |
| 30 | + // if (!globalState) throw new Error("Global state is not defined"); |
| 31 | + // globalState.userController.user = { |
| 32 | + // name: "John Doe", |
| 33 | + // "Date of Birth": "01/01/2000", |
| 34 | + // "ID submitted": "American Passport", |
| 35 | + // "Passport Number": "1234567-US", |
| 36 | + // }; |
| 37 | + // await goto("/register"); |
| 38 | + // }; |
| 39 | + }); |
26 | 40 | </script> |
27 | 41 |
|
28 | | -<main class="h-screen pt-[3svh] px-[5vw] pb-[4.5svh] flex flex-col justify-between items-center"> |
| 42 | +<main |
| 43 | + class="pt-[3svh] px-[5vw] pb-[4.5svh] flex flex-col justify-between items-center" |
| 44 | +> |
29 | 45 | <section> |
30 | 46 | <Hero |
31 | 47 | title="Verify your account" |
32 | 48 | subtitle="Get your passport ready. You’ll be directed to a site where you can verify your account in a swift and secure process" |
33 | 49 | /> |
34 | | - <img class="mx-auto mt-20" src="images/Passport.svg" alt="passport"> |
| 50 | + <img class="mx-auto mt-20" src="images/Passport.svg" alt="passport" /> |
35 | 51 | </section> |
36 | | - <ButtonAction class="w-full" callback={async() => { |
37 | | - try { |
38 | | - await handleVerification(); |
39 | | - } catch (error) { |
40 | | - console.error("Verification failed:", error); |
41 | | - // Consider adding user-facing error handling here |
42 | | - } |
43 | | - }}>I'm ready</ButtonAction> |
| 52 | + <ButtonAction class="w-full mt-10" callback={handleVerification} |
| 53 | + >I'm ready</ButtonAction |
| 54 | + > |
| 55 | + <Drawer bind:isPaneOpen={showVeriffModal}> |
| 56 | + {#if $verifStep === 0} |
| 57 | + <Passport></Passport> |
| 58 | + {:else if $verifStep === 1} |
| 59 | + <Selfie></Selfie> |
| 60 | + {/if} |
| 61 | + </Drawer> |
44 | 62 | </main> |
0 commit comments