From f835f35c8531eace5c858346113f4952231453ef Mon Sep 17 00:00:00 2001
From: sanjay-k1910
Date: Wed, 25 Oct 2023 19:00:32 +0530
Subject: [PATCH 01/54] fix: ecosystem option hide issue
Signed-off-by: sanjay-k1910
---
src/components/Profile/EditUserProfile.tsx | 72 ++++++++++++----------
src/components/Profile/UserProfile.tsx | 16 +++--
2 files changed, 52 insertions(+), 36 deletions(-)
diff --git a/src/components/Profile/EditUserProfile.tsx b/src/components/Profile/EditUserProfile.tsx
index 2c31e0660..7d025a57d 100644
--- a/src/components/Profile/EditUserProfile.tsx
+++ b/src/components/Profile/EditUserProfile.tsx
@@ -1,11 +1,11 @@
import { useEffect, useRef, useState } from "react";
import type { UserProfile } from "./interfaces";
-import { setToLocalStorage, updateUserProfile } from "../../api/Auth";
-import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, imageSizeAccepted, storageKeys} from "../../config/CommonConstant";
+import { getFromLocalStorage, setToLocalStorage, updateUserProfile } from "../../api/Auth";
+import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, imageSizeAccepted, storageKeys } from "../../config/CommonConstant";
import type { AxiosResponse } from "axios";
import CustomAvatar from '../Avatar'
import { calculateSize, dataURItoBlob } from "../../utils/CompressImage";
-import { Alert,Button} from "flowbite-react";
+import { Alert, Button } from "flowbite-react";
import { Form, Formik, FormikHelpers } from "formik";
import * as yup from "yup"
import React from "react";
@@ -28,7 +28,7 @@ interface EditUserProfileProps {
updateProfile: (updatedProfile: UserProfile) => void;
}
-const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile}: EditUserProfileProps) => {
+const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile }: EditUserProfileProps) => {
const [loading, setLoading] = useState(false)
const [isImageEmpty, setIsImageEmpty] = useState(true)
@@ -54,7 +54,7 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile}: E
if (firstNameInputRef.current) {
firstNameInputRef.current.focus();
}
- }, []);
+ }, []);
useEffect(() => {
@@ -166,11 +166,19 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile}: E
}
const resUpdateUserDetails = await updateUserProfile(userData)
+ const existingUser = await getFromLocalStorage(storageKeys.USER_PROFILE)
+
const { data } = resUpdateUserDetails as AxiosResponse
- setToLocalStorage(storageKeys.USER_PROFILE, userData)
+
+ const updatedUser = JSON.parse(existingUser)
+
+ const updatedUserData = {
+ ...updatedUser,
+ ...userData
+ }
updateProfile(userData);
- await setToLocalStorage(storageKeys.USER_PROFILE, userData);
+ await setToLocalStorage(storageKeys.USER_PROFILE, updatedUserData);
window.location.reload();
setLoading(false)
}
@@ -219,7 +227,7 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile}: E
values: Values,
{ resetForm }: FormikHelpers
) => {
- await updateUserDetails(values);
+ await updateUserDetails(values);
toggleEditProfile();
}}
@@ -321,28 +329,28 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile}: E
-
-
+
)}
diff --git a/src/components/Profile/UserProfile.tsx b/src/components/Profile/UserProfile.tsx
index d5c8e3cfc..cd6eaf840 100644
--- a/src/components/Profile/UserProfile.tsx
+++ b/src/components/Profile/UserProfile.tsx
@@ -1,7 +1,7 @@
import { useEffect, useState } from 'react';
import type { AxiosResponse } from 'axios';
import { apiStatusCodes, storageKeys } from '../../config/CommonConstant';
-import { getFromLocalStorage, getUserProfile } from '../../api/Auth';
+import { getFromLocalStorage, getUserProfile, setToLocalStorage } from '../../api/Auth';
import BreadCrumbs from '../BreadCrumbs';
import type { UserProfile } from './interfaces';
import DisplayUserProfile from './DisplayUserProfile';
@@ -9,9 +9,16 @@ import React from 'react';
import AddPasskey from './AddPasskey';
import EditUserProfile from './EditUserProfile';
+interface IUserProfile {
+ firstName: string
+ lastName: string
+ email: string
+ profileImg: string
+}
+
const UserProfile = () => {
const [isEditProfileOpen, setIsEditProfileOpen] = useState(false);
- const [prePopulatedUserProfile, setPrePopulatedUserProfile] = useState(null);
+ const [prePopulatedUserProfile, setPrePopulatedUserProfile] = useState(null);
const fetchUserProfile = async () => {
try {
@@ -21,6 +28,8 @@ const UserProfile = () => {
if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
setPrePopulatedUserProfile(data?.data);
+ await setToLocalStorage(storageKeys.USER_PROFILE, data?.data)
+ await setToLocalStorage(storageKeys.USER_EMAIL, data?.data?.email)
}
} catch (error) {
}
@@ -37,7 +46,7 @@ const UserProfile = () => {
}, []);
- const updatePrePopulatedUserProfile = (updatedProfile: UserProfile) => {
+ const updatePrePopulatedUserProfile = (updatedProfile: IUserProfile) => {
setPrePopulatedUserProfile(updatedProfile);
};
@@ -107,7 +116,6 @@ const UserProfile = () => {
-
);
};
From 039392b32febe3ca1b28d3e1db0fc638dbb74c71 Mon Sep 17 00:00:00 2001
From: sanjay-k1910
Date: Wed, 25 Oct 2023 19:19:50 +0530
Subject: [PATCH 02/54] fix: dark mode issue on update profile form
Signed-off-by: sanjay-k1910
---
src/components/Profile/EditUserProfile.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/Profile/EditUserProfile.tsx b/src/components/Profile/EditUserProfile.tsx
index 7d025a57d..49c7016cd 100644
--- a/src/components/Profile/EditUserProfile.tsx
+++ b/src/components/Profile/EditUserProfile.tsx
@@ -346,7 +346,7 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile }:
+ )}
+
+ ),
+ },
+ ],
+ };
+ });
- setVerificationList(credentialList);
- } else {
- setErrMsg(response as string);
+ setVerificationList(credentialList);
+ } else {
+ setErrMsg(response as string);
+ }
}
+ } catch (error) {
+ setErrMsg('An error occurred while fetching the proof request list');
}
- } catch (error) {
- setErrMsg('An error occurred while fetching the proof request list');
- }
- setLoading(false);
- };
+ setLoading(false);
+ };
- const presentProofById = async (id: string) => {
- try {
- const response = await verifyPresentation(id);
- const { data } = response as AxiosResponse;
+ const presentProofById = async (id: string) => {
+ try {
+ const response = await verifyPresentation(id);
+ const { data } = response as AxiosResponse;
- if (data?.statusCode === apiStatusCodes?.API_STATUS_CREATED) {
- setOpenModal(false)
- setProofReqSuccess(data.message)
- setVerifyloader(false)
+ if (data?.statusCode === apiStatusCodes?.API_STATUS_CREATED) {
+ setOpenModal(false)
+ setProofReqSuccess(data.message)
+ setVerifyloader(false)
+ setTimeout(() => {
+ getproofRequestList()
+ }, 2000)
+ } else {
+ setOpenModal(false)
+ setErrMsg(response as string);
+ setVerifyloader(false)
+ }
setTimeout(() => {
- getproofRequestList()
- }, 2000)
- } else {
+ setProofReqSuccess('')
+ setErrMsg('')
+ }, 4000)
+ } catch (error) {
setOpenModal(false)
- setErrMsg(response as string);
setVerifyloader(false)
+ console.error("An error occurred:", error);
+ setErrMsg("An error occurred while processing the presentation.");
}
- setTimeout(() => {
- setProofReqSuccess('')
- setErrMsg('')
- }, 4000)
- } catch (error) {
- setOpenModal(false)
- setVerifyloader(false)
- console.error("An error occurred:", error);
- setErrMsg("An error occurred while processing the presentation.");
- }
- };
+ };
- const openProofRequestModel = (flag: boolean, requestId: string, state: boolean) => {
- setRequestId(requestId)
- setOpenModal(flag)
- setView(state === "done" ? true : false)
+ const openProofRequestModel = (flag: boolean, requestId: string, state: boolean) => {
+ setRequestId(requestId)
+ setOpenModal(flag)
+ setView(state === "done" ? true : false)
- }
+ }
- const requestProof = async (proofVericationId: string) => {
- if (proofVericationId) {
- setOpenModal(false)
- presentProofById(proofVericationId)
+ const requestProof = async (proofVericationId: string) => {
+ if (proofVericationId) {
+ setOpenModal(false)
+ presentProofById(proofVericationId)
+ }
}
- }
- useEffect(() => {
- let getData: NodeJS.Timeout
+ useEffect(() => {
+ let getData: NodeJS.Timeout
- if (searchText.length >= 1) {
- getData = setTimeout(() => { }, 1000);
- } else {
- getproofRequestList()
- }
+ if (searchText.length >= 1) {
+ getData = setTimeout(() => { }, 1000);
+ } else {
+ getproofRequestList()
+ }
- return () => clearTimeout(getData)
- }, [searchText])
+ return () => clearTimeout(getData)
+ }, [searchText])
- const searchInputChange = (e: ChangeEvent) => {
- setSearchText(e.target.value);
- }
+ const searchInputChange = (e: ChangeEvent) => {
+ setSearchText(e.target.value);
+ }
- const schemeSelection = () => {
- window.location.href = pathRoutes.organizations.verification.schema
- }
+ const schemeSelection = () => {
+ window.location.href = pathRoutes.organizations.verification.schema
+ }
- const header = [
- { columnName: 'Request Id' },
- { columnName: 'Connection Id' },
- { columnName: 'Requested On' },
- { columnName: 'Status' },
- { columnName: 'Action' },
- ];
+ const header = [
+ { columnName: 'Request Id' },
+ { columnName: 'Connection Id' },
+ { columnName: 'Requested On' },
+ { columnName: 'Status' },
+ { columnName: 'Action' },
+ ];
- return (
-
-
-
-
- Verification List
-
-
-
-
-
-
-
-
+ return (
+
+
+
+
+ Verification List
+
+
+
+
+
+ {
+ walletCreated &&
+
+
+
+ }
+ onClickEvent={schemeSelection}
+ />
}
- onClickEvent={schemeSelection}
- />
-
- {
- (proofReqSuccess || errMsg) && (
-
-
setErrMsg(null)}
- >
-
-
- {proofReqSuccess || errMsg}
-
-
-
-
- )}
- {loading ? (
-
-
- ) : verificationList && verificationList.length > 0 ? (
-
-
- {verificationList && verificationList.length > 0 &&
-
- }
-
-
- ) : (
-
-
- There isn't any data available.
-
-
- )}
+ {
+ (proofReqSuccess || errMsg) && (
+
+
setErrMsg(null)}
+ >
+
+
+ {proofReqSuccess || errMsg}
+
+
+
+
+ )}
-
+
+
+ :
+
+ {
+
+ loading ? (
+
+
+
+ ) : verificationList && verificationList.length > 0 ? (
+
+
+ {verificationList && verificationList.length > 0 &&
+
+ }
+
+
+ ) : (
+
+
+ There isn't any data available.
+
+
+ )
+
+ }
+
}
- requestId={requestId}
- userData={userData}
- view={view}
- />
+
+
+
-
- )
-}
+ )
+ }
-export default VerificationCredentialList;
+ export default VerificationCredentialList;
diff --git a/src/components/organization/OrgDropDown.tsx b/src/components/organization/OrgDropDown.tsx
index 4169a7abb..48e423e77 100644
--- a/src/components/organization/OrgDropDown.tsx
+++ b/src/components/organization/OrgDropDown.tsx
@@ -29,6 +29,7 @@ const OrgDropDown = () => {
const goToOrgDashboard = async (org: Organisation) => {
await removeFromLocalStorage(storageKeys.ECOSYSTEM_ID)
await removeFromLocalStorage(storageKeys.ECOSYSTEM_ROLE)
+ await removeFromLocalStorage(storageKeys.ORG_DETAILS)
await setOrgRoleDetails(org)
window.location.href = pathRoutes.organizations.dashboard;
diff --git a/src/components/organization/WalletSpinup.tsx b/src/components/organization/WalletSpinup.tsx
index 8028e0f2e..113699d9f 100644
--- a/src/components/organization/WalletSpinup.tsx
+++ b/src/components/organization/WalletSpinup.tsx
@@ -28,7 +28,6 @@ interface Values {
}
interface ValuesShared {
- seed: string;
label: string;
}
@@ -37,36 +36,234 @@ enum AgentType {
DEDICATED = 'dedicated',
}
+interface ISharedAgentForm {
+ seeds: string
+ isCopied: boolean
+ copyTextVal: (e: any) => void
+ orgName: string
+ loading: boolean
+ submitSharedWallet: (values: ValuesShared) => void
+}
+
+interface IDedicatedAgentForm {
+ seeds: string
+ loading: boolean
+ submitDedicatedWallet: (values: Values) => void
+}
+
+const SharedAgentForm = ({ orgName, seeds, isCopied, loading, copyTextVal, submitSharedWallet }: ISharedAgentForm) => (
+
+
+
+
+
+
+ {seeds}
+
+ copyTextVal(e)}
+ >
+ {isCopied
+ ?
+ :
+ }
+
+
+
+
+
!value || !value.includes(' '))
+ .matches(
+ /^[A-Za-z0-9-][^ !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]*$/,
+ 'Wallet label must be alphanumeric only',
+ )
+ .min(2, 'Wallet label must be at least 2 characters')
+ .max(25, 'Wallet label must be at most 25 characters'),
+ })}
+ validateOnBlur
+ validateOnChange
+ enableReinitialize
+ onSubmit={(values: ValuesShared) => submitSharedWallet(values)}
+ >
+ {(formikHandlers): JSX.Element => (
+
+ )}
+
+
+);
+
+const DedicatedAgentForm = ({ seeds, loading, submitDedicatedWallet }: IDedicatedAgentForm) => (
+
?@[\]^_`{|}~]*$/,
+ 'Wallet name must be alphanumeric only',
+ )
+ .label('Wallet name'),
+ password: yup
+ .string()
+ .matches(
+ passwordRegex,
+ 'Password must contain one Capital, Special character',
+ )
+ .required('Wallet password is required')
+ .label('Wallet password'),
+ })}
+ validateOnBlur
+ validateOnChange
+ enableReinitialize
+ onSubmit={(values: Values) => submitDedicatedWallet(values)}
+ >
+ {(formikHandlers): JSX.Element => (
+
+ )}
+
+);
+
const WalletSpinup = (props: {
setWalletSpinupStatus: (flag: boolean) => void;
orgName: string
}) => {
const [agentType, setAgentType] = useState
(AgentType.SHARED);
-
const [loading, setLoading] = useState(false);
-
const [walletSpinStep, setWalletSpinStep] = useState(0);
-
const [success, setSuccess] = useState(null);
-
const [agentSpinupCall, setAgentSpinupCall] = useState(false);
-
const [failure, setFailure] = useState(null);
-
const [seeds, setSeeds] = useState('');
-
const [isCopied, setIsCopied] = useState(false);
+ // const [organization, setOrganization] = useState(props.orgName)
-
- const generateWalletname = () => {
-
- }
useEffect(() => {
setSeeds(nanoid(32));
- generateWalletname()
}, []);
- function copyTextVal(event: React.MouseEvent) {
+ const copyTextVal = (event: React.MouseEvent) => {
event.preventDefault()
setIsCopied(true);
@@ -183,202 +380,9 @@ const WalletSpinup = (props: {
console.log(`error-in-wallet-creation-process`, JSON.stringify(data));
});
- const DedicatedAgentForm = () => (
- ?@[\]^_`{|}~]*$/,
- 'Wallet name must be alphanumeric only',
- )
- .label('Wallet name'),
- password: yup
- .string()
- .matches(
- passwordRegex,
- 'Password must contain one Capital, Special character',
- )
- .required('Wallet password is required')
- .label('Wallet password'),
- })}
- validateOnBlur
- validateOnChange
- enableReinitialize
- onSubmit={(values: Values) => submitDedicatedWallet(values)}
- >
- {(formikHandlers): JSX.Element => (
-
- )}
-
- );
-
const orgName = props?.orgName ? props?.orgName?.split(" ").reduce((s, c) => (s.charAt(0).toUpperCase() + s.slice(1)) + (c.charAt(0).toUpperCase() + c.slice(1))
) : ""
- const SharedAgentForm = () => (
- !value || !value.includes(' '))
- .matches(
- /^[A-Za-z0-9-][^ !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]*$/,
- 'Wallet label must be alphanumeric only',
- )
- .min(2, 'Wallet label must be at least 2 characters')
- .max(25, 'Wallet label must be at most 25 characters'),
- })}
- validateOnBlur
- validateOnChange
- enableReinitialize
- onSubmit={(values: ValuesShared) => submitSharedWallet(values)}
- >
- {(formikHandlers): JSX.Element => (
-
- )}
-
- );
return (
@@ -444,9 +448,9 @@ const WalletSpinup = (props: {
{!agentSpinupCall ? (
agentType === AgentType.SHARED ? (
-
+
) : (
-
+
)
) : (
Date: Thu, 26 Oct 2023 13:50:20 +0530
Subject: [PATCH 04/54] refactor: commented code
Signed-off-by: sanjay-k1910
---
src/components/organization/WalletSpinup.tsx | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/components/organization/WalletSpinup.tsx b/src/components/organization/WalletSpinup.tsx
index 113699d9f..7b3e329a9 100644
--- a/src/components/organization/WalletSpinup.tsx
+++ b/src/components/organization/WalletSpinup.tsx
@@ -111,10 +111,6 @@ const SharedAgentForm = ({ orgName, seeds, isCopied, loading, copyTextVal, submi
name="label"
className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-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-primary-500 dark:focus:border-primary-500"
type="text"
- // onChange={(e) => {
- // formikHandlers.handleChange(e)
- // setOrganization(e.target.value)
- // }}
/>
{formikHandlers?.errors?.label &&
formikHandlers?.touched?.label && (
From a291236a458a672412ae89617e2f8a9821f49e3c Mon Sep 17 00:00:00 2001
From: bhavanakarwade
Date: Thu, 26 Oct 2023 14:54:36 +0530
Subject: [PATCH 05/54] fix: length of the input field characters
Signed-off-by: bhavanakarwade
---
.../Authentication/SignUpUserName.tsx | 127 +++++++++++++-----
.../CreateEcosystemOrgModal/index.tsx | 32 ++++-
.../EditEcosystemOrgModal/index.tsx | 24 ++++
src/components/Profile/EditUserProfile.tsx | 33 ++++-
.../organization/EditOrgdetailsModal.tsx | 63 +++++++--
5 files changed, 224 insertions(+), 55 deletions(-)
diff --git a/src/components/Authentication/SignUpUserName.tsx b/src/components/Authentication/SignUpUserName.tsx
index c91195775..94f814727 100644
--- a/src/components/Authentication/SignUpUserName.tsx
+++ b/src/components/Authentication/SignUpUserName.tsx
@@ -1,7 +1,5 @@
import 'react-toastify/dist/ReactToastify.css';
-
import * as yup from 'yup';
-
import { Button, Label } from 'flowbite-react';
import {
Field,
@@ -9,12 +7,11 @@ import {
Formik
} from 'formik';
import { useState } from 'react';
-
-import React from 'react';
import SignUpUserPasskey from './SignUpUserPasskey.js';
import SignUpUser from './SignUpUser.js';
import NavBar from './NavBar.js';
import FooterBar from './FooterBar.js';
+import React from 'react';
interface nameValues {
firstName: string;
@@ -126,13 +123,13 @@ const SignUpUserName = () => {
.string()
.required('First name is required')
.min(2, 'First name must be at least 2 characters')
- .max(50, 'First name must be at most 255 characters')
+ .max(50, 'First name must be at most 50 characters')
.trim(),
lastName: yup
.string()
.required('Last name is required')
.min(2, 'Last name must be at least 2 characters')
- .max(50, 'Last name must be at most 255 characters')
+ .max(50, 'Last name must be at most 50 characters')
.trim()
})}
validateOnBlur
@@ -151,72 +148,134 @@ const SignUpUserName = () => {
lastName: formikHandlers.values.lastName
})
return (
-
- )
+ );
}}
diff --git a/src/components/CreateEcosystemOrgModal/index.tsx b/src/components/CreateEcosystemOrgModal/index.tsx
index 5ebda9078..967e5500e 100644
--- a/src/components/CreateEcosystemOrgModal/index.tsx
+++ b/src/components/CreateEcosystemOrgModal/index.tsx
@@ -14,6 +14,7 @@ import { createOrganization } from "../../api/organization";
import { getFromLocalStorage } from "../../api/Auth";
import { createEcosystems } from "../../api/ecosystem";
import { getOrgDetails } from "../../config/ecosystem";
+import React from "react";
interface Values {
name: string;
@@ -340,7 +341,19 @@ const CreateEcosystemOrgModal = (props: IProps) => {
name="name"
value={formikHandlers.values.name}
className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-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-primary-500 dark:focus:border-primary-500"
- placeholder={`Enter ${popupName} Name`} />
+ placeholder={`Enter ${popupName} Name`}
+ onChange={(e) => {
+ const value = e.target.value;
+ formikHandlers.setFieldValue('name', value);
+ formikHandlers.setFieldTouched('name', true);
+
+ if (value.length > 50) {
+ formikHandlers.setFieldError('name', props.isorgModal ? 'Organization name must be at most 50 characters' : 'Ecosystem name must be at most 50 characters');
+ } else {
+ formikHandlers.setFieldError('name', undefined);
+ }
+ }}
+ />
{
(formikHandlers?.errors?.name && formikHandlers?.touched?.name) &&
{formikHandlers?.errors?.name}
@@ -365,7 +378,19 @@ const CreateEcosystemOrgModal = (props: IProps) => {
value={formikHandlers.values.description}
as='textarea'
className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-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-primary-500 dark:focus:border-primary-500"
- placeholder={`Enter ${popupName} Description`} />
+ placeholder={`Enter ${popupName} Description`}
+ onChange={(e) => {
+ const value = e.target.value;
+ formikHandlers.setFieldValue('description', value);
+ formikHandlers.setFieldTouched('description', true);
+
+ if (value.length > 50) {
+ formikHandlers.setFieldError('description', 'Description must be at most 255 characters');
+ } else {
+ formikHandlers.setFieldError('description', undefined);
+ }
+ }}
+ />
{
(formikHandlers?.errors?.description && formikHandlers?.touched?.description) &&
{formikHandlers?.errors?.description}
@@ -385,14 +410,11 @@ const CreateEcosystemOrgModal = (props: IProps) => {
)}
-
-
)
}
-
return (
<>
{renderEcosystemModal()}
diff --git a/src/components/EditEcosystemOrgModal/index.tsx b/src/components/EditEcosystemOrgModal/index.tsx
index b2ec9e95c..986e5bba8 100644
--- a/src/components/EditEcosystemOrgModal/index.tsx
+++ b/src/components/EditEcosystemOrgModal/index.tsx
@@ -295,6 +295,18 @@ const EditPopupModal = (props: EditEntityModalProps) => {
value={formikHandlers.values.name}
className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-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-primary-500 dark:focus:border-primary-500"
placeholder={`Enter ${props.isOrganization ? "Organization" : "Ecosystem"} Name`}
+ onChange={(e) => {
+ const value = e.target.value;
+ formikHandlers.setFieldValue('name', value);
+ formikHandlers.setFieldTouched('name', true);
+
+ if (value.length > 50) {
+ formikHandlers.setFieldError('name', props.isOrganization ? 'Organization name must be at most 50 characters' : 'Ecosystem name must be at most 50 characters');
+ } else {
+ formikHandlers.setFieldError('name', undefined);
+ }
+ }}
+
/>
{formikHandlers?.errors?.name && formikHandlers?.touched?.name && (
{formikHandlers?.errors?.name}
@@ -312,6 +324,18 @@ const EditPopupModal = (props: EditEntityModalProps) => {
as='textarea'
className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-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-primary-500 dark:focus:border-primary-500"
placeholder={`Enter ${props.isOrganization ? "Organization" : "Ecosystem"} Description`}
+ onChange={(e) => {
+ const value = e.target.value;
+ formikHandlers.setFieldValue('description', value);
+ formikHandlers.setFieldTouched('description', true);
+
+ if (value.length > 50) {
+ formikHandlers.setFieldError('description', 'Description must be at most 255 characters');
+ } else {
+ formikHandlers.setFieldError('description', undefined);
+ }
+ }}
+
/>
{formikHandlers?.errors?.description && formikHandlers?.touched?.description && (
{formikHandlers?.errors?.description}
diff --git a/src/components/Profile/EditUserProfile.tsx b/src/components/Profile/EditUserProfile.tsx
index 2c31e0660..0a74fee1b 100644
--- a/src/components/Profile/EditUserProfile.tsx
+++ b/src/components/Profile/EditUserProfile.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useRef, useState } from "react";
+import { useEffect, useRef, useState} from "react";
import type { UserProfile } from "./interfaces";
import { setToLocalStorage, updateUserProfile } from "../../api/Auth";
import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, imageSizeAccepted, storageKeys} from "../../config/CommonConstant";
@@ -8,7 +8,6 @@ import { calculateSize, dataURItoBlob } from "../../utils/CompressImage";
import { Alert,Button} from "flowbite-react";
import { Form, Formik, FormikHelpers } from "formik";
import * as yup from "yup"
-import React from "react";
interface Values {
profileImg: string;
@@ -179,12 +178,12 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile}: E
firstName: yup.string()
.required("First Name is required")
.min(2, 'First name must be at least 2 characters')
- .max(255, 'First name must be at most 255 characters'),
-
+ .max(50, 'First name must be at most 50 characters'),
+
lastName: yup.string()
.required("Last Name is required")
.min(2, 'Last name must be at least 2 characters')
- .max(255, 'Last name must be at most 255 characters')
+ .max(50, 'Last name must be at most 50 characters')
});
@@ -253,7 +252,17 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile}: E
name="firstName"
placeholder="Enter your first name"
value={formikHandlers.values.firstName}
- onChange={formikHandlers.handleChange}
+ onChange={(e) => {
+ const value = e.target.value;
+ formikHandlers.setFieldValue('firstName', value);
+ formikHandlers.setFieldTouched('firstName', true);
+
+ if (value.length > 50) {
+ formikHandlers.setFieldError('firstName', 'First name must be at most 50 characters');
+ } else {
+ formikHandlers.setFieldError('firstName', undefined);
+ }
+ }}
onBlur={formikHandlers.handleBlur}
ref={firstNameInputRef}
className="bg-gray-50 py-3 px-4 font-medium text-gray-900 border border-gray-300 w-full rounded-md focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500 max-w-100/6rem" />
@@ -278,7 +287,17 @@ const EditUserProfile = ({ toggleEditProfile, userProfileInfo, updateProfile}: E
name="lastName"
placeholder="Enter your last name"
value={formikHandlers.values.lastName}
- onChange={formikHandlers.handleChange}
+ onChange={(e) => {
+ const value = e.target.value;
+ formikHandlers.setFieldValue('lastName', value);
+ formikHandlers.setFieldTouched('lastName', true);
+
+ if (value.length > 50) {
+ formikHandlers.setFieldError('lastName', 'Last name must be at most 50 characters');
+ } else {
+ formikHandlers.setFieldError('lastName', undefined);
+ }
+ }}
onBlur={formikHandlers.handleBlur}
className="bg-gray-50 py-3 px-4 font-medium text-gray-900 border border-gray-300 w-full rounded-md focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500 max-w-100/6rem" />
{(formikHandlers?.errors?.lastName && formikHandlers?.touched?.lastName) && (
diff --git a/src/components/organization/EditOrgdetailsModal.tsx b/src/components/organization/EditOrgdetailsModal.tsx
index 997179817..3e055d5a6 100644
--- a/src/components/organization/EditOrgdetailsModal.tsx
+++ b/src/components/organization/EditOrgdetailsModal.tsx
@@ -2,7 +2,7 @@ import * as yup from "yup"
import { Avatar, Button, Label, Modal } from 'flowbite-react';
import { Field, Form, Formik, FormikHelpers } from 'formik';
-import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, apiStatusCodes, imageSizeAccepted, storageKeys } from '../../config/CommonConstant'
+import { IMG_MAX_HEIGHT, IMG_MAX_WIDTH, apiStatusCodes, imageSizeAccepted} from '../../config/CommonConstant'
import { calculateSize, dataURItoBlob } from "../../utils/CompressImage";
import { useEffect, useState } from "react";
@@ -10,26 +10,24 @@ import { AlertComponent } from "../AlertComponent";
import type { AxiosResponse } from 'axios';
import { updateOrganization } from "../../api/organization";
import type { Organisation } from "./interfaces";
+import React from "react";
interface Values {
website: any;
name: string;
description: string;
}
-
interface ILogoImage {
logoFile: string | File
imagePreviewUrl: string | ArrayBuffer | null | File,
fileName: string
}
-
interface EditOrgdetailsModalProps {
openModal: boolean;
setMessage: (message: string) => void;
setOpenModal: (flag: boolean) => void;
onEditSucess?: () => void;
orgData: Organisation | null;
-
}
const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => {
@@ -55,7 +53,7 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => {
setOrgData({
name: props.orgData.name || '',
description: props.orgData.description || '',
- website: props?.orgData?.website || "",
+ website: props?.orgData?.website || "",
});
setLogoImage({
@@ -76,7 +74,7 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => {
setOrgData({
name: '',
description: '',
- website:''
+ website:''
})
setLogoImage({
@@ -282,7 +280,6 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => {
className="hidden"
id="organizationlogo" title=""
onChange={(event): void => handleImageChange(event)} />
- {/* {selectedImage || 'No File Chosen'} */}
{imgError ? {imgError}
: {logoImage.fileName || 'No File Chosen'}}
@@ -308,7 +305,31 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => {
name="name"
value={formikHandlers.values.name}
className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-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-primary-500 dark:focus:border-primary-500"
- placeholder="Your organization name" />
+ placeholder="Your organization name"
+ onChange={(e) => {
+ const value = e.target.value;
+ formikHandlers.setFieldValue(
+ 'name',
+ value,
+ );
+ formikHandlers.setFieldTouched(
+ 'name',
+ true,
+ );
+
+ if (value.length > 50) {
+ formikHandlers.setFieldError(
+ 'name',
+ 'Organization name must be at most 50 characters',
+ );
+ } else {
+ formikHandlers.setFieldError(
+ 'name',
+ undefined,
+ );
+ }
+ }}
+ />
{
(formikHandlers?.errors?.name && formikHandlers?.touched?.name) &&
{formikHandlers?.errors?.name}
@@ -334,7 +355,31 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => {
value={formikHandlers.values.description}
as='textarea'
className="bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-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-primary-500 dark:focus:border-primary-500"
- placeholder="Description of your organization" />
+ placeholder="Description of your organization"
+ onChange={(e) => {
+ const value = e.target.value;
+ formikHandlers.setFieldValue(
+ 'description',
+ value,
+ );
+ formikHandlers.setFieldTouched(
+ 'description',
+ true,
+ );
+
+ if (value.length > 50) {
+ formikHandlers.setFieldError(
+ 'description',
+ 'Description must be at most 50 characters',
+ );
+ } else {
+ formikHandlers.setFieldError(
+ 'description',
+ undefined,
+ );
+ }
+ }}
+ />
{
(formikHandlers?.errors?.description && formikHandlers?.touched?.description) &&
{formikHandlers?.errors?.description}
From 6c3535487d7aea64df7b7cd1d88b380eaec6fd97 Mon Sep 17 00:00:00 2001
From: sanjay-k1910
Date: Fri, 27 Oct 2023 15:38:26 +0530
Subject: [PATCH 06/54] feat: multi-ecosystem
Signed-off-by: sanjay-k1910
---
src/api/ecosystem.ts | 3 +-
src/app/LayoutCommon.astro | 2 +-
src/components/Ecosystem/Dashboard.tsx | 71 ++---
src/components/Ecosystem/EcosystemList.tsx | 249 ++++++++++++++++++
.../Ecosystem/EcosystemSidebarOption.tsx | 60 +----
src/components/Ecosystem/interfaces/index.ts | 6 +
src/config/ecosystem.ts | 202 +++++++-------
src/config/pathRoutes.ts | 10 +-
src/pages/dashboard.astro | 1 +
.../dashboard.astro} | 0
.../endorsement/index.astro | 0
src/pages/ecosystems/index.astro | 16 ++
.../invitation.astro | 10 +-
.../invitations.astro | 10 +-
14 files changed, 437 insertions(+), 203 deletions(-)
create mode 100644 src/components/Ecosystem/EcosystemList.tsx
rename src/pages/{ecosystem/index.astro => ecosystems/dashboard.astro} (100%)
rename src/pages/{ecosystem => ecosystems}/endorsement/index.astro (100%)
create mode 100644 src/pages/ecosystems/index.astro
rename src/pages/{ecosystem => ecosystems}/invitation.astro (75%)
rename src/pages/{ecosystem => ecosystems}/invitations.astro (81%)
diff --git a/src/api/ecosystem.ts b/src/api/ecosystem.ts
index bab35e7ca..d42ee22d7 100644
--- a/src/api/ecosystem.ts
+++ b/src/api/ecosystem.ts
@@ -62,9 +62,8 @@ export const updateEcosystem = async (dataPayload: CreateEcosystemPayload) => {
}
};
-export const getEcosystem = async (orgId: string) => {
+export const getEcosystems = async (orgId: string, pageNumber?: number, pageSize?: number, search = '') => {
const url = `${apiRoutes.Ecosystem.root}/${orgId}`;
-
const axiosPayload = {
url,
config: await getHeaderConfigs(),
diff --git a/src/app/LayoutCommon.astro b/src/app/LayoutCommon.astro
index ed0817e24..c253a4d63 100644
--- a/src/app/LayoutCommon.astro
+++ b/src/app/LayoutCommon.astro
@@ -46,7 +46,7 @@ const supabaseKey = process.env.PUBLIC_SUPABASE_KEY || import.meta.env.PUBLIC_SU
+ , 'dark:scrollbar-track-gray-900 dark:scrollbar-thumb-gray-700' , 'dark:bg-[#111827]']}>
diff --git a/src/components/Ecosystem/Dashboard.tsx b/src/components/Ecosystem/Dashboard.tsx
index c4600b5c2..d6c195f5a 100644
--- a/src/components/Ecosystem/Dashboard.tsx
+++ b/src/components/Ecosystem/Dashboard.tsx
@@ -9,7 +9,7 @@ import CustomSpinner from '../CustomSpinner';
import endorseIcon from '../../assets/endorser-icon.svg';
import memberIcon from '../../assets/member-icon.svg';
import MemberList from './MemberList';
-import { getEcosystem, getEcosystemDashboard } from '../../api/ecosystem';
+import { getEcosystems, getEcosystemDashboard } from '../../api/ecosystem';
import { EmptyListMessage } from '../EmptyListComponent';
import CreateEcosystemOrgModal from '../CreateEcosystemOrgModal';
import { AlertComponent } from '../AlertComponent';
@@ -118,20 +118,21 @@ const Dashboard = () => {
const fetchEcosystemDetails = async () => {
setLoading(true);
const id = await getFromLocalStorage(storageKeys.ORG_ID);
+ const ecosystemId = await getFromLocalStorage(storageKeys.ECOSYSTEM_ID);
setOrgId(id);
if (id) {
- const response = await getEcosystem(id);
+ const response = await getEcosystems(id);
const { data } = response as AxiosResponse;
if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
- const ecosystemData = data?.data[0];
+ const ecosystemData = data?.data.find((item: { id: string }) => item.id === ecosystemId);
if (ecosystemData) {
- await setToLocalStorage(storageKeys.ECOSYSTEM_ID, ecosystemData?.id);
const ecosystemOrg =
ecosystemData?.ecosystemOrgs &&
ecosystemData?.ecosystemOrgs.length > 0 &&
ecosystemData?.ecosystemOrgs[0];
setEcosystemDetails({
+ id: ecosystemData?.id,
logoUrl: ecosystemData?.logoUrl,
name: ecosystemData?.name,
description: ecosystemData?.description,
@@ -422,36 +423,36 @@ const Dashboard = () => {
)}
-
-
-
-
-
-
{
- setSuccess(value);
- }}
- isOrganization={false}
- onEditSuccess={handleEditModalClose}
- entityData={ecosystemDetails}
+
+
+
+ window.location.href = pathRoutes.ecosystem.endorsements}
+ />
+
+
+
+
+
+ {
+ setSuccess(value);
+ }}
+ isOrganization={false}
+ onEditSuccess={handleEditModalClose}
+ entityData={ecosystemDetails}
+ />
) : (
@@ -481,8 +482,8 @@ const Dashboard = () => {
feature={!orgId ? Features.CRETAE_ORG : ''}
message={'No Ecosystem found'}
description={`Get started by creating ${!orgId
- ? 'a new Organization to set up your Ecosystem'
- : 'an Ecosystem'
+ ? 'a new Organization to set up your Ecosystem'
+ : 'an Ecosystem'
}`}
buttonContent={`${!orgId ? '' : 'Create Ecosystem'}`}
svgComponent={
diff --git a/src/components/Ecosystem/EcosystemList.tsx b/src/components/Ecosystem/EcosystemList.tsx
new file mode 100644
index 000000000..2af1a087a
--- /dev/null
+++ b/src/components/Ecosystem/EcosystemList.tsx
@@ -0,0 +1,249 @@
+'use client';
+
+import { Card, Pagination } from 'flowbite-react';
+import { ChangeEvent, useEffect, useState } from 'react';
+import { apiStatusCodes, storageKeys } from '../../config/CommonConstant';
+
+import { AlertComponent } from '../AlertComponent';
+import type { AxiosResponse } from 'axios';
+import BreadCrumbs from '../BreadCrumbs';
+import CustomAvatar from '../Avatar'
+import { Features } from '../../utils/enums/features';
+import RoleViewButton from '../RoleViewButton';
+import SearchInput from '../SearchInput';
+import { pathRoutes } from '../../config/pathRoutes';
+import { getFromLocalStorage, removeFromLocalStorage, setToLocalStorage } from '../../api/Auth';
+import { EmptyListMessage } from '../EmptyListComponent';
+import CustomSpinner from '../CustomSpinner';
+import CreateEcosystemOrgModal from '../CreateEcosystemOrgModal';
+import { getEcosystems } from '../../api/ecosystem';
+import type { IEcosystem } from './interfaces';
+import { checkEcosystem, type ICheckEcosystem } from '../../config/ecosystem';
+
+const initialPageState = {
+ pageNumber: 1,
+ pageSize: 9,
+ total: 100,
+};
+
+const EcosystemList = () => {
+ const [openModal, setOpenModal] = useState
(false);
+ const [loading, setLoading] = useState(true)
+ const [message, setMessage] = useState(null)
+ const [error, setError] = useState(null)
+ const [currentPage, setCurrentPage] = useState(initialPageState);
+ const onPageChange = (page: number) => {
+ setCurrentPage({
+ ...currentPage,
+ pageNumber: page
+ })
+ };
+ const [searchText, setSearchText] = useState("");
+
+ const [ecosystemList, setEcosystemList] = useState | null>(null)
+ const [isEcosystemData, setIsEcosystemData] = useState()
+
+ const createOrganizationModel = () => {
+ setOpenModal(true)
+ }
+
+ const fetchEcosystems = async () => {
+ setLoading(true);
+ const id = await getFromLocalStorage(storageKeys.ORG_ID);
+ // setOrgId(id);
+ if (id) {
+ const response = await getEcosystems(id, currentPage.pageNumber, currentPage.pageSize, searchText);
+ const { data } = response as AxiosResponse;
+
+ if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
+ const ecosystemData = data?.data;
+ if (ecosystemData) {
+ console.log(6565, data)
+ setEcosystemList(ecosystemData)
+ } else {
+ await removeFromLocalStorage(storageKeys.ECOSYSTEM_ID);
+ setError(response as string)
+ }
+ } else {
+ await removeFromLocalStorage(storageKeys.ECOSYSTEM_ID);
+ setError(response as string)
+ }
+ }
+ setLoading(false);
+ };
+
+ //This useEffect is called when the searchText changes
+ useEffect(() => {
+ let getData: NodeJS.Timeout
+
+ if (searchText.length >= 1) {
+ getData = setTimeout(() => {
+ fetchEcosystems()
+ }, 1000)
+ } else {
+ fetchEcosystems()
+ }
+
+ return () => clearTimeout(getData)
+ }, [searchText, openModal, currentPage.pageNumber])
+
+ useEffect(() => {
+ const queryParameters = new URLSearchParams(window?.location?.search)
+ const isModel = queryParameters.get("orgModal") || ''
+
+ if (isModel !== '') {
+ setOpenModal(true)
+ }
+
+ const checkEcosystemData = async () => {
+ const data: ICheckEcosystem = await checkEcosystem();
+ setIsEcosystemData(data)
+ }
+ checkEcosystemData();
+ }, [])
+
+ //onCHnage of Search input text
+ const searchInputChange = (e: ChangeEvent) => {
+ setSearchText(e.target.value);
+ }
+
+ const redirectOrgDashboard = async (ecosystemId: string, ecosystemRole: string) => {
+ await setToLocalStorage(storageKeys.ECOSYSTEM_ID, ecosystemId);
+ await setToLocalStorage(storageKeys.ECOSYSTEM_ROLE, ecosystemRole);
+ window.location.href = pathRoutes.ecosystem.dashboard
+ }
+
+ const isEcosystemList = Boolean(ecosystemList && ecosystemList?.length > 0)
+ const showCreateButton = Boolean(isEcosystemList && (isEcosystemData?.isMultiEcosystem || isEcosystemData?.isEcosystemLead))
+ console.log(6534, isEcosystemData, showCreateButton, isEcosystemList, isEcosystemData?.isMultiEcosystem, isEcosystemData?.isEcosystemLead, (isEcosystemList && isEcosystemData?.isMultiEcosystem) || isEcosystemData?.isEcosystemLead)
+ return (
+
+
+
+
+
+ Ecosystems
+
+
+
+
+
+
+ {
+ showCreateButton &&
+
+
+
+
+
+ }
+ onClickEvent={createOrganizationModel}
+ />
+ }
+
+
+
{
+ setMessage(null)
+ setError(null)
+ }}
+ />
+
+ {loading
+ ?
+
+
+ : isEcosystemList ? (
+ {
+ isEcosystemList && ecosystemList && ecosystemList.map((item) => {
+ const role = item?.ecosystemOrgs && item?.ecosystemOrgs.length > 0 && item?.ecosystemOrgs[0]?.ecosystemRole?.name || ""
+ return (
+
redirectOrgDashboard(item.id, role)} className='transform transition duration-500 hover:scale-105 hover:bg-gray-50 cursor-pointer overflow-hidden overflow-ellipsis' style={{ maxHeight: '100%', maxWidth: '100%', overflow: 'auto' }}>
+
+ {(item.logoUrl) ?
:
}
+
+
+
+ {item.name}
+
+
{item.description}
+
+
+ -
+
+
+ Roles:
+ {item?.ecosystemOrgs && item?.ecosystemOrgs?.length > 0 && item?.ecosystemOrgs[0].ecosystemRole &&
+ item?.ecosystemOrgs[0]?.ecosystemRole?.name &&
+
+ {item?.ecosystemOrgs[0]?.ecosystemRole?.name}
+
+ }
+
+
+
+
+
+
+
+
+ )
+ })
+ }
+
)
+ : ecosystemList && (
+
+
+ } />)
+ }
+
+
+ {
+ isEcosystemList && (
+
+ )
+ }
+
+ {
+ setMessage(value)
+ if (value) {
+ setTimeout(() => {
+ window.location.reload();
+ }, 2000);
+ } else {
+ fetchEcosystems();
+ }
+ }}
+ isorgModal={false}
+ />
+
+
+
+ )
+}
+
+export default EcosystemList;
diff --git a/src/components/Ecosystem/EcosystemSidebarOption.tsx b/src/components/Ecosystem/EcosystemSidebarOption.tsx
index 0fc019aae..4904e4005 100644
--- a/src/components/Ecosystem/EcosystemSidebarOption.tsx
+++ b/src/components/Ecosystem/EcosystemSidebarOption.tsx
@@ -1,11 +1,9 @@
import { useEffect, useState } from 'react'
import { ICheckEcosystem, checkEcosystem } from '../../config/ecosystem'
import { pathRoutes } from '../../config/pathRoutes'
-import React from 'react';
const EcosystemSidebarOption = () => {
const [isEcosystemEnabled, setIsEcosystemEnabled] = useState(false);
- const [showSubMenus, setShowSubMenus] = useState(true);
useEffect(() => {
const checkEcosystemData = async () => {
@@ -18,12 +16,9 @@ const EcosystemSidebarOption = () => {
if (isEcosystemEnabled) {
return (
- setShowSubMenus(!showSubMenus)}
+
@@ -38,53 +33,8 @@ const EcosystemSidebarOption = () => {
-
- Ecosystem
-
-
-
-
-
- {
- showSubMenus &&
-
- }
+ Ecosystems
+
)
}
diff --git a/src/components/Ecosystem/interfaces/index.ts b/src/components/Ecosystem/interfaces/index.ts
index bd8f6c334..24e41c258 100644
--- a/src/components/Ecosystem/interfaces/index.ts
+++ b/src/components/Ecosystem/interfaces/index.ts
@@ -1,9 +1,15 @@
export interface IEcosystem {
+ id: string
name: string
description: string
logoUrl: string
joinedDate?: string
role?: string
+ ecosystemOrgs?: {
+ ecosystemRole: {
+ name: string
+ }
+ }[]
}
export interface Ecosystem {
diff --git a/src/config/ecosystem.ts b/src/config/ecosystem.ts
index deb0dbed9..7cd383955 100644
--- a/src/config/ecosystem.ts
+++ b/src/config/ecosystem.ts
@@ -1,114 +1,134 @@
-import type { AxiosResponse } from "axios"
-import { getFromLocalStorage, setToLocalStorage } from "../api/Auth"
-import { getEcosystem } from "../api/ecosystem"
-import { EcosystemRoles } from "../common/enums"
-import { apiStatusCodes, storageKeys } from "./CommonConstant"
-import { getOrganizationById } from "../api/organization"
+import type { AxiosResponse } from 'axios';
+import { getFromLocalStorage, setToLocalStorage } from '../api/Auth';
+import { getEcosystems } from '../api/ecosystem';
+import { EcosystemRoles } from '../common/enums';
+import { apiStatusCodes, storageKeys } from './CommonConstant';
+import { getOrganizationById } from '../api/organization';
export interface ICheckEcosystem {
- isEnabledEcosystem: boolean;
- isEcosystemMember: boolean;
- isEcosystemLead: boolean;
+ isEnabledEcosystem: boolean;
+ isEcosystemMember: boolean;
+ isEcosystemLead: boolean;
+ isMultiEcosystem: boolean;
}
export interface IOrgDetails {
- orgName: string
- orgDid: string
+ orgName: string;
+ orgDid: string;
}
const ecosystemId = async () => {
- const id = await getFromLocalStorage(storageKeys.ECOSYSTEM_ID)
- return id
-}
+ const id = await getFromLocalStorage(storageKeys.ECOSYSTEM_ID);
+ return id;
+};
const getOrgData = async () => {
- const data = await getFromLocalStorage(storageKeys.ORG_DETAILS)
- return data
-}
+ const data = await getFromLocalStorage(storageKeys.ORG_DETAILS);
+ return data;
+};
const getEcosystemRole = async () => {
- const data = await getFromLocalStorage(storageKeys.ECOSYSTEM_ROLE)
- return data
-}
+ const data = await getFromLocalStorage(storageKeys.ECOSYSTEM_ROLE);
+ return data;
+};
const getOrgId = async () => {
- const id = await getFromLocalStorage(storageKeys.ORG_ID)
- return id
-}
+ const id = await getFromLocalStorage(storageKeys.ORG_ID);
+ return id;
+};
const getUserProfile = async () => {
- const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE)
- const userDetails = userProfile && await JSON.parse(userProfile)
- return userDetails
-}
+ const userProfile = await getFromLocalStorage(storageKeys.USER_PROFILE);
+ const userDetails = userProfile && (await JSON.parse(userProfile));
+ return userDetails;
+};
const checkEcosystem = async (): Promise => {
- await getEcosystemId()
- const userData = await getUserProfile()
- const role = await getEcosystemRole()
-
- const isEnabledEcosystem = userData?.enableEcosystem
- const ecosystemRole = role || EcosystemRoles.ecosystemLead
-
- return {
- isEnabledEcosystem,
- isEcosystemMember: ecosystemRole === EcosystemRoles.ecosystemMember && isEnabledEcosystem,
- isEcosystemLead: ecosystemRole === EcosystemRoles.ecosystemLead && isEnabledEcosystem
- }
-}
+ await getEcosystemId();
+ const userData = await getUserProfile();
+ const role = await getEcosystemRole();
+
+ const isEnabledEcosystem = userData?.enableEcosystem;
+ const ecosystemRole = role || EcosystemRoles.ecosystemLead;
+
+ const isMultiEcosystem = userData?.multiEcosystemSupport;
+ // const isMultiEcosystem = false
+
+ return {
+ isEnabledEcosystem,
+ isMultiEcosystem,
+ isEcosystemMember:
+ ecosystemRole === EcosystemRoles.ecosystemMember && isEnabledEcosystem,
+ isEcosystemLead:
+ ecosystemRole === EcosystemRoles.ecosystemLead && isEnabledEcosystem,
+ };
+};
const getEcosystemId = async (): Promise => {
- const ecoId = await ecosystemId()
- const ecoRole = await getEcosystemRole()
- const orgId = await getOrgId()
- if (!ecoId || !ecoRole) {
- try {
- if(orgId){
- const { data } = await getEcosystem(orgId) as AxiosResponse
-
- if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS && data?.data && data?.data.length > 0) {
- const response = data?.data[0]
- const id = response?.id
- const role = response?.ecosystemOrgs && response?.ecosystemOrgs.length > 0 && response?.ecosystemOrgs[0]?.ecosystemRole?.name
- await setToLocalStorage(storageKeys.ECOSYSTEM_ID, id);
- if(role){
- await setToLocalStorage(storageKeys.ECOSYSTEM_ROLE, role);
- }
- return id
- }
- }
- } catch (err) {
- console.log("ERROR-Get Ecosystem", err)
- }
- }
- return ecoId
-}
+ const ecoId = await ecosystemId();
+ const ecoRole = await getEcosystemRole();
+ const orgId = await getOrgId();
+ if (!ecoId || !ecoRole) {
+ try {
+ if (orgId) {
+ const { data } = (await getEcosystems(orgId)) as AxiosResponse;
+
+ if (
+ data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS &&
+ data?.data &&
+ data?.data.length > 0
+ ) {
+ const response = data?.data[0];
+ const id = response?.id;
+ const role =
+ response?.ecosystemOrgs &&
+ response?.ecosystemOrgs.length > 0 &&
+ response?.ecosystemOrgs[0]?.ecosystemRole?.name;
+ await setToLocalStorage(storageKeys.ECOSYSTEM_ID, id);
+ if (role) {
+ await setToLocalStorage(storageKeys.ECOSYSTEM_ROLE, role);
+ }
+ return id;
+ }
+ }
+ } catch (err) {
+ console.log('ERROR-Get Ecosystem', err);
+ }
+ }
+ return ecoId;
+};
const getOrgDetails = async (): Promise => {
- const orgId = await getOrgId()
- const org = await getOrgData()
- const orgData: IOrgDetails = org && JSON.parse(org)
- const isOrgData = Object.keys(orgData).length > 0
- const isOrgDid = orgData?.orgDid
- if (!isOrgData || !isOrgDid) {
- try {
- if(orgId){
- const { data } = await getOrganizationById(orgId) as AxiosResponse
-
- if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
- const orgData: IOrgDetails = {
- orgName: data?.data?.name,
- orgDid: data?.data && data?.data?.org_agents?.length > 0 ? data?.data?.org_agents[0]?.orgDid : ""
- }
- await setToLocalStorage(storageKeys.ORG_DETAILS, JSON.stringify(orgData));
- return orgData
- }
- }
- } catch (err) {
- console.log("ERROR-Get ORG Details", err)
- }
- }
- return orgData
-}
+ const orgId = await getOrgId();
+ const org = await getOrgData();
+ const orgData: IOrgDetails = org && JSON.parse(org);
+ const isOrgData = Object.keys(orgData).length > 0;
+ const isOrgDid = orgData?.orgDid;
+ if (!isOrgData || !isOrgDid) {
+ try {
+ if (orgId) {
+ const { data } = (await getOrganizationById(orgId)) as AxiosResponse;
+
+ if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
+ const orgData: IOrgDetails = {
+ orgName: data?.data?.name,
+ orgDid:
+ data?.data && data?.data?.org_agents?.length > 0
+ ? data?.data?.org_agents[0]?.orgDid
+ : '',
+ };
+ await setToLocalStorage(
+ storageKeys.ORG_DETAILS,
+ JSON.stringify(orgData),
+ );
+ return orgData;
+ }
+ }
+ } catch (err) {
+ console.log('ERROR-Get ORG Details', err);
+ }
+ }
+ return orgData;
+};
-export { checkEcosystem, getEcosystemId, getOrgDetails }
\ No newline at end of file
+export { checkEcosystem, getEcosystemId, getOrgDetails };
diff --git a/src/config/pathRoutes.ts b/src/config/pathRoutes.ts
index 0472b3f1b..1cbdb9584 100644
--- a/src/config/pathRoutes.ts
+++ b/src/config/pathRoutes.ts
@@ -34,11 +34,11 @@ export const pathRoutes = {
},
},
ecosystem: {
- root: '/ecosystem',
- profile: "/ecosystem/profile",
- endorsements: "/ecosystem/endorsement",
- invitation:"/ecosystem/invitation",
- sentinvitation:'/ecosystem/invitations'
+ root: '/ecosystems',
+ dashboard: "/ecosystems/dashboard",
+ endorsements: "/ecosystems/endorsement",
+ invitation:"/ecosystems/invitation",
+ sentinvitation:'/ecosystems/invitations'
},
documentation: {
root: 'https://docs.credebl.id'
diff --git a/src/pages/dashboard.astro b/src/pages/dashboard.astro
index be1dfb0df..33f76a0e4 100644
--- a/src/pages/dashboard.astro
+++ b/src/pages/dashboard.astro
@@ -7,6 +7,7 @@ import { checkUserSession } from '../utils/check-session';
const response = await checkUserSession(Astro.cookies);
const route: string = pathRoutes.auth.sinIn
if (!response) {
+ await localStorage.clear()
return Astro.redirect(route);
}
---
diff --git a/src/pages/ecosystem/index.astro b/src/pages/ecosystems/dashboard.astro
similarity index 100%
rename from src/pages/ecosystem/index.astro
rename to src/pages/ecosystems/dashboard.astro
diff --git a/src/pages/ecosystem/endorsement/index.astro b/src/pages/ecosystems/endorsement/index.astro
similarity index 100%
rename from src/pages/ecosystem/endorsement/index.astro
rename to src/pages/ecosystems/endorsement/index.astro
diff --git a/src/pages/ecosystems/index.astro b/src/pages/ecosystems/index.astro
new file mode 100644
index 000000000..1849c2d9d
--- /dev/null
+++ b/src/pages/ecosystems/index.astro
@@ -0,0 +1,16 @@
+---
+import LayoutSidebar from '../../app/LayoutSidebar.astro';
+import { checkUserSession } from '../../utils/check-session';
+import { pathRoutes } from '../../config/pathRoutes';
+import EcosystemList from '../../components/Ecosystem/EcosystemList';
+
+const response = await checkUserSession(Astro.cookies);
+const route: string = pathRoutes.auth.sinIn
+if (!response) {
+ return Astro.redirect(route);
+}
+---
+
+
+
+
\ No newline at end of file
diff --git a/src/pages/ecosystem/invitation.astro b/src/pages/ecosystems/invitation.astro
similarity index 75%
rename from src/pages/ecosystem/invitation.astro
rename to src/pages/ecosystems/invitation.astro
index ab1fc836f..c7578c5f1 100644
--- a/src/pages/ecosystem/invitation.astro
+++ b/src/pages/ecosystems/invitation.astro
@@ -2,19 +2,15 @@
import LayoutSidebar from '../../app/LayoutSidebar.astro';
import { checkUserSession } from '../../utils/check-session';
import { pathRoutes } from '../../config/pathRoutes';
-import EcoSystemReceivedInvitations from '../../components/EcosystemInvite/EcoSystemReceivedInvitations'
+import EcoSystemReceivedInvitations from '../../components/EcosystemInvite/EcoSystemReceivedInvitations';
const response = await checkUserSession(Astro.cookies);
-const route = pathRoutes.auth.sinIn
+const route = pathRoutes.auth.sinIn;
if (!response) {
return Astro.redirect(route);
}
---
-
+
-
-
-
-
diff --git a/src/pages/ecosystem/invitations.astro b/src/pages/ecosystems/invitations.astro
similarity index 81%
rename from src/pages/ecosystem/invitations.astro
rename to src/pages/ecosystems/invitations.astro
index e1edcb51e..98c1e7c39 100644
--- a/src/pages/ecosystem/invitations.astro
+++ b/src/pages/ecosystems/invitations.astro
@@ -2,19 +2,15 @@
import LayoutSidebar from '../../app/LayoutSidebar.astro';
import { checkUserSession } from '../../utils/check-session';
import { pathRoutes } from '../../config/pathRoutes';
-import SentInvitations from '../../components/EcosystemInvite/SentInvitations'
+import SentInvitations from '../../components/EcosystemInvite/SentInvitations';
const response = await checkUserSession(Astro.cookies);
-const route = pathRoutes.auth.sinIn
+const route = pathRoutes.auth.sinIn;
if (!response) {
return Astro.redirect(route);
}
---
-
+
-
-
-
-
From 5c7a4f5bbb623ad57eae31e932d358cb214765d9 Mon Sep 17 00:00:00 2001
From: karan
Date: Fri, 27 Oct 2023 17:26:53 +0530
Subject: [PATCH 07/54] refactor: connection list read only on sidebar
Signed-off-by: karan
---
src/app/SideBar.astro | 24 ++++++++
src/components/ConnectionsList/index.tsx | 77 ++++++++++++++++++++++++
src/config/pathRoutes.ts | 1 +
src/pages/connections.astro | 8 +++
4 files changed, 110 insertions(+)
create mode 100644 src/components/ConnectionsList/index.tsx
create mode 100644 src/pages/connections.astro
diff --git a/src/app/SideBar.astro b/src/app/SideBar.astro
index 62e3d9e49..1ca03c146 100644
--- a/src/app/SideBar.astro
+++ b/src/app/SideBar.astro
@@ -163,6 +163,30 @@ import { pathRoutes } from '../config/pathRoutes';
+
+
+
+
+
+
+ Connections
+
+
+
-
+
+
+
GitHub Repository
+
+
+
Documentation
-
-
-
-
-
- Support
-
+
diff --git a/src/components/organization/invitations/Invitations.tsx b/src/components/organization/invitations/Invitations.tsx
index 017f0e3fa..43db0c787 100644
--- a/src/components/organization/invitations/Invitations.tsx
+++ b/src/components/organization/invitations/Invitations.tsx
@@ -164,14 +164,14 @@ const Invitations = () => {
{invitation.email}
- -
+
-
{invitation.orgRoles.length>1 ? 'Roles:' : 'Role:'}
@@ -226,7 +226,6 @@ const Invitations = () => {
>
Invited On: {dateConversion(invitation.createDateTime)}
-
))
diff --git a/src/components/organization/users/Members.tsx b/src/components/organization/users/Members.tsx
index 677419589..b1d0766cb 100644
--- a/src/components/organization/users/Members.tsx
+++ b/src/components/organization/users/Members.tsx
@@ -144,15 +144,16 @@ const Members = () => {
) : (
usersList &&
usersList?.length > 0 && (
-