Skip to content

Commit

Permalink
fix: routes changes for verifcation with email flow (#739)
Browse files Browse the repository at this point in the history
* refactor: parameter name

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

* refactor: added query parameter

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

* fix: remove unnecessary code

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

* fix: query param issue

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

* fix: css issues

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

* fix: create did button restrictions

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

---------

Signed-off-by: bhavanakarwade <[email protected]>
  • Loading branch information
bhavanakarwade authored Aug 26, 2024
1 parent a22ec34 commit 48b580b
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 103 deletions.
78 changes: 35 additions & 43 deletions src/components/Verification/AttributesListData.tsx
Original file line number Diff line number Diff line change
@@ -1,54 +1,46 @@
import { Card } from 'flowbite-react';
import CopyDid from '../../commonComponents/CopyDid';

interface AttributesListProps {
attributeDataList: { entity: string; properties: any[] }[]
attributeDataList: { [key: string]: any }[]
}

const AttributesListData = ({attributeDataList}: AttributesListProps): JSX.Element => {
return (
<>
<Card >
<div className="flex h-full flex-col justify-center gap-0 sm:p-0">
<div className="flex border-b">
<div className="w-5/12 font-semibold flex truncate md:pl-1 sm:mr-8 md:mr-0 text-primary-700 dark:bg-gray-800 text-xl">
Attributes
</div>
<div className="w-1/12 font-semibold flex justify-start truncate md:pl-1 sm:mr-8 md:mr-0 text-primary-700 dark:bg-gray-800 text-xl">
</div>
<div className="w-6/12 font-semibold flex truncate sm:pl-4 text-primary-700 dark:bg-gray-800 text-xl">
{' '}
Values
</div>
</div>
const AttributesListData = ({ attributeDataList }: AttributesListProps): JSX.Element => {

{
attributeDataList?.map((item, index) => (
<div
key={item?.entity + 1}
className="flex w-full"
>
<div
className={`flex w-full text-lg`}
>
<div className="w-5/12 m-1 p-1 text-start text-gray-700 dark:text-white text-lg">
{item?.entity}
</div>
<div className="w-1/12 m-1 p-1 flex items-center text-gray-700 dark:text-white text-lg">
:
</div>
<div className="w-6/12 m-1 truncate p-1 flex justify-start text-gray-700 dark:text-white text-lg">
{item?.properties.join(', ')}
return (
<>
{attributeDataList?.map((item, index) => (
<Card key={index} className="mb-4">
<div className="flex flex-col justify-start gap-2 p-4">
<div className="flex justify-start text-xl font-semibold text-gray-900 dark:text-white mb-2">
{`Credential ${index + 1}`}
</div>


{Object.entries(item).map(([key, value], idx) => (
<div key={idx} className="flex w-full text-lg items-center">
<div className="w-3/12 font-semibold text-primary-700 dark:bg-gray-800 m-1 p-1 flex justify-start items-center text-start">
{key}
</div>
<div className="flex items-center p-1 m-1">
:
</div>
<div className="w-9/12 m-1 text-start text-gray-600 dark:text-white items-center cursor-pointer overflow-auto">
{key === 'schemaId' || key === 'credDefId' ? (
<div className="flex items-center">
<CopyDid value={value} className="truncate font-courier mt-2" />
</div>
</div>
) : (
<span className="truncate font-courier">{value}</span>
)}
</div>
))
}

</div>
))}
</div>
</Card>
))}
</>
);
}

</>
)
}

export default AttributesListData;
export default AttributesListData;
13 changes: 7 additions & 6 deletions src/components/Verification/EmailAttributesSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@ const EmailAttributesSelection = () => {

const handleAttributeChange = async (
attributeName: string,
schemaId: string | undefined,
changeType: 'checkbox' | 'input' | 'select',
value: string | boolean,
schemaId?: string | undefined,
credDefId?: string | undefined
) => {
const updatedAttributes = attributeData?.map(attribute => {
if (attribute.attributeName === attributeName && attribute.schemaId === schemaId) {
if (attribute.attributeName === attributeName && attribute.schemaId === schemaId && attribute.credDefId === credDefId) {
switch (changeType) {
case 'checkbox':
return {
...attribute,
isChecked: value as boolean,
value: attribute?.value || '',
value: (value as boolean) ? attribute.value : '',
selectedOption: attribute?.condition || 'Select',
inputError: '',
selectError: '',
Expand Down Expand Up @@ -255,7 +256,7 @@ const EmailAttributesSelection = () => {
showCheckbox={true}
isVerificationUsingEmail={true}
onChange={(checked: boolean) => {
handleAttributeChange(attribute?.attributeName, attribute?.schemaId, 'checkbox', checked);
handleAttributeChange(attribute?.attributeName, 'checkbox', checked, attribute?.schemaId, attribute?.credDefId);
}}
/>
</div>
Expand All @@ -270,7 +271,7 @@ const EmailAttributesSelection = () => {
disabled={!attribute?.isChecked}
value={attribute?.selectedOption}
onChange={(e) =>
handleAttributeChange(attribute?.attributeName, attribute?.schemaId, 'select', e.target.value)
handleAttributeChange(attribute?.attributeName, 'select', e.target.value, attribute?.schemaId, attribute?.credDefId)
}
className={`${!attribute?.isChecked
? 'opacity-50 cursor-not-allowed'
Expand Down Expand Up @@ -302,7 +303,7 @@ const EmailAttributesSelection = () => {
type="number"
value={attribute?.value}
onChange={(e) =>
handleAttributeChange(attribute?.attributeName, attribute?.schemaId, 'input', e.target.value)
handleAttributeChange(attribute?.attributeName, 'input', e.target.value, attribute?.schemaId, attribute?.credDefId)
}
disabled={!attribute?.isChecked}
className={`${!attribute?.isChecked
Expand Down
13 changes: 5 additions & 8 deletions src/components/Verification/ProofRequestPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@ const ProofRequest = (props: IProofRrquestDetails) => {
) : (
<div className=" text-gray-500 dark:text-gray-300 w-full">
<div className="mt-1 ">
<AttributesListData attributeDataList={aggregatedData} />
<SchemaCredDefDetails
schemaCredDefList={props?.userData?.slice(0, 1)}
/>

<AttributesListData attributeDataList={props?.userData} />

</div>
</div>
)}
Expand Down Expand Up @@ -204,11 +203,9 @@ const ProofRequest = (props: IProofRrquestDetails) => {
) : (
<div className=" text-gray-500 dark:text-gray-300 w-full">
<div className="mt-1">
<AttributesListData attributeDataList={aggregatedData} />
<AttributesListData attributeDataList={props?.userData} />


<SchemaCredDefDetails
schemaCredDefList={props?.userData?.slice(0, 1)}
/>
</div>
</div>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Verification/VerificationDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const VerificationDashboard = () => {
<Dashboard
title="Verify Credential"
options={options}
backButtonPath={pathRoutes.organizations.issuedCredentials}
backButtonPath={pathRoutes.organizations.credentials}
/>
);
};
Expand Down
12 changes: 6 additions & 6 deletions src/config/pathRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ export const pathRoutes = {
},
verification: {
requestProof: '/organizations/verification/verify-credentials',
email: '/organizations/verification/verify-credentials/email/schemas',
email: '/organizations/verification/verify-credentials/schema',
schema: '/organizations/verification/verify-credentials/schemas',
credDef: '/organizations/verification/verify-credentials/schemas/cred-defs',
w3cAttributes: '/organizations/verification/verify-credentials/email/schemas/attributes',
attributes: '/organizations/verification/verify-credentials/email/schemas/cred-defs/attributes',
emailVerification: '/organizations/verification/verify-credentials/email/schemas/cred-defs/attributes/verification-email',
w3cEmailVerification: '/organizations/verification/verify-credentials/email/schemas/attributes/verification-email',
emailCredDef: '/organizations/verification/verify-credentials/email/schemas/cred-defs',
w3cAttributes: '/organizations/verification/verify-credentials/schema/attributes',
attributes: '/organizations/verification/verify-credentials/schema/cred-defs/attributes',
emailVerification: '/organizations/verification/verify-credentials/schema/cred-defs/attributes/verification-email',
w3cEmailVerification: '/organizations/verification/verify-credentials/schema/attributes/verification-email',
emailCredDef: '/organizations/verification/verify-credentials/schema/cred-defs',
connections: '/organizations/verification/verify-credentials/schemas/cred-defs/connections',
W3CConnections: '/organizations/verification/verify-credentials/schemas/connections',

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import LayoutSidebar from "../../../../../../../../app/LayoutSidebar.astro";
import EmailAttributesSelection from "../../../../../../../../components/Verification/EmailAttributesSelection";
import { checkUserSession } from "../../../../../../../../utils/check-session";
import LayoutSidebar from "../../../../../../app/LayoutSidebar.astro";
import EmailAttributesSelection from "../../../../../../components/Verification/EmailAttributesSelection";
import { checkUserSession } from "../../../../../../utils/check-session";
const response = await checkUserSession({cookies: Astro.cookies, currentPath: Astro.url.pathname});
if (!response.authorized) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
---
import LayoutSidebar from "../../../../../../../app/LayoutSidebar.astro";
import EmailCredDefSelection from "../../../../../../../components/Verification/EmailCredDefSelection";
import { pathRoutes } from "../../../../../../../config/pathRoutes";
import EmailVerification from "../../../../../../../components/Verification/EmailVerification";
import { checkUserSession } from "../../../../../../../utils/check-session";
const response = await checkUserSession({cookies: Astro.cookies, currentPath: Astro.url.pathname});
const route: string = pathRoutes.auth.sinIn
if (!response.authorized) {
return Astro.redirect(response.redirect);
}
---

<LayoutSidebar notFoundPage={!response.permitted}>
<EmailCredDefSelection client:load/>
<EmailVerification client:load />
</LayoutSidebar>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import LayoutSidebar from "../../../../../../../../app/LayoutSidebar.astro";
import EmailVerification from "../../../../../../../../components/Verification/EmailVerification";
import { checkUserSession } from "../../../../../../../../utils/check-session";
const response = await checkUserSession({cookies: Astro.cookies, currentPath: Astro.url.pathname});
if (!response.authorized) {
return Astro.redirect(response.redirect);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
import LayoutSidebar from "../../../../../../app/LayoutSidebar.astro";
import EmailSchemaSelection from "../../../../../../components/Verification/EmailSchemaSelection";
import EmailCredDefSelection from "../../../../../../components/Verification/EmailCredDefSelection";
import { pathRoutes } from "../../../../../../config/pathRoutes";
import { checkUserSession } from "../../../../../../utils/check-session";
const response = await checkUserSession({cookies: Astro.cookies, currentPath: Astro.url.pathname});
const route: string = pathRoutes.auth.sinIn
if (!response.authorized) {
Expand All @@ -12,5 +13,5 @@ if (!response.authorized) {
---

<LayoutSidebar notFoundPage={!response.permitted}>
<EmailSchemaSelection client:load/>
<EmailCredDefSelection client:load/>
</LayoutSidebar>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
import LayoutSidebar from "../../../../../app/LayoutSidebar.astro";
import EmailSchemaSelection from "../../../../../components/Verification/EmailSchemaSelection";
import { pathRoutes } from "../../../../../config/pathRoutes";
import { checkUserSession } from "../../../../../utils/check-session";
const response = await checkUserSession({cookies: Astro.cookies, currentPath: Astro.url.pathname});
const route: string = pathRoutes.auth.sinIn
if (!response.authorized) {
return Astro.redirect(response.redirect);
}
---

<LayoutSidebar notFoundPage={!response.permitted}>
<EmailSchemaSelection client:load/>
</LayoutSidebar>

0 comments on commit 48b580b

Please sign in to comment.