Skip to content

Commit f70e462

Browse files
committed
fix: show the kyc status message on the frontend
1 parent 90ecfa0 commit f70e462

File tree

5 files changed

+26
-9
lines changed

5 files changed

+26
-9
lines changed

src/components/popups/KYCVerification.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ 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";
78

89
/**
910
* KYCVerification Props Interface
@@ -32,8 +33,9 @@ export default function KYCVerification({ onCompleted }: KYCVerificationProps) {
3233

3334
const verificationData = useSelector((state) => state.sumsubVerification);
3435

35-
const { showModal, completed, completedText, description, verifying, completedActionText, actionText, loading, title } = verificationData;
36-
36+
const { showModal, completed, verifying, completedActionText, actionText, loading, title } = verificationData;
37+
const user = useSelector((state) => state.user.data);
38+
3739
const closeModal = () => {
3840
dispatch(closeVerificationModal());
3941
};
@@ -48,13 +50,20 @@ export default function KYCVerification({ onCompleted }: KYCVerificationProps) {
4850
triggerCompleteAction();
4951
};
5052

53+
const statuMessage = useMemo(() => {
54+
if (user?.kycStatus === KYCSTATUS.VERIFIED) return t("kyc.default.completed");
55+
if (user?.kycStatus === KYCSTATUS.PENDING) return "Your verification is currently being processed. Thank you for your patience";
56+
if (user?.kycStatus === KYCSTATUS.REJECTED) return "We regret to inform you that your verification process has been rejected. Please review your submitted information and try again.";
57+
return t("kyc.default.reason");
58+
}, [user?.kycStatus]);
59+
5160
return (
5261
<Modal show={showModal} onClose={closeModal}>
5362
<div className="px-6 py-6">
5463
{!verifying ? (
5564
<div className="flex flex-col text-left">
5665
<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>
66+
<p className="pt-8">{statuMessage}</p>
5867
</div>
5968
) : (
6069
<></>

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ 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";
@@ -41,7 +41,7 @@ export default function ProfileHeader() {
4141
const { authUser, profileUser, isKycVerified } = useMultiSelector<unknown, ProfileHeaderMultiSelector>({
4242
authUser: (state: IRootState) => state.user.data,
4343
profileUser: (state: IRootState) => state.profileUser.current,
44-
isKycVerified: (state: IRootState) => state.user.data?.kycStatus === "VERIFIED",
44+
isKycVerified: (state: IRootState) => state.user.data?.kycStatus === KYCSTATUS.VERIFIED,
4545
});
4646

4747
const user = useMemo(() => {

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)