Skip to content

Commit

Permalink
fix: schema card click issue (#749)
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]>

* fix: popup card fixes

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

* fix: remove click on card

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

* fix: remove card click

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

* fix: cred def details

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

* fix: schema card click issue

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

---------

Signed-off-by: bhavanakarwade <[email protected]>
  • Loading branch information
bhavanakarwade authored Aug 29, 2024
1 parent 644bb63 commit 4a3576c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 51 deletions.
1 change: 1 addition & 0 deletions src/components/Verification/EmailVerification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ const EmailVerification = () => {

payload = {
goalCode: "verification",
reuseConnection: true,
protocolVersion: ProtocolVersion.V1,
isShortenUrl: true,
autoAcceptProof: AutoAccept.NEVER,
Expand Down
102 changes: 51 additions & 51 deletions src/components/Verification/VerificationSchemasList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { checkEcosystem, type ICheckEcosystem } from '../../config/ecosystem';
import { getFromLocalStorage, setToLocalStorage } from '../../api/Auth';
import { apiStatusCodes, itemPerPage, storageKeys } from '../../config/CommonConstant';
import { getAllSchemas, getAllSchemasByOrgId } from '../../api/Schema';
import { DidMethod, SchemaType } from '../../common/enums';
import { DidMethod, SchemaTypes } from '../../common/enums';
import { getOrganizationById } from '../../api/organization';
import { Create, SchemaEndorsement } from '../Issuance/Constant';
import BreadCrumbs from '../BreadCrumbs';
Expand Down Expand Up @@ -40,24 +40,16 @@ const VerificationSchemasList = () => {
const [selectedSchemas, setSelectedSchemas] = useState<ISchema[]>([]);
const [w3cSchema, setW3cSchema] = useState<boolean>(false);
const [isNoLedger, setIsNoLedger] = useState<boolean>(false);
const [schemaType, setSchemaType] = useState('');

const getSchemaListDetails = async (
schemasListParameter: {
itemPerPage: number,
page: number,
search: string,
sortingOrder: string,
sortBy: string,
allSearch: string
},
flag: boolean,
) => {
const getSchemaListDetails = async () => {

try {
const organizationId = await getFromLocalStorage(storageKeys.ORG_ID);
setLoading(true);
let schemasList;
if (allSchemasFlag) {
schemasList = await getAllSchemas(schemasListParameter, SchemaType.INDY);
if (allSchemasFlag) {
schemasList = await getAllSchemas(schemasListParameter, schemaType);
} else {
schemasList = await getAllSchemasByOrgId(
schemasListParameter,
Expand Down Expand Up @@ -99,33 +91,27 @@ const VerificationSchemasList = () => {
};

useEffect(() => {
getSchemaListDetails(schemasListParameter, false);
getSchemaListDetails();
}, [schemasListParameter, allSchemasFlag]);


const onSchemaListParameterSearch = async (
event: ChangeEvent<HTMLInputElement>,
): Promise<void> => {
event.preventDefault();
const inputValue = event.target.value;
setSearchValue(inputValue);

getSchemaListDetails(
{
...schemasListParameter,
search: inputValue,
},
false,
);

if (allSchemasFlag) {
getSchemaListDetails(
{
...schemasListParameter,
allSearch: inputValue,
},
false,
);
setSchemasListParameter(prevParams => ({
...prevParams,
allSearch: inputValue,
page: 1,
}));
} else {
setSchemasListParameter(prevParams => ({
...prevParams,
search: inputValue,
page: 1,
}));
}
};

Expand All @@ -134,25 +120,24 @@ const VerificationSchemasList = () => {
attributes: IAttributesDetails[],
issuerId: string,
created: string,
checked: boolean,
) => {
const schemaDetails = {
schemaId: schemaId,
attributes: attributes,
issuerId: issuerId,
createdDate: created,
};

const isSelected = selectedSchemas.some((schema) => schema.schemaId === schemaId);
if (isSelected) {
const updatedSchemas = selectedSchemas.filter((schema) => schema.schemaId !== schemaId);

setSelectedSchemas(updatedSchemas);

if (checked) {
setSelectedSchemas((prevSelectedSchemas) => [...prevSelectedSchemas, schemaDetails]);
} else {
setSelectedSchemas([...selectedSchemas, schemaDetails]);
setSelectedSchemas((prevSelectedSchemas) =>
prevSelectedSchemas.filter((schema) => schema.schemaId !== schemaId)
);
}
};


const handleW3cSchemas = async (checked: boolean, schemaData?: ISchemaData) => {
const updateSchemas = (prevSchemas: ISchemaData[]) => {
let updatedSchemas = [...prevSchemas];
Expand Down Expand Up @@ -193,9 +178,11 @@ const VerificationSchemasList = () => {
}
if (did.includes(DidMethod.POLYGON) || did.includes(DidMethod.KEY) || did.includes(DidMethod.WEB)) {
setW3cSchema(true);
setSchemaType(SchemaTypes.schema_W3C)
}
if (did.includes(DidMethod.INDY)) {
setW3cSchema(false);
setSchemaType(SchemaTypes.schema_INDY)
}
if (did.includes(DidMethod.KEY) || did.includes(DidMethod.WEB)) {
setIsNoLedger(true);
Expand Down Expand Up @@ -235,15 +222,19 @@ const VerificationSchemasList = () => {

const options = ['All schemas'];

const handleFilter = (e: React.ChangeEvent<HTMLSelectElement>) => {
if (e.target.value === 'All schemas') {
setAllSchemasFlag(true);
} else {
setAllSchemasFlag(false);
getSchemaListDetails(schemasListParameter, false);
}
};

const handleFilter = async (e: React.ChangeEvent<HTMLSelectElement>) => {
const selectedFilter = e.target.value;
setAllSchemasFlag(selectedFilter === 'All schemas');

setSchemasListParameter((prevParams) => ({
...prevParams,
page: 1,
search: '',
allSearch: '',
}));
setSearchValue('');

};
useEffect(() => {
fetchOrganizationDetails();
(async () => {
Expand Down Expand Up @@ -346,8 +337,17 @@ const VerificationSchemasList = () => {
w3cSchema={w3cSchema}
noLedger={isNoLedger}
isVerificationUsingEmail={true}
onChange={(checked) => handleW3cSchemas(checked, element)}
onClickCallback={handleSchemaSelection}
onChange={(checked) => {
w3cSchema
? handleW3cSchemas(checked, element)
: handleSchemaSelection(
element['schemaLedgerId'],
element['attributes'],
element['issuerId'],
element['createDateTime'],
checked
);
}}
/>
</div>
))}
Expand Down

0 comments on commit 4a3576c

Please sign in to comment.