Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Ecosystem Dashboard count #329

Merged
merged 25 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cad1d12
Merge branch 'develop' of https://github.com/credebl/studio into ecos…
MoulikaKulkarni Oct 7, 2023
e9569aa
Merge branch 'feat-endorsement' of https://github.com/credebl/studio …
MoulikaKulkarni Oct 9, 2023
a1be1a6
Merge branch 'feat-endorsement' of https://github.com/credebl/studio …
MoulikaKulkarni Oct 9, 2023
76eaef3
Merge branch 'develop' of https://github.com/credebl/studio into org-…
MoulikaKulkarni Oct 10, 2023
4ce9dcd
feat: OrgRegistrationPopup
MoulikaKulkarni Oct 10, 2023
99edee3
feat: ecosystem dashboard count
MoulikaKulkarni Oct 10, 2023
ed0cdbf
feat: ecosystem dashboard count
MoulikaKulkarni Oct 10, 2023
a43489c
feat: ecosystem dashboard count
MoulikaKulkarni Oct 11, 2023
1455e23
feat: ecosystem dashboard count
MoulikaKulkarni Oct 11, 2023
0d6a484
feat: ecosystem dashboard count
MoulikaKulkarni Oct 11, 2023
f12c5d2
Merge branch 'develop' of https://github.com/credebl/studio into ecos…
MoulikaKulkarni Oct 11, 2023
844c58c
feat: ecosystem dashboard count
MoulikaKulkarni Oct 11, 2023
9997bf9
feat: ecosystem dashboard count
MoulikaKulkarni Oct 11, 2023
3ea539b
feat: ecosystem dashboard count
MoulikaKulkarni Oct 11, 2023
e661f2a
feat: ecosystem dashboard count
MoulikaKulkarni Oct 11, 2023
552581e
feat: ecosystem dashboard count
MoulikaKulkarni Oct 11, 2023
3398209
feat: ecosystem dashboard count
MoulikaKulkarni Oct 11, 2023
e02e7b9
feat: ecosystem dashboard count
MoulikaKulkarni Oct 11, 2023
56c8ffe
feat: ecosystem dashboard count
MoulikaKulkarni Oct 11, 2023
01d7ea3
feat: ecosystem dashboard count
MoulikaKulkarni Oct 11, 2023
1a6a42f
Delete src/components/Ecosystem/OrgRegistrationPopup.tsx
MoulikaKulkarni Oct 11, 2023
3c05ddb
feat: ecosystem dashboard count
MoulikaKulkarni Oct 11, 2023
586c33a
Merge branch 'ecosystem-count' of https://github.com/credebl/studio i…
MoulikaKulkarni Oct 11, 2023
77cd20f
feat: ecosystem dashboard count
MoulikaKulkarni Oct 11, 2023
afebb85
feat: ecosystem dashboard count
MoulikaKulkarni Oct 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/api/ecosystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,31 @@ export const createCredDefRequest = async (data: object, ecosystemId: string, or
const err = error as Error
return err?.message
}
}
}

export const getEcosystemDashboard = async (ecosystemId: string, orgId: string) => {

const url = `${apiRoutes.Ecosystem.root}/${ecosystemId}/${orgId}/dashboard`

const token = await getFromLocalStorage(storageKeys.TOKEN)

const config = {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
}
}
const axiosPayload = {
url,
config
}

try {
return await axiosGet(axiosPayload);
}
catch (error) {
const err = error as Error
return err?.message
}

}
104 changes: 74 additions & 30 deletions src/components/Ecosystem/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import CustomSpinner from '../CustomSpinner';
import endorseIcon from '../../assets/endorser-card.svg';
import userCard from '../../assets/User_Card.svg';
import MemberList from './MemberList';
import { getEcosystem } from '../../api/ecosystem';
import { getEcosystem, getEcosystemDashboard } from '../../api/ecosystem';
import { EmptyListMessage } from '../EmptyListComponent';
import CreateEcosystemOrgModal from '../CreateEcosystemOrgModal';
import { AlertComponent } from '../AlertComponent';
Expand All @@ -21,6 +21,7 @@ import EditPopupModal from '../EditEcosystemOrgModal';
import { getFromLocalStorage, setToLocalStorage } from '../../api/Auth';
import { getEcosytemReceivedInvitations } from '../../api/invitations';
import { pathRoutes } from '../../config/pathRoutes';
import type { EcosystemDashboard } from '../organization/interfaces';


