diff --git a/src/components/Ecosystem/Endorsement/index.tsx b/src/components/Ecosystem/Endorsement/index.tsx index 138030654..47681e953 100644 --- a/src/components/Ecosystem/Endorsement/index.tsx +++ b/src/components/Ecosystem/Endorsement/index.tsx @@ -2,7 +2,7 @@ import { Alert, Pagination } from 'flowbite-react'; import { useEffect, useState } from 'react'; import type { ChangeEvent } from 'react'; -import { apiStatusCodes, storageKeys } from '../../../config/CommonConstant'; +import { apiStatusCodes, itemPerPage, storageKeys } from '../../../config/CommonConstant'; import EndorsementPopup from './EndorsementPopup'; import type { AxiosResponse } from 'axios'; import BreadCrumbs from '../../BreadCrumbs'; @@ -36,7 +36,7 @@ const EndorsementList = () => { const [orgId, setOrgId] = useState(''); const [endorsementListAPIParameter, setEndorsementListAPIParameter] = useState({ - itemPerPage: 9, + itemPerPage: itemPerPage, page: 1, search: '', sortBy: 'id', diff --git a/src/components/Issuance/BulkIssuance.tsx b/src/components/Issuance/BulkIssuance.tsx index 1410f23d6..8a209bf50 100644 --- a/src/components/Issuance/BulkIssuance.tsx +++ b/src/components/Issuance/BulkIssuance.tsx @@ -7,7 +7,7 @@ import { uploadCsvFile, } from '../../api/BulkIssuance'; import { getFromLocalStorage, setToLocalStorage } from '../../api/Auth'; -import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; +import { apiStatusCodes, itemPerPage, storageKeys } from '../../config/CommonConstant'; import { AlertComponent } from '../AlertComponent'; import type { AxiosResponse } from 'axios'; import { pathRoutes } from '../../config/pathRoutes'; @@ -23,6 +23,8 @@ import RoleViewButton from '../RoleViewButton'; import { Features } from '../../utils/enums/features'; import { Create, SchemaEndorsement } from './Constant'; import { DidMethod, SchemaTypes } from '../../common/enums'; +import type { GetAllSchemaListParameter } from '../Resources/Schema/interfaces'; +import { getAllSchemas } from '../../api/Schema'; export interface SelectRef { clearValue(): void; @@ -32,7 +34,7 @@ const BulkIssuance = () => { const [requestId, setRequestId] = useState(""); const [process, setProcess] = useState(false); const [loading, setLoading] = useState(true); - const [credentialOptions, setCredentialOptions] = useState([]); + const [ credentialOptionsData, setCredentialOptionsData] = useState([]); const [credentialSelected, setCredentialSelected] = useState(); const [isFileUploaded, setIsFileUploaded] = useState(false); const [uploadedFileName, setUploadedFileName] = useState(''); @@ -46,6 +48,15 @@ const BulkIssuance = () => { const [mounted, setMounted] = useState(false) const [schemaType, setSchemaType]= useState(); const [selectedTemplate, setSelectedTemplate] = useState(); + const [isAllSchema, setIsAllSchema] = useState(); + const [schemaListAPIParameters, setSchemaListAPIParameters] = useState({ + itemPerPage: itemPerPage, + page: 1, + search: '', + sortBy: 'id', + sortingOrder: 'desc', + allSearch: '', + }); const onPageChange = (page: number) => { @@ -61,12 +72,15 @@ const BulkIssuance = () => { }; const [currentPage, setCurrentPage] = useState(initialPageState); - const getSchemaCredentials = async () => { + const getSchemaCredentials = async (schemaListAPIParameters: GetAllSchemaListParameter) => { try { setLoading(true); const orgId = await getFromLocalStorage(storageKeys.ORG_ID); const orgDid = await getFromLocalStorage(storageKeys.ORG_DID); + + const isAllSchemaSelectedFlag = await getFromLocalStorage(storageKeys.ALL_SCHEMAS) + setIsAllSchema(isAllSchemaSelectedFlag) let currentSchemaType = schemaType; @@ -77,14 +91,14 @@ const BulkIssuance = () => { } setSchemaType(currentSchemaType); - if (currentSchemaType && orgId) { + if (currentSchemaType && orgId && isAllSchemaSelectedFlag =='false') { const response = await getSchemaCredDef(currentSchemaType); const { data } = response as AxiosResponse; if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - const { data: credentialDefs } = data; + const { data: credentialDefsData } = data; - const options = credentialDefs.map( + const options = credentialDefsData.map( ({ schemaName, schemaVersion, @@ -103,7 +117,40 @@ const BulkIssuance = () => { schemaAttributes: schemaAttributes && typeof schemaAttributes === "string" && JSON.parse(schemaAttributes) }), ); - setCredentialOptions(options); + setCredentialOptionsData(options); + } else { + setUploadMessage({message: response as string, type: "failure"}); + setSuccess(null) + setFailure(null) + } + setLoading(false); + } + + if (currentSchemaType && orgId &&isAllSchemaSelectedFlag =='true') { + const response = await getAllSchemas(schemaListAPIParameters,currentSchemaType); + const { data } = response as AxiosResponse; + + + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + const credentialDefsData = data.data.data; + + + const options = credentialDefsData.map(({ + name, + version, + schemaLedgerId, + attributes, + type + } : ICredentials) => ({ + value: version, + label: `${name} [${version}]`, + schemaName: name, + type:type, + schemaVersion: version, + schemaIdentifier: schemaLedgerId, + attributes: Array.isArray(attributes) ? attributes : (attributes ? JSON.parse(attributes) : []), + })); + setCredentialOptionsData(options); } else { setUploadMessage({message: response as string, type: "failure"}); setSuccess(null) @@ -119,7 +166,7 @@ const BulkIssuance = () => { }; useEffect(() => { - getSchemaCredentials(); + getSchemaCredentials(schemaListAPIParameters); setMounted(true); (async () => { try { @@ -433,7 +480,7 @@ const BulkIssuance = () => { const isCredSelected = Boolean(credentialSelected); - const selectedCred: ICredentials | boolean | undefined = credentialOptions && credentialOptions.length > 0 && credentialOptions.find( + const selectedCred: ICredentials | boolean | undefined = credentialOptionsData && credentialOptionsData.length > 0 && credentialOptionsData.find( (item: { value: string }) => item.value && item.value === credentialSelected, @@ -529,7 +576,7 @@ const BulkIssuance = () => { isRtl={false} isSearchable={true} name="color" - options={credentialOptions} + options={ credentialOptionsData} onChange={(value: ICredentials | null) => { if (schemaType === SchemaTypes.schema_INDY) { setSelectedTemplate(value?.credentialDefinitionId); @@ -562,16 +609,32 @@ const BulkIssuance = () => {

Attributes:
- {credentialSelected?.schemaAttributes.map( - (element: IAttributes) => ( -
- - {element.attributeName} - -
- ), - )} + { + isAllSchema ==='false' ? ( + credentialSelected?.schemaAttributes?.map( + (element: IAttributes) => ( +
+ + {element.attributeName} + +
+ ), + ) + ) : ( + credentialSelected?.attributes?.map( + (element: IAttributes) => ( +
+ + {element.attributeName} + +
+ ), + ) + ) + + }
+ )} diff --git a/src/components/Issuance/EmailIssuance.tsx b/src/components/Issuance/EmailIssuance.tsx index badf364e6..862803a52 100644 --- a/src/components/Issuance/EmailIssuance.tsx +++ b/src/components/Issuance/EmailIssuance.tsx @@ -11,7 +11,7 @@ import IssuancePopup from './IssuancePopup'; import type { AxiosResponse } from 'axios'; import { getFromLocalStorage } from '../../api/Auth'; import { getSchemaCredDef } from '../../api/BulkIssuance'; -import { storageKeys, apiStatusCodes, CREDENTIAL_CONTEXT_VALUE, proofPurpose } from '../../config/CommonConstant'; +import { storageKeys, apiStatusCodes, CREDENTIAL_CONTEXT_VALUE, proofPurpose, itemPerPage } from '../../config/CommonConstant'; import type { IAttributes, ICredentials, IEmailCredentialData, IIssueAttributes, ITransformedData } from './interface'; import { Field, FieldArray, Form, Formik } from 'formik'; import CustomSpinner from '../CustomSpinner'; @@ -24,13 +24,23 @@ import { checkEcosystem } from '../../config/ecosystem'; import type { ICheckEcosystem} from '../../config/ecosystem'; import { Features } from '../../utils/enums/features'; import { Create, SchemaEndorsement } from './Constant'; -import { DidMethod, SchemaTypes, CredentialType, SchemaTypeValue, ProofType } from '../../common/enums'; +import { DidMethod, SchemaTypes, CredentialType, SchemaTypeValue, ProofType, SchemaType } from '../../common/enums'; +import { getAllSchemas } from '../../api/Schema'; +import type { GetAllSchemaListParameter } from '../Resources/Schema/interfaces'; const EmailIssuance = () => { const [formData, setFormData] = useState(); const [userData, setUserData] = useState(); const [loading, setLoading] = useState(true); const [credentialOptions, setCredentialOptions] = useState([]); + const [schemaListAPIParameter, setSchemaListAPIParameter] = useState({ + itemPerPage: itemPerPage, + page: 1, + search: '', + sortBy: 'id', + sortingOrder: 'desc', + allSearch: '', + }); const [credentialSelected, setCredentialSelected] = useState( ); @@ -50,12 +60,17 @@ const EmailIssuance = () => { const [credDefId, setCredDefId] = useState(); const [schemasIdentifier, setSchemasIdentifier] = useState(); const [schemaTypeValue, setSchemaTypeValue] = useState(); + const [isAllSchemaFlagSelected, setIsAllSchemaFlagSelected] = useState(); - const getSchemaCredentials = async () => { + const getSchemaCredentials = async (schemaListAPIParameter: GetAllSchemaListParameter) => { + try { setLoading(true); const orgId = await getFromLocalStorage(storageKeys.ORG_ID); const orgDid = await getFromLocalStorage(storageKeys.ORG_DID); + + const allSchemaSelectedFlag = await getFromLocalStorage(storageKeys.ALL_SCHEMAS) + setIsAllSchemaFlagSelected(allSchemaSelectedFlag) let currentSchemaType = schemaType; if (orgDid?.includes(DidMethod.POLYGON)) { @@ -75,67 +90,100 @@ const EmailIssuance = () => { } setSchemaType(currentSchemaType); - if (currentSchemaType && orgId) { + + if (currentSchemaType && orgId && allSchemaSelectedFlag === 'false') { + const response = await getSchemaCredDef(currentSchemaType); const { data } = response as AxiosResponse; - if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { - const credentialDefs = data.data; - - const options = credentialDefs.map(({ - schemaName, - schemaVersion, - credentialDefinition, - credentialDefinitionId, - schemaIdentifier, - schemaAttributes - } : ICredentials) => ({ - value: schemaType===SchemaTypes.schema_INDY ? credentialDefinitionId : schemaVersion, - label: `${schemaName} [${schemaVersion}]${currentSchemaType === SchemaTypes.schema_INDY ? ` - (${credentialDefinition})` : ''}`, - schemaName: schemaName, - schemaVersion: schemaVersion, - credentialDefinition: credentialDefinition, - schemaIdentifier: schemaIdentifier, - credentialDefinitionId: credentialDefinitionId, - schemaAttributes: - schemaAttributes && - typeof schemaAttributes === 'string' && - JSON.parse(schemaAttributes), - })); - setCredentialOptions(options); + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + const credentialDefs = data.data; + + const options = credentialDefs.map(({ + schemaName, + schemaVersion, + credentialDefinition, + credentialDefinitionId, + schemaIdentifier, + schemaAttributes + } : ICredentials) => ({ + value: schemaType===SchemaTypes.schema_INDY ? credentialDefinitionId : schemaVersion, + label: `${schemaName} [${schemaVersion}]${currentSchemaType === SchemaTypes.schema_INDY ? ` - (${credentialDefinition})` : ''}`, + schemaName: schemaName, + schemaVersion: schemaVersion, + credentialDefinition: credentialDefinition, + schemaIdentifier: schemaIdentifier, + credentialDefinitionId: credentialDefinitionId, + schemaAttributes: + schemaAttributes && + typeof schemaAttributes === 'string' && + JSON.parse(schemaAttributes), + })); + setCredentialOptions(options); + } else { + setSuccess(null); + setFailure(null); + } + setLoading(false); + } + + if (currentSchemaType === SchemaTypes.schema_W3C && orgId && allSchemaSelectedFlag === 'true') { + + const response = await getAllSchemas(schemaListAPIParameter,currentSchemaType); + const { data } = response as AxiosResponse; + + if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) { + const credentialDefs = data.data.data; + + const options = credentialDefs.map(({ + name, + version, + schemaLedgerId, + attributes, + type + } : ICredentials) => ({ + value: version, + label: `${name} [${version}]`, + schemaName: name, + type:type, + schemaVersion: version, + schemaIdentifier: schemaLedgerId, + attributes: Array.isArray(attributes) ? attributes : (attributes ? JSON.parse(attributes) : []), + })); + setCredentialOptions(options); - - } else { - setSuccess(null); - setFailure(null); - } - setLoading(false); - } - - } catch (error) { - setSuccess(null); - setFailure(null); - } - }; + + } else { + setSuccess(null); + setFailure(null); + } + setLoading(false); + } + + } catch (error) { + setSuccess(null); + setFailure(null); + } + }; - useEffect(() => { - getSchemaCredentials(); - setMounted(true); - (async () => { - try { - const data: ICheckEcosystem = await checkEcosystem(); - setIsEcosystemData(data); - } catch (error) { - console.log(error); - } - })(); - }, []); + useEffect(() => { + getSchemaCredentials(schemaListAPIParameter); + setMounted(true); + (async () => { + try { + const data: ICheckEcosystem = await checkEcosystem(); + setIsEcosystemData(data); + } catch (error) { + console.log(error); + } + })(); + }, []); - useEffect(() => { - if (isEditing && inputRef.current) { - inputRef.current.focus(); - } - }, [isEditing]); + useEffect(() => { + if (isEditing && inputRef.current) { + inputRef.current.focus(); + } + }, [isEditing]); const confirmOOBCredentialIssuance = async () => { setIssueLoader(true); @@ -361,7 +409,9 @@ const EmailIssuance = () => { setCredentialSelected(value ?? null); setSchemasIdentifier(value?.schemaIdentifier) } - setAttributes(value?.schemaAttributes ?? []); + + setAttributes(value?.schemaAttributes ?? value?.attributes ?? []); + }} ref={selectInputRef} /> @@ -370,9 +420,9 @@ const EmailIssuance = () => { }
- {credentialSelected && ( - - + {credentialSelected && + + (

@@ -394,23 +444,33 @@ const EmailIssuance = () => { Attributes: +

- {credentialSelected?.schemaAttributes?.map( - (element: IAttributes) => ( -
- - {element.attributeName} - -
- ), - )} + { + isAllSchemaFlagSelected ==='false' ? ( + credentialSelected?.schemaAttributes?.map((element: IAttributes) => ( +
+ + {element.attributeName} + +
+ )) + ) : ( + credentialSelected?.attributes?.map((element: IAttributes) => ( +
+ + {element.attributeName} + +
+ )) + ) + }
)} + +
diff --git a/src/components/Issuance/interface.ts b/src/components/Issuance/interface.ts index 1454c53aa..8c27ddd77 100644 --- a/src/components/Issuance/interface.ts +++ b/src/components/Issuance/interface.ts @@ -27,6 +27,11 @@ export interface IAttributes { } export interface ICredentials { + name?:string; + version?:string; + type?:string; + attributes?:IAttributes[]; + schemaLedgerId?:string; value?:String; label?: string; credentialDefinitionId?: string; @@ -34,7 +39,7 @@ export interface ICredentials { schemaName: string; schemaVersion: string; schemaIdentifier: string; - schemaAttributes: IAttributes[]; + schemaAttributes?: IAttributes[]; credentialDefinition?: string; } diff --git a/src/components/Resources/Schema/SchemasList.tsx b/src/components/Resources/Schema/SchemasList.tsx index bc1f9cfb6..c93b39ede 100644 --- a/src/components/Resources/Schema/SchemasList.tsx +++ b/src/components/Resources/Schema/SchemasList.tsx @@ -4,7 +4,7 @@ import React, { useEffect, useState } from 'react'; import type { ChangeEvent } from 'react'; import type { GetAllSchemaListParameter } from './interfaces'; -import { apiStatusCodes, storageKeys } from '../../../config/CommonConstant'; +import { apiStatusCodes, itemPerPage, storageKeys } from '../../../config/CommonConstant'; import { getAllSchemas, getAllSchemasByOrgId } from '../../../api/Schema'; import type { AxiosResponse } from 'axios'; @@ -46,7 +46,7 @@ const SchemaList = (props: { const [allSchemaFlag, setAllSchemaFlag] = useState(false); const [orgId, setOrgId] = useState(''); const [schemaListAPIParameter, setSchemaListAPIParameter] = useState({ - itemPerPage: 9, + itemPerPage: itemPerPage, page: 1, search: '', sortBy: 'id', @@ -207,14 +207,18 @@ const SchemaList = (props: { const options = ['All schemas']; - const handleFilter = (e: React.ChangeEvent) => { + const handleFilter = async (e: React.ChangeEvent) => { console.log('Handle filter', e.target.value); if (e.target.value === 'All schemas') { setAllSchemaFlag(true); + await setToLocalStorage (storageKeys.ALL_SCHEMAS, `true`); + } else { setAllSchemaFlag(false); + await setToLocalStorage (storageKeys.ALL_SCHEMAS, `false`); getSchemaList(schemaListAPIParameter, false); } + }; const fetchOrganizationDetails = async () => { @@ -254,6 +258,10 @@ const SchemaList = (props: { console.log(error); } })(); + + (async () => { + await setToLocalStorage (storageKeys.ALL_SCHEMAS, `false`); + })(); setSearchValue(''); }, []); diff --git a/src/components/Resources/Schema/interfaces/index.ts b/src/components/Resources/Schema/interfaces/index.ts index 444ade7eb..8cd5a4346 100644 --- a/src/components/Resources/Schema/interfaces/index.ts +++ b/src/components/Resources/Schema/interfaces/index.ts @@ -1,11 +1,11 @@ import type { SchemaTypeValue } from "../../../../common/enums"; export interface GetAllSchemaListParameter { - itemPerPage: number, - page: number, - search: string, - sortBy: string, - allSearch: string + itemPerPage?: number, + page?: number, + search?: string, + sortBy?: string, + allSearch?: string } export interface IAttributes { diff --git a/src/components/User/UserDashBoard.tsx b/src/components/User/UserDashBoard.tsx index f60de25a1..ab06f7650 100644 --- a/src/components/User/UserDashBoard.tsx +++ b/src/components/User/UserDashBoard.tsx @@ -4,7 +4,7 @@ import type { AxiosResponse } from 'axios'; import CustomAvatar from '../Avatar/index'; import type { Organisation } from '../organization/interfaces'; import type { UserActivity } from './interfaces'; -import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; +import { apiStatusCodes, itemPerPage, storageKeys } from '../../config/CommonConstant'; import { getOrganizationById, getOrganizations } from '../../api/organization'; import { getUserActivity } from '../../api/users'; import { @@ -68,7 +68,7 @@ const UserDashBoard = () => { const [schemaCount, setSchemaCount] = useState(0); const [schemaList, setSchemaList] = useState | null>(null); const [schemaListAPIParameter, setSchemaListAPIParameter] = useState({ - itemPerPage: 9, + itemPerPage: itemPerPage, page: 1, search: '', sortBy: 'id', diff --git a/src/components/Verification/VerificationSchemasList.tsx b/src/components/Verification/VerificationSchemasList.tsx index c177271c6..298288dd6 100644 --- a/src/components/Verification/VerificationSchemasList.tsx +++ b/src/components/Verification/VerificationSchemasList.tsx @@ -5,7 +5,7 @@ import type { ChangeEvent } from 'react'; import type { AxiosResponse } from 'axios'; import { checkEcosystem, type ICheckEcosystem } from '../../config/ecosystem'; import { getFromLocalStorage, setToLocalStorage } from '../../api/Auth'; -import { apiStatusCodes, storageKeys } from '../../config/CommonConstant'; +import { apiStatusCodes, itemPerPage, storageKeys } from '../../config/CommonConstant'; import { getAllSchemas, getAllSchemasByOrgId } from '../../api/Schema'; import { DidMethod, SchemaType } from '../../common/enums'; import { getOrganizationById } from '../../api/organization'; @@ -26,7 +26,7 @@ const VerificationSchemasList = () => { const [loading, setLoading] = useState(true); const [allSchemasFlag, setAllSchemasFlag] = useState(false); const [schemasListParameter, setSchemasListParameter] = useState({ - itemPerPage: 9, + itemPerPage: itemPerPage, page: 1, search: '', sortBy: 'id', diff --git a/src/components/organization/walletCommonComponents/DedicatedAgent.tsx b/src/components/organization/walletCommonComponents/DedicatedAgent.tsx index f1c0b7369..3ab8d7a08 100644 --- a/src/components/organization/walletCommonComponents/DedicatedAgent.tsx +++ b/src/components/organization/walletCommonComponents/DedicatedAgent.tsx @@ -388,6 +388,7 @@ const isSubmitButtonDisabled = () => { })} onSubmit={async (values: IValuesShared) => { + values.network = isSelectedNetwork; submitDedicatedWallet( values, diff --git a/src/components/organization/walletCommonComponents/SharedAgent.tsx b/src/components/organization/walletCommonComponents/SharedAgent.tsx index dc364d72f..682b4d062 100644 --- a/src/components/organization/walletCommonComponents/SharedAgent.tsx +++ b/src/components/organization/walletCommonComponents/SharedAgent.tsx @@ -10,6 +10,7 @@ import { DidMethod, Ledgers, Network } from '../../../common/enums'; import SetDomainValueInput from './SetDomainValueInput'; import SetPrivateKeyValueInput from './SetPrivateKeyValue'; import type { ISharedAgentForm, IValuesShared } from "./interfaces"; +import React from "react"; interface IDetails { [key: string]: string | { [subKey: string]: string }; } @@ -298,7 +299,7 @@ const SharedAgentForm = ({ if (!values.privatekey) { values.privatekey = privateKeyValue; } - + values.network = selectedNetwork; submitSharedWallet( values, domainValue, diff --git a/src/config/CommonConstant.ts b/src/config/CommonConstant.ts index 3bfde0115..aa13004e8 100644 --- a/src/config/CommonConstant.ts +++ b/src/config/CommonConstant.ts @@ -9,6 +9,7 @@ export const CREDENTIAL_CONTEXT_VALUE = 'https://www.w3.org/2018/credentials/v1' export const schemaVersionRegex = /^\d{1,5}(?=.*[0-9])(?:\.\d{1,5})?(?:\.\d{1,5})?$/gm export const proofPurpose = 'assertionMethod' export const limitedAttributesLength = 3 +export const itemPerPage = 9 export const apiStatusCodes = { API_STATUS_SUCCESS : 200, @@ -53,7 +54,8 @@ export const storageKeys = { ORG_DID:'did', SCHEMA_TYPE:'type', SELECT_ORG_IN_ECOSYSTEM: 'select_orgs_in_ecosystem', - ERROR_ORG_IN_ECOSYSTEM: 'error_orgs_in_ecosystem' + ERROR_ORG_IN_ECOSYSTEM: 'error_orgs_in_ecosystem', + ALL_SCHEMAS:'allSchemaFlag' } export const emailCredDefHeaders = [