Skip to content

Commit

Permalink
resolved decryption errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bhavanakarwade committed Dec 12, 2024
1 parent 76f5026 commit 7cb1061
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 29 deletions.
23 changes: 15 additions & 8 deletions src/components/Profile/DisplayProfileImg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,27 @@ import { getFromLocalStorage } from "../../api/Auth.ts";
import { storageKeys } from "../../config/CommonConstant.ts";

const DisplayProfileImg = () => {
const [userObj, setUserObj] = useState<IUserProfile | null>(null)
const [userObj, setUserObj] = useState<IUserProfile>({
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(() => {
Expand Down
23 changes: 18 additions & 5 deletions src/components/Profile/DisplayUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<IUserProfile>({
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)
Expand Down Expand Up @@ -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}
</p>
<p className="text-sm text-gray-900 dark:text-white mb-1" role="none">
{userObj?.['email']}
{userObj?.email}
</p>
<p
className="text-base font-medium text-gray-900 truncate dark:text-gray-300"
role="none"
>
{TextTittlecase(userObj?.['roles'])}
{TextTittlecase(userObj?.roles)}
</p>
</>
}
Expand Down
20 changes: 10 additions & 10 deletions src/components/User/UserDashBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 `);
Expand Down Expand Up @@ -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,
);
Expand Down Expand Up @@ -481,7 +481,7 @@ const UserDashBoard = () => {

</div>
<div className="cursor-pointer">
{ecoMessage && ecoMessage.length > 0 &&
{ecoMessage && ecoMessage?.length > 0 &&
<AlertComponent
message={ecoMessage}
type={ecoMessage ? 'warning' : 'failure'}
Expand All @@ -495,7 +495,7 @@ const UserDashBoard = () => {
}

</div>
{walletData && walletData.length > 0 ? (
{walletData && walletData?.length > 0 ? (
<></>
) : (
<div
Expand Down Expand Up @@ -599,8 +599,8 @@ const UserDashBoard = () => {
{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 (
Expand All @@ -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 ? (
<CustomAvatar
className="dark:text-white dark:text-white max-w-[100%] w-full h-full rounded-full"
size="40px"
Expand Down Expand Up @@ -661,7 +661,7 @@ const UserDashBoard = () => {
OrganizationRoles.organizationIssuer,
) ? (
<span
title={org?.roles?.slice(0, org.roles.length - 1).join(", ")}
title={org?.roles?.slice(0, org?.roles?.length - 1).join(", ")}
>
<svg
width="24"
Expand Down Expand Up @@ -735,7 +735,7 @@ const UserDashBoard = () => {
>
<button
onClick={() => {
goToOrgSchema(org, org.id, org.roles);
goToOrgSchema(org, org?.id, org?.roles);
}}
className={`p-1 rounded-md ${
!(
Expand Down
12 changes: 6 additions & 6 deletions src/components/organization/OrgDropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ const OrgDropDown = () => {
};

const setOrgRoleDetails = async (org: Organisation) => {
if (org && org.id !== undefined && org.id !== null) { // Added check
if (org && org?.id !== undefined && org?.id !== null) { // Added check
await setToLocalStorage(storageKeys.ORG_ID, org.id.toString());
}
const roles: string[] = org?.userOrgRoles?.length > 0
? org?.userOrgRoles.map((role) => role?.orgRole?.name)
: [];
if (roles.length > 0) { // Added check
await setToLocalStorage(storageKeys.ORG_ROLES, roles.toString());
if (roles?.length > 0) { // Added check
await setToLocalStorage(storageKeys.ORG_ROLES, roles?.toString());
}
};

Expand Down Expand Up @@ -161,8 +161,8 @@ const OrgDropDown = () => {
</div>
{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 (
Expand All @@ -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 ? (
<CustomAvatar
className="dark:text-white max-w-[100%] w-full h-full rounded-full font-sm"
size="35px"
Expand Down

0 comments on commit 7cb1061

Please sign in to comment.