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

Commit

Permalink
Adding missing status for loading state
Browse files Browse the repository at this point in the history
  • Loading branch information
sandoche committed Oct 10, 2022
1 parent ff92a74 commit ee5c509
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pages/[key]/results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const ResultsPage: NextPage = () => {
},
});

const showLoading = isLoading || data?.status === CheckResultsStatus.willTakeLonger;
const showLoading = isLoading || data?.status === CheckResultsStatus.willTakeLonger || data?.status === CheckResultsStatus.loading;
const showSuccess = data?.status === CheckResultsStatus.finished && data.isClear === true;
const showFailure = data?.status === CheckResultsStatus.finished && data.isClear === false;
const showError = error || data?.status === CheckResultsStatus.notFound;
Expand Down
10 changes: 5 additions & 5 deletions pages/api/check-results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
return;
}

// List of status: https://documentation.onfido.com/#report-status
// List of results: https://documentation.onfido.com/#report-results
// List of status: https://documentation.onfido.com/#check-status
// List of results: https://documentation.onfido.com/#check-results
const simplifiedStatus = new Map([
['awaiting_data', CheckResultsStatus.willTakeLonger],
['awaiting_approval', CheckResultsStatus.willTakeLonger],
['in_progress', CheckResultsStatus.loading],
['awaiting_applicant', CheckResultsStatus.finished],
['complete', CheckResultsStatus.finished],
['cancelled', CheckResultsStatus.finished],
['withdrawn', CheckResultsStatus.finished],
['paused', CheckResultsStatus.willTakeLonger],
['reopened', CheckResultsStatus.willTakeLonger],
]);

// This need to be updated / improved depending on the answer from the support
Expand Down
1 change: 1 addition & 0 deletions types/CheckResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface CheckResults {
}

export enum CheckResultsStatus {
loading = 'loading',
willTakeLonger = 'will-take-longer',
finished = 'finished',
notFound = 'not-found',
Expand Down

0 comments on commit ee5c509

Please sign in to comment.