From 664e1fb5419bb28693790c5eaab49d6a686f9cca Mon Sep 17 00:00:00 2001 From: pranalidhanavade <137780597+pranalidhanavade@users.noreply.github.com> Date: Tue, 3 Sep 2024 11:22:37 +0530 Subject: [PATCH] fix: Unable to store credentials during connection issuance when using schemas from other organizations. (#754) * fix: payload changes for connection issuance Signed-off-by: pranalidhanavade * fix: refactored logic of API call for org and all schema flag Signed-off-by: pranalidhanavade * fix: removed unused imports Signed-off-by: pranalidhanavade * fix: changes in imports Signed-off-by: pranalidhanavade * fix: resolved comments on PR Signed-off-by: pranalidhanavade --------- Signed-off-by: pranalidhanavade --- src/components/Issuance/BulkIssuance.tsx | 17 +++++++----- src/components/Issuance/EmailIssuance.tsx | 27 ++++++++++++------- src/components/Issuance/Issuance.tsx | 5 +++- .../walletCommonComponents/DedicatedAgent.tsx | 14 +++++----- 4 files changed, 39 insertions(+), 24 deletions(-) diff --git a/src/components/Issuance/BulkIssuance.tsx b/src/components/Issuance/BulkIssuance.tsx index 709db7f74..b6a9210ca 100644 --- a/src/components/Issuance/BulkIssuance.tsx +++ b/src/components/Issuance/BulkIssuance.tsx @@ -48,7 +48,7 @@ const BulkIssuance = () => { const [mounted, setMounted] = useState(false) const [schemaType, setSchemaType]= useState(); const [selectedTemplate, setSelectedTemplate] = useState(); - const [isAllSchema, setIsAllSchema] = useState(); + const [isAllSchema, setIsAllSchema] = useState(); const [schemaListAPIParameters, setSchemaListAPIParameters] = useState({ itemPerPage: itemPerPage, page: 1, @@ -80,7 +80,12 @@ const BulkIssuance = () => { const orgDid = await getFromLocalStorage(storageKeys.ORG_DID); const isAllSchemaSelectedFlag = await getFromLocalStorage(storageKeys.ALL_SCHEMAS) - setIsAllSchema(isAllSchemaSelectedFlag) + if(isAllSchemaSelectedFlag === `false` || !isAllSchemaSelectedFlag){ + setIsAllSchema(false) + } + else if(isAllSchemaSelectedFlag ==='true'){ + setIsAllSchema(true) + } let currentSchemaType = schemaType; @@ -91,7 +96,7 @@ const BulkIssuance = () => { } setSchemaType(currentSchemaType); - if ((currentSchemaType === SchemaTypes.schema_INDY && isAllSchemaSelectedFlag === 'true') || (currentSchemaType && orgId && isAllSchemaSelectedFlag =='false')) { + if ((currentSchemaType === SchemaTypes.schema_INDY && isAllSchema) || (currentSchemaType && orgId && !isAllSchema)) { const response = await getSchemaCredDef(currentSchemaType); const { data } = response as AxiosResponse; @@ -126,9 +131,7 @@ const BulkIssuance = () => { } setLoading(false); } - - - else if (currentSchemaType === SchemaTypes.schema_W3C && orgId && isAllSchemaSelectedFlag === 'true') { + else if (currentSchemaType === SchemaTypes.schema_W3C && orgId && isAllSchema) { const response = await getAllSchemas(schemaListAPIParameters,currentSchemaType); @@ -171,6 +174,8 @@ const BulkIssuance = () => { useEffect(() => { getSchemaCredentials(schemaListAPIParameters); + }, [isAllSchema]); + useEffect(() => { setMounted(true); (async () => { try { diff --git a/src/components/Issuance/EmailIssuance.tsx b/src/components/Issuance/EmailIssuance.tsx index 8841e5a0a..08e366944 100644 --- a/src/components/Issuance/EmailIssuance.tsx +++ b/src/components/Issuance/EmailIssuance.tsx @@ -60,7 +60,7 @@ const EmailIssuance = () => { const [credDefId, setCredDefId] = useState(); const [schemasIdentifier, setSchemasIdentifier] = useState(); const [schemaTypeValue, setSchemaTypeValue] = useState(); - const [isAllSchemaFlagSelected, setIsAllSchemaFlagSelected] = useState(); + const [isAllSchemaFlagSelected, setIsAllSchemaFlagSelected] = useState(); const getSchemaCredentials = async (schemaListAPIParameter: GetAllSchemaListParameter) => { @@ -70,7 +70,13 @@ const EmailIssuance = () => { const orgDid = await getFromLocalStorage(storageKeys.ORG_DID); const allSchemaSelectedFlag = await getFromLocalStorage(storageKeys.ALL_SCHEMAS) - setIsAllSchemaFlagSelected(allSchemaSelectedFlag) + if(allSchemaSelectedFlag === `false` || !allSchemaSelectedFlag){ + setIsAllSchemaFlagSelected(false) + } + else if(allSchemaSelectedFlag ==='true'){ + setIsAllSchemaFlagSelected(true) + + } let currentSchemaType = schemaType; if (orgDid?.includes(DidMethod.POLYGON)) { @@ -88,10 +94,8 @@ const EmailIssuance = () => { setCredentialType(CredentialType.INDY) currentSchemaType = SchemaTypes.schema_INDY; } - setSchemaType(currentSchemaType); - - if((currentSchemaType === SchemaTypes.schema_INDY && orgId && allSchemaSelectedFlag === 'true') || (currentSchemaType && allSchemaSelectedFlag === 'false')){ + if((currentSchemaType === SchemaTypes.schema_INDY && orgId && isAllSchemaFlagSelected ) || (currentSchemaType && !isAllSchemaFlagSelected)){ const response = await getSchemaCredDef(currentSchemaType); const { data } = response as AxiosResponse; @@ -127,10 +131,9 @@ const EmailIssuance = () => { } setLoading(false); } - - - else if (currentSchemaType === SchemaTypes.schema_W3C && orgId && allSchemaSelectedFlag === 'true') { - const response = await getAllSchemas(schemaListAPIParameter,currentSchemaType); + + else if (currentSchemaType === SchemaTypes.schema_W3C && orgId && allSchemaSelectedFlag) { + const response = await getAllSchemas(schemaListAPIParameter,currentSchemaType); const { data } = response as AxiosResponse; if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { @@ -168,7 +171,7 @@ const EmailIssuance = () => { }; useEffect(() => { - getSchemaCredentials(schemaListAPIParameter); + setMounted(true); (async () => { try { @@ -186,6 +189,10 @@ const EmailIssuance = () => { } }, [isEditing]); + useEffect(() => { + getSchemaCredentials(schemaListAPIParameter); + }, [isAllSchemaFlagSelected]); + const confirmOOBCredentialIssuance = async () => { setIssueLoader(true); diff --git a/src/components/Issuance/Issuance.tsx b/src/components/Issuance/Issuance.tsx index 720790535..2b8e283fc 100644 --- a/src/components/Issuance/Issuance.tsx +++ b/src/components/Issuance/Issuance.tsx @@ -55,6 +55,7 @@ const IssueCred = () => { const [w3cSchema, setW3CSchema]= useState(false); const [credentialType, setCredentialType] = useState(); const [schemaType, setSchemaType] = useState(); + const [orgDid, setOrgDid]= useState(''); useEffect(() => { fetchOrganizationDetails(); @@ -75,12 +76,14 @@ const IssueCred = () => { setCredentialType(CredentialType.JSONLD); setSchemaType(SchemaTypeValue.POLYGON) await getSchemaAndUsers(true) + setOrgDid(did); } else if (did?.includes(DidMethod.KEY) || did?.includes(DidMethod.WEB)) { setW3CSchema(true); setSchemaType(SchemaTypeValue.NO_LEDGER) setCredentialType(CredentialType.JSONLD); await getSchemaAndUsers(true) + setOrgDid(did); } else if (did?.includes(DidMethod.INDY)) { setW3CSchema(false); @@ -330,7 +333,7 @@ const getSelectedUsers = async (): Promise => { w3cSchemaDetails.schemaName ], issuer: { - "id": w3cSchemaDetails.issuerDid + "id": orgDid }, issuanceDate: new Date().toISOString(), //FIXME: Logic for passing default value as 0 for empty value of number dataType attributes. diff --git a/src/components/organization/walletCommonComponents/DedicatedAgent.tsx b/src/components/organization/walletCommonComponents/DedicatedAgent.tsx index 3ab8d7a08..70661405b 100644 --- a/src/components/organization/walletCommonComponents/DedicatedAgent.tsx +++ b/src/components/organization/walletCommonComponents/DedicatedAgent.tsx @@ -553,11 +553,11 @@ const isSubmitButtonDisabled = () => {
  1. - Step 1: -
    + Step 1: +
    Copy the address and get the free tokens for the testnet.
    For eg. use  - + https://faucet.polygon.technology/  to get free token @@ -565,11 +565,11 @@ const isSubmitButtonDisabled = () => {
  2. - Step 2: -
    Check that you have recieved the tokens.
    -
    For eg. copy the address and check the balance on + Step 2: +
    Check that you have recieved the tokens.
    +
    For eg. copy the address and check the balance on