Skip to content

Commit

Permalink
Merge pull request #312 from credebl/create-and-edit-ecosystems
Browse files Browse the repository at this point in the history
feat:Create and Edit Ecosystems
  • Loading branch information
16-karan authored Oct 5, 2023
2 parents cc51160 + 324a3d2 commit 589f160
Show file tree
Hide file tree
Showing 13 changed files with 642 additions and 478 deletions.
65 changes: 65 additions & 0 deletions src/api/ecosystems.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { axiosPost, axiosPut } from "../services/apiRequests"
import { apiRoutes } from "../config/apiRoutes";
import { getFromLocalStorage } from "./Auth";
import { storageKeys } from "../config/CommonConstant";

interface datapayload{
data:object
}
export const createEcosystems = async (Datapayload:datapayload) => {

const url = apiRoutes.ecosystem.create
const payload = Datapayload
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
}
}

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




192 changes: 58 additions & 134 deletions src/app/SideBar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,63 @@ import { pathRoutes } from "../config/pathRoutes";
</a>
</li>



<li>
<a
href="/ecosystems"
class="flex items-center p-2 text-base text-gray-900 rounded-lg hover:bg-gray-100 group dark:text-gray-200 dark:hover:bg-gray-700"
>
<svg
class="flex-shrink-0 w-6 h-6 text-gray-500 transition duration-75 group-hover:text-gray-900 dark:text-gray-400 dark:group-hover:text-white"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
>
<path
clip-rule="evenodd"
fill-rule="evenodd"
d="M.99 5.24A2.25 2.25 0 013.25 3h13.5A2.25 2.25 0 0119 5.25l.01 9.5A2.25 2.25 0 0116.76 17H3.26A2.267 2.267 0 011 14.74l-.01-9.5zm8.26 9.52v-.625a.75.75 0 00-.75-.75H3.25a.75.75 0 00-.75.75v.615c0 .414.336.75.75.75h5.373a.75.75 0 00.627-.74zm1.5 0a.75.75 0 00.627.74h5.373a.75.75 0 00.75-.75v-.615a.75.75 0 00-.75-.75H11.5a.75.75 0 00-.75.75v.625zm6.75-3.63v-.625a.75.75 0 00-.75-.75H11.5a.75.75 0 00-.75.75v.625c0 .414.336.75.75.75h5.25a.75.75 0 00.75-.75zm-8.25 0v-.625a.75.75 0 00-.75-.75H3.25a.75.75 0 00-.75.75v.625c0 .414.336.75.75.75H8.5a.75.75 0 00.75-.75zM17.5 7.5v-.625a.75.75 0 00-.75-.75H11.5a.75.75 0 00-.75.75V7.5c0 .414.336.75.75.75h5.25a.75.75 0 00.75-.75zm-8.25 0v-.625a.75.75 0 00-.75-.75H3.25a.75.75 0 00-.75.75V7.5c0 .414.336.75.75.75H8.5a.75.75 0 00.75-.75z"
></path>
</svg>
<span class="ml-3" sidebar-toggle-item>Ecosystem</span>
</a>
</li>
<!--
<ul id="dropdown-ecosystem" class="hidden py-2 space-y-2">
<li>
<a
href='featurecoming'
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"
>Ecosystems</a
>
</li>
<li>
<a
href='featurecoming'
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"
>Trust Frameworks</a
>
</li>
<li>
<a
href='featurecoming'
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"
>Members</a
>
</li>
<li>
<a
href='featurecoming'
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"
>Trust Registries</a
>
</li>
</ul>
</li -->


<li>
<a
href={pathRoutes.organizations.users}
Expand Down Expand Up @@ -122,70 +179,7 @@ import { pathRoutes } from "../config/pathRoutes";
</a>
</li>

<!-- <li>
<a
href={pathRoutes.users.invitations}
class="flex items-center p-2 text-base text-gray-900 rounded-lg hover:bg-gray-100 group dark:text-gray-200 dark:hover:bg-gray-700"
>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
  <path d="M9.978 13.2329L19.37 6.56494C19.312 6.50191 19.2498 6.44278 19.184 6.38794L11.2 0.650939C10.8566 0.392942 10.4392 0.252371 10.0097 0.25003C9.58011 0.247688 9.16123 0.383702 8.815 0.637939L0.8 6.39994C0.726113 6.46135 0.65692 6.52821 0.593 6.59994L9.978 13.2329Z" fill="#6B7280"/>
  <path d="M11.181 14.8639C10.8416 15.1166 10.4292 15.2521 10.006 15.2499C9.57095 15.2509 9.14735 15.1106 8.799 14.8499L0 8.62694V17.9999C0 18.5304 0.210714 19.0391 0.585786 19.4142C0.960859 19.7892 1.46957 19.9999 2 19.9999H18C18.5304 19.9999 19.0391 19.7892 19.4142 19.4142C19.7893 19.0391 20 18.5304 20 17.9999V8.57294L11.181 14.8639Z" fill="#6B7280"/>
