diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e22fe11f5..3ba3e6cc8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -38,5 +38,5 @@ jobs: uses: denoland/deployctl@v1 with: project: "credebl-studio" - entrypoint: "server/entry.mjs" - root: "dist" + entrypoint: "server/entry.mjs" # 📝 Update the entrypoint if necessary + root: "dist" # 📝 Update the root if necessary diff --git a/src/components/Profile/DisplayProfileImg.tsx b/src/components/Profile/DisplayProfileImg.tsx index bebfd4d53..9dd2ceff5 100644 --- a/src/components/Profile/DisplayProfileImg.tsx +++ b/src/components/Profile/DisplayProfileImg.tsx @@ -10,9 +10,11 @@ const DisplayProfileImg = () => { const getUserDetails = async () => { const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE) const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES) - const parsedUser = userProfile ? JSON.parse(userProfile) : null; - parsedUser.roles = orgRoles - setUserObj(parsedUser) + if (userProfile) { + const parsedUser = JSON.parse(userProfile); + parsedUser.roles = orgRoles || []; + setUserObj(parsedUser); + } } useEffect(() => { diff --git a/src/components/Profile/DisplayUser.tsx b/src/components/Profile/DisplayUser.tsx index 83a704006..e69bd7d83 100644 --- a/src/components/Profile/DisplayUser.tsx +++ b/src/components/Profile/DisplayUser.tsx @@ -12,9 +12,14 @@ const DisplayUser = () => { const getUserDetails = async () => { const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE) const orgRoles = await getFromLocalStorage(storageKeys.ORG_ROLES) - const parsedUser = userProfile ? JSON.parse(userProfile) : null - parsedUser.roles = orgRoles - setUserObj(parsedUser) + if (userProfile) { + const parsedUser = JSON.parse(userProfile); + if (parsedUser) { + parsedUser.roles = orgRoles || []; + setUserObj(parsedUser); + } + } + } useEffect(() => { const fetchData = async () => { diff --git a/src/components/Verification/VerificationSchemasList.tsx b/src/components/Verification/VerificationSchemasList.tsx index 32d1579da..73302d56e 100644 --- a/src/components/Verification/VerificationSchemasList.tsx +++ b/src/components/Verification/VerificationSchemasList.tsx @@ -396,4 +396,4 @@ const VerificationSchemasList = () => { ); }; -export default VerificationSchemasList; \ No newline at end of file +export default VerificationSchemasList; diff --git a/src/components/organization/OrgDropDown.tsx b/src/components/organization/OrgDropDown.tsx index f0b075124..1c2f9b70f 100644 --- a/src/components/organization/OrgDropDown.tsx +++ b/src/components/organization/OrgDropDown.tsx @@ -1,3 +1,6 @@ +import '../../common/global.css'; + +import type { IOrgInfo, Organisation } from './interfaces'; import { apiStatusCodes, storageKeys } from '../../config/CommonConstant.ts'; import { getFromLocalStorage, @@ -5,12 +8,11 @@ import { setToLocalStorage, } from '../../api/Auth'; import { useEffect, useState } from 'react'; -import '../../common/global.css'; + +import { AiOutlineSearch } from 'react-icons/ai'; import type { AxiosResponse } from 'axios'; import { BiChevronDown } from 'react-icons/bi'; -import { AiOutlineSearch } from 'react-icons/ai'; import CustomAvatar from '../Avatar/index.tsx'; -import type { IOrgInfo, Organisation } from './interfaces'; import { getOrganizations } from '../../api/organization.ts'; import { pathRoutes } from '../../config/pathRoutes.ts'; @@ -74,8 +76,14 @@ const OrgDropDown = () => { const handleActiveOrg = async (organizations: Organisation[]) => { let activeOrgDetails; const orgInfoDetails = await getFromLocalStorage(storageKeys.ORG_INFO); - activeOrgDetails = orgInfoDetails ? JSON.parse(orgInfoDetails) : null; - + + if (orgInfoDetails) { + try { + activeOrgDetails = JSON.parse(orgInfoDetails); + } catch (error) { + console.error('Error parsing orgInfoDetails from LocalStorage:', error); + } + } if (activeOrgDetails && Object.keys(activeOrgDetails)?.length > 0) { setActiveOrg(activeOrgDetails); } else if (organizations?.[0]) { diff --git a/src/components/organization/configuration-settings/CreateDid.tsx b/src/components/organization/configuration-settings/CreateDid.tsx index 2171810db..c6ab2d68e 100644 --- a/src/components/organization/configuration-settings/CreateDid.tsx +++ b/src/components/organization/configuration-settings/CreateDid.tsx @@ -1,21 +1,23 @@ import * as yup from 'yup'; + import { Button, Checkbox, Label, Modal } from 'flowbite-react'; +import { CommonConstants, DidMethod, Network } from '../../../common/enums'; +import type { EditOrgdetailsModalProps, IFormikValues } from '../interfaces'; import { Field, Form, Formik } from 'formik'; import type { FormikHelpers as FormikActions, FormikProps } from 'formik'; import { apiStatusCodes, storageKeys } from '../../../config/CommonConstant'; +import { createDid, getOrganizationById } from '../../../api/organization'; import { useEffect, useRef, useState } from 'react'; + import { AlertComponent } from '../../AlertComponent'; import type { AxiosResponse } from 'axios'; -import { createDid, getOrganizationById } from '../../../api/organization'; -import type { EditOrgdetailsModalProps, IFormikValues } from '../interfaces'; -import { createPolygonKeyValuePair } from '../../../api/Agent'; -import { nanoid } from 'nanoid'; -import TokenWarningMessage from '../walletCommonComponents/TokenWarningMessage'; import CopyDid from '../../../commonComponents/CopyDid'; -import { getFromLocalStorage } from '../../../api/Auth'; -import { ethers } from 'ethers'; +import TokenWarningMessage from '../walletCommonComponents/TokenWarningMessage'; +import { createPolygonKeyValuePair } from '../../../api/Agent'; import { envConfig } from '../../../config/envConfig'; -import { CommonConstants, Network, DidMethod } from '../../../common/enums'; +import { ethers } from 'ethers'; +import { getFromLocalStorage } from '../../../api/Auth'; +import { nanoid } from 'nanoid'; interface IPolygonKeys { privateKey: string; @@ -276,7 +278,7 @@ const CreateDIDModal = (props: EditOrgdetailsModalProps) => { * { formikHandlers.handleChange(e); setLedgerValue(e.target.value); @@ -298,7 +300,7 @@ const CreateDIDModal = (props: EditOrgdetailsModalProps) => { >Method * { formikHandlers.handleChange(e); setMethod(e.target.value); @@ -323,7 +325,7 @@ const CreateDIDModal = (props: EditOrgdetailsModalProps) => { Network * { formikHandlers.handleChange(e); setNetworkValue(e.target.value); @@ -375,7 +377,7 @@ const CreateDIDModal = (props: EditOrgdetailsModalProps) => { id="did-method" disabled={true} name="did-method" - value={completeDidMethodValue} + value={completeDidMethodValue || ''} className="bg-gray-50 text-gray-600 text-sm rounded-lg block w-full p-2.5 dark:bg-gray-700 dark:placeholder-gray-400 dark:text-white h-11" placeholder="DID Method" readOnly @@ -466,7 +468,7 @@ const CreateDIDModal = (props: EditOrgdetailsModalProps) => { id="privatekey" name="privatekey" className="truncate bg-gray-50 border mt-2 border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 h-11" - value={formikHandlers.values.privatekey} + value={formikHandlers.values.privatekey || ''} onChange={(e) => { formikHandlers.setFieldValue('privatekey', e.target.value); setWalletErrorMessage(null); diff --git a/src/components/organization/interfaces/index.ts b/src/components/organization/interfaces/index.ts index e0b7b526c..20a799c8b 100644 --- a/src/components/organization/interfaces/index.ts +++ b/src/components/organization/interfaces/index.ts @@ -266,4 +266,4 @@ export interface ILedgerItem { createDateTime: string; lastChangedDateTime: string; deletedAt: string | null; - } \ No newline at end of file + }