This repository was archived by the owner on Jul 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Kta 60 results after uploading data #10
Merged
+466
−124
Merged
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
964543c
Adding Loading spinner component
sandoche d96e8f6
New result page created
sandoche 3921de9
Adding applicantId to the cookies
sandoche de58137
Adding redirection to result
sandoche 5ba7607
Implementing style box of result
sandoche 70f9e02
Loading block added
sandoche 37f3da5
Creating dummy endpoint
sandoche 6927c18
Improving types
sandoche 16d396f
Polling logic implemented
sandoche 9cf1099
Improve readability
sandoche 0c1bd4f
Handling the results
sandoche 50479d6
Removing test console.log
sandoche 8c4bf61
Implementing logic to display results
sandoche 38ad8b7
Success component implemented
sandoche 52f64d0
Changing text
sandoche e98e5df
Adding try again button
sandoche e90e078
Improving button style
sandoche 417f2e3
Handling long loadings
sandoche 27343a4
Code is handling all the type of errors
sandoche 9c01863
Refactoring button
sandoche ec5abc2
Renaming constant
sandoche e58f818
Adding user data in cookies
sandoche 09eee96
Adding data to localstorage instead of cookies
sandoche ce892df
Retry feature implemented, UX needs to be improved
sandoche be81221
Adding a comment to the code
sandoche 2e4e7cd
Improving error management
sandoche f4d72e7
Adding setting to remove refetch
sandoche f77e45b
Reorganizing components in folders
sandoche 2cbbe4f
Fixing renaming of components
sandoche dd15f99
Refactoring and creating a card component
sandoche 5622d4f
Refactoring the components for results
sandoche 6d0d0c6
Refactoring the loading component
sandoche 49526f9
Improve retry action
sandoche b0af28f
Fixing issue with bad importation
sandoche 3990e21
Fixing bad importation
sandoche 7fe73d3
Refactored the results success
sandoche ca89fda
Refactored the results failure page
sandoche 43d54ba
Refactoring the api calls
sandoche 5189393
Refactoring api calls and moving them to a service
sandoche 57a6198
Adding loading animation and disabled fields while sending
sandoche a100775
Improving style
sandoche b194efe
Fixing mobile responsive
sandoche 0d87e75
Improving style of landing page
sandoche 8fc0bcd
Updating first error page
sandoche c44fa7c
Updated design to have the full flow more consistent
sandoche 1415084
Changing failure text to make it more clear
sandoche 88a07da
Results error text improved
sandoche 0287365
Rephrasing the text
sandoche 2f4ed1d
Rewriting positive message
sandoche 9b5cec9
Reformatting values and adding comments for the constants
sandoche 203e88d
Adding better error handling, linting rule of no magic number, and fi…
sandoche ff92a74
Renaming e to event
sandoche ee5c509
Adding missing status for loading state
sandoche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,42 @@ | ||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction | ||
import { OnfidoApiError } from '@onfido/api'; | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
|
||
import getOnfido from '../../helpers/onfido'; | ||
import type ApplicantTokenPair from '../../types/ApplicantTokenPair'; | ||
import { SERVER_ERROR, SUCCESS } from '../../utils/statusCodes'; | ||
|
||
const endpointName = 'generate-token'; | ||
|
||
const onfido = getOnfido(); | ||
|
||
export default async function handler(req: NextApiRequest, res: NextApiResponse<ApplicantTokenPair>) { | ||
const applicantProperties = req.body; // https://documentation.onfido.com/#applicant-object | ||
console.log('Starting', endpointName); | ||
const applicant = await onfido.applicant.create(applicantProperties); | ||
export default async function handler(req: NextApiRequest, res: NextApiResponse<ApplicantTokenPair | unknown>) { | ||
try { | ||
const applicantProperties = req.body; // https://documentation.onfido.com/#applicant-object | ||
console.log('Starting', endpointName); | ||
const applicant = await onfido.applicant.create(applicantProperties); | ||
|
||
console.log('Applicant created', endpointName); | ||
console.log('Applicant created', endpointName); | ||
|
||
const sdkToken = await onfido.sdkToken.generate({ | ||
applicantId: applicant.id, | ||
// referrer: 'http://localhost/**' | ||
// crossDeviceUrl: "https://example.com" | ||
}); | ||
const result = { applicantId: applicant.id, sdkToken }; | ||
const sdkToken = await onfido.sdkToken.generate({ | ||
applicantId: applicant.id, | ||
// referrer: 'http://localhost/**' | ||
// crossDeviceUrl: "https://example.com" | ||
}); | ||
const result = { applicantId: applicant.id, sdkToken }; | ||
|
||
console.log('Returning result', endpointName); | ||
res.status(200).json(result); | ||
console.log('Returning result', endpointName); | ||
res.status(SUCCESS).json(result); | ||
} catch (error: unknown | OnfidoApiError) { | ||
if (error instanceof OnfidoApiError) { | ||
// An error response was received from the Onfido API, extra info is available. | ||
console.error(error.message); | ||
console.error(error.type); | ||
console.error(error.isClientError()); | ||
} else { | ||
// No response was received for some reason e.g. a network error. | ||
console.error({ error }); | ||
} | ||
res.status(SERVER_ERROR).json(error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const SUCCESS = 200; | ||
export const NOT_FOUND = 404; | ||
export const SERVER_ERROR = 500; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh cool, I didn't know about this rule. 👍 I added to https://near-foundation.atlassian.net/jira/software/c/projects/ENG/boards/1?modal=detail&selectedIssue=ENG-156&quickFilter=1