</svg>
<span class="ml-3" sidebar-toggle-item>Received Invitations</span>
</a>
</li> -->
<!-- <li>
<button
type="button"
class="flex items-center w-full p-2 text-base text-gray-900 transition duration-75 rounded-lg group hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-700"
aria-controls="dropdown-layouts"
data-collapse-toggle="dropdown-layouts"
>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" viewBox="0 0 400 400">
  <g clip-path="url(#a)">
    <path fill="#6B7280" d="M244.651 354.785c-14.007 4.934-29.06 7.627-44.733 7.627a134.406 134.406 0 0 1-44.687-7.611c-5.56 9.071-12.557 17.174-20.762 24.061 20.077 8.71 42.206 13.55 65.448 13.55 23.236 0 45.361-4.838 65.435-13.544a99.268 99.268 0 0 1-20.701-24.083ZM112.008 125.044a99.275 99.275 0 0 1-10.528-29.97C65.912 121.6 41.362 162.105 36.023 208.378a99.88 99.88 0 0 1 31.22-5.933c5.766-30.713 21.963-57.792 44.765-77.401Zm220.585 77.401a99.844 99.844 0 0 1 31.22 5.933c-5.34-46.272-29.889-86.779-65.457-113.304a99.275 99.275 0 0 1-10.528 29.97c22.801 19.609 38.998 46.687 44.765 77.401Zm-132.679-55.031c38.66 0 70-31.34 70-70s-31.34-70-70-70-70 31.34-70 70 31.34 70 70 70ZM35.012 241.792C1.531 261.122-9.94 303.934 9.39 337.414c12.966 22.457 36.495 35.012 60.688 35.012 11.874 0 23.911-3.025 34.934-9.39 33.48-19.33 44.952-62.143 25.622-95.622-12.966-22.458-36.494-35.013-60.688-35.012-11.874 0-23.912 3.026-34.934 9.39Zm234.182 25.623c-19.329 33.48-7.858 76.291 25.622 95.621 11.025 6.365 23.059 9.391 34.935 9.391 24.191 0 47.722-12.556 60.687-35.012 19.329-33.48 7.859-76.293-25.622-95.623-11.024-6.365-23.057-9.391-34.934-9.39-24.191.001-47.723 12.557-60.688 35.013Z"/>
  </g>
  <defs>
    <clipPath id="a">
      <path fill="#fff" d="M0 0h399.83v399.83H0z"/>
    </clipPath>
  </defs>
