Skip to content

Commit

Permalink
Merge pull request #163 from credebl/user-dashboard-organization-list…
Browse files Browse the repository at this point in the history
…-issue

refactor/fix: User dashboard and organization list issue
  • Loading branch information
tipusinghaw authored Aug 28, 2023
2 parents c81eef6 + bb177cd commit 9a7c638
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 61 deletions.
17 changes: 11 additions & 6 deletions src/app/NavBarSidebar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,17 @@ import AgentHealth from '../commonComponents/AgentHealth';
<span class="sr-only">View </span>
<!-- Icon -->
<svg
class="w-6 h-6 text-gray-500 dark:text-gray"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 14 20">
<path d="M12.133 10.632v-1.8A5.406 5.406 0 0 0 7.979 3.57.946.946 0 0 0 8 3.464V1.1a1 1 0 0 0-2 0v2.364a.946.946 0 0 0 .021.106 5.406 5.406 0 0 0-4.154 5.262v1.8C1.867 13.018 0 13.614 0 14.807 0 15.4 0 16 .538 16h12.924C14 16 14 15.4 14 14.807c0-1.193-1.867-1.789-1.867-4.175ZM3.823 17a3.453 3.453 0 0 0 6.354 0H3.823Z"/>
</svg>
xmlns="http://www.w3.org/2000/svg"
width="22"
height="22"
fill="none"
viewBox="0 0 30 30"
<path stroke="#6B7280"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2.5"
d="M14 2.219c2.289 0 4.484.814 6.102 2.265C21.721 5.934 22.63 7.9 22.63 9.95c0 3.173.711 5.548 1.634 7.295 1.178 2.232 1.768 3.347 1.735 3.602-.038.298-.087.38-.33.553-.208.15-1.242.15-3.31.15H5.64c-2.068 0-3.102 0-3.31-.15-.243-.173-.291-.255-.33-.553-.032-.255.557-1.37 1.735-3.602.923-1.747 1.634-4.122 1.634-7.295 0-2.05.91-4.017 2.528-5.467C9.516 3.034 11.71 2.219 14 2.219Zm0 0v.003M9.771 26.383a6.35 6.35 0 0 0 4.235 1.614 6.35 6.35 0 0 0 4.235-1.614"
/></svg>
</button>
<!-- Dropdown menu -->
<div
Expand Down
147 changes: 103 additions & 44 deletions src/app/SideBar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ import { pathRoutes } from "../config/pathRoutes";
href={pathRoutes.users.dashboard}
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="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"
><path d="M2 10a8 8 0 018-8v8h8a8 8 0 11-16 0z"></path><path
d="M12 2.252A8.014 8.014 0 0117.748 8H12V2.252z"></path></svg
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="17" height="17"
fill="none"
viewBox="0 0 25 25"
<path fill="#6B7280"
d="M16.28 25c1.566 0 2.91-.082 4.033-.332 1.138-.253 2.124-.693 2.893-1.462.769-.77 1.21-1.755 1.462-2.893.25-1.123.332-2.467.332-4.033V12.5a2.5 2.5 0 0 0-2.5-2.5h-10a2.5 2.5 0 0 0-2.5 2.5v10a2.5 2.5 0 0 0 2.5 2.5h3.78ZM0 16.28c0 1.566.082 2.91.332 4.033.253 1.138.693 2.124 1.462 2.893.77.769 1.755 1.21 2.892 1.462.11.024.219.047.329.068 1.355.262 2.485-.885 2.485-2.266V12.5A2.5 2.5 0 0 0 5 10H2.5A2.5 2.5 0 0 0 0 12.5v3.78ZM8.72 0C7.153 0 5.81.082 4.686.332c-1.137.253-2.123.693-2.892 1.462-.77.77-1.21 1.755-1.462 2.892l-.06.281C.006 6.341 1.174 7.5 2.573 7.5H22.47c1.38 0 2.528-1.13 2.266-2.485a11.98 11.98 0 0 0-.068-.329c-.253-1.137-.694-2.123-1.463-2.892-.769-.769-1.755-1.21-2.892-1.462C19.19.082 17.846 0 16.279 0H8.72Z"
/></svg>
<span class="ml-3" sidebar-toggle-item>Dashboard</span>
</a>
</li>
Expand All @@ -80,14 +80,14 @@ import { pathRoutes } from "../config/pathRoutes";
href={pathRoutes.organizations.root}
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="w-6 h-6 text-gray-500 dark:text-gray"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
viewBox="0 0 18 20">
<path d="M16 0H4a2 2 0 0 0-2 2v1H1a1 1 0 0 0 0 2h1v2H1a1 1 0 0 0 0 2h1v2H1a1 1 0 0 0 0 2h1v2H1a1 1 0 0 0 0 2h1v1a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2Zm-5.5 4.5a3 3 0 1 1 0 6 3 3 0 0 1 0-6ZM13.929 17H7.071a.5.5 0 0 1-.5-.5 3.935 3.935 0 1 1 7.858 0 .5.5 0 0 1-.5.5Z"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg"
width="17"
height="17"
fill="none"
viewBox="0 0 25 25"
<path fill="#6B7280"
d="M19.898 14.073h3.54c.854 0 1.562.707 1.562 1.561v7.805c0 .854-.708 1.561-1.563 1.561h-7.812a1.572 1.572 0 0 1-1.563-1.561v-7.805c0-.854.708-1.56 1.563-1.56h2.759v-.928H6.59v.927h2.784c.855 0 1.563.707 1.563 1.561v7.805c0 .854-.708 1.561-1.563 1.561H1.562A1.572 1.572 0 0 1 0 23.439v-7.805c0-.854.708-1.56 1.563-1.56h3.515V12.61c0-.537.684-.805 1.294-.805h5.371v-.878h-3.37a1.572 1.572 0 0 1-1.562-1.561V1.56A1.572 1.572 0 0 1 8.373 0h7.813c.855 0 1.562.707 1.562 1.561v7.805a1.57 1.57 0 0 1-1.562 1.56h-2.881v.903c2.026 0 3.272-.024 5.297-.024.61 0 1.294.244 1.294.805v1.463h.002Z"
/></svg>
<span class="ml-3" sidebar-toggle-item>Organizations</span>
</a>
</li>
Expand All @@ -97,14 +97,24 @@ import { pathRoutes } from "../config/pathRoutes";
href={pathRoutes.organizations.users}
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="w-6 h-6 text-gray-500 dark:text-gray"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
viewBox="0 0 18 20">
<path d="M16 0H4a2 2 0 0 0-2 2v1H1a1 1 0 0 0 0 2h1v2H1a1 1 0 0 0 0 2h1v2H1a1 1 0 0 0 0 2h1v2H1a1 1 0 0 0 0 2h1v1a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2Zm-5.5 4.5a3 3 0 1 1 0 6 3 3 0 0 1 0-6ZM13.929 17H7.071a.5.5 0 0 1-.5-.5 3.935 3.935 0 1 1 7.858 0 .5.5 0 0 1-.5.5Z"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg"
width="18"
height="17"
fill="none"
viewBox="0 0 28 28"
<path fill="#6B7280"
fill-rule="evenodd"
d="M4.4 6.8a6.8 6.8 0 1 1 14.399 0 6.8 6.8 0 0 1-14.4 0Z"
clip-rule="evenodd"/> 
<path fill="#6B7280"
d="M18.78 11.303a.316.316 0 0 0 .084.402 5.6 5.6 0 1 0 0-9.008.316.316 0 0 0-.083.403 8.76 8.76 0 0 1 1.012 4.102 8.76 8.76 0 0 1-1.012 4.1Z"/> 
<path fill="#6B7280"
fill-rule="evenodd"
d="M4.216 17.119C6.187 16.263 8.775 16 11.99 16c3.218 0 5.807.264 7.78 1.121 2.148.934 3.454 2.526 4.138 4.773A1.631 1.631 0 0 1 22.348 24H1.635a1.633 1.633 0 0 1-1.563-2.11c.686-2.247 1.994-3.838 4.144-4.771Z"
clip-rule="evenodd"/> 
<path fill="#6B7280"
d="M20.5 15.458c-.662.041-.7.93-.092 1.196 1.668.725 2.924 1.793 3.825 3.155.738 1.118 1.886 1.99 3.226 1.99h2.85c1.13 0 1.957-1.124 1.558-2.222a7.076 7.076 0 0 0-.07-.188c-.549-1.384-1.488-2.402-2.878-3.051-1.306-.61-2.94-.861-4.865-.937l-.032-.001h-.031c-1.134 0-2.319-.015-3.49.058Z"
/></svg>
<span class="ml-3" sidebar-toggle-item>Users</span>
</a>
</li>
Expand Down Expand Up @@ -181,39 +191,88 @@ import { pathRoutes } from "../config/pathRoutes";
aria-controls="dropdown-credentials"
data-collapse-toggle="dropdown-credentials"
>
<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"
><path d="M9 2a1 1 0 000 2h2a1 1 0 100-2H9z"></path><path
fill-rule="evenodd"
d="M4 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v11a2 2 0 01-2 2H6a2 2 0 01-2-2V5zm3 4a1 1 0 000 2h.01a1 1 0 100-2H7zm3 0a1 1 0 000 2h3a1 1 0 100-2h-3zm-3 4a1 1 0 100 2h.01a1 1 0 100-2H7zm3 0a1 1 0 100 2h3a1 1 0 100-2h-3z"
clip-rule="evenodd"></path></svg
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="18"
height="17"
fill="none"
viewBox="0 0 25 25"
<path fill="#6B7280"
d="M23 9.487h-5.27V8.184a.997.997 0 0 0-.999-.999h-1.895v-.818c.872-.685 1.376-1.665 1.376-2.708C16.212 1.64 14.326 0 12.005 0 9.683 0 7.798 1.64 7.798 3.659c0 1.043.504 2.023 1.376 2.708v.818H7.278a.998.998 0 0 0-.999 1v1.302H1a.998.998 0 0 0-.999 1V23A.996.996 0 0 0 1 24h22c.554 0 1-.446 1-1V10.487a1 1 0 0 0-1-.999ZM10.669 4.971c-.549-.318-.877-.808-.877-1.312 0-.901 1.009-1.66 2.209-1.66 1.195 0 2.209.759 2.209 1.66 0 .504-.328.999-.877 1.312a1 1 0 0 0-.5.867V7.18h-1.665V5.838c0-.357-.19-.685-.5-.867ZM8.273 9.184h7.46v2.566h-7.46V9.184Zm13.729 12.818H1.998h14.733L19.5 22l2.497.002h.005Z"
/></svg>
<span
class="flex-1 ml-3 text-left whitespace-nowrap"
sidebar-toggle-item>Credentials</span
>
<svg
sidebar-toggle-item
class="w-6 h-6"
fill="#6B7280"
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-credentials" class="hidden py-2 space-y-2">
<li>

