diff --git a/src/api/Auth.ts b/src/api/Auth.ts index 52239ccce..8a376ec25 100644 --- a/src/api/Auth.ts +++ b/src/api/Auth.ts @@ -229,10 +229,10 @@ export const encryptData = (value: any): string => { const CRYPTO_PRIVATE_KEY: string = `${envConfig.PUBLIC_CRYPTO_PRIVATE_KEY}` try { - const encJson: string = CryptoJS.AES.encrypt(JSON.stringify(value), CRYPTO_PRIVATE_KEY).toString(); - let encData = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(encJson)) - - return encData; + if (typeof (value) !== 'string') { + value = JSON.stringify(value) + } + return CryptoJS.AES.encrypt(value, CRYPTO_PRIVATE_KEY).toString(); } catch (error) { // Handle encryption error console.error('Encryption error:', error); @@ -244,14 +244,8 @@ export const decryptData = (value: any): string => { const CRYPTO_PRIVATE_KEY: string = `${envConfig.PUBLIC_CRYPTO_PRIVATE_KEY}` try { - - let decData = CryptoJS.enc.Base64.parse(value).toString(CryptoJS.enc.Utf8) - let bytes = CryptoJS.AES.decrypt(decData, CRYPTO_PRIVATE_KEY).toString(CryptoJS.enc.Utf8) - const parsedData = JSON.parse(bytes); - if (typeof parsedData !== 'string') { - return JSON.stringify(parsedData); - } - return parsedData; + let bytes = CryptoJS.AES.decrypt(value, CRYPTO_PRIVATE_KEY); + return bytes.toString(CryptoJS.enc.Utf8); } catch (error) { // Handle decryption error or invalid input console.error('Decryption error:', error); @@ -312,4 +306,4 @@ export const getFromCookies = (cookies: AstroCookies, key: string) =>{ export const removeFromLocalStorage = async (key: string) => { await localStorage.removeItem(key); return true; -}; +}; \ No newline at end of file diff --git a/src/api/ecosystem.ts b/src/api/ecosystem.ts index e72823489..32aa96821 100644 --- a/src/api/ecosystem.ts +++ b/src/api/ecosystem.ts @@ -66,11 +66,11 @@ export const updateEcosystem = async (dataPayload: CreateEcosystemPayload) => { export const getEcosystems = async ( orgId: string, - pageNumber?: number, - pageSize?: number, + pageNumber: number = 1, + pageSize: number = 10, search = '', ) => { - const url = `${apiRoutes.Ecosystem.root}/${orgId}`; + const url = `${apiRoutes.Ecosystem.root}/${orgId}?pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}`; const axiosPayload = { url, config: await getHeaderConfigs(), diff --git a/src/commonComponents/EcosystemProfileCard.tsx b/src/commonComponents/EcosystemProfileCard.tsx index 57973186b..f097fc649 100644 --- a/src/commonComponents/EcosystemProfileCard.tsx +++ b/src/commonComponents/EcosystemProfileCard.tsx @@ -28,9 +28,9 @@ const EcosystemProfileCard = ({getEndorsementListData}:IEndorsement) => { setLoading(false) const { data } = response as AxiosResponse; if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - setEcosystemList(data?.data.ecosystemDetails + setEcosystemList(data?.data.ecosystemList ) - const ecosystemData = data?.data?.ecosystemDetails?.find((item: { id: string }) => item.id === ecosystemId); + const ecosystemData = data?.data?.ecosystemList?.find((item: { id: string }) => item.id === ecosystemId); if (ecosystemData) { setEcosystemId(ecosystemData?.id) const ecosystemOrg = diff --git a/src/components/Authentication/SignInUser.tsx b/src/components/Authentication/SignInUser.tsx index 18d6ab4a8..58c49e205 100644 --- a/src/components/Authentication/SignInUser.tsx +++ b/src/components/Authentication/SignInUser.tsx @@ -87,13 +87,11 @@ const SignInUser = () => { const saveEmail = async (values: emailValue) => { setEmail(values); - await removeFromLocalStorage(storageKeys.TOKEN) - await removeFromLocalStorage(storageKeys.USER_EMAIL) - await removeFromLocalStorage(storageKeys.ORG_ID) - await removeFromLocalStorage(storageKeys.ORG_ROLES) - await removeFromLocalStorage(storageKeys.ECOSYSTEM_ID) - await removeFromLocalStorage(storageKeys.ECOSYSTEM_ROLE) - await removeFromLocalStorage(storageKeys.USER_PROFILE) + + for await (const value of Object.values(storageKeys)){ + await removeFromLocalStorage(value) + } + setCurrentComponent('password'); await setToLocalStorage(storageKeys.LOGIN_USER_EMAIL, values.email); setIsPasskeySuccess(true); diff --git a/src/components/Ecosystem/Dashboard.tsx b/src/components/Ecosystem/Dashboard.tsx index c6d5c07dc..da2c8272a 100644 --- a/src/components/Ecosystem/Dashboard.tsx +++ b/src/components/Ecosystem/Dashboard.tsx @@ -123,7 +123,7 @@ const Dashboard = () => { const response = await getEcosystems(id); const { data } = response as AxiosResponse; if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - const ecosystemData = data?.data?.ecosystemDetails?.find( + const ecosystemData = data?.data?.ecosystemList?.find( (item: { id: string }) => item.id === ecosystemId, ); if (ecosystemData) { @@ -165,7 +165,6 @@ const Dashboard = () => { if (ecosystemId && orgId) { const response = await getEcosystemDashboard(ecosystemId, orgId); - const { data } = response as AxiosResponse; if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { diff --git a/src/components/Ecosystem/EcosystemList.tsx b/src/components/Ecosystem/EcosystemList.tsx index 22d8ee433..d7bc4a3ff 100644 --- a/src/components/Ecosystem/EcosystemList.tsx +++ b/src/components/Ecosystem/EcosystemList.tsx @@ -72,7 +72,7 @@ const EcosystemList = () => { const { data } = response as AxiosResponse; if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - const ecosystemData = data?.data.ecosystemDetails; + const ecosystemData = data?.data.ecosystemList; if (ecosystemData) { setEcosystemList(ecosystemData); diff --git a/src/components/Ecosystem/Endorsement/EndorsementPopup.tsx b/src/components/Ecosystem/Endorsement/EndorsementPopup.tsx index a2234f1dc..0d3037afd 100644 --- a/src/components/Ecosystem/Endorsement/EndorsementPopup.tsx +++ b/src/components/Ecosystem/Endorsement/EndorsementPopup.tsx @@ -188,11 +188,11 @@ const EndorsementPopup = (props: { > Decline @@ -202,13 +202,13 @@ const EndorsementPopup = (props: { isProcessing={loading} color="bg-primary-800" disabled={loading || !isAccess || loadingReject} - className={`${isAccess ? "hover:bg-primary-800 dark:hover:text-primary-700 dark:hover:bg-primary-700" : ""} text-base font-medium text-center text-white bg-primary-700 rounded-lg focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:focus:ring-primary-800 mr-3`} + className={`${isAccess ? "hover:bg-secondary-700 hover:!bg-secondary-700 dark:hover:text-primary-700 dark:hover:bg-secondary-700" : ""} text-base font-medium text-center text-white bg-primary-700 rounded-lg focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:focus:ring-primary-800 mr-3`} onClick={() => { SignEndorsement(props.endorsementData.id); }} > (); + const [searchValue, setSearchValue] = useState(''); const getSchemaList = async ( schemaListAPIParameter: GetAllSchemaListParameter, @@ -97,14 +98,18 @@ const SchemaList = (props: { getSchemaList(schemaListAPIParameter, false); }, [schemaListAPIParameter, allSchemaFlag]); + const onSearch = async ( event: ChangeEvent, ): Promise => { event.preventDefault(); + const inputValue = event.target.value; + setSearchValue(inputValue); + getSchemaList( { ...schemaListAPIParameter, - search: event.target.value, + search: inputValue, }, false, ); @@ -113,7 +118,7 @@ const SchemaList = (props: { getSchemaList( { ...schemaListAPIParameter, - allSearch: event.target.value, + allSearch: inputValue, }, false, ); @@ -169,6 +174,7 @@ const SchemaList = (props: { console.log(error); } })(); + setSearchValue(''); }, []); const createSchemaTitle = isEcosystemData?.isEcosystemMember @@ -191,7 +197,7 @@ const SchemaList = (props: {

Schemas

- + {formikHandlers?.errors?.method && formikHandlers?.touched?.method && ( @@ -357,9 +361,9 @@ const SharedAgentForm = ({ {generatedKeys && formikHandlers.values.method === DidMethod.POLYGON && ()} - {formikHandlers.values.method === DidMethod.POLYGON && (setPrivateKeyValue(val)} privateKeyValue={privateKeyValue}/>)} + {formikHandlers.values.method === DidMethod.POLYGON && (setPrivateKeyValue(val)} privateKeyValue={privateKeyValue} formikHandlers={formikHandlers}/>)} - {formikHandlers.values.method === DidMethod.WEB && (setDomainValue(val)} domainValue={domainValue}/>)} + {formikHandlers.values.method === DidMethod.WEB && (setDomainValue(val)} domainValue={domainValue} formikHandlers={formikHandlers}/>)} {formikHandlers.values.method !== DidMethod.POLYGON && formikHandlers.values.method !== DidMethod.KEY && formikHandlers.values.method !== DidMethod.WEB && (
@@ -383,7 +387,7 @@ const SharedAgentForm = ({ {mappedData && selectedLedger && mappedData[selectedLedger] && Object.keys(mappedData[selectedLedger])?.map( (ledger) => ( - + ), )} @@ -912,11 +916,11 @@ const WalletSpinup = (props: { const submitSharedWallet = async ( values: ValuesShared, - privateKey: string, + privatekey: string, domain: string, endPoint: string, ) => { - const polygonPrivateKey = privateKey.slice(2); + const polygonPrivateKey = privatekey.slice(2); setLoading(true); const payload = { keyType: values.keyType || 'ed25519', diff --git a/src/components/organization/walletCommonComponents/LegderLessMethods.tsx b/src/components/organization/walletCommonComponents/LegderLessMethods.tsx index 56b5cc895..92178be62 100644 --- a/src/components/organization/walletCommonComponents/LegderLessMethods.tsx +++ b/src/components/organization/walletCommonComponents/LegderLessMethods.tsx @@ -15,56 +15,54 @@ interface IProps { const LedgerLessMethodsComponent = ({ formikHandlers, setSelectedDid, selectedDid, mappedData, selectedLedger, selectedNetwork }: IProps) => { return ( -
- +
+ - + - {formikHandlers?.errors?.network && - formikHandlers?.touched?.network && ( - - {formikHandlers?.errors?.network} - - )} -
- ) + {formikHandlers?.errors?.network && + formikHandlers?.touched?.network && ( + + {formikHandlers?.errors?.network} + + )} +
+ ); } export default LedgerLessMethodsComponent; \ No newline at end of file diff --git a/src/components/organization/walletCommonComponents/SetDomainValueInput.tsx b/src/components/organization/walletCommonComponents/SetDomainValueInput.tsx index c99d60e10..e99d02c69 100644 --- a/src/components/organization/walletCommonComponents/SetDomainValueInput.tsx +++ b/src/components/organization/walletCommonComponents/SetDomainValueInput.tsx @@ -1,29 +1,44 @@ -import React from "react" import {Label } from 'flowbite-react'; -import { Field} from 'formik'; - +import { Field } from 'formik'; interface IProps { setDomainValue:(val:string)=>void domainValue:string -} + formikHandlers: { + handleChange: (e: React.ChangeEvent) => void; + handleBlur: (e: React.FocusEvent) => void; + }; + } -const SetDomainValueInput = ({ setDomainValue, domainValue }: IProps) => ( - <> -
-
-
-
- setDomainValue(e.target.value)} - placeholder="Please enter domain" - /> - -) + const SetDomainValueInput = ({ + setDomainValue, + domainValue, + formikHandlers, + }: IProps) => ( + <> +
+
+
+
+ { + setDomainValue(e.target.value); + formikHandlers.handleChange(e); + }} + onBlur={formikHandlers.handleBlur} + placeholder="Please enter domain" + /> + + {formikHandlers.errors?.domain && + formikHandlers.touched?.domain && + formikHandlers.errors.domain} + + + ); export default SetDomainValueInput; \ No newline at end of file diff --git a/src/components/organization/walletCommonComponents/SetPrivateKeyValue.tsx b/src/components/organization/walletCommonComponents/SetPrivateKeyValue.tsx index 5da06d06b..ba987dca8 100644 --- a/src/components/organization/walletCommonComponents/SetPrivateKeyValue.tsx +++ b/src/components/organization/walletCommonComponents/SetPrivateKeyValue.tsx @@ -1,29 +1,43 @@ -import React from "react" import {Label } from 'flowbite-react'; import { Field} from 'formik'; - - interface IProps { setPrivateKeyValue:(val:string)=>void privateKeyValue:string + formikHandlers: { + handleChange: (e: React.ChangeEvent) => void; + handleBlur: (e: React.FocusEvent) => void; + }; } -const SetPrivateKeyValue = ({setPrivateKeyValue, privateKeyValue}:IProps) =>( - <> -
-
-
-
- setPrivateKeyValue(e.target.value)} - placeholder="Enter private key" - /> - -) -export default SetPrivateKeyValue; \ No newline at end of file +const SetPrivateKeyValueInput = ({ + setPrivateKeyValue, + privateKeyValue, + formikHandlers, +}: IProps) => ( + <> +
+
+
+
+ { + setPrivateKeyValue(e.target.value); + formikHandlers.handleChange(e); + }} + onBlur={formikHandlers.handleBlur} + placeholder="Enter private key" + /> + + {formikHandlers.errors?.privatekey && + formikHandlers.touched?.privatekey && + formikHandlers.errors.privatekey} + + +); +export default SetPrivateKeyValueInput; \ No newline at end of file diff --git a/src/config/ecosystem.ts b/src/config/ecosystem.ts index 44603de7d..f3e5e93a9 100644 --- a/src/config/ecosystem.ts +++ b/src/config/ecosystem.ts @@ -38,14 +38,19 @@ const getOrgId = async () => { return id; }; -const getUserProfile = async () => { - const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE); - const userDetails = userProfile && (await JSON.parse(userProfile)); - return userDetails; +export const getUserProfile = async () => { + try { + const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE); + const userDetails = userProfile && (await JSON.parse(userProfile)); + return userDetails; + } catch (err) { + + } }; const checkEcosystem = async (): Promise => { await getEcosystemId(); + const userData = await getUserProfile(); const role = await getEcosystemRole(); @@ -72,12 +77,11 @@ const getEcosystemId = async (): Promise => { try { if (orgId) { const { data } = (await getEcosystems(orgId)) as AxiosResponse; - if ( data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS && - data?.data?.ecosystemDetails?.length > 0 + data?.data?.ecosystemList?.length > 0 ) { - const response = data?.data.ecosystemDetails[0]; + const response = data?.data.ecosystemList[0]; const id = response?.id; const role = response?.ecosystemOrgs &&