Skip to content

Commit

Permalink
Merge pull request #321 from credebl/feat-ecosystem-invitation
Browse files Browse the repository at this point in the history
feat: ecosystem invitation
  • Loading branch information
nishad-ayanworks authored Oct 7, 2023
2 parents 8919626 + 64ff3e2 commit 357eae6
Show file tree
Hide file tree
Showing 17 changed files with 990 additions and 455 deletions.
3 changes: 2 additions & 1 deletion src/api/ecosystem.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import { axiosGet, axiosPost, axiosPut } from "../services/apiRequests"
import { apiRoutes } from "../config/apiRoutes";
import { getFromLocalStorage } from "./Auth";
Expand Down Expand Up @@ -88,4 +89,4 @@ export const getEcosystem = async () => {
const err = error as Error
return err?.message
}
}
}
108 changes: 108 additions & 0 deletions src/api/invitations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,60 @@ export const createInvitations = async (invitationList: Array<object>) => {
}
}

export const getEcosystemList = async () => {

const url = `${apiRoutes.Ecosystem.root}`

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
}
}
export const createEcoSystemInvitations = async (invitationList: Array<object>,ecosystemId: string) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.Ecosystem.root}/${ecosystemId}/${orgId}${apiRoutes.Ecosystem.invitations}`

const payload = {
invitations: invitationList,
}
const token = await getFromLocalStorage(storageKeys.TOKEN)

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

try {
return await axiosPost(axiosPayload);
}
catch (error) {
const err = error as Error
return err?.message
}
}
// Received Invitations by User
export const getUserInvitations = async (pageNumber: number, pageSize: number, search = '') => {

Expand Down Expand Up @@ -95,6 +149,60 @@ export const getUserInvitations = async (pageNumber: number, pageSize: number, s
}
}

// getEcosytemReceivedInvitations
export const getEcosytemReceivedInvitations = async (pageNumber: number, pageSize: number, search = '') => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);

const url = `${apiRoutes.Ecosystem.root}/${orgId}/?pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}`

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
}
}
export const getEcosystemInvitations = async (pageNumber: number, pageSize: number, search:string) => {
const ecosystemId = await getFromLocalStorage(storageKeys.ECOSYSTEM_ID);
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.Ecosystem.root}/${ecosystemId}/${orgId}${apiRoutes.Ecosystem.invitations}`

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
}
}

// Accept/ Reject Invitations
export const acceptRejectInvitations = async (invitationId: number,orgId: number, status: string) => {

Expand Down
2 changes: 0 additions & 2 deletions src/components/CreateEcosystemOrgModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,11 @@ const CreateEcosystemOrgModal = (props: IProps) => {
try {
setLoading(true)
const user_data = JSON.parse(await getFromLocalStorage(storageKeys.USER_PROFILE))
const organizationId = await getFromLocalStorage(storageKeys.ORG_ID);
const ecoData = {
name: values.name,
description: values.description,
logo: logoImage?.imagePreviewUrl as string || "",
tags: "",
orgId: Number(organizationId),
userId: Number(user_data?.id)
}
const resCreateEco = await createEcosystems(ecoData)
Expand Down
Loading

0 comments on commit 357eae6

Please sign in to comment.