Skip to content

Commit 0e6fbdd

Browse files
authored
Merge pull request #1081 from dacadeorg/fix/kyc-verification-frontend
fix: show the kyc status message on the frontend
2 parents 3974367 + ff6cd2f commit 0e6fbdd

File tree

10 files changed

+43
-10
lines changed

10 files changed

+43
-10
lines changed

public/locales/bg/common.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@
359359
"kyc.default.title": "Identity verification",
360360
"kyc.default.completed": "Your identity has been verified successfully.",
361361
"kyc.default.reason": "To ensure the safety and security of our platform, we require all users to verify their identity. This verification process helps us maintain a trusted community of members who are committed to upholding our standards. Please take a moment to complete your KYC verification to help us in our efforts to create a safe and secure environment for everyone.",
362+
"kyc.verification.pending": "Вашата верификация в момента се обработва. Благодарим ви за търпението.",
363+
"kyc.verification.rejected": "Съжаляваме да ви информираме, че процесът на вашата верификация е отхвърлен. Моля, свържете се с екипа за поддръжка за повече информация.",
362364
"kyc.default.button": "Start verification",
363365
"kyc.default.button.completed": "Go to profile",
364366
"kyc.payout.reason": "To cashout, you need to verify your identity first.",

public/locales/en/common.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@
417417
"kyc.default.title": "Identity verification",
418418
"kyc.default.completed": "Your identity has been verified successfully.",
419419
"kyc.default.reason": "To ensure the safety and security of our platform, we require all users to verify their identity. This verification process helps us maintain a trusted community of members who are committed to upholding our standards. Please take a moment to complete your KYC verification to help us in our efforts to create a safe and secure environment for everyone.",
420+
"kyc.verification.pending":"Your verification is currently being processed. Thank you for your patience",
421+
"kyc.verification.rejected":"We regret to inform you that your verification process has been rejected. Please contact support team for more information.",
420422
"kyc.default.button": "Start verification",
421423
"kyc.default.button.completed": "Go to profile",
422424
"kyc.payout.reason": "To cashout, you need to verify your identity first.",

public/locales/es/common.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@
373373
"kyc.default.title": "Identity verification",
374374
"kyc.default.completed": "Your identity has been verified successfully.",
375375
"kyc.default.reason": "To ensure the safety and security of our platform, we require all users to verify their identity. This verification process helps us maintain a trusted community of members who are committed to upholding our standards. Please take a moment to complete your KYC verification to help us in our efforts to create a safe and secure environment for everyone.",
376+
"kyc.verification.pending": "Su verificación está siendo procesada actualmente. Gracias por su paciencia.",
377+
"kyc.verification.rejected": "Lamentamos informarle que su proceso de verificación ha sido rechazado. Por favor, póngase en contacto con el equipo de soporte para obtener más información.",
376378
"kyc.default.button": "Start verification",
377379
"kyc.default.button.completed": "Go to profile",
378380
"kyc.payout.reason": "To cashout, you need to verify your identity first.",

public/locales/hr/common.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@
359359
"kyc.default.title": "Identity verification",
360360
"kyc.default.completed": "Your identity has been verified successfully.",
361361
"kyc.default.reason": "To ensure the safety and security of our platform, we require all users to verify their identity. This verification process helps us maintain a trusted community of members who are committed to upholding our standards. Please take a moment to complete your KYC verification to help us in our efforts to create a safe and secure environment for everyone.",
362+
"kyc.verification.pending": "Vaša verifikacija trenutno se obrađuje. Hvala vam na strpljenju.",
363+
"kyc.verification.rejected": "Žao nam je obavijestiti vas da je vaš proces verifikacije odbijen. Molimo vas da kontaktirate tim za podršku radi više informacija.",
362364
"kyc.default.button": "Start verification",
363365
"kyc.default.button.completed": "Go to profile",
364366
"kyc.payout.reason": "To cashout, you need to verify your identity first.",

