Skip to content

Commit

Permalink
fix: Unable to store credentials during connection issuance when usin…
Browse files Browse the repository at this point in the history
…g schemas from other organizations. (#754)

* fix: payload changes for connection issuance

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

* fix: refactored logic of API call for org and all schema flag

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

* fix: removed unused imports

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

* fix: changes in  imports

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

* fix: resolved comments on PR

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

---------

Signed-off-by: pranalidhanavade <[email protected]>
  • Loading branch information
pranalidhanavade authored Sep 3, 2024
1 parent 2a9c6da commit 664e1fb
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 24 deletions.
17 changes: 11 additions & 6 deletions src/components/Issuance/BulkIssuance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const BulkIssuance = () => {
const [mounted, setMounted] = useState<boolean>(false)
const [schemaType, setSchemaType]= useState<SchemaTypes>();
const [selectedTemplate, setSelectedTemplate] = useState<any>();
const [isAllSchema, setIsAllSchema] = useState<string>();
const [isAllSchema, setIsAllSchema] = useState<boolean>();
const [schemaListAPIParameters, setSchemaListAPIParameters] = useState({
itemPerPage: itemPerPage,
page: 1,
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -171,6 +174,8 @@ const BulkIssuance = () => {

useEffect(() => {
getSchemaCredentials(schemaListAPIParameters);
}, [isAllSchema]);
useEffect(() => {
setMounted(true);
(async () => {
try {
Expand Down
27 changes: 17 additions & 10 deletions src/components/Issuance/EmailIssuance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const EmailIssuance = () => {
const [credDefId, setCredDefId] = useState<string>();
const [schemasIdentifier, setSchemasIdentifier] = useState<string>();
const [schemaTypeValue, setSchemaTypeValue] = useState<SchemaTypeValue>();
const [isAllSchemaFlagSelected, setIsAllSchemaFlagSelected] = useState<string>();
const [isAllSchemaFlagSelected, setIsAllSchemaFlagSelected] = useState<boolean>();

const getSchemaCredentials = async (schemaListAPIParameter: GetAllSchemaListParameter) => {

Expand All @@ -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)) {
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -168,7 +171,7 @@ const EmailIssuance = () => {
};

useEffect(() => {
getSchemaCredentials(schemaListAPIParameter);
setMounted(true);
(async () => {
try {
Expand All @@ -186,6 +189,10 @@ const EmailIssuance = () => {
}
}, [isEditing]);

useEffect(() => {
getSchemaCredentials(schemaListAPIParameter);
}, [isAllSchemaFlagSelected]);

const confirmOOBCredentialIssuance = async () => {
setIssueLoader(true);

Expand Down
5 changes: 4 additions & 1 deletion src/components/Issuance/Issuance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const IssueCred = () => {
const [w3cSchema, setW3CSchema]= useState<boolean>(false);
const [credentialType, setCredentialType] = useState<CredentialType>();
const [schemaType, setSchemaType] = useState<SchemaTypeValue>();
const [orgDid, setOrgDid]= useState<string>('');

useEffect(() => {
fetchOrganizationDetails();
Expand All @@ -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);
Expand Down Expand Up @@ -330,7 +333,7 @@ const getSelectedUsers = async (): Promise<SelectedUsers[]> => {
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,23 +553,23 @@ const isSubmitButtonDisabled = () => {
</Label>
<ol>
<li className='mb-2'>
<span className='font-semibold text-sm text-gray-800'>Step 1:</span>
<div className='ml-4 text-sm text-gray-700'>
<span className='font-semibold text-sm text-gray-800 dark:text-white'>Step 1:</span>
<div className='ml-4 text-sm text-gray-900 dark:text-white'>
Copy the address and get the free tokens for the testnet.
<div> For eg. use&nbsp;
<a href='https://faucet.polygon.technology/' className='text-blue-900 text-sm underline'>
<a href='https://faucet.polygon.technology/' className='text-blue-900 dark:text-primary-500 text-sm underline'>
https://faucet.polygon.technology/&nbsp;
</a>
to get free token
</div>
</div>
</li>
<li className='mb-2'>
<span className='font-semibold text-sm'>Step 2:</span>
<div className='ml-4 text-sm text-gray-700'>Check that you have recieved the tokens.</div>
<div className='ml-4 text-sm text-gray-700'>For eg. copy the address and check the balance on
<span className='font-semibold text-sm gray-800 dark:text-white'>Step 2:</span>
<div className='ml-4 text-sm text-gray-900 dark:text-white'>Check that you have recieved the tokens.</div>
<div className='ml-4 text-sm text-gray-900 dark:text-white'>For eg. copy the address and check the balance on
<div>
<a href='https://mumbai.polygonscan.com/' className='text-blue-900 text-sm underline'>
<a href='https://mumbai.polygonscan.com/' className='text-blue-900 dark:text-primary-500 text-sm underline'>
https://mumbai.polygonscan.com/&nbsp;
</a>
</div>
Expand Down

0 comments on commit 664e1fb

Please sign in to comment.