<a
href={pathRoutes.organizations.issuedCredentials}
class="flex items-center p-2 text-base text-gray-500 transition duration-75 rounded-lg pl-11 group hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-700"
>Issuance</a
>
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"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
fill="none"
viewBox="0 0 25 22"
<path stroke="#6B7280"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="1.25"
d="M4 4h3.125M4 6.885h3.125M1 1h15.702M4.695 10h.962m1.453 0h.96m1.422 0h.962m1.452 0h.962M17 1v4.952m0 3.715V13H1V1"/> 
<path fill="#6B7280"
d="M14 5.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0Zm-3.816 0a1.316 1.316 0 1 0 2.632 0 1.316 1.316 0 0 0-2.633 0Z"/> 
<path stroke="#6B7280"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="1.25"
d="M7.164 13.647v1.47h7.53m-6.024.589v2.353h6.526m-4.518.294V21h11.044l3.263-1.177m0 0v-9.705m0 9.705h3.012m-3.012-9.705L23.48 8.353 16.2 6l-1.004.588-.25 1.47.501 1.177 3.263.883.502 1.764 1.004 1.765h1.506m3.263-3.53h3.012"
/></svg>
<span class="ml-2" >Issuance</span>
</a>
</li>
<li>
<a
href={pathRoutes.organizations.credentials}
class="flex items-center p-2 text-base text-gray-500 transition duration-75 rounded-lg pl-11 group hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-700"
>Verification</a
>
</li>
</ul>
</button>
</li>
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"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
fill="none"
viewBox="0 0 25 25"
<path fill="#6B7280"
d="M19.322 8.824h-4.427V7.612c0-.515-.375-.93-.84-.93h-1.592v-.76a3.335 3.335 0 0 0 1.156-2.52C13.62 1.527 12.035 0 10.085 0 8.135 0 6.55 1.526 6.55 3.403c0 .97.424 1.881 1.157 2.519v.76H6.114c-.465 0-.84.415-.84.93v1.212H.84c-.465 0-.839.414-.839.93v11.638c0 .515.374.93.84.93h12.78l-.993-1.86 7.534-7.962V9.753c0-.51-.374-.93-.84-.93Zm-10.36-4.2c-.461-.296-.737-.752-.737-1.221 0-.838.848-1.544 1.856-1.544 1.004 0 1.855.706 1.855 1.544 0 .47-.275.93-.736 1.22a.952.952 0 0 0-.42.807v1.248H9.381V5.43a.958.958 0 0 0-.42-.806ZM6.948 8.54h6.267v2.141H6.949v-2.14Zm5.678 11.922H1.68v-9.78h16.804l.065 1.37 1.21.447h.403l-7.534 7.963Z"/> 
<path fill="#6B7280"
d="M24.997 17.854c0 3.945-2.889 7.143-6.452 7.143s-6.451-3.198-6.451-7.143 2.888-7.143 6.451-7.143c3.563 0 6.452 3.198 6.452 7.143Zm-11.292 0c0 2.96 2.167 5.358 4.84 5.358s4.84-2.399 4.84-5.358c0-2.96-2.167-5.359-4.84-5.359s-4.84 2.4-4.84 5.359Z"/> 
<path stroke="#6B7280"
stroke-linecap="round"
stroke-width="1.5"
d="m15.328 17.984 2.24 2.55 4.48-4.464"
/></svg>
<span class="ml-2" >Verification</span>
</a>
</li>

