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:Edit ecosystem modal component #325

Merged
merged 10 commits into from
Oct 11, 2023
12 changes: 8 additions & 4 deletions src/api/ecosystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface CreateEcosystemPayload {
name: string
description: string
logo: string
tags: string
tags?: string
userId: number
}

Expand Down Expand Up @@ -44,10 +44,13 @@ export const createEcosystems = async (dataPayload: CreateEcosystemPayload) => {
}
}

export const updateEcosystem = async (data: object) => {
export const updateEcosystem = async (dataPayload: CreateEcosystemPayload) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.Ecosystem.root}/${orgId}`
const payload = data
const ecosystemId = await getFromLocalStorage(storageKeys.ECOSYSTEM_ID);

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

const axiosPayload = {
url,
payload,
Expand All @@ -63,6 +66,7 @@ export const updateEcosystem = async (data: object) => {
}
}


export const getEcosystem = async (orgId: string) => {
const url = `${apiRoutes.Ecosystem.root}/${orgId}`

Expand Down
127 changes: 86 additions & 41 deletions src/components/Ecosystem/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,60 @@ import { AlertComponent } from '../AlertComponent';
import { ICheckEcosystem, checkEcosystem } from '../../config/ecosystem';
import RoleViewButton from '../RoleViewButton';
import SendInvitationModal from '../organization/invitations/SendInvitationModal';
import { Dropdown } from 'flowbite-react';
import EditPopupModal from '../EditEcosystemOrgModal';
import { getFromLocalStorage, setToLocalStorage } from '../../api/Auth';
import { getEcosytemReceivedInvitations } from '../../api/invitations';
import { pathRoutes } from '../../config/pathRoutes';


const initialPageState = {
pageNumber: 1,
pageSize: 10,
total: 0,
};

const Dashboard = () => {
const [ecosystemDetails, setEcosystemDetails] = useState<IEcosystem | null>();
const [success, setSuccess] = useState<string | null>(null);
const [failure, setFailure] = useState<string | null>(null);
const [message, setMessage] = useState<string | null>(null);
const [loading, setLoading] = useState<boolean | null>(true);
const [error, setError] = useState<string | null>(null);
const [ecosystemId, setEcosystemId] = useState('');
const [openModal, setOpenModal] = useState<boolean>(false);
const [viewButton, setViewButton] = useState<boolean>(false);
const [currentPage, setCurrentPage] = useState(initialPageState);
const [isEcosystemLead, setIsEcosystemLead] = useState(false);
const [ecosystemDetails, setEcosystemDetails] = useState<IEcosystem | null>();
const [success, setSuccess] = useState<string | null>(null);
const [failure, setFailure] = useState<string | null>(null);
const [message, setMessage] = useState<string | null>(null);
const [loading, setLoading] = useState<boolean | null>(true);
const [ecosystemId, setEcosystemId] = useState('')
const [editOpenModal, setEditOpenModal] = useState<boolean>(false);
const [dropdownOpen, setDropdownOpen] = useState(false);
const [error, setError] = useState<string | null>(null);
const [openModal, setOpenModal] = useState<boolean>(false);
const [viewButton, setViewButton] = useState<boolean>(false);
const [currentPage, setCurrentPage] = useState(initialPageState);
const [isEcosystemLead, setIsEcosystemLead] = useState(false);

const createEcosystemModel = () => {
setOpenModal(true);
};

const props = { openModal, setOpenModal };
const createInvitationsModel = () => {
setOpenModal(true);
};

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

const createInvitationsModel = () => {
props.setOpenModal(true);
};
const handleEditModalClose = () => {
setEditOpenModal(false);
setDropdownOpen(false);
fetchEcosystemDetails()
};
pranalidhanavade marked this conversation as resolved.
Show resolved Hide resolved

const getAllEcosystemInvitations = async () => {
setLoading(true);
const response = await getEcosytemReceivedInvitations(
currentPage.pageNumber,
currentPage.pageSize,
'',
);
const { data } = response as AxiosResponse;
const getAllEcosystemInvitations = async () => {
setLoading(true);
const response = await getEcosytemReceivedInvitations(
currentPage.pageNumber,
currentPage.pageSize,
''
);
const { data } = response as AxiosResponse;

if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
const totalPages = data?.data?.totalPages;
Expand Down Expand Up @@ -142,7 +155,7 @@ const Dashboard = () => {
<>
<div className="cursor-pointer">
{<AlertComponent
message={message ? message : error}
message={message || error}
type={message ? 'warning' : 'failure'}
viewButton={viewButton}
path={pathRoutes.ecosystem.invitation}
Expand Down Expand Up @@ -199,9 +212,9 @@ const Dashboard = () => {
<SendInvitationModal
ecosystemId={ecosystemId}
flag={true}
openModal={props.openModal}
openModal={openModal}
setMessage={(data) => setMessage(data)}
setOpenModal={props.setOpenModal}
setOpenModal={setOpenModal}
/>
<RoleViewButton
buttonTitle="Invite"
Expand All @@ -223,17 +236,39 @@ const Dashboard = () => {
}
onClickEvent={createInvitationsModel}
/>
<div className="ml-4">
<svg
className="w-6 h-6 text-gray-800 cursor-pointer dark:text-white"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
viewBox="0 0 4 15"
>
<path d="M3.5 1.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm0 6.041a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm0 5.959a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Z" />
</svg>
</div>
<Dropdown
label={"test"}
open={dropdownOpen}
onToggle={() => setDropdownOpen(!dropdownOpen)}
renderTrigger={() => <svg
className="ml-4 w-4 h-4 text-gray-800 cursor-pointer dark:text-white"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
viewBox="0 0 4 15"

>
<path d="M3.5 1.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm0 6.041a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm0 5.959a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Z" />
</svg>}
>
<Dropdown.Item onClick={EditEcosystemOrgModal}>
<div>
Edit Ecosystem
</div>
</Dropdown.Item>
<Dropdown.Item>
<div>
Enable/Disable Ecosystem
</div>
</Dropdown.Item>
<Dropdown.Item>
<div>
Manual Registration
</div>
</Dropdown.Item>


</Dropdown>
</div>
)}
</div>
Expand Down Expand Up @@ -274,6 +309,16 @@ const Dashboard = () => {
<div className="mt-4 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">
<MemberList />
</div>
<EditPopupModal
openModal={editOpenModal}
setOpenModal={setEditOpenModal}
setMessage={(value) => {
setSuccess(value);
}}
isOrganization={false}
onEditSuccess={handleEditModalClose}
entityData={ecosystemDetails}
/>
</>
)}
</div>
Expand All @@ -288,7 +333,7 @@ const Dashboard = () => {
<div className="flex items-center justify-center mb-4">
<CreateEcosystemOrgModal
openModal={openModal}
setOpenModal={props.setOpenModal}
setOpenModal={setOpenModal}
setMessage={(value) => {
setSuccess(value);
fetchEcosystemDetails();
Expand Down
1 change: 1 addition & 0 deletions src/components/Ecosystem/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export interface Ecosystem {
logoUrl: string
website: string
roles: string[]
logoFile:string
}
Loading