From 7cb1061bebef5c3d15bdeb676248bf1715e9761b Mon Sep 17 00:00:00 2001
From: bhavanakarwade
Date: Thu, 12 Dec 2024 11:25:56 +0530
Subject: [PATCH] resolved decryption errors
---
src/components/Profile/DisplayProfileImg.tsx | 23 +++++++++++++-------
src/components/Profile/DisplayUser.tsx | 23 +++++++++++++++-----
src/components/User/UserDashBoard.tsx | 20 ++++++++---------
src/components/organization/OrgDropDown.tsx | 12 +++++-----
4 files changed, 49 insertions(+), 29 deletions(-)
diff --git a/src/components/Profile/DisplayProfileImg.tsx b/src/components/Profile/DisplayProfileImg.tsx
index 3ce1e73f..1c43cfed 100644
--- a/src/components/Profile/DisplayProfileImg.tsx
+++ b/src/components/Profile/DisplayProfileImg.tsx
@@ -6,20 +6,27 @@ import { getFromLocalStorage } from "../../api/Auth.ts";
import { storageKeys } from "../../config/CommonConstant.ts";
const DisplayProfileImg = () => {
- const [userObj, setUserObj] = useState(null)
+ const [userObj, setUserObj] = useState({
+ id: '',
+ profileImg: '',
+ username: '',
+ email: '',
+ firstName: '',
+ lastName: '',
+ isEmailVerified: false,
+ keycloakUserId: '',
+ publicProfile: false,
+ isPublic: false,
+ roles: ''
+ })
const getUserDetails = async () => {
const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE)
- console.log("🚀 ~ getUserDetails ~ userProfile: type of:::::::", typeof userProfile)
- console.log("🚀 ~ getUserDetails ~ userProfile22222222222:", userProfile)
const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES)
- // const parsedUser = userProfile ? JSON.parse(userProfile) : null;
- // console.log("🚀 ~ getUserDetails ~ parsedUser type of:", typeof parsedUser)
- // console.log("🚀 ~ getUserDetails ~ parsedUser:", parsedUser)
- // if (parsedUser) {
+ if (orgRoles) {
userProfile.roles = orgRoles;
setUserObj(userProfile);
- // }
+ }
}
useEffect(() => {
diff --git a/src/components/Profile/DisplayUser.tsx b/src/components/Profile/DisplayUser.tsx
index da05ba1a..228c3e2a 100644
--- a/src/components/Profile/DisplayUser.tsx
+++ b/src/components/Profile/DisplayUser.tsx
@@ -3,11 +3,24 @@ import { useEffect, useState } from "react";
import { TextTittlecase } from "../../utils/TextTransform.ts";
import { getFromLocalStorage } from "../../api/Auth.ts";
import { storageKeys } from "../../config/CommonConstant.ts";
+import type { IUserProfile } from "./interfaces/index.ts";
const DisplayUser = () => {
- const [userObj, setUserObj] = useState(null)
-
+ const [userObj, setUserObj] = useState({
+ id: '',
+ profileImg: '',
+ username: '',
+ email: '',
+ firstName: '',
+ lastName: '',
+ isEmailVerified: false,
+ keycloakUserId: '',
+ publicProfile: false,
+ isPublic: false,
+ roles: ''
+ })
+
let timer:any= null
const getUserDetails = async () => {
const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE)
@@ -43,16 +56,16 @@ const DisplayUser = () => {
className="text-xl font-medium text-gray-900 truncate dark:text-gray-300 mb-1"
role="none"
>
- {userObj?.['firstName']}
+ {userObj?.firstName}
- {userObj?.['email']}
+ {userObj?.email}
- {TextTittlecase(userObj?.['roles'])}
+ {TextTittlecase(userObj?.roles)}
>
}
diff --git a/src/components/User/UserDashBoard.tsx b/src/components/User/UserDashBoard.tsx
index caee6ac9..ad02731e 100644
--- a/src/components/User/UserDashBoard.tsx
+++ b/src/components/User/UserDashBoard.tsx
@@ -99,7 +99,7 @@ const UserDashBoard = () => {
if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
const totalPages = data?.data?.totalPages;
const invitationList = data?.data?.invitations;
- if (invitationList.length > 0) {
+ if (invitationList?.length > 0) {
setMessage(`You have received invitations to join organization`);
setViewButton(true);
}
@@ -150,7 +150,7 @@ const UserDashBoard = () => {
const invitationPendingList =
data?.data?.invitations &&
data?.data?.invitations?.filter((invitation: { status: string }) => {
- return invitation.status === 'pending';
+ return invitation?.status === 'pending';
});
if (invitationPendingList && invitationPendingList?.length > 0) {
setEcoMessage(`You have received invitation to join ecosystem `);
@@ -248,7 +248,7 @@ const UserDashBoard = () => {
const { data } = response as AxiosResponse;
if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
- setCredDefCount(data.data.totalItems);
+ setCredDefCount(data?.data?.totalItems);
const credentialDefs = data?.data?.data?.filter(
(ecosystem: Organisation, index: number) => index < 3,
);
@@ -481,7 +481,7 @@ const UserDashBoard = () => {
- {ecoMessage && ecoMessage.length > 0 &&
+ {ecoMessage && ecoMessage?.length > 0 &&
{
}
- {walletData && walletData.length > 0 ? (
+ {walletData && walletData?.length > 0 ? (
<>>
) : (
{
{organizationsList && organizationsList?.length > 0 ? (
<>
{organizationsList?.map((org, index) => {
- const roles: string[] = org.userOrgRoles.map(
- (role) => role.orgRole.name,
+ const roles: string[] = org?.userOrgRoles?.map(
+ (role) => role?.orgRole?.name,
);
org.roles = roles;
return (
@@ -618,7 +618,7 @@ const UserDashBoard = () => {
href="#"
className="flex items-center py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white rounded-md mr-2"
>
- {org.logoUrl ? (
+ {org?.logoUrl ? (
{
OrganizationRoles.organizationIssuer,
) ? (
{orgList?.length > 0 ? (
orgList?.map((org) => {
- const roles: string[] = org.userOrgRoles.map(
- (role) => role.orgRole.name,
+ const roles: string[] = org?.userOrgRoles?.map(
+ (role) => role?.orgRole?.name,
);
org.roles = roles;
return (
@@ -175,7 +175,7 @@ const OrgDropDown = () => {
href="#"
className="flex items-center w-full px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white"
>
- {org.logoUrl ? (
+ {org?.logoUrl ? (