diff --git a/src/api/ecosystems.ts b/src/api/ecosystems.ts
index c9944b326..d26382d04 100644
--- a/src/api/ecosystems.ts
+++ b/src/api/ecosystems.ts
@@ -32,6 +32,32 @@ export const createEcosystems = async (data: object) => {
}
}
+export const updateEcosystem = async (data: object, orgId:string) => {
+
+ const url = `${apiRoutes.organizations.update}/${orgId}`
+ const payload = data
+ const token = await getFromLocalStorage(storageKeys.TOKEN)
+
+ const config = {
+ headers: {
+ 'Content-Type': 'application/json',
+ Authorization: `Bearer ${token}`
+ }
+ }
+ const axiosPayload = {
+ url,
+ payload,
+ config
+ }
+
+ try {
+ return await axiosPut(axiosPayload);
+ }
+ catch (error) {
+ const err = error as Error
+ return err?.message
+ }
+}
diff --git a/src/components/Ecosystems/CreateEcosystems.tsx b/src/components/Ecosystems/CreateEcosystems.tsx
index 3e2f3190f..aa9f1ed2b 100644
--- a/src/components/Ecosystems/CreateEcosystems.tsx
+++ b/src/components/Ecosystems/CreateEcosystems.tsx
@@ -16,7 +16,6 @@ import { getFromLocalStorage } from "../../api/Auth";
interface Values {
name: string;
description: string;
-
}
interface ILogoImage {
@@ -139,11 +138,11 @@ try{
const ecoData = {
name: values.name,
description: values.description,
+ logo: logoImage?.imagePreviewUrl as string || "",
tag:"",
orgId: Number(organizationId),
userId:Number(user_data?.id)
}
-
const resCreateOrg = await createEcosystems(ecoData)
const { data } = resCreateOrg as AxiosResponse
@@ -243,11 +242,11 @@ try{
-
+
Choose file
handleImageChange(event)} />
{/* {selectedImage || 'No File Chosen'} */}
{imgError ? {imgError}
: {logoImage.fileName || 'No File Chosen'} }
@@ -327,5 +326,4 @@ try{
)
}
-
export default CreateEcosystems;
diff --git a/src/components/Ecosystems/Dashboard.tsx b/src/components/Ecosystems/Dashboard.tsx
index 55ec5c1f8..48c9b1688 100644
--- a/src/components/Ecosystems/Dashboard.tsx
+++ b/src/components/Ecosystems/Dashboard.tsx
@@ -17,65 +17,67 @@ const initialPageState = {
};
const Dashboard = () => {
- const [openModal, setOpenModal,] = useState(false);
- const [editEcosystemModal, setEditEcosystemModal] = useState(false);
- const props = { openModal, setOpenModal, editEcosystemModal, setEditEcosystemModal };
-
+ const [openModal, setOpenModal,] = useState(false);
+ const [editEcosystemModal, setEditEcosystemModal] = useState(false);
+ const props = { openModal, setOpenModal, editEcosystemModal, setEditEcosystemModal };
- const createEcosystemModel = () => {
- props.setOpenModal(true)
- }
- const EditEcosystemsModel = () => {
- props.setEditEcosystemModal(true); // Open the EditEcosystems modal
- };
+ const createEcosystemModel = () => {
+ props.setOpenModal(true)
+ }
+
+ const EditEcosystemsModel = () => {
+ props.setEditEcosystemModal(true); // Open the EditEcosystems modal
+ };
return (
-
+
{/* Use EditEcosystemsModel */}
-
-
-
-
-
-
-
- Ecosystems
-
-
-
-
-
+
+
+
+
+
+
+
+ Ecosystems
+
+
+
+
+
setMessage(data)}
setOpenModal={props.setEditEcosystemModal} setMessage={function (message: string): void {
throw new Error('Function not implemented.');
- } } EcoData={null} />
+ }} EcoData={null} />
- setMessage(data)}
- setOpenModal={props.setOpenModal} setMessage={function (message: string): void {
- throw new Error('Function not implemented.');
- } } />
+ setMessage(data)}
+ setOpenModal={props.setOpenModal} setMessage={function (message: string): void {
+ throw new Error('Function not implemented.');
+ }}
+ // EcoData={null}
+ />
-
-
- }
- onClick={createEcosystemModel}
- />
-
-
+
+
+ }
+ onClick={createEcosystemModel}
+ />
+
+
)
}
diff --git a/src/components/Ecosystems/EcosystemDashboard.tsx b/src/components/Ecosystems/EcosystemDashboard.tsx
deleted file mode 100644
index ac82fbee9..000000000
--- a/src/components/Ecosystems/EcosystemDashboard.tsx
+++ /dev/null
@@ -1,247 +0,0 @@
-'use client';
-
-import { Button, 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 CreateEcosystems from "./CreateEcosystems";
-import CustomAvatar from '../Avatar'
-import { Features } from '../../utils/enums/features';
-import type { Ecosystem } from './interfaces'
-import RoleViewButton from '../RoleViewButton';
-import SearchInput from '../SearchInput';
-import { getOrganizations } from '../../api/organization';
-import { pathRoutes } from '../../config/pathRoutes';
-import { setToLocalStorage } from '../../api/Auth';
-import { EmptyListMessage } from '../EmptyListComponent';
-import CustomSpinner from '../CustomSpinner';
-import React from 'react';
-
-const initialPageState = {
- pageNumber: 1,
- pageSize: 9,
- total: 100,
-};
-
-const EcosystemDashbaord = () => {
- 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 [organizationsList, setOrganizationList] = useState | null>(null)
-
- const props = { openModal, setOpenModal };
-
- const createOrganizationModel = () => {
- props.setOpenModal(true)
- }
-
- //Fetch the user organization list
- const getAllOrganizations = async () => {
-
- setLoading(true)
- const response = await getOrganizations(currentPage.pageNumber, currentPage.pageSize, searchText);
- const { data } = response as AxiosResponse
-
- if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
-
- const totalPages = data?.data?.totalPages;
-
- // const orgList = data?.data?.organizations.map((userOrg: Ecosystem) => {
- // const roles: string[] = userOrg.userOrgRoles.map(role => role.orgRole.name)
- // userOrg.roles = roles
- // return userOrg;
- // })
-
-// setOrganizationList(orgList)
-// setCurrentPage({
-// ...currentPage,
-// total: totalPages
-// })
-// }
-// else{
-// setError(response as string)
-
-// }
-// setLoading(false)
- }
-
-
- //This useEffect is called when the searchText changes
- useEffect(() => {
-
- // let getData: string | number | NodeJS.Timeout | undefined;
- let getData: NodeJS.Timeout
-
- if (searchText.length >= 1) {
- getData = setTimeout(() => {
- getAllOrganizations()
-
- }, 1000)
- } else {
- getAllOrganizations()
- }
-
- return () => clearTimeout(getData)
- }, [searchText, openModal, currentPage.pageNumber])
-
- useEffect(() => {
- const queryParameters = new URLSearchParams(window?.location?.search)
- const isModel = queryParameters.get("orgModal") || ''
-
- if (isModel !== '') {
- props.setOpenModal(true)
- }
-
- }, [])
-
- //onCHnage of Search input text
- const searchInputChange = (e: ChangeEvent) => {
- setSearchText(e.target.value);
- }
-
- const redirectOrgDashboard = async (activeOrg: Ecosystem) => {
-
- // await setToLocalStorage(storageKeys.ORG_ID, activeOrg.id.toString());
- // const roles: string[] = activeOrg?.userOrgRoles.map(role => role.orgRole.name)
- // activeOrg.roles = roles
-
- // await setToLocalStorage(storageKeys.ORG_ROLES, roles.toString());
- // window.location.href = pathRoutes.organizations.dashboard
- }
-
-
- return (
-
-
-
-
-
- Organizations
-
-
-
-
-
- }
- onClickEvent={createOrganizationModel}
- />
-
-
-
setMessage(data)}
- setOpenModal={
- props.setOpenModal
- } />
-
- {
- setMessage(null)
- setError(null)
- }}
- />
-
- {loading
- ?
-
-
- : organizationsList && organizationsList?.length > 0 ? (
- {
- organizationsList.map((org) => (
-
redirectOrgDashboard(org)} 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' }}>
-
- {(org.logoUrl) ?
:
}
-
-
-
-
- {org.name}
-
-
-
-
-
-
-
- Roles:
- {org.roles &&
- org.roles.length > 0 &&
- org.roles.map((role: string, index: number) => {
- return (
-
- {role.charAt(0).toUpperCase() + role.slice(1)}
-
- );
- })}
-
-
-
-
-
-
-
-
- ))
- }
-
)
- : organizationsList && (
-
- } />)
- }
-
-
-
- {organizationsList && organizationsList?.length > 0 && (
-
- )
- }
-
-
-
-
- )
-}
-}
-export default EcosystemDashbaord;
diff --git a/src/components/Ecosystems/EditEcosystems.tsx b/src/components/Ecosystems/EditEcosystems.tsx
index ca57592dd..d55bb1226 100644
--- a/src/components/Ecosystems/EditEcosystems.tsx
+++ b/src/components/Ecosystems/EditEcosystems.tsx
@@ -8,7 +8,7 @@ import { useEffect, useState } from "react";
import { AlertComponent } from "../AlertComponent";
import type { AxiosResponse } from 'axios';
-import { updateOrganization } from "../../api/organization";
+import { updateEcosystem } from "../../api/ecosystems";
import type { Ecosystem } from "./interfaces";
import React from "react";
@@ -44,7 +44,7 @@ const EditEcosystemsModal = (props: EditEcosystemsModalProps) => {
const [isImageEmpty, setIsImageEmpty] = useState(true)
const [isPublic, setIsPublic] = useState(true)
- const [initialOrgData, setOrgData] = useState({
+ const [initialEcoData, setEcoData] = useState({
name: props?.EcoData?.name || "",
description: props?.EcoData?.description || "",
website: props?.EcoData?.website || "",
@@ -53,7 +53,7 @@ const EditEcosystemsModal = (props: EditEcosystemsModalProps) => {
useEffect(() => {
if (props.EcoData) {
- setOrgData({
+ setEcoData({
name: props.EcoData.name || '',
description: props.EcoData.description || '',
website: props?.EcoData?.website || "",
@@ -74,7 +74,7 @@ const EditEcosystemsModal = (props: EditEcosystemsModalProps) => {
useEffect(() => {
if (props.openModal === false) {
- setOrgData({
+ setEcoData({
name: '',
description: '',
website:''
@@ -162,7 +162,7 @@ const EditEcosystemsModal = (props: EditEcosystemsModalProps) => {
}
}
- const submitUpdateOrganization = async (values: Values) => {
+ const submitUpdateEcosystem = async (values: Values) => {
setLoading(true)
@@ -175,7 +175,7 @@ const EditEcosystemsModal = (props: EditEcosystemsModalProps) => {
isPublic: isPublic
}
- const resUpdateOrg = await updateOrganization(EcoData, EcoData.orgId?.toString() as string)
+ const resUpdateOrg = await updateEcosystem(EcoData, EcoData.orgId?.toString() as string)
const { data } = resUpdateOrg as AxiosResponse
setLoading(false)
@@ -197,7 +197,7 @@ const EditEcosystemsModal = (props: EditEcosystemsModalProps) => {
imagePreviewUrl: "",
fileName: ''
})
- setOrgData(initialOrgData)
+ setEcoData(initialEcoData)
props.setOpenModal(false)
}
}>
@@ -212,7 +212,7 @@ const EditEcosystemsModal = (props: EditEcosystemsModalProps) => {
/>
{
values: Values,
{ resetForm }: FormikHelpers
) => {
- submitUpdateOrganization(values)
+ submitUpdateEcosystem(values)
}}
>
{(formikHandlers): JSX.Element => (
@@ -280,11 +280,11 @@ const EditEcosystemsModal = (props: EditEcosystemsModalProps) => {
-
+
Choose file
handleImageChange(event)} />
{/* {selectedImage || 'No File Chosen'} */}
{imgError ? {imgError}
: {logoImage.fileName || 'No File Chosen'} }
@@ -346,67 +346,9 @@ const EditEcosystemsModal = (props: EditEcosystemsModalProps) => {
}
- {/*
-
-
-
*/}
- {/*
*/}
+
- {/*
-
-
-
-
-
-
setIsPublic(false)}
- id="private"
- name="private"
- />
-
Private
- Only the connected organization can see you organization details
-
-
-
-
-
-
-
setIsPublic(true)}
- checked={isPublic === true}
- id="public"
- name="public"
- />
-
-
Public
- Your profile and organization details can be seen by everyone
-
-
*/}
{
>
-
Save
)}
-
diff --git a/src/components/organization/CreateOrgFormModal.tsx b/src/components/organization/CreateOrgFormModal.tsx
index 2d57380b9..d2d74da56 100644
--- a/src/components/organization/CreateOrgFormModal.tsx
+++ b/src/components/organization/CreateOrgFormModal.tsx
@@ -10,6 +10,7 @@ import { AlertComponent } from "../AlertComponent";
import type { AxiosResponse } from 'axios';
import { asset } from '../../lib/data.js';
import { createOrganization } from "../../api/organization";
+import React from "react";
interface Values {
name: string;
@@ -138,7 +139,6 @@ const CreateOrgFormModal = (props: { openModal: boolean; setMessage: (message: s
logo: logoImage?.imagePreviewUrl as string || "",
website: ""
}
-
const resCreateOrg = await createOrganization(orgData)
const { data } = resCreateOrg as AxiosResponse
diff --git a/src/pages/ecosystems/index.astro b/src/pages/ecosystems/index.astro
index dc759a44e..bb9899381 100644
--- a/src/pages/ecosystems/index.astro
+++ b/src/pages/ecosystems/index.astro
@@ -3,7 +3,7 @@ import LayoutSidebar from '../../app/LayoutSidebar.astro';
import Dashboard from '../../components/Ecosystems/Dashboard';
import { checkUserSession } from '../../utils/check-session';
import { pathRoutes } from '../../config/pathRoutes';
-import EcosystemDashbaord from '../../components/Ecosystems/EcosystemDashboard';
+
const response = await checkUserSession(Astro.cookies);
const route: string = pathRoutes.auth.sinIn
if (!response) {
@@ -13,5 +13,4 @@ if (!response) {
-
\ No newline at end of file