Skip to content

Commit

Permalink
Merge pull request #323 from credebl/fix-ecosystem-invitation-issues
Browse files Browse the repository at this point in the history
Fix ecosystem invitation issues
  • Loading branch information
nishad-ayanworks authored Oct 10, 2023
2 parents 40adccb + 2f28d11 commit 4e4796c
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/app/SideBar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ import { pathRoutes } from '../config/pathRoutes';
<ul id="dropdown-ecosystems" class="py-2 space-y-2">
<li>
<a
href={pathRoutes.ecosystem.profile}
href={pathRoutes.ecosystem.root}
class="flex items-center p-2 text-base text-gray-900 transition duration-75 rounded-lg pl-11 group hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-700"
>
<svg
Expand Down
4 changes: 3 additions & 1 deletion src/components/EcosystemInvite/EcoInvitationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import React from 'react';
interface InvitationProps{
invitationId:string;
invitationEmail:string
ecosytem:[]
}

const EcoInvitationList = (props: InvitationProps ) => {

const {invitationId, invitationEmail} = props
const {invitationId, invitationEmail,ecosytem} = props

return (
<>
<div className="flex space-x-4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const initialPageState = {


export interface EcosystemInvitation {
ecosystem: any
ecosystem: []
id: string
createDateTime: string
createdBy: number
Expand Down Expand Up @@ -146,7 +146,7 @@ const ReceivedInvitations = () => {
if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) {
setMessage(data?.message);
setLoading(false);
window.location.href = pathRoutes.ecosystem.profile
window.location.href = pathRoutes.ecosystem.root
} else {
setError(response as string);
setLoading(false);
Expand Down Expand Up @@ -239,6 +239,7 @@ stroke-linejoin="round"
<EcoInvitationList
invitationId={invitation.id}
invitationEmail={invitation.email}
ecosytem={invitation.ecosystem}
/>

<div id={invitation.email} className="flex">
Expand Down
1 change: 1 addition & 0 deletions src/components/EcosystemInvite/SentInvitations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const SentInvitations = () => {
if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
setLoading(true);
await getAllSentInvitations();
setMessage('Invitation deleted successfully')
} else {
setError(response as string);
}
Expand Down
39 changes: 14 additions & 25 deletions src/components/User/UserDashBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { apiStatusCodes, storageKeys } from '../../config/CommonConstant';
import { getOrganizations } from '../../api/organization';
import { getUserActivity } from '../../api/users';
import {
getEcosytemReceivedInvitations,
getUserEcosystemInvitations,
getUserInvitations,
} from '../../api/invitations';
import { pathRoutes } from '../../config/pathRoutes';
import { setToLocalStorage } from '../../api/Auth';
import { getFromLocalStorage, setToLocalStorage } from '../../api/Auth';
import { dateConversion } from '../../utils/DateConversion';
import DateTooltip from '../Tooltip';

Expand Down Expand Up @@ -49,16 +49,8 @@ const UserDashBoard = () => {
if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
const totalPages = data?.data?.totalPages;
const invitationList = data?.data?.invitations;
const orgName = invitationList.map(
(invitations: { organisation: { name: string } }) => {
return invitations.organisation.name;
},
);

if (invitationList.length > 0) {
setMessage(
`You have received invitations to join ${orgName} organisation`,
);
setMessage(`You have received invitations to join organisation`);
setViewButton(true);
}
setCurrentPage({
Expand All @@ -73,7 +65,7 @@ const UserDashBoard = () => {

const getAllEcosystemInvitations = async () => {
setLoading(true);
const response = await getEcosytemReceivedInvitations(
const response = await getUserEcosystemInvitations(
currentPage.pageNumber,
currentPage.pageSize,
'',
Expand All @@ -82,21 +74,14 @@ const UserDashBoard = () => {

if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
const totalPages = data?.data?.totalPages;
const invitationList = data?.data;
const ecoSystemName = invitationList.map(
(invitations: { name: string }) => {
return invitations.name;
},
);
const invitationPendingList = data?.data?.invitations.filter(
(invitation: { status: string }) => {
return invitation.status === 'pending';
},
);

if (invitationPendingList.length > 0) {
setEcoMessage(
`You have received invitation to join ${ecoSystemName} ecosystem `,
);
setEcoMessage(`You have received invitation to join ecosystem `);
setViewButton(true);
}
setCurrentPage({
Expand Down Expand Up @@ -154,12 +139,17 @@ const UserDashBoard = () => {

setLoading(false);
};

const checkOrgId = async () => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
if (orgId) {
await getAllEcosystemInvitations();
}
};
useEffect(() => {
getAllInvitations();
getAllOrganizations();
getUserRecentActivity();
getAllEcosystemInvitations();
checkOrgId();
}, []);

const goToOrgDashboard = async (orgId: number, roles: string[]) => {
Expand Down Expand Up @@ -193,7 +183,6 @@ const UserDashBoard = () => {
setError(null);
}}
/>
{/* } */}
</div>

<div className="grid w-full grid-cols-1 gap-4 mt-0 mb-4 xl:grid-cols-2 2xl:grid-cols-3">
Expand All @@ -202,7 +191,7 @@ const UserDashBoard = () => {
<h2 className="text-base font-bold text-gray-500 dark:text-white mb-2">
Organizations
</h2>

{organizationsList?.map((org) => {
const roles: string[] = org.userOrgRoles.map(
(role) => role.orgRole.name,
Expand Down
1 change: 1 addition & 0 deletions src/config/pathRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const pathRoutes = {
},
},
ecosystem: {
root:'/ecosystem',
profile: "/ecosystem/profile",
endorsements: "/ecosystem/endorsements",
invitation:"/ecosystem/invitation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ if (!response) {

<LayoutSidebar>
<Dashboard client:visible/>
</LayoutSidebar>
</LayoutSidebar>
8 changes: 0 additions & 8 deletions src/pages/ecosystem/profile.astro

This file was deleted.

0 comments on commit 4e4796c

Please sign in to comment.