From 62c54278b7cfdea132426bafc2a0e8f793ac27ca Mon Sep 17 00:00:00 2001 From: karan Date: Wed, 27 Sep 2023 12:29:17 +0530 Subject: [PATCH 1/4] refactore public profile apis and ui and bug fixes Signed-off-by: karan --- src/api/organization.ts | 21 +------ .../Resources/Schema/SchemasList.tsx | 58 ++++++++++++++++++- .../Verification/SchemaCredDefDetails.tsx | 12 ++-- src/components/Verification/Verification.tsx | 4 +- .../organization/EditOrgdetailsModal.tsx | 4 +- src/components/organization/WalletSpinup.tsx | 4 +- .../publicProfile/OrgUserInfoLayout.astro | 48 +++++---------- .../OrganisationPublicProfile.tsx | 8 ++- .../publicProfile/ProfileDesign.astro | 2 +- .../publicProfile/PublicProfiles.tsx | 22 ------- src/config/apiRoutes.ts | 3 +- src/pages/explore.astro | 1 - src/pages/org/[org].astro | 11 +++- 13 files changed, 100 insertions(+), 98 deletions(-) diff --git a/src/api/organization.ts b/src/api/organization.ts index 2543b8dc7..0397c2447 100644 --- a/src/api/organization.ts +++ b/src/api/organization.ts @@ -1,4 +1,4 @@ -import { axiosGet, axiosPost, axiosPut } from "../services/apiRequests" +import { axiosGet, axiosPost, axiosPublicOrganisationGet, axiosPut } from "../services/apiRequests" import { apiRoutes } from "../config/apiRoutes"; import { getFromLocalStorage } from "./Auth"; @@ -305,23 +305,6 @@ export const createConnection = async (orgName: string) => { // public profile -export const getPublicUsers = async (pageNumber: number, pageSize: number, search :string) => { - - const url = `${apiRoutes.public.users}?pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}` - - const axiosPayload = { - url, - } - - try { - return await axiosPublicUserGet(axiosPayload); - } - catch (error) { - const err = error as Error - return err?.message - } -} - export const getPublicOrganizations = async (pageNumber: number, pageSize: number, search :string) => { const url = `${apiRoutes.public.organizations}?pageNumber=${pageNumber}&pageSize=${pageSize}&search=${search}` @@ -337,7 +320,7 @@ export const getPublicOrganizations = async (pageNumber: number, pageSize: numbe } try { - return await axiosGet(axiosPayload); + return await axiosPublicOrganisationGet(axiosPayload); } catch (error) { const err = error as Error diff --git a/src/components/Resources/Schema/SchemasList.tsx b/src/components/Resources/Schema/SchemasList.tsx index 66c031bb1..1497cdb12 100644 --- a/src/components/Resources/Schema/SchemasList.tsx +++ b/src/components/Resources/Schema/SchemasList.tsx @@ -17,6 +17,7 @@ import type { SchemaDetails } from '../../Verification/interface'; import SearchInput from '../../SearchInput'; import { getFromLocalStorage } from '../../../api/Auth'; import { pathRoutes } from '../../../config/pathRoutes'; +import { getOrganizationById } from '../../../api/organization'; const SchemaList = (props: { schemaSelectionCallback: (schemaId: string, schemaDetails: SchemaDetails) => void; }) => { const [schemaList, setSchemaList] = useState([]) @@ -33,6 +34,7 @@ const SchemaList = (props: { schemaSelectionCallback: (schemaId: string, schemaD allSearch: "" }) + const [walletStatus, setWalletStatus]=useState(false) const [totalItem, setTotalItem] = useState(0) const getSchemaList = async (schemaListAPIParameter: GetAllSchemaListParameter, flag: boolean) => { try { @@ -122,6 +124,23 @@ const SchemaList = (props: { schemaSelectionCallback: (schemaId: string, schemaD } }; + const fetchOrganizationDetails = async () => { + setLoading(true) + const orgId = await getFromLocalStorage(storageKeys.ORG_ID) + const response = await getOrganizationById(orgId as string); + const { data } = response as AxiosResponse + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + if (data?.data?.org_agents && data?.data?.org_agents?.length > 0) { + setWalletStatus(true) + } + } + setLoading(false) +} + +useEffect(()=>{ + fetchOrganizationDetails() +},[]) + return (
@@ -154,7 +173,7 @@ const SchemaList = (props: { schemaSelectionCallback: (schemaId: string, schemaD
- + : + + + + +
+ } + onClickEvent={() => { + window.location.href = `${pathRoutes.organizations.dashboard}?OrgId=${orgId}` + }} + />}
@@ -214,7 +248,10 @@ const SchemaList = (props: { schemaSelectionCallback: (schemaId: string, schemaD totalPages={Math.ceil(totalItem / schemaListAPIParameter?.itemPerPage)} />)} - ) : () : ( +
+ {walletStatus ? + { window.location.href = `${pathRoutes.organizations.createSchema}?OrgId=${orgId}` }} - />) + /> + : + + + } + onClick={() => { + window.location.href = `${pathRoutes.organizations.dashboard}?OrgId=${orgId}` + }} + />} + +
+ ) } diff --git a/src/components/Verification/SchemaCredDefDetails.tsx b/src/components/Verification/SchemaCredDefDetails.tsx index 15c08b10e..3d1e68654 100644 --- a/src/components/Verification/SchemaCredDefDetails.tsx +++ b/src/components/Verification/SchemaCredDefDetails.tsx @@ -7,15 +7,15 @@ const SchemaCredDefDetails = ({ schemaCredDefList }: SchemaCredDefProps) => { return ( <> - {schemaCredDefList.map((item, index) => ( -
+ {schemaCredDefList.map((item) => ( +
Schema Id
-
:
{' '} -
+
:
{' '} +
{Object.values(item)[2]}
@@ -28,9 +28,9 @@ const SchemaCredDefDetails = ({ schemaCredDefList }: SchemaCredDefProps) => { {' '} :
{' '} -
+
{Object.values(item)[1] - ? Object.values(item)[1].slice(0, 36) + ? Object.values(item)[1] : ''}
diff --git a/src/components/Verification/Verification.tsx b/src/components/Verification/Verification.tsx index 213fbe8c2..1b1adc76d 100644 --- a/src/components/Verification/Verification.tsx +++ b/src/components/Verification/Verification.tsx @@ -28,7 +28,7 @@ interface VerifyCredentialPayload { connectionId: string; attributes: Array<{ attributeName: string; - credDefId: string; + credDefId?: string ; }>; comment: string; orgId: number; @@ -56,7 +56,7 @@ const VerificationCred = () => { const schemaAttributes = await getFromLocalStorage(storageKeys.SCHEMA_ATTR) const parsedSchemaDetails = JSON.parse(schemaAttributes) || []; const attributes = parsedSchemaDetails.attribute.map((ele: any) => { - const attributes = ele.attributeName ? ele.attributeName : 'Not available'; + const attributes = ele.displayName ? ele.displayName : 'Not available'; return { data: [ { diff --git a/src/components/organization/EditOrgdetailsModal.tsx b/src/components/organization/EditOrgdetailsModal.tsx index f37487ef2..181c63abd 100644 --- a/src/components/organization/EditOrgdetailsModal.tsx +++ b/src/components/organization/EditOrgdetailsModal.tsx @@ -223,8 +223,8 @@ const EditOrgdetailsModal = (props: EditOrgdetailsModalProps) => { .trim(), description: yup .string() - .min(2, 'Organization description must be at least 2 characters') - .max(255, 'Organization description must be at most 255 characters') + .min(2, 'Description must be at least 2 characters') + .max(255, 'Description must be at most 255 characters') .required('Description is required') })} validateOnBlur diff --git a/src/components/organization/WalletSpinup.tsx b/src/components/organization/WalletSpinup.tsx index 7f7dfc016..574106287 100644 --- a/src/components/organization/WalletSpinup.tsx +++ b/src/components/organization/WalletSpinup.tsx @@ -305,7 +305,9 @@ const WalletSpinup = (props: { .matches( /^[A-Za-z0-9-][^ !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]*$/, 'Wallet label must be alphanumeric only', - ), + ) + .min(2, 'Wallet label must be at least 2 characters') + .max(25, 'Wallet label must be at most 25 characters'), })} validateOnBlur validateOnChange diff --git a/src/components/publicProfile/OrgUserInfoLayout.astro b/src/components/publicProfile/OrgUserInfoLayout.astro index 4aafa1197..169294fbf 100644 --- a/src/components/publicProfile/OrgUserInfoLayout.astro +++ b/src/components/publicProfile/OrgUserInfoLayout.astro @@ -1,5 +1,6 @@ --- interface UserDetails { + profileImg: string; lastName: string; firstName: string; email: string; @@ -7,6 +8,7 @@ interface UserDetails { id: number; username: string; } +import CustomAvatar from "../../components/Avatar" const { orgUsersData } = Astro.props; --- {orgUsersData && @@ -19,46 +21,26 @@ const { orgUsersData } = Astro.props; orgUsersData?.map((orgUser: UserDetails) => { return ( <> -
+
{orgUser.firstName && - - - - - - - - - - - - - - + + { orgUser?.profileImg ? ( + + ) : ( + + )} +
{orgUser.firstName} {orgUser.lastName} -
} +
+ }
-
+
{orgUser.email && -

{orgUser.email}

+

{orgUser.email}

}
diff --git a/src/components/publicProfile/OrganisationPublicProfile.tsx b/src/components/publicProfile/OrganisationPublicProfile.tsx index bb6d2953d..d5834913d 100644 --- a/src/components/publicProfile/OrganisationPublicProfile.tsx +++ b/src/components/publicProfile/OrganisationPublicProfile.tsx @@ -5,7 +5,7 @@ import { getPublicOrganizations } from '../../api/organization'; import type { AxiosResponse } from 'axios'; import { apiStatusCodes } from '../../config/CommonConstant'; import SearchInput from '../SearchInput'; -import { Button, Card, Pagination } from 'flowbite-react'; +import { Card, Pagination } from 'flowbite-react'; import CustomSpinner from '../CustomSpinner'; import CustomAvatar from '../Avatar'; import { EmptyListMessage } from '../EmptyListComponent'; @@ -132,14 +132,16 @@ const OrganisationPublicProfile = () => { )}
) : ( - organizationsList && ( +
+ {organizationsList && (
- ) + )} +
)}
diff --git a/src/components/publicProfile/ProfileDesign.astro b/src/components/publicProfile/ProfileDesign.astro index 8951b01cc..544d3ebd5 100644 --- a/src/components/publicProfile/ProfileDesign.astro +++ b/src/components/publicProfile/ProfileDesign.astro @@ -20,7 +20,7 @@ import CustomAvatar from "../../components/Avatar" - {orgData?.website} + {orgData?.website} }

{orgData?.description}

diff --git a/src/components/publicProfile/PublicProfiles.tsx b/src/components/publicProfile/PublicProfiles.tsx index f89513402..830243c03 100644 --- a/src/components/publicProfile/PublicProfiles.tsx +++ b/src/components/publicProfile/PublicProfiles.tsx @@ -1,6 +1,5 @@ 'use client'; -import PublicUserList from './PublicUserList'; import OrganisationPublicProfile from './OrganisationPublicProfile'; const PublicProfile = () => { @@ -27,19 +26,6 @@ const PublicProfile = () => { Organisations -
  • - -
  • @@ -51,14 +37,6 @@ const PublicProfile = () => { >
    -
    - -
    diff --git a/src/config/apiRoutes.ts b/src/config/apiRoutes.ts index a1d650476..cb9353209 100644 --- a/src/config/apiRoutes.ts +++ b/src/config/apiRoutes.ts @@ -67,7 +67,6 @@ export const apiRoutes = { getAllSchemaFromPlatform: '/platform/schemas', }, public:{ - organizations: '/organization/public-profiles', - users:'/users/public-profiles', + organizations: '/orgs/public-profile', } } diff --git a/src/pages/explore.astro b/src/pages/explore.astro index 8edab03cc..a4d4a52d2 100644 --- a/src/pages/explore.astro +++ b/src/pages/explore.astro @@ -1,6 +1,5 @@ --- import PublicProfile from "../components/publicProfile/PublicProfiles" -import PublicProfileLayout from "../app/PublicProfileLayout.astro" import LayoutCommon from "../app/LayoutCommon.astro"; --- diff --git a/src/pages/org/[org].astro b/src/pages/org/[org].astro index fae0c9afd..0cb46146c 100644 --- a/src/pages/org/[org].astro +++ b/src/pages/org/[org].astro @@ -7,12 +7,17 @@ import OrgUserInfoLayout from '../../components/publicProfile/OrgUserInfoLayout. const { org } = Astro.params; const baseUrl = process.env.PUBLIC_BASE_URL || import.meta.env.PUBLIC_BASE_URL const response = await fetch( - `${baseUrl}/organization/public-profiles/${org}`, + `${baseUrl}/orgs/public-profiles/${org}`, ); const data = await response?.json(); - const orgData = data?.data; -const orgUsersData = orgData?.userOrgRoles?.map( +const orgUsersFilterByRole = orgData?.userOrgRoles?.filter( + (users: { orgRole: {name:string}; }) => { + return users?.orgRole.name === "owner" + }, +); + +const orgUsersData = orgUsersFilterByRole?.map( (users: { user: { firstName: string } }) => { return users?.user; }, From d064653d58bec17479d8a09688bc96c37eda66a4 Mon Sep 17 00:00:00 2001 From: karan Date: Mon, 2 Oct 2023 12:58:48 +0530 Subject: [PATCH 2/4] removed sonar code smell Signed-off-by: karan --- src/components/Resources/Schema/SchemasList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Resources/Schema/SchemasList.tsx b/src/components/Resources/Schema/SchemasList.tsx index f17a6fd55..8d8db0cbc 100644 --- a/src/components/Resources/Schema/SchemasList.tsx +++ b/src/components/Resources/Schema/SchemasList.tsx @@ -127,7 +127,7 @@ const SchemaList = (props: { schemaSelectionCallback: (schemaId: string, schemaD const fetchOrganizationDetails = async () => { setLoading(true) const orgId = await getFromLocalStorage(storageKeys.ORG_ID) - const response = await getOrganizationById(orgId as string); + const response = await getOrganizationById(orgId); const { data } = response as AxiosResponse if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { if (data?.data?.org_agents && data?.data?.org_agents?.length > 0) { From 75e6eca9f65878bd26c404538bc4abb56580e34c Mon Sep 17 00:00:00 2001 From: karan Date: Tue, 3 Oct 2023 15:52:51 +0530 Subject: [PATCH 3/4] added scroll and dark mode Signed-off-by: karan --- src/components/Verification/ProofRequestPopup.tsx | 2 +- src/components/Verification/SchemaCredDefDetails.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Verification/ProofRequestPopup.tsx b/src/components/Verification/ProofRequestPopup.tsx index 8ed725d20..f2561a07b 100644 --- a/src/components/Verification/ProofRequestPopup.tsx +++ b/src/components/Verification/ProofRequestPopup.tsx @@ -91,7 +91,7 @@ const ProofRequest = (props: { Close modal
    -

    +

    {' '} Verification Details

    diff --git a/src/components/Verification/SchemaCredDefDetails.tsx b/src/components/Verification/SchemaCredDefDetails.tsx index 939be9fe9..a945660a6 100644 --- a/src/components/Verification/SchemaCredDefDetails.tsx +++ b/src/components/Verification/SchemaCredDefDetails.tsx @@ -15,7 +15,7 @@ const SchemaCredDefDetails = ({ schemaCredDefList }: SchemaCredDefProps) => { Schema Id
    :
    {' '} -
    {Object.values(item)[2]}
    @@ -29,7 +29,7 @@ const SchemaCredDefDetails = ({ schemaCredDefList }: SchemaCredDefProps) => { {' '} : {' '} -
    +
    {Object.values(item)[1] ? Object.values(item)[1] : ''} From 7a48babfdc800fda8f94c9d2e3603b28375f6527 Mon Sep 17 00:00:00 2001 From: karan Date: Tue, 3 Oct 2023 16:17:11 +0530 Subject: [PATCH 4/4] removed unwanted code Signed-off-by: karan --- src/components/Verification/SchemaCredDefDetails.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Verification/SchemaCredDefDetails.tsx b/src/components/Verification/SchemaCredDefDetails.tsx index a945660a6..d1cf1b9d2 100644 --- a/src/components/Verification/SchemaCredDefDetails.tsx +++ b/src/components/Verification/SchemaCredDefDetails.tsx @@ -8,15 +8,15 @@ const SchemaCredDefDetails = ({ schemaCredDefList }: SchemaCredDefProps) => { return ( <> {schemaCredDefList.map((item) => ( -
    +
    Schema Id
    :
    {' '} -
    +
    {Object.values(item)[2]}
    @@ -29,7 +29,7 @@ const SchemaCredDefDetails = ({ schemaCredDefList }: SchemaCredDefProps) => { {' '} :
    {' '} -
    +
    {Object.values(item)[1] ? Object.values(item)[1] : ''}