</svg>
<span
class="flex-1 ml-3 text-left whitespace-nowrap"
sidebar-toggle-item>Members</span
>
<svg
sidebar-toggle-item
class="w-6 h-6"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
><path
fill-rule="evenodd"
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
clip-rule="evenodd"></path></svg
>
</button> -->
<!--ul id="dropdown-layouts" class="hidden py-2 space-y-2"-->
<!-- <li>
<a
href={pathRoutes.organizations.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"
>Organizations</a
>
</li> -->
<!-- <li>
<a
href={pathRoutes.organizations.users}
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"
>Users</a
>
</li> -->
<!-- </ul> -->
<!-- </li> -->


<li>
<button
Expand Down Expand Up @@ -278,76 +272,6 @@ import { pathRoutes } from "../config/pathRoutes";
</button>
</li>

<!-- li>
<button
type="button"
class="flex items-center w-full p-2 text-base text-gray-900 transition duration-75 rounded-lg group hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-700"
aria-controls="dropdown-ecosystem"
data-collapse-toggle="dropdown-ecosystem"
data-collapse-toggle="dropdown-ecosystem"
>
<svg
class="flex-shrink-0 w-6 h-6 text-gray-500 transition duration-75 group-hover:text-gray-900 dark:text-gray-400 dark:group-hover:text-white"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
>
<path
clip-rule="evenodd"
fill-rule="evenodd"
d="M.99 5.24A2.25 2.25 0 013.25 3h13.5A2.25 2.25 0 0119 5.25l.01 9.5A2.25 2.25 0 0116.76 17H3.26A2.267 2.267 0 011 14.74l-.01-9.5zm8.26 9.52v-.625a.75.75 0 00-.75-.75H3.25a.75.75 0 00-.75.75v.615c0 .414.336.75.75.75h5.373a.75.75 0 00.627-.74zm1.5 0a.75.75 0 00.627.74h5.373a.75.75 0 00.75-.75v-.615a.75.75 0 00-.75-.75H11.5a.75.75 0 00-.75.75v.625zm6.75-3.63v-.625a.75.75 0 00-.75-.75H11.5a.75.75 0 00-.75.75v.625c0 .414.336.75.75.75h5.25a.75.75 0 00.75-.75zm-8.25 0v-.625a.75.75 0 00-.75-.75H3.25a.75.75 0 00-.75.75v.625c0 .414.336.75.75.75H8.5a.75.75 0 00.75-.75zM17.5 7.5v-.625a.75.75 0 00-.75-.75H11.5a.75.75 0 00-.75.75V7.5c0 .414.336.75.75.75h5.25a.75.75 0 00.75-.75zm-8.25 0v-.625a.75.75 0 00-.75-.75H3.25a.75.75 0 00-.75.75V7.5c0 .414.336.75.75.75H8.5a.75.75 0 00.75-.75z"
></path>
</svg>
<span
class="flex-1 ml-3 text-left whitespace-nowrap"
sidebar-toggle-item>Ecosystems</span
>
<svg
sidebar-toggle-item
class="w-6 h-6"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
><path
fill-rule="evenodd"
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
clip-rule="evenodd"></path></svg
>
</button>
<ul id="dropdown-ecosystem" class="hidden py-2 space-y-2">
<li>
<a
href='featurecoming'
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"
>Ecosystems</a
>
</li>
<li>
<a
href='featurecoming'
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"
>Trust Frameworks</a
>
</li>
<li>
<a
href='featurecoming'
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"
>Members</a
>
</li>
<li>
<a
href='featurecoming'
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"
>Trust Registries</a
>
</li>
</ul>
</li -->



<li>
Expand Down
11 changes: 7 additions & 4 deletions src/components/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use client';

import { Button } from 'flowbite-react';
import CreateOrgFormModal from "./organization/CreateOrgFormModal.js";
import { useEffect, useState } from 'react';
import { useState } from 'react';
import PopupModal from '../components/PopupModal/index.js'
import React from 'react';

export default function Dashboard() {

Expand Down Expand Up @@ -31,9 +32,11 @@ export default function Dashboard() {

{
props.openModal &&
<CreateOrgFormModal
<PopupModal
openModal={props.openModal}
setOpenModal= {props.setOpenModal} />
setOpenModal= {props.setOpenModal}
isorgModal={true}
/>
}
</div>
</div>
Expand Down
68 changes: 68 additions & 0 deletions src/components/Ecosystems/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
'use client';
import { useState } from 'react';
import BreadCrumbs from '../BreadCrumbs';
import { EmptyListMessage } from '../EmptyListComponent';
import PopupModal from '../PopupModal';
import React from 'react';



const initialPageState = {
pageNumber: 1,
pageSize: 9,
total: 100,
};

const Dashboard = () => {
const [openModal, setOpenModal,] = useState<boolean>(false);
const [editEcosystemModal, setEditEcosystemModal] = useState<boolean>(false);
const props = { openModal, setOpenModal, editEcosystemModal, setEditEcosystemModal };


const createEcosystemModel = () => {
props.setOpenModal(true)
}

const EditEcosystemsModel = () => {
props.setEditEcosystemModal(true);
};

return (
<div>
<div className="pl-6 mb-4 col-span-full xl:mb-2">
<BreadCrumbs />
<h1 className="ml-1 text-xl font-semibold text-gray-900 sm:text-2xl dark:text-white">
Ecosystems
</h1>
</div>
<div
className="p-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800"
>
<div className="flex items-center justify-center mb-4">

<PopupModal
openModal={props.openModal}
setOpenModal={props.setOpenModal} setMessage={function (message: string): void {
throw new Error('Function not implemented.');
}}
isorgModal={false}
/>


<EmptyListMessage

message={'No Ecosystem found'}
description={'Get started by creating an ecosystem'}
buttonContent={'Create Ecosystem'}
svgComponent={<svg className='pr-2 mr-1' xmlns="http://www.w3.org/2000/svg" width="24" height="15" fill="none" viewBox="0 0 24 24">
<path fill="#fff" d="M21.89 9.89h-7.78V2.11a2.11 2.11 0 1 0-4.22 0v7.78H2.11a2.11 2.11 0 1 0 0 4.22h7.78v7.78a2.11 2.11 0 1 0 4.22 0v-7.78h7.78a2.11 2.11 0 1 0 0-4.22Z" />
</svg>}
onClick={createEcosystemModel}
/>
</div>
</div>
</div>
)
}

export default Dashboard;
13 changes: 13 additions & 0 deletions src/components/Ecosystems/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export interface Ecosystem {
id: number
createDateTime: string
createdBy: number
lastChangedDateTime: string
lastChangedBy: number
name: string
description: string
logoUrl: string
website: string
roles: string[]

}
Loading

0 comments on commit 589f160

Please sign in to comment.