Skip to content

Commit

Permalink
feat: add own organizations in ecosystem (#667)
Browse files Browse the repository at this point in the history
* feat: created page

Signed-off-by: sanjay.khatal <[email protected]>

* feat: add own organizations in the ecosystem

Signed-off-by: sanjay.khatal <[email protected]>

* feat: add orgs in ecosystem

Signed-off-by: sanjay.khatal <[email protected]>

* fix: types, redirection and error handling

Signed-off-by: sanjay.khatal <[email protected]>

* fix: sonarlint issues

Signed-off-by: sanjay.khatal <[email protected]>

* fix: role wise list access

Signed-off-by: bhavanakarwade <[email protected]>

* fix: resolved comments

Signed-off-by: bhavanakarwade <[email protected]>

* fix: pagesize

Signed-off-by: bhavanakarwade <[email protected]>

---------

Signed-off-by: sanjay.khatal <[email protected]>
Signed-off-by: bhavanakarwade <[email protected]>
Co-authored-by: bhavanakarwade <[email protected]>
  • Loading branch information
sanjay-k1910 and bhavanakarwade authored Apr 26, 2024
1 parent 642c9db commit 5c26347
Show file tree
Hide file tree
Showing 13 changed files with 621 additions and 172 deletions.
24 changes: 24 additions & 0 deletions src/api/ecosystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,27 @@ export const getEcosystemMemberList = async ({
return err?.message;
}
};


export const addOrganizationInEcosystem = async (
data: string[],
ecosystemId: string,
orgId: string,
) => {
const url = `${apiRoutes.Ecosystem.root}/${ecosystemId}/${orgId}${apiRoutes.organizations.root}`;
const payload = {
organizationIds: data
};
const axiosPayload = {
url,
payload,
config: await getHeaderConfigs(),
};

try {
return await axiosPost(axiosPayload);
} catch (error) {
const err = error as Error;
return err?.message;
}
};
4 changes: 3 additions & 1 deletion src/api/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ export const getOrganizations = async (
pageNumber: number,
pageSize: number,
search = '',
role = ''
) => {
const url = `${apiRoutes.organizations.getAll}?pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}`;
const roleQuery = role ? `&role=${role}` : ''
const url = `${apiRoutes.organizations.getAll}?pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}${roleQuery}`;

const token = await getFromLocalStorage(storageKeys.TOKEN);

Expand Down
19 changes: 9 additions & 10 deletions src/commonComponents/datatable/SortDataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { IDataTable } from './interface';
import CustomSpinner from '../../components/CustomSpinner';
import SearchInput from '../../components/SearchInput';
import { Pagination } from 'flowbite-react';
import { ChangeEvent, useState } from 'react';
import { useState } from 'react';
import { EmptyListMessage } from '../../components/EmptyListComponent';

const SortDataTable: React.FC<IDataTable> = ({
Expand All @@ -28,13 +28,14 @@ const SortDataTable: React.FC<IDataTable> = ({
discription,
noExtraHeight,
sortOrder,
itemPerPage
}) => {
const [selectedValue, setSelectedValue] = useState(sortOrder ?? '');

const handleSortByValues = (event: { target: { value: any } }) => {
const newSelectedValue = event.target.value;
setSelectedValue(newSelectedValue);
if(searchSortByValue){
if (searchSortByValue) {
searchSortByValue(newSelectedValue);
}
};
Expand All @@ -48,9 +49,8 @@ const SortDataTable: React.FC<IDataTable> = ({
nextPage?: number;
lastPage?: number;
};

const startItem = (nextPage - 2) * 10 + 1;
const endItem = Math.min((nextPage - 1) * 10, totalItem);
const startItem = (nextPage - 2) * (itemPerPage || 10) + 1;
const endItem = Math.min((nextPage - 1) * (itemPerPage || 10), totalItem);

const sortValues = [
{
Expand Down Expand Up @@ -177,13 +177,12 @@ const SortDataTable: React.FC<IDataTable> = ({
</tr>
) : (
<tbody className="bg-white dark:bg-gray-800 w-full">
{data.length ? (
data.map((ele, index) => (
{data?.length ? (
data?.map((ele, index) => (
<tr
key={index}
className={`${
index % 2 !== 0 ? 'bg-gray-50 dark:bg-gray-700' : ''
}`}
className={`${index % 2 !== 0 ? 'bg-gray-50 dark:bg-gray-700' : ''
}`}
>
{ele.data.map((subEle, index) => (
<td
Expand Down
3 changes: 2 additions & 1 deletion src/commonComponents/datatable/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface IDataTable {
currentPage: any;
onPageChange: (page: number) => void;
totalPages: number;
searchSortByValue: (value: any) => void;
searchSortByValue?: (value: string) => void;
isPagination?: boolean;
isSearch: boolean;
isRefresh: boolean;
Expand All @@ -47,4 +47,5 @@ export interface IDataTable {
}
| {};
sortOrder?:string;
itemPerPage?: number;
}
Loading

0 comments on commit 5c26347

Please sign in to comment.