Skip to content

fix: ecosystem alignment, received invitation, updated interfaces, added success alert, added title tooltip, handled button loading, improved interfaces and logic for storage #567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/components/Ecosystem/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ const Dashboard = () => {
{ecosystemDetails ? (
<div>
{isEcosystemLead ? (
<>
<div
className={`mt-4 items-center justify-between p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800 w-full`}
>
Expand All @@ -302,7 +301,7 @@ const Dashboard = () => {
)}
</div>
<div>
<div className="w-full">
<div className="w-full sm:max-w-100/13rem">
<h3 className="mb-1 text-xl font-bold text-gray-900 dark:text-white">
{ecosystemDetails?.name}
</h3>
Expand Down Expand Up @@ -386,9 +385,7 @@ const Dashboard = () => {
</div>
</div>
</div>
</>
) : (
<>
<div
className={`mt-4 relative flex flex-wrap items-center p-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800`}
>
Expand Down Expand Up @@ -459,7 +456,6 @@ const Dashboard = () => {
<RoleTablet role={ecosystemDetails?.role || ''} />
</div>
</div>
</>
)}

<div className="mt-4 p-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ const ReceivedInvitations = () => {
'',
);
const { data } = response as AxiosResponse;

if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
const totalPages = data?.data?.totalPages;

Expand Down Expand Up @@ -147,8 +146,8 @@ const ReceivedInvitations = () => {
status,
);
setLoading(false);
const { data } = response as AxiosResponse;
if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) {
const { data } = response as AxiosResponse;
if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
setMessage(data?.message);
getAllInvitations();
} else {
Expand All @@ -158,6 +157,7 @@ const ReceivedInvitations = () => {
setLoading(false);
} catch (err) {
console.log('ERROR - Accept/Reject Ecosystem::', err);
setLoading(false);
}
};

Expand Down
69 changes: 18 additions & 51 deletions src/components/Issuance/Issuance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,16 @@ import * as Yup from 'yup';
import { Alert, Button, Card } from 'flowbite-react';
import { ErrorMessage, Field, Form, Formik } from 'formik';
import { apiStatusCodes, storageKeys } from '../../config/CommonConstant';
import { getFromLocalStorage, removeFromLocalStorage } from '../../api/Auth';
import { getFromLocalStorage } from '../../api/Auth';
import { useEffect, useState } from 'react';
import BackButton from '../../commonComponents/backbutton'
import type { AxiosResponse } from 'axios';
import BreadCrumbs from '../BreadCrumbs';
import CustomSpinner from '../CustomSpinner';
import { issueCredential } from '../../api/issuance';
import { pathRoutes } from '../../config/pathRoutes';

interface SchemaDetails {
schemaName: string;
version: string;
schemaId: string;
credDefId: string;
}

interface SelectedUsers {
userName: string;
connectionId: string;
}

interface Attributes {
name: string;
value: string;
dataType: string;
}
interface IssuanceFormPayload {
userName?: string;
connectionId: string;
attributes: Attributes[];
credentialDefinitionId: string;
orgId: string;
}

interface DataTypeAttributes {
schemaDataType: string;
attributeName:string
}

interface Attribute {
attributeName: string;
schemaDataType: string;
displayName: string;
}
import { AlertComponent } from '../AlertComponent';
import type {Attribute, DataTypeAttributes, IssuanceFormPayload, SchemaDetails, SelectedUsers} from './interface'

const IssueCred = () => {
const [schemaLoader, setSchemaLoader] = useState<boolean>(true);
Expand All @@ -65,10 +31,13 @@ const IssueCred = () => {
const [issuanceLoader, setIssuanceLoader] = useState<boolean>(false);
const [failure, setFailure] = useState<string | null>(null);
const [schemaAttributesDetails, setSchemaAttributesDetails] = useState<Attribute[]>([]);
const [success, setSuccess]= useState<string | null>(null)
const [error, setError]= useState<string | null>(null)

useEffect(() => {
getSchemaAndUsers();
getSchemaDetails();
return(() => setUserLoader(false))
}, []);

const getSchemaAndUsers = async () => {
Expand Down Expand Up @@ -170,29 +139,31 @@ const IssueCred = () => {
setIssuanceLoader(true);
const issueCredRes = await issueCredential(convertedAttributesValues);
const { data } = issueCredRes as AxiosResponse;
setIssuanceLoader(false);


if (data?.statusCode === apiStatusCodes.API_STATUS_CREATED) {
goToIssueCredList();
setSuccess(data?.message)
window.location.href = `${pathRoutes.organizations.issuedCredentials}`;
} else {
setFailure(issueCredRes as string);
setIssuanceLoader(false);
}
};

const goToIssueCredList = () => {
removeFromLocalStorage(storageKeys.SELECTED_USER);
removeFromLocalStorage(storageKeys.SCHEMA_ID);
removeFromLocalStorage(storageKeys.CRED_DEF_ID);
window.location.href = `${pathRoutes.organizations.issuedCredentials}`;
};

return (
<div className="px-4 pt-2">
<div className="mb-4 col-span-full xl:mb-2">
<div className="flex justify-between items-center">
<BreadCrumbs />
<BackButton path={pathRoutes.back.issuance.connections} />
</div>
<AlertComponent
message={ success ?? error}
type={success ? 'success' : 'failure'}
onAlertClose={() => {
setError(null);
setSuccess(null);
}}
/>
<h1 className="ml-1 text-xl font-semibold text-gray-900 sm:text-2xl dark:text-white">
Issuance
</h1>
Expand Down Expand Up @@ -260,10 +231,6 @@ const IssueCred = () => {
<h5 className="text-xl font-bold leading-none dark:text-white">
{user.userName}
</h5>
{/* Needed for multiple users issuance */}
{/* <div className="flex justify-end">
<img src={DeleteIcon}></img>
</div> */}
</div>
<div className="flex">
<h5 className="text-xl font-bold leading-none dark:text-white flex flex-wrap">
Expand Down
36 changes: 36 additions & 0 deletions src/components/Issuance/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,39 @@ export interface IConnectionList {
connectionId: string;
createDateTime: string;
}

export interface SchemaDetails {
schemaName: string;
version: string;
schemaId: string;
credDefId: string;
}

export interface SelectedUsers {
userName: string;
connectionId: string;
}

export interface Attributes {
name: string;
value: string;
dataType: string;
}
export interface IssuanceFormPayload {
userName?: string;
connectionId: string;
attributes: Attributes[];
credentialDefinitionId: string;
orgId: string;
}

export interface DataTypeAttributes {
schemaDataType: string;
attributeName:string
}

export interface Attribute {
attributeName: string;
schemaDataType: string;
displayName: string;
}
1 change: 0 additions & 1 deletion src/components/Profile/DisplayUserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const DisplayUserProfile = ({

<Button
type="button"
title="Add new credential-definition on ledger"
color="bg-primary-800"
onClick={toggleEditProfile}
className='text-base font-medium text-center text-white bg-primary-700 rounded-lg hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800"'
Expand Down
7 changes: 4 additions & 3 deletions src/components/Resources/Schema/SchemasList.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import { Alert, Pagination } from 'flowbite-react';
import { ChangeEvent, useEffect, useState } from 'react';
import React, { ChangeEvent, useEffect, useState } from 'react';
import type { GetAllSchemaListParameter } from './interfaces';
import { apiStatusCodes, storageKeys } from '../../../config/CommonConstant';
import { getAllSchemas, getAllSchemasByOrgId } from '../../../api/Schema';
Expand Down Expand Up @@ -172,8 +172,8 @@ const SchemaList = (props: {
}, []);

const createSchemaTitle = isEcosystemData?.isEcosystemMember
? { title: 'Schema Endorsement', svg: <SchemaEndorsement/> }
: { title: 'Create', svg: <Create/> };
? { title: 'Schema Endorsement', toolTip: 'Add new schema request', svg: <SchemaEndorsement/> }
: { title: 'Create', svg: <Create/>, toolTip: 'Create new schema' };
const emptyListTitle = 'No Schemas';
const emptyListDesc = 'Get started by creating a new Schema';
const emptyListBtn = isEcosystemData?.isEcosystemMember
Expand Down Expand Up @@ -209,6 +209,7 @@ const SchemaList = (props: {
<div className="flex space-x-2">
{walletStatus ? (
<RoleViewButton
title={createSchemaTitle.toolTip}
buttonTitle={createSchemaTitle.title}
feature={Features.CRETAE_SCHEMA}
svgComponent={createSchemaTitle.svg}
Expand Down
10 changes: 3 additions & 7 deletions src/components/Resources/Schema/ViewSchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ const ViewSchemas = () => {
/>
</svg>
),
tooltip: 'Add new credential-definition request'
}
: {
title: 'Create',
Expand All @@ -285,6 +286,7 @@ const ViewSchemas = () => {
</svg>
</div>
),
tooltip: 'Create new credential-definition'
};

return (
Expand Down Expand Up @@ -472,12 +474,6 @@ const ViewSchemas = () => {
</div>

<div className="flex items-center">
{/* <div className="custom-control custom-checkbox d-flex align-items-center pt-4 p-2"> */}
{/* <Field type="checkbox" id="Revocable" name="revocable" className="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600" /> */}
{/* <Label className="ml-2 text-sm font-medium text-gray-900 dark:text-gray-300" >
Revocable
</Label> */}
{/* </div> */}
{createloader && (
<div className="ml-auto">
<p className="text-gray-500 text-sm italic ml-5">
Expand Down Expand Up @@ -525,7 +521,7 @@ const ViewSchemas = () => {
<div className="float-right py-4 px-2">
<Button
type="submit"
title="Add new credential-definition request"
title={submitButtonTitle.tooltip}
isProcessing={createloader}
color="bg-primary-800"
disabled={createloader}
Expand Down
13 changes: 6 additions & 7 deletions src/components/RoleViewButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import { ReactElement, useEffect, useState } from 'react';

import React, { ReactElement, useEffect, useState } from 'react';
import { Button } from 'flowbite-react';
import { Features } from '../../utils/enums/features';
import { Roles } from '../../utils/enums/roles';
import { getFromLocalStorage } from '../../api/Auth';
import { storageKeys } from '../../config/CommonConstant';
import { getUserRoles } from '../../config/ecosystem'

interface RoleViewButtonProps {
title?:string
buttonTitle?: string,
svgComponent?: ReactElement,
onClickEvent?: () => void,
feature: string,
isOutline?: boolean,
isPadding?: boolean
isPadding?: boolean,
}


const RoleViewButton = ({ buttonTitle, svgComponent, onClickEvent, feature, isOutline, isPadding }: RoleViewButtonProps) => {
const RoleViewButton = ({ title, buttonTitle, svgComponent, onClickEvent, feature, isOutline, isPadding }: RoleViewButtonProps) => {

const [userRoles, setUserRoles] = useState<string[]>([])

Expand Down Expand Up @@ -70,13 +68,14 @@ const RoleViewButton = ({ buttonTitle, svgComponent, onClickEvent, feature, isOu
{
isRoleAccess()
&& <Button
title={title}
outline={Boolean(isOutline)}
onClick={onClickEvent}
color={isOutline ? "bg-primary-800" : "bg-primary-700"}
className={`${isOutline
? "!p-0 role-btn group flex h-min items-center justify-center text-center focus:z-10 focus:ring-2 ring-primary-700 bg-white-700 hover:bg-secondary-700 ring-2 text-black font-medium rounded-md text-sm dark:text-white dark:hover:text-primary-700"
: `${isPadding ? "!p-0" : ""} text-base font-medium text-center text-white bg-primary-700 hover:!bg-primary-800 rounded-md hover:bg-primary-800 focus:ring-4 focus:ring-primary-300 sm:w-auto dark:bg-primary-600 dark:hover:bg-primary-700 dark:focus:ring-primary-800`
}`} >
}`}>
{svgComponent}
{buttonTitle}
</Button>
Expand Down
Loading