Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Kta 60 results after uploading data #10

Merged
merged 53 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
964543c
Adding Loading spinner component
sandoche Oct 6, 2022
d96e8f6
New result page created
sandoche Oct 6, 2022
3921de9
Adding applicantId to the cookies
sandoche Oct 6, 2022
de58137
Adding redirection to result
sandoche Oct 6, 2022
5ba7607
Implementing style box of result
sandoche Oct 6, 2022
70f9e02
Loading block added
sandoche Oct 6, 2022
37f3da5
Creating dummy endpoint
sandoche Oct 6, 2022
6927c18
Improving types
sandoche Oct 6, 2022
16d396f
Polling logic implemented
sandoche Oct 6, 2022
9cf1099
Improve readability
sandoche Oct 6, 2022
0c1bd4f
Handling the results
sandoche Oct 6, 2022
50479d6
Removing test console.log
sandoche Oct 6, 2022
8c4bf61
Implementing logic to display results
sandoche Oct 6, 2022
38ad8b7
Success component implemented
sandoche Oct 6, 2022
52f64d0
Changing text
sandoche Oct 6, 2022
e98e5df
Adding try again button
sandoche Oct 6, 2022
e90e078
Improving button style
sandoche Oct 6, 2022
417f2e3
Handling long loadings
sandoche Oct 6, 2022
27343a4
Code is handling all the type of errors
sandoche Oct 6, 2022
9c01863
Refactoring button
sandoche Oct 6, 2022
ec5abc2
Renaming constant
sandoche Oct 6, 2022
e58f818
Adding user data in cookies
sandoche Oct 6, 2022
09eee96
Adding data to localstorage instead of cookies
sandoche Oct 6, 2022
ce892df
Retry feature implemented, UX needs to be improved
sandoche Oct 6, 2022
be81221
Adding a comment to the code
sandoche Oct 7, 2022
2e4e7cd
Improving error management
sandoche Oct 7, 2022
f4d72e7
Adding setting to remove refetch
sandoche Oct 7, 2022
f77e45b
Reorganizing components in folders
sandoche Oct 7, 2022
2cbbe4f
Fixing renaming of components
sandoche Oct 7, 2022
dd15f99
Refactoring and creating a card component
sandoche Oct 7, 2022
5622d4f
Refactoring the components for results
sandoche Oct 7, 2022
6d0d0c6
Refactoring the loading component
sandoche Oct 7, 2022
49526f9
Improve retry action
sandoche Oct 7, 2022
b0af28f
Fixing issue with bad importation
sandoche Oct 7, 2022
3990e21
Fixing bad importation
sandoche Oct 7, 2022
7fe73d3
Refactored the results success
sandoche Oct 7, 2022
ca89fda
Refactored the results failure page
sandoche Oct 7, 2022
43d54ba
Refactoring the api calls
sandoche Oct 7, 2022
5189393
Refactoring api calls and moving them to a service
sandoche Oct 7, 2022
57a6198
Adding loading animation and disabled fields while sending
sandoche Oct 7, 2022
a100775
Improving style
sandoche Oct 7, 2022
b194efe
Fixing mobile responsive
sandoche Oct 7, 2022
0d87e75
Improving style of landing page
sandoche Oct 7, 2022
8fc0bcd
Updating first error page
sandoche Oct 7, 2022
c44fa7c
Updated design to have the full flow more consistent
sandoche Oct 7, 2022
1415084
Changing failure text to make it more clear
sandoche Oct 10, 2022
88a07da
Results error text improved
sandoche Oct 10, 2022
0287365
Rephrasing the text
sandoche Oct 10, 2022
2f4ed1d
Rewriting positive message
sandoche Oct 10, 2022
9b5cec9
Reformatting values and adding comments for the constants
sandoche Oct 10, 2022
203e88d
Adding better error handling, linting rule of no magic number, and fi…
sandoche Oct 10, 2022
ff92a74
Renaming e to event
sandoche Oct 10, 2022
ee5c509
Adding missing status for loading state
sandoche Oct 10, 2022
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
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ module.exports = {
'react/jsx-props-no-spreading': 'off',
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'no-magic-numbers': 'error',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
reportUnusedDisableDirectives: true, // https://eslint.org/docs/user-guide/configuring#report-unused-eslint-disable-comments
settings: {
Expand Down
23 changes: 0 additions & 23 deletions components/FirstStep.tsx

This file was deleted.

19 changes: 19 additions & 0 deletions components/common/CenteredCard.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.card {
width: 94vw;
max-width: 32em;
border-color: rgb(130, 136, 147);
border-width: 1px;
border-style: solid;
padding: 32px;
border-radius: 8px;
margin: auto;
margin-top: 32px;
text-align: center;
min-height: 37.5em;
background-color: #fcfcfd;

@media (max-width: 478px) {
border: none;
background-color: #fff;
}
}
5 changes: 5 additions & 0 deletions components/common/CenteredCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import styles from './CenteredCard.module.scss';

export default function CenteredCard({ children }: { children: React.ReactNode }): JSX.Element {
return <div className={styles.card}>{children}</div>;
}
9 changes: 9 additions & 0 deletions components/common/CenteredCardContent.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.contentCentered {
min-height: 37.5em;
height: 100%;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
28 changes: 28 additions & 0 deletions components/common/CenteredCardContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* eslint-disable react/require-default-props */
import LoadingSpinner from './LoadingSpinner';

import styles from './CenteredCardContent.module.css';

export default function CenteredCardContent({
title,
description,
iconClasses,
isLoading = false,
children = null,
}: {
title: string;
description: string | JSX.Element;
iconClasses: string;
isLoading?: boolean;
children?: React.ReactNode;
}): JSX.Element {
return (
<div className={styles.contentCentered}>
{isLoading && <LoadingSpinner />}
<i className={iconClasses} style={{ fontSize: '98px' }} aria-hidden="true" />
<h1 className="fs-2 mb-2">{title}</h1>
<p className="text-secondary mb-4">{description}</p>
{children}
</div>
);
}
7 changes: 7 additions & 0 deletions components/common/LoadingSpinner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function LoadingSpinner(): JSX.Element {
return (
<div className="spinner-border" role="status">
<span className="sr-only">Loading...</span>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
// https://getbootstrap.com/docs/5.0/forms/layout/
// https://getbootstrap.com/docs/5.0/layout/gutters/

export default function ApplicantForm({ onSubmit }: { onSubmit: (event: React.SyntheticEvent) => void }): JSX.Element {
export default function ApplicantForm({ onSubmit, loading }: { onSubmit: (event: React.SyntheticEvent) => void; loading: boolean }): JSX.Element {
return (
<form className="applicant-form mt-5" onSubmit={onSubmit}>
<div className="row">
<div className="col-md-6 pb-2">
<div className="form-floating">
<input name="firstName" type="text" className="form-control" aria-label="First Name" required />
<input name="firstName" type="text" className="form-control" aria-label="First Name" disabled={loading} required />
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
<label htmlFor="firstName">First Name</label>
</div>
</div>
<div className="col-md-6 pb-2">
<div className="form-floating">
<input name="lastName" type="text" className="form-control" aria-label="Last Name" required />
<input name="lastName" type="text" className="form-control" aria-label="Last Name" disabled={loading} required />
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
<label htmlFor="lastName">Last Name</label>
</div>
Expand All @@ -24,23 +24,23 @@ export default function ApplicantForm({ onSubmit }: { onSubmit: (event: React.Sy

<div className="pb-2">
<div className="form-floating">
<input name="email" type="email" className="form-control" required />
<input name="email" type="email" className="form-control" disabled={loading} required />
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
<label htmlFor="email">Email Address</label>
</div>
</div>

<div className="pb-2">
<div className="form-floating">
<input name="dob" type="date" className="form-control" required />
<input name="dob" type="date" className="form-control" disabled={loading} required />
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
<label htmlFor="dob">Date of Birth</label>
</div>
</div>

<div className="d-flex justify-content-end">
<button name="submit" type="submit" className="btn btn-lg btn-primary">
Start <i className="fa fa-chevron-right" aria-hidden="true" />
<button name="submit" type="submit" className="btn btn-lg btn-primary" disabled={loading}>
Start {loading ? <span className="spinner-border spinner-border-sm" role="status" aria-hidden="true" /> : <i className="fa fa-chevron-right" aria-hidden="true" />}
</button>
</div>
</form>
Expand Down
23 changes: 23 additions & 0 deletions components/form/FirstStep.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { SdkHandle } from 'onfido-sdk-ui';

import CenteredCard from '../common/CenteredCard';
import Header from '../layout/Header';

import ApplicantForm from './ApplicantForm';

function FirstStep({ onfidoInstance, onSubmit, loading }: { onfidoInstance: SdkHandle | null; onSubmit: (event: React.SyntheticEvent) => void; loading: boolean }): JSX.Element {
return onfidoInstance ? (
<div />
) : (
<CenteredCard>
<Header />
<h3 className="mb-4">We want to get to know you!</h3>
<p>Start by introducing yourself here.</p>
<p>On the next page, we&apos;ll ask you to provide other information (documents or photos) that will help verify your identity.</p>

<ApplicantForm onSubmit={onSubmit} loading={loading} />
</CenteredCard>
);
}

export default FirstStep;
9 changes: 6 additions & 3 deletions components/Header.tsx → components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ export default function Header(): JSX.Element {
return (
<header>
<h1 className="mb-5">
<Link href="/">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img alt="NEAR logo" src="/img/logo_nm.svg" className="logo" />
<Link href="/" passHref>
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<a>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img alt="NEAR logo" src="/img/logo_nm.svg" className="logo" />
</a>
</Link>
</h1>
</header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function MainLayout({ children }: { children: React.ReactNode })
</Head>

<main>{children} </main>
<footer>
<footer className="text-center">
<Link href="/privacy-policy">Privacy Policy</Link> | © 2022{' '}
<a href="https://near.foundation/" target="_blank" rel="noreferrer">
NEAR Foundation
Expand Down
11 changes: 11 additions & 0 deletions components/results/ResultsError.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import CenteredCardContent from '../common/CenteredCardContent';

import ResultsRetryButton from './ResultsRetryButton';

export default function ResultsFailure(): JSX.Element {
return (
<CenteredCardContent title="An error occured" description="Sorry, an error occurred; we invite you to try again." iconClasses="fa fa-exclamation-circle text-warning mb-4">
<ResultsRetryButton />
</CenteredCardContent>
);
}
15 changes: 15 additions & 0 deletions components/results/ResultsFailure.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import CenteredCardContent from '../common/CenteredCardContent';

import ResultsRetryButton from './ResultsRetryButton';

export default function ResultsFailure(): JSX.Element {
return (
<CenteredCardContent
title="Verification failed"
description="We could not verify your identity. If you believe that you submitted any information incorrectly, you may try again."
iconClasses="fa fa-times-circle text-danger mb-4"
>
<ResultsRetryButton />
</CenteredCardContent>
);
}
22 changes: 22 additions & 0 deletions components/results/ResultsLoading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import CenteredCardContent from '../common/CenteredCardContent';

export default function ResultsLoading({ willTakeLonger }: { willTakeLonger: boolean }): JSX.Element {
return (
<CenteredCardContent
title=""
iconClasses=""
isLoading
description={
willTakeLonger ? (
<p>
<strong>This identity verification is taking more time than usual.</strong>
<br />
Feel free to close this page and come back later to {window.location.href}
</p>
) : (
'Please wait...'
)
}
/>
);
}
12 changes: 12 additions & 0 deletions components/results/ResultsRetryButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Link from 'next/link';

export default function ResultsRetryButton(): JSX.Element {
return (
<Link href={`/${process.env.NEXT_PUBLIC_KYC_ENDPOINT_KEY}?retry=1`} passHref>
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<a className="btn btn-primary">
Try again <i className="fa fa-repeat" aria-hidden="true" />
</a>
</Link>
);
}
11 changes: 11 additions & 0 deletions components/results/ResultsSuccess.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import CenteredCardContent from '../common/CenteredCardContent';

export default function ResultsSuccess(): JSX.Element {
return (
<CenteredCardContent
title="Verification validated"
description="Congratulations! 🎉 We have verified your identity and are excited to move forward. NEAR Foundation will contact you for the next steps shortly. You can now close this window."
iconClasses="fa fa-check-circle text-success mb-4"
/>
);
}
5 changes: 5 additions & 0 deletions constants/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const COOKIES_EXPIRATION_TIME = 2592000; // 30 days
export const COOKIE_CHECK_ID_NAME = 'onfido-check-id';
export const LOCALSTORAGE_USER_DATA_NAME = 'onfido-user-data';
export const SHORT_POLLING_INTERVAL = 1000; // 1 second - Short polling applies when the check is in progress
export const LONG_POLLING_INTERVAL = 30_000; // 30 seconds - Long polling applies when the check is under manual approval
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"lint:fix": "next lint --dir . --fix"
"lint": "next lint"
},
"dependencies": {
"@onfido/api": "^2.1.1",
"@tanstack/react-query": "^4.10.1",
"next": "12.1.6",
"onfido-sdk-ui": "^6.16.0",
"react": "18.1.0",
Expand Down
Loading