</ul>
</button>
</li>

<!-- li>
<button
Expand Down
8 changes: 3 additions & 5 deletions src/components/Resources/Schema/ViewSchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@ const ViewSchemas = () => {
setCreateLoader(false)
}
getCredentialDefinitionList(schemaDetails?.schemaId, orgId)
setTimeout(() => {
setSuccess('')
setFailur('')
}, 4000);
}

return (
<div className="px-4 pt-6">
Expand Down Expand Up @@ -280,6 +275,7 @@ const ViewSchemas = () => {
name="tagName"
placeholder="Enter Credential definition"
className="w-full bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500"
disabled={createloader}
/>
{
(formikHandlers?.errors?.tagName && formikHandlers?.touched?.tagName) &&
Expand Down Expand Up @@ -334,13 +330,15 @@ const ViewSchemas = () => {
Create
</Button>
</div>

<div className='float-right p-2'>
<Button
type="reset"
color='bg-primary-800'
onClick={() => {
setCredDefAuto('')
}}
disabled={createloader}
className='bg-secondary-700 ring-primary-700 bg-white-700 hover:bg-secondary-700 ring-2 text-black font-medium rounded-lg text-sm px-4 lg:px-5 py-2 lg:py-2.5 mr-2 ml-auto'

style={{ height: '2.6rem', width: '6rem', minWidth: '2rem' }}
Expand Down
36 changes: 33 additions & 3 deletions src/components/User/UserDashBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import CustomAvatar from '../Avatar'
import { EmptyListMessage } from "../EmptyListComponent";
import type { Organisation } from "../organization/interfaces";
import type { UserActivity } from "./interfaces";
import { apiStatusCodes } from "../../config/CommonConstant";
import { apiStatusCodes, storageKeys } from "../../config/CommonConstant";
import { getOrganizations } from "../../api/organization";
import { getUserActivity } from "../../api/users";
import { getUserInvitations } from "../../api/invitations";
import moment from "moment";
import { pathRoutes } from "../../config/pathRoutes";
import { setToLocalStorage } from "../../api/Auth";

const initialPageState = {
pageNumber: 1,
Expand Down Expand Up @@ -115,6 +116,11 @@ const UserDashBoard = () => {
window.location.href = pathRoutes.users.invitations
}

const goToOrgDashboard = async (orgId: number, roles: string[]) => {
await setToLocalStorage(storageKeys.ORG_ID, orgId.toString());
window.location.href = pathRoutes.organizations.dashboard;
};

return (
<div className="px-4 pt-6">
<div className="cursor-pointer" onClick={redirectToInvitations}>
Expand All @@ -136,12 +142,12 @@ const UserDashBoard = () => {
<div
className=" justify-between p-4 bg-white border border-gray-200 rounded-lg shadow-sm sm:flex dark:border-gray-700 sm:p-6 dark:bg-gray-800"
>
<div className="w-full">
<div className="w-full" >
<h2 className="text-base font-bold text-gray-500 dark:text-gray-400">
Organizations
</h2>

{
{/* {
organizationsList
&& organizationsList.map(org => {
return <div className="pt-4 flex">
Expand All @@ -154,9 +160,33 @@ const UserDashBoard = () => {
</div>
})
} */}


{organizationsList?.map((org) => {
const roles: string[] = org.userOrgRoles.map(role => role.orgRole.name)
org.roles = roles
return (
<div onClick={() => goToOrgDashboard(org?.id, org?.roles)}>
<a
href="#"
className="flex items-center px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white"
>
{org.logoUrl ? (
<CustomAvatar className='dark:text-white' size="25" src={org?.logoUrl} round />
) : (
<CustomAvatar className='dark:text-white' size="25" name={org?.name} round />
)}

<span className="ml-3 text-base font-bold text-gray-500 dark:text-white">{org?.name}</span>
</a>
</div>
)
})
}



<a
href="/organizations"
className="float-right inline-flex items-center p-2 text-sm font-medium rounded-lg text-primary-700 hover:bg-gray-100 dark:text-primary-500 dark:hover:bg-gray-700"
Expand Down
9 changes: 6 additions & 3 deletions src/components/organization/OrganizationsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,14 @@ const OrganizationsList = () => {

<div className="flex items-center justify-end mb-4">

{organizationsList && organizationsList?.length > 0 && (
<Pagination
currentPage={currentPage.pageNumber}
onPageChange={onPageChange}
totalPages={currentPage.total}
currentPage={currentPage.pageNumber}
onPageChange={onPageChange}
totalPages={currentPage.total}
/>
)
}
</div>
</div>
</div>
Expand Down

0 comments on commit 9a7c638

Please sign in to comment.