Skip to content

Commit

Permalink
Merge pull request #376 from credebl/refactor-memberlist
Browse files Browse the repository at this point in the history
refactor : memberlist and schema
  • Loading branch information
sanjay-k1910 authored Oct 19, 2023
2 parents 6c99176 + 97d3d01 commit 2ace7b4
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 49 deletions.
6 changes: 3 additions & 3 deletions src/commonComponents/datatable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ const DataTable: React.FC<DataTableProps> = ({ header,displaySelect, data, loadi
<tbody className="bg-white dark:bg-gray-800">
{data.length ? data.map((ele, index) => (

<tr key={index+1} className={`${index % 2 !== 0 ? 'bg-gray-50 dark:bg-gray-700' : ''}`} >
<tr key={index} className={`${index % 2 !== 0 ? 'bg-gray-50 dark:bg-gray-700' : ''}`} >

{ele.data.map(subEle => (
<td key={index+1} className={` p-4 text-sm font-normal text-gray-900 whitespace-nowrap dark:text-white align-middle `}>
{ele.data.map((subEle,index) => (
<td key={index} className={` p-4 text-sm font-normal text-gray-900 whitespace-nowrap dark:text-white align-middle `}>
<div>{subEle.data}</div>
{subEle.subData && subEle.subData}
</td>
Expand Down
3 changes: 1 addition & 2 deletions src/components/Ecosystem/Endorsement/EndorsementCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ const EndorsementCard = ({ fromEndorsementList, data, onClickCallback, cardTrans
</div>
)
})}
{!allAttributes && attributesData.length > 3 && <span>...</span>}

{!allAttributes && attributesData.length === 3 && <span>...</span>}
</div>
</div>
</li>
Expand Down
59 changes: 31 additions & 28 deletions src/components/Ecosystem/MemberList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ const MemberList = () => {
const [currentPage, setCurrentPage] = useState(initialPageState);

const getEcosystemMembers = async () => {
const userOrgId= await getFromLocalStorage(storageKeys.ORG_ID)
const userOrgId = await getFromLocalStorage(storageKeys.ORG_ID);
setLoading(true);
const response = await getEcosystemMemberList(
currentPage.pageNumber,
currentPage.pageSize,
'',
);
const { data } = response as AxiosResponse;

if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
const totalPages = data?.data?.totalPages;

Expand All @@ -51,13 +51,14 @@ const MemberList = () => {
return 0;
}
};
const sortedMemberList = data?.data?.members?.sort(compareMembers);
const sortedMemberList = data?.data?.members?.sort(compareMembers);
const membersData = sortedMemberList?.map(
(member: {
orgId: string;
ecosystem: {createDateTime: string};
ecosystem: { createDateTime: string };
ecosystemRole: { name: string };
orgName: string;
orgDid: string;
role: string;
createDateTime: any;
status: string;
Expand All @@ -75,16 +76,30 @@ const MemberList = () => {
</DateTooltip>
) || 'Not available',
},
{
data: member.orgDid ? (
<span className="text-sm mr-2 px-2.5 py-1 rounded-md">
{member?.orgDid}
</span>
) : (
<span className="text-sm mr-2 px-2.5 py-1 rounded-md">
Not available
</span>
),
},
{
data: member.ecosystemRole.name ? (
<span
className={`${
member.ecosystemRole.name === 'Ecosystem Lead'
? 'bg-primary-100 text-primary-800 dark:bg-gray-900 dark:text-primary-400 border border-primary-100 dark:border-primary-500'
: 'bg-green-100 text-green-800 dark:bg-gray-700 dark:text-green-400 border border-green-100 dark:border-green-500'
} text-sm font-medium mr-2 px-2.5 py-1 rounded-md`}
>
{member?.orgId === userOrgId ? member?.ecosystemRole?.name + (' (You)') : member?.ecosystemRole?.name}
<span className="text-sm px-2.5 py-1 rounded-md">
<span
className={`${
member.ecosystemRole.name === 'Ecosystem Lead'
? 'bg-primary-100 text-primary-800 dark:bg-gray-900 dark:text-primary-400 border border-primary-100 dark:border-primary-500'
: 'bg-green-100 text-green-800 dark:bg-gray-700 dark:text-green-400 border border-green-100 dark:border-green-500'
} text-sm font-medium mr-1 px-2.5 py-1 rounded-md`}
>
{member?.ecosystemRole?.name}
</span>
{member?.orgId === userOrgId ? '(You)' : ''}
</span>
) : (
'Not available'
Expand All @@ -99,25 +114,13 @@ const MemberList = () => {
: 'bg-green-100 text-green-700 dark:bg-gray-700 dark:text-green-400 rounded border border-green-100 dark:border-green-500'
} text-sm font-medium mr-2 px-2.5 py-1 rounded-md`}
>
{member.status}
{member.status.charAt(0) +
member.status.slice(1).toLowerCase()}
</span>
) : (
'Not available'
),
},
{
data: (
<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>
),
},
],
};
},
Expand Down Expand Up @@ -149,9 +152,9 @@ const MemberList = () => {
const header = [
{ columnName: 'Organization' },
{ columnName: 'Member Since' },
{ columnName: 'Role' },
{ columnName: 'Organization Did', width: 'w-1.5 pl-6' },
{ columnName: 'Role', width: 'pl-7' },
{ columnName: 'Status' },
{ columnName: 'Action' },
];

return (
Expand Down
30 changes: 14 additions & 16 deletions src/components/Resources/Schema/SchemasList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,20 @@ const SchemaList = (props: { schemaSelectionCallback: (schemaId: string, schemaD
checkEcosystemData();
}, [])

const createSchemaTitle = isEcosystemData?.isEcosystemMember ? {
title: "Schema Endorsement", svg: <svg className='mr-2 mt-1' xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" viewBox="0 0 25 25">
<path fill="#fff" d="M21.094 0H3.906A3.906 3.906 0 0 0 0 3.906v12.5a3.906 3.906 0 0 0 3.906 3.907h.781v3.906a.781.781 0 0 0 1.335.553l4.458-4.46h10.614A3.906 3.906 0 0 0 25 16.407v-12.5A3.907 3.907 0 0 0 21.094 0Zm2.343 16.406a2.343 2.343 0 0 1-2.343 2.344H10.156a.782.782 0 0 0-.553.228L6.25 22.333V19.53a.781.781 0 0 0-.781-.781H3.906a2.344 2.344 0 0 1-2.344-2.344v-12.5a2.344 2.344 0 0 1 2.344-2.344h17.188a2.343 2.343 0 0 1 2.343 2.344v12.5Zm-3.184-5.951a.81.81 0 0 1-.17.254l-3.125 3.125a.781.781 0 0 1-1.105-1.106l1.792-1.79h-7.489a2.343 2.343 0 0 0-2.344 2.343.781.781 0 1 1-1.562 0 3.906 3.906 0 0 1 3.906-3.906h7.49l-1.793-1.79a.78.78 0 0 1 .254-1.277.781.781 0 0 1 .852.17l3.125 3.125a.79.79 0 0 1 .169.852Z" />
</svg>
} : {
title: "Create", svg: <div className='pr-3'>
<svg xmlns="http://www.w3.org/2000/svg" width="15" 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>
</div>
}
const schemaEndorsement = <svg className='mr-2 mt-1' xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" viewBox="0 0 25 25">
<path fill="#fff" d="M21.094 0H3.906A3.906 3.906 0 0 0 0 3.906v12.5a3.906 3.906 0 0 0 3.906 3.907h.781v3.906a.781.781 0 0 0 1.335.553l4.458-4.46h10.614A3.906 3.906 0 0 0 25 16.407v-12.5A3.907 3.907 0 0 0 21.094 0Zm2.343 16.406a2.343 2.343 0 0 1-2.343 2.344H10.156a.782.782 0 0 0-.553.228L6.25 22.333V19.53a.781.781 0 0 0-.781-.781H3.906a2.344 2.344 0 0 1-2.344-2.344v-12.5a2.344 2.344 0 0 1 2.344-2.344h17.188a2.343 2.343 0 0 1 2.343 2.344v12.5Zm-3.184-5.951a.81.81 0 0 1-.17.254l-3.125 3.125a.781.781 0 0 1-1.105-1.106l1.792-1.79h-7.489a2.343 2.343 0 0 0-2.344 2.343.781.781 0 1 1-1.562 0 3.906 3.906 0 0 1 3.906-3.906h7.49l-1.793-1.79a.78.78 0 0 1 .254-1.277.781.781 0 0 1 .852.17l3.125 3.125a.79.79 0 0 1 .169.852Z" />
</svg>

const create = <div className='pr-3'>
<svg xmlns="http://www.w3.org/2000/svg" width="15" 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>
</div>

const createSchemaTitle = isEcosystemData?.isEcosystemMember ? { title: "Schema Endorsement", svg: schemaEndorsement } : { title: "Create", svg: create }
const emptyListTitle = "No Schemas"
const emptyListDesc = "Get started by creating a new Schema"
const emptyListBtn = isEcosystemData?.isEcosystemMember ? "Request Endorsement" : "Create Schema"
const emptyListBtn = isEcosystemData?.isEcosystemMember ? { title: "Schema Endorsement", svg: schemaEndorsement } : { title: "Create Schema", svg: create }
return (
<div className="px-4 pt-6">
<div className="mb-4 col-span-full xl:mb-2">
Expand Down Expand Up @@ -275,10 +275,8 @@ const SchemaList = (props: { schemaSelectionCallback: (schemaId: string, schemaD
<EmptyListMessage
message={emptyListTitle}
description={emptyListDesc}
buttonContent={emptyListBtn}
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>}
buttonContent={emptyListBtn.title}
svgComponent={emptyListBtn.svg}
onClick={() => {
window.location.href = `${pathRoutes.organizations.createSchema}?OrgId=${orgId}`
}}
Expand Down

0 comments on commit 2ace7b4

Please sign in to comment.