diff --git a/src/components/Ecosystem/Dashboard.tsx b/src/components/Ecosystem/Dashboard.tsx index 4fa471c61..80f76bfd8 100644 --- a/src/components/Ecosystem/Dashboard.tsx +++ b/src/components/Ecosystem/Dashboard.tsx @@ -18,6 +18,7 @@ import { ICheckEcosystem, checkEcosystem, getEcosystemId, + getOwnerAdminRole, } from '../../config/ecosystem'; import { Button, Dropdown } from 'flowbite-react'; import EditPopupModal from '../EditEcosystemOrgModal'; @@ -198,14 +199,19 @@ const Dashboard = () => { const navigateToInvitation = () => { window.location.href = pathRoutes.ecosystem.sentinvitation; }; + const [isAccess, setIsAccess] = useState(false); + const checkEcosystemData = async () => { + const data: ICheckEcosystem = await checkEcosystem(); + setIsEcosystemLead(Boolean(data)); + }; + const checkEcosystemAccess = async () => { + const data = await getOwnerAdminRole(); + setIsAccess(data); + }; useEffect(() => { getDashboardData(); - - const checkEcosystemData = async () => { - const data: ICheckEcosystem = await checkEcosystem(); - setIsEcosystemLead(data.isEcosystemLead); - }; + checkEcosystemAccess() checkEcosystemData(); }, []); @@ -330,7 +336,8 @@ const Dashboard = () => {
- {dropdownOpen ? ( + {dropdownOpen && isAccess ? ( ( @@ -373,7 +380,7 @@ const Dashboard = () => { ) : (
Requested {props.endorsementData?.type === EndorsementType.credDef ? "Credential Definition" : "Schema" }
+
+ Requested{' '} + {props.endorsementData?.type === EndorsementType.credDef + ? 'Credential Definition' + : 'Schema'} +
) : ( -
View {props.endorsementData?.type === EndorsementType.credDef ? "Credential Definition" : "Schema"}
+
+ View{' '} + {props.endorsementData?.type === EndorsementType.credDef + ? 'Credential Definition' + : 'Schema'} +
)}
@@ -145,23 +172,13 @@ const EndorsementPopup = (props: {
{isEcosystemData?.isEcosystemLead && - props.endorsementData?.status === EndorsementStatus.requested ? ( + props.endorsementData?.status === EndorsementStatus.requested ? (
- +
) : ( <> {!isEcosystemData?.isEcosystemLead && - isEcosystemData?.isEcosystemMember && - props.endorsementData?.status === EndorsementStatus.signed ? ( + isEcosystemData?.isEcosystemMember && + props.endorsementData?.status === EndorsementStatus.signed ? (
) : ( @@ -273,7 +285,7 @@ const EndorsementPopup = (props: { )}
- + ); }; diff --git a/src/components/EcosystemInvite/SentInvitations.tsx b/src/components/EcosystemInvite/SentInvitations.tsx index df0098883..ec92721b4 100644 --- a/src/components/EcosystemInvite/SentInvitations.tsx +++ b/src/components/EcosystemInvite/SentInvitations.tsx @@ -15,6 +15,8 @@ import RoleViewButton from '../RoleViewButton'; import SendInvitationModal from '../organization/invitations/SendInvitationModal'; import { getFromLocalStorage } from '../../api/Auth'; import { Features } from '../../utils/enums/features'; +import { getOwnerAdminRole } from '../../config/ecosystem'; +import { OrganizationRoles } from '../../common/enums'; const initialPageState = { pageNumber: 1, @@ -32,7 +34,8 @@ const SentInvitations = () => { useState | null>(null); const [ecosystemId, setEcosystemId] = useState(''); const [openModal, setOpenModal] = useState(false); - + const [isAccess, setIsAccess] = useState(false); + const onPageChange = (page: number) => { setCurrentPage({ ...currentPage, @@ -40,6 +43,11 @@ const SentInvitations = () => { }); }; + const checkEcosystemAccess = async () => { + const data = await getOwnerAdminRole(OrganizationRoles.organizationOwner); + setIsAccess(data); + }; + const getAllSentInvitations = async () => { const ecosystemId = await getFromLocalStorage(storageKeys.ECOSYSTEM_ID); setEcosystemId(ecosystemId); @@ -94,6 +102,7 @@ const SentInvitations = () => { } else { getAllSentInvitations(); } + checkEcosystemAccess(); return () => clearTimeout(getData); }, [searchText, currentPage.pageNumber]); @@ -110,7 +119,7 @@ const SentInvitations = () => {
{ onClick={() => deletInvitations(invitation.id)} color="bg-white" className="ml-5 font-normal items-center mt-5 text-xl text-primary-700 border border-blue-700 text-center hover:!bg-primary-800 hover:text-white rounded-lg focus:ring-4 focus:ring-primary-300 sm:w-auto dark:hover:bg-primary-700 dark:text-white dark:bg-primary-700 dark:focus:ring-blue-800" + disabled={!isAccess} > { const [currentPage, setCurrentPage] = useState(initialPageState); const [organizationsList, setOrganizationList] = useState | null>(null); + const [activityList, setActivityList] = useState | null>( null, ); @@ -74,7 +76,7 @@ const UserDashBoard = () => { allSearch: '', }); const [ecoCount, setEcoCount] = useState(0); - const [ecosystemList, setEcosystemList] = useState([]); + const [ecosystemList, setEcosystemList] = useState([]); const [credDefList, setCredDefList] = useState([]); const [credDefCount, setCredDefCount] = useState(0); const [walletData, setWalletData] = useState([]); @@ -84,6 +86,7 @@ const UserDashBoard = () => { const [orgLoading, setOrgLoading] = useState(true); const [schemaLoading, setSchemaLoading] = useState(true); const [walletLoading, setWalletLoading] = useState(true); + const [isAccess, setIsAccess]= useState(false) const getAllInvitations = async () => { setLoading(true); @@ -156,15 +159,13 @@ const UserDashBoard = () => { const orgList = data?.data?.organizations.filter( (userOrg: Organisation, index: number) => index < 3, ); - setOrganizationList(orgList); + setOrganizationList(orgList); } else { setError(response as string); } - setOrgLoading(false); }; - //Fetch the user recent activity const getUserRecentActivity = async () => { setLoading(true); const response = await getUserActivity(5); @@ -307,6 +308,11 @@ const UserDashBoard = () => { } setWalletLoading(false); }; + + const checkEcosystemAccess = async () => { + const data = await getOwnerAdminRole(); + setIsAccess(data); + }; const getAllResponses = async () => { const role = await getFromLocalStorage(storageKeys.ORG_ROLES); @@ -337,6 +343,7 @@ const UserDashBoard = () => { getSchemaList(schemaListAPIParameter, false); fetchEcosystems(); getSchemaCredentials(); + checkEcosystemAccess() } }, [organizationsList]); @@ -415,7 +422,8 @@ const UserDashBoard = () => { window.location.href = pathRoutes.organizations.credentials; }; - const navigateToInvitation = () => { + const navigateToInvitation = async (ecosystemId: string) => { + await setToLocalStorage(storageKeys.ECOSYSTEM_ID, ecosystemId); window.location.href = pathRoutes.ecosystem.sentinvitation; }; @@ -530,7 +538,7 @@ const UserDashBoard = () => { <> ) : (
{walletLoading ? ( @@ -1179,9 +1187,10 @@ const UserDashBoard = () => { ?.name === EcosystemRoles.ecosystemLead && (
-
+

Organizations

- +
- - +
+ +
} onClickEvent={createOrganizationModel} /> -
- setMessage(data)} diff --git a/src/components/organization/invitations/SendInvitationModal.tsx b/src/components/organization/invitations/SendInvitationModal.tsx index d2fde63e0..cb05119ca 100644 --- a/src/components/organization/invitations/SendInvitationModal.tsx +++ b/src/components/organization/invitations/SendInvitationModal.tsx @@ -323,7 +323,7 @@ const SendInvitationModal = (props: {