Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
32 changes: 22 additions & 10 deletions app/incode/incode.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
'use client';
import { useEffect, useRef } from "react"

import { useEffect, useRef } from "react";
import { create } from "@incodetech/welcome";

function Incode({ session, baseUrl }:UserConsentPropTypes) {
const containerRef = useRef<HTMLDivElement>(null);
const isMounted = useRef(false);
let isOnboardingFinished = false;
console.log(session)
let incode: any;

useEffect(() => {
if (window && window.OnBoarding) {
// Initialize the SDK
incode = window.OnBoarding.create({
incode = create({
apiURL: baseUrl
});
}
});
console.log(incode)

if (incode && isMounted.current) {
return;
Expand All @@ -41,6 +38,21 @@ function Incode({ session, baseUrl }:UserConsentPropTypes) {
})
}

function captureDocument() {
incode.renderCamera("document", containerRef.current, {
onSuccess: (evt: any) => {
console.log(evt);
finishOnboarding();
},
onError: console.log,
token: session,
showTutorial: true,
onLog: console.log,
numberOfTries: 3,
nativeCamera:true
});
}

function processId() {
return incode.processId({ token: session.token })
.then(() => {
Expand All @@ -55,14 +67,13 @@ function Incode({ session, baseUrl }:UserConsentPropTypes) {
incode.renderCamera("selfie", containerRef.current, {
token: session,
numberOfTries: 3,
onSuccess: finishOnboarding,
onSuccess: captureDocument,
onError: console.log,
showTutorial: true,
});
}

function finishOnboarding() {
console.log("faceMatch")
incode
.getFinishStatus(null, { token: session.token })
.then((response: any) => {
Expand All @@ -74,6 +85,7 @@ function Incode({ session, baseUrl }:UserConsentPropTypes) {
}

function saveDeviceData() {
console.log('incode:', incode)
incode.sendGeolocation({ token: session.token });
incode.sendFingerprint({ token: session.token });
captureIdFrontSide();
Expand Down
18 changes: 2 additions & 16 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
import { Incode } from "./incode/incode";
import Script from "next/script";
import startOnboardingSession from "./incode/session";

// Declare the SDK object
declare global {
interface Window {
OnBoarding:any;
}
}

export default async function Home() {
const session: any = await startOnboardingSession();
const baseUrl: string = process.env.INCODE_SDK_URL || "";

return (
<>
{
/* Load the sdk library using "beforeInteractive" strategy */
<Script
id="incode-sdk"
src={process.env.INCODE_WEB_SDK_URL}
strategy="beforeInteractive"/>
}
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<div className="z-10 w-full max-w-5xl items-center justify-between font-mono text-sm lg:flex">
{ <Incode
session={session}
baseUrl={baseUrl}>
</Incode>}
</Incode>
}
</div>
</main>
</>
Expand Down
Loading