src/components/popups/KYCVerification.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import Modal from "@/components/ui/Modal";
22
import { useTranslation } from "next-i18next";
33
import ArrowButton from "@/components/ui/button/Arrow";
44
import { useSelector } from "@/hooks/useTypedSelector";
5-
import { closeVerificationModal, launchWebSdk, triggerCompleteAction } from "@/store/feature/kyc.slice";
5+
import { KYCSTATUS, closeVerificationModal, launchWebSdk, triggerCompleteAction } from "@/store/feature/kyc.slice";
66
import { useDispatch } from "@/hooks/useTypedDispatch";
7+
import { useMemo } from "react";
8+
import { toggleBodyScrolling } from "@/store/feature/ui.slice";
79

810
/**
911
* KYCVerification Props Interface
@@ -32,9 +34,13 @@ export default function KYCVerification({ onCompleted }: KYCVerificationProps) {
3234

3335
const verificationData = useSelector((state) => state.sumsubVerification);
3436

35-
const { showModal, completed, completedText, description, verifying, completedActionText, actionText, loading, title } = verificationData;
37+
const { showModal, completed, verifying, completedActionText, actionText, loading, title } = verificationData;
38+
const user = useSelector((state) => state.user.data);
39+
40+
const kycStatus = user?.kycStatus;
3641

3742
const closeModal = () => {
43+
dispatch(toggleBodyScrolling(false));
3844
dispatch(closeVerificationModal());
3945
};
4046
const verify = () => {
@@ -48,13 +54,20 @@ export default function KYCVerification({ onCompleted }: KYCVerificationProps) {
4854
triggerCompleteAction();
4955
};
5056

57+
const statusMessage = useMemo(() => {
58+
if (kycStatus === KYCSTATUS.VERIFIED) return t("kyc.default.completed");
59+
if (kycStatus === KYCSTATUS.PENDING) return t("kyc.verification.pending");
60+
if (kycStatus === KYCSTATUS.REJECTED) return t("kyc.verification.rejected");
61+
return t("kyc.default.reason");
62+
}, [kycStatus, t]);
63+
5164
return (
5265
<Modal show={showModal} onClose={closeModal}>
5366
<div className="px-6 py-6">
5467
{!verifying ? (
5568
<div className="flex flex-col text-left">
5669
<h1 className="text-.5xl leading-snug font-medium">{title || t("kyc.default.title")}</h1>
57-
<p className="pt-8">{completed ? completedText || t("kyc.default.completed") : description || t("kyc.default.reason")}</p>
70+
<p className="pt-8">{statusMessage}</p>
5871
</div>
5972
) : (
6073
<></>
@@ -65,7 +78,7 @@ export default function KYCVerification({ onCompleted }: KYCVerificationProps) {
6578
<span className="text-sm font-medium cursor-pointer text-primary" onClick={closeModal}>
6679
{t("profile.edit.close")}
6780
</span>
68-
{!verifying && (
81+
{!verifying && kycStatus !== KYCSTATUS.REJECTED && (
6982
<ArrowButton loading={loading} disabled={loading} onClick={verify}>
7083
{completed ? completedActionText || t("kyc.default.button.completed") : actionText || t("kyc.default.button")}
7184
</ArrowButton>

src/components/popups/user/Dropdown.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { useDispatch } from "@/hooks/useTypedDispatch";
1616
import VerifiedIcon from "@/icons/verified.svg";
1717
import { IRootState } from "@/store";
1818
import { Wallet } from "@/types/wallet";
19+
import { KYCSTATUS } from "@/store/feature/kyc.slice";
1920

2021
/**
2122
* interface for UserProfileDropdown multiSelector
@@ -55,7 +56,7 @@ const UserProfileDropdown = ({ buttonStyles, onClose }: { buttonStyles?: CSSProp
5556
error: (state: IRootState) => state.store.error,
5657
});
5758
const username = user?.displayName;
58-
const isKycVerified = useMemo(() => user?.kycStatus === "VERIFIED", [user]);
59+
const isKycVerified = useMemo(() => user?.kycStatus === KYCSTATUS.VERIFIED, [user]);
5960

6061
/**
6162
* Logout handler.

src/components/sections/profile/Header.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ import { useRouter } from "next/router";
1010
import { useMemo } from "react";
1111
import { useTranslation } from "next-i18next";
1212
import { useDispatch } from "@/hooks/useTypedDispatch";
13-
import { openVerificationModal } from "@/store/feature/kyc.slice";
13+
import { KYCSTATUS, openVerificationModal } from "@/store/feature/kyc.slice";
1414
import KYCVerification from "@/components/popups/KYCVerification";
1515
import { useDiscordConnect } from "@/hooks/useDiscordConnect";
1616
import { User } from "@/types/bounty";
1717
import { IRootState } from "@/store";
1818
import Link from "next/link";
19+
import { toggleBodyScrolling } from "@/store/feature/ui.slice";
1920

2021
/**
2122
* interface for ProfileHeader multiSelector
@@ -41,7 +42,7 @@ export default function ProfileHeader() {
4142
const { authUser, profileUser, isKycVerified } = useMultiSelector<unknown, ProfileHeaderMultiSelector>({
4243
authUser: (state: IRootState) => state.user.data,
4344
profileUser: (state: IRootState) => state.profileUser.current,
44-
isKycVerified: (state: IRootState) => state.user.data?.kycStatus === "VERIFIED",
45+
isKycVerified: (state: IRootState) => state.user.data?.kycStatus === KYCSTATUS.VERIFIED,
4546
});
4647

4748
const user = useMemo(() => {
@@ -64,8 +65,10 @@ export default function ProfileHeader() {
6465
}, [isCurrentUser, isKycVerified]);
6566

6667
const dispatch = useDispatch();
68+
6769
const triggerKYCVerification = () => {
6870
dispatch(openVerificationModal({}));
71+
dispatch(toggleBodyScrolling(true))
6972
};
7073

7174
const { canConnectDiscord, triggerDiscordOauth } = useDiscordConnect();

src/components/ui/Popup.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import classNames from "classnames";
2-
import { ReactElement } from "react";
2+
import { ReactElement} from "react";
33

44
/**
55
* Popups interface props
@@ -31,6 +31,7 @@ interface PopupProps {
3131
* @returns {ReactElement}
3232
*/
3333
export default function Popup({ center, onClose, show, children, className = "" }: PopupProps): ReactElement {
34+
3435
return show ? (
3536
<div className={classNames(`fixed z-999 w-screen h-screen overflow-y-scroll top-0 left-0 ${className}`, { "flex items-center": center })}>
3637
<div className="opacity-25 fixed inset-0 z-0 bg-black w-full h-screen top-0 left-0" onClick={onClose} />

src/store/feature/kyc.slice.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import api from "@/config/api";
66
import { fetchUser } from "../services/user.service";
77
import snsWebSdk from "@sumsub/websdk";
88

9+
export enum KYCSTATUS {
10+
PENDING = "PENDING",
11+
VERIFIED = "VERIFIED",
12+
REJECTED = "REJECTED",
13+
}
14+
915
interface SumsubVerificationState {
1016
sumsubToken: string | null;
1117
showModal: boolean;
@@ -59,7 +65,7 @@ export const getSumsubToken = () => async (dispatch: Dispatch) => {
5965
* @returns {(dispatch: any) => any}
6066
*/
6167
export const openVerificationModal = (payload: any) => (dispatch: any, getState: () => IRootState) => {
62-
const isKycVerified = getState().user.data?.kycStatus === "VERIFIED";
68+
const isKycVerified = getState().user.data?.kycStatus === KYCSTATUS.VERIFIED;
6369
if (isKycVerified) {
6470
dispatch(closeVerificationModal());
6571
triggerCompleteAction();

src/types/bounty.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Colors, Community, Referral } from "./community";
33
import { ReactNode } from "react";
44
import { Feedback } from "./feedback";
55
import { Team } from "./challenge";
6+
import { KYCSTATUS } from "@/store/feature/kyc.slice";
67

78
export interface Bounty {
89
url: string;
@@ -151,7 +152,7 @@ export interface User {
151152
discord?: {
152153
connected?: boolean;
153154
};
154-
kycStatus: string;
155+
kycStatus: KYCSTATUS;
155156
referrals: Referral;
156157
}
157158

0 commit comments

Comments
 (0)