Skip to content

Commit

Permalink
chore: fixed repeatableKYCSteps logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-hades committed Oct 10, 2023
1 parent d38eb29 commit d15f44a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/api/user/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ export type User = {

/*
A map of `kycStepPassed` keys and a timestamp as value.
So if now > `repeatableKycSteps[xxx]` you retry that step
So if now > `repeatableKYCSteps[xxx]` you retry that step
*/
repeatableKycSteps?: Record<number, number>;
repeatableKYCSteps?: Record<string, string>;
};

export type ReferralType = 'CONTACTS' | 'T1' | 'T2';
Expand Down
16 changes: 8 additions & 8 deletions src/screens/FaceRecognitionFlow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {StatusOverlay} from '@screens/FaceRecognitionFlow/components/StatusOverl
import {EmotionsAuthCameraFeed} from '@screens/FaceRecognitionFlow/EmotionsAuthCameraFeed';
import {FaceAuthCameraFeed} from '@screens/FaceRecognitionFlow/FaceAuthCameraFeed';
import {FaceAuthUserConsent} from '@screens/FaceRecognitionFlow/FaceAuthUserConsent';
import {dayjs} from '@services/dayjs';
import {unsafeUserSelector} from '@store/modules/Account/selectors';
import {
emotionsAuthStatusSelector,
Expand Down Expand Up @@ -80,17 +81,16 @@ export function FaceRecognition() {

useEffect(() => {
if (user.kycStepPassed === 2) {
if (
(user?.repeatableKycSteps?.[0] ?? Number.MAX_SAFE_INTEGER) < Date.now()
) {
setFaceRecognitionPhase(kycStepToFaceRecognitionPhase(0));
} else if (
(user?.repeatableKycSteps?.[1] ?? Number.MAX_SAFE_INTEGER) < Date.now()
) {
const step1Timestamp = user?.repeatableKYCSteps?.['1'];
if (step1Timestamp && dayjs(step1Timestamp).valueOf() < Date.now()) {
setFaceRecognitionPhase(kycStepToFaceRecognitionPhase(1));
}
const step0Timestamp = user?.repeatableKYCSteps?.['0'];
if (step0Timestamp && dayjs(step0Timestamp).valueOf() < Date.now()) {
setFaceRecognitionPhase(kycStepToFaceRecognitionPhase(0));
}
}
}, [user.kycStepPassed, user?.repeatableKycSteps]);
}, [user.kycStepPassed, user?.repeatableKYCSteps]);

return (
<View style={styles.container}>
Expand Down
12 changes: 5 additions & 7 deletions src/store/modules/FaceRecognition/types.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
// SPDX-License-Identifier: ice License 1.0

export type FaceAuthStatus =
export type BaseAuthStatus =
| 'LOADING'
| 'SUCCESS'
| 'FAILED'
| 'BANNED'
| 'TRY_LATER';

export type FaceAuthStatus = BaseAuthStatus;

export type EmotionsAuthStatus =
| 'LOADING'
| 'SUCCESS'
| 'FAILED'
| 'BANNED'
| BaseAuthStatus
| 'NEED_MORE_EMOTIONS'
| 'SESSION_EXPIRED'
| 'TRY_LATER';
| 'SESSION_EXPIRED';

export type CameraRatio = '16:9' | '4:3';

0 comments on commit d15f44a

Please sign in to comment.