const initialPageState = {
Expand All @@ -43,6 +44,9 @@ const Dashboard = () => {
const [viewButton, setViewButton] = useState<boolean>(false);
const [currentPage, setCurrentPage] = useState(initialPageState);
const [isEcosystemLead, setIsEcosystemLead] = useState(false);
const [ecosystemDashboard, setEcosystemDashboard] = useState<EcosystemDashboard | null>(null)
const [ecosystemDetailsNotFound, setEcosystemDetailsNotFound] = useState(false);


const createEcosystemModel = () => {
setOpenModal(true);
Expand Down Expand Up @@ -78,11 +82,11 @@ const Dashboard = () => {
const ecoSystemName = invitationList.map((invitations: { name: string; }) => {
return invitations.name
})
const invitationPendingList = data?.data?.invitations.filter((invitation: { status: string; }) => {
const invitationPendingList = data?.data?.invitations && data?.data?.invitations?.filter((invitation: { status: string; }) => {
return invitation.status === 'pending'
})

if (invitationPendingList.length > 0) {
if (invitationPendingList && invitationPendingList.length > 0) {
setMessage(`You have received invitation to join ${ecoSystemName} ecosystem `)
setViewButton(true);
}
Expand All @@ -97,33 +101,60 @@ const Dashboard = () => {
};

const fetchEcosystemDetails = async () => {
setLoading(true);
const orgId = await getFromLocalStorage(storageKeys.ORG_ID)
if (orgId) {
const response = await getEcosystem(orgId);
const { data } = response as AxiosResponse;

if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
const ecosystemData = data?.data[0]
if (ecosystemData?.id) {
await setToLocalStorage(storageKeys.ECOSYSTEM_ID, ecosystemData?.id)
setEcosystemId(ecosystemData?.id)
setEcosystemDetails({
logoUrl: ecosystemData.logoUrl,
name: ecosystemData.name,
description: ecosystemData.description
})
}
} else {
setFailure(response as string)
}
}
setLoading(false)
setLoading(true);
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
if (orgId) {
const response = await getEcosystem(orgId);
const { data } = response as AxiosResponse;

if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
const ecosystemData = data?.data[0];
await setToLocalStorage(storageKeys.ECOSYSTEM_ID, ecosystemData?.id);
setEcosystemId(ecosystemData?.id);
setEcosystemDetails({
logoUrl: ecosystemData.logoUrl,
name: ecosystemData.name,
description: ecosystemData.description,
});
} else {
setEcosystemDetailsNotFound(true);

}
}
setLoading(false);
};

const fetchEcosystemDashboard = async () => {

setLoading(true)

const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const ecosystemId = await getFromLocalStorage(storageKeys.ECOSYSTEM_ID);

const response = await getEcosystemDashboard(ecosystemId as string, orgId as string);

const { data } = response as AxiosResponse

if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
setEcosystemDashboard(data?.data)
}
else {
setFailure(response as string)
setFailure(response as string);
setLoading(false);
}
setLoading(false)

}

const getDashboardData = async () => {
await fetchEcosystemDetails();
await fetchEcosystemDashboard();
getAllEcosystemInvitations();
};

useEffect(() => {
fetchEcosystemDetails();
getAllEcosystemInvitations();
getDashboardData();

const checkEcosystemData = async () => {
const data: ICheckEcosystem = await checkEcosystem();
Expand All @@ -133,7 +164,9 @@ const Dashboard = () => {

}, []);

return (


return (
<div className="px-4 pt-6">
<div className="mb-4 col-span-full xl:mb-2">
<BreadCrumbs />
Expand Down Expand Up @@ -286,7 +319,7 @@ const Dashboard = () => {
Member
</h3>
<span className="text-2xl font-semi-bold leading-none text-white sm:text-3xl dark:text-white">
23
{ecosystemDashboard?.membersCount}
</span>
</div>
</div>
Expand All @@ -300,7 +333,7 @@ const Dashboard = () => {
Endorsements
</h3>
<span className="text-2xl font-semi-bold leading-none text-white sm:text-3xl dark:text-white">
598
{ecosystemDashboard?.endorsementsCount}
</span>
</div>
</div>
Expand Down Expand Up @@ -366,6 +399,17 @@ const Dashboard = () => {
)}
</div>
)}

{ecosystemDetailsNotFound && (
<AlertComponent
message="Ecosystem details not found."
type="failure"
onAlertClose={() => {
setEcosystemDetailsNotFound(false);
setFailure(null);
}}
/>
)}
</div>
);
};
Expand Down
5 changes: 5 additions & 0 deletions src/components/organization/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,8 @@ export interface Connection {
lastChangedDateTime: string
lastChangedBy: number
}

export interface EcosystemDashboard {
membersCount: number
endorsementsCount: number
}
1 change: 1 addition & 0 deletions src/config/pathRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const pathRoutes = {
},
ecosystem: {
root: '/ecosystem',
profile: "/ecosystem/profile",
endorsements: "/ecosystem/endorsement",
invitation:"/ecosystem/invitation"
},
Expand Down