Skip to content

Commit

Permalink
Merge pull request #93 from credebl/161-issuance-new-flow
Browse files Browse the repository at this point in the history
fix:Issuance flow
  • Loading branch information
tipusinghaw authored Aug 11, 2023
2 parents 8d154cb + 6f17da8 commit c0ccc16
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/api/issuance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getFromLocalStorage } from './Auth';

export const getIssuedCredentials = async (state: IssueCredential) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.Issuance.getIssuedCredentials}?orgId=${orgId}&state=${state}`;
const url = `${apiRoutes.Issuance.getIssuedCredentials}?orgId=${orgId}`;

const axiosPayload = {
url,
Expand Down
6 changes: 3 additions & 3 deletions src/commonComponents/SchemaCard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Card } from 'flowbite-react';
import { dateConversion } from '../utils/DateConversion';

const SchemaCard = (props: { schemaName: string, version: string, schemaId: string, issuerDid: string, attributes: string[], created: string, onClickCallback: (schemaId: string) => void; },) => {
const SchemaCard = (props: {className:string, schemaName: string, version: string, schemaId: string, issuerDid: string, attributes: string[], created: string, onClickCallback: (schemaId: string) => void; },) => {
return (
<Card onClick={() => {
props.onClickCallback(props.schemaId)
Expand All @@ -15,11 +15,11 @@ const SchemaCard = (props: { schemaName: string, version: string, schemaId: stri
Version: {props.version}
</p>
</div>
<div className='float-right ml-auto '>
{/* <div className='float-right ml-auto '>
<p className='dark:text-white'>
{dateConversion(props.created)}
</p>
</div>
</div> */}
</div>
<div className="min-w-0 flex-1">
<p className="truncate text-sm font-medium text-gray-900 dark:text-white pb-2">
Expand Down
8 changes: 6 additions & 2 deletions src/commonComponents/datatable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ interface DataTableProps {
data: TableData[];
loading: boolean;
callback?: (clickId: string | null | undefined) => void;
displaySelect?:boolean;
}

const DataTable: React.FC<DataTableProps> = ({ header, data, loading, callback }) => {
const DataTable: React.FC<DataTableProps> = ({ header,displaySelect, data, loading, callback }) => {

return (
<div className="flex flex-col ">
Expand Down Expand Up @@ -41,13 +42,16 @@ const DataTable: React.FC<DataTableProps> = ({ header, data, loading, callback }
</thead>
<tbody className="bg-white dark:bg-gray-800">
{data.length ? data.map((ele, index) => (
<tr className={`${index % 2 !== 0 ? 'bg-gray-50 dark:bg-gray-700' : ''} ${callback && ele.clickId ? 'cursor-pointer' : ''}`} onClick={() => callback ? callback(ele?.clickId) : ''}>
<tr className={`${index % 2 !== 0 ? 'bg-gray-50 dark:bg-gray-700' : ''}`} onClick={() => callback ? callback(ele?.clickId) : ''}>
{ele.data.map(subEle => (
<td className={` p-4 text-sm font-normal text-gray-900 whitespace-nowrap dark:text-white align-middle `}>
<div>{subEle.data}</div>
{subEle.subData && subEle.subData}
</td>
))}
{displaySelect &&
<button onClick={() => callback ? callback(ele?.clickId) : ''} type="button" className="text-center mt-2 text-white bg-gradient-to-r from-blue-500 via-blue-600 to-blue-700 hover:bg-gradient-to-br focus:ring-4 focus:outline-none focus:ring-blue-300 dark:focus:ring-blue-800 font-medium rounded-lg text-sm px-5 py-2.5 text-center mr-2 mb-2">Select</button>
}
</tr>
)) : <tr className="text-center"><td className="p-2 text-center text-gray-500" colSpan={header.length}>No Data Found</td></tr>}
</tbody>
Expand Down
10 changes: 7 additions & 3 deletions src/components/Issuance/CredDefSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ const CredDefSelection = () => {
color="info"
/>
</div>
: <SchemaCard schemaName={schemaState?.schemaName} version={schemaState?.version} schemaId={schemaDetailsState.schemaId} issuerDid={schemaDetailsState.issuerDid} attributes={schemaDetailsState.attributes} created={schemaDetailsState.createdDateTime}
onClickCallback={schemaSelectionCallback} />}
:
<div className="m-1 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
<SchemaCard className=" col-span-1 sm:col-span-2 md:col-span-1" schemaName={schemaState?.schemaName} version={schemaState?.version} schemaId={schemaDetailsState.schemaId} issuerDid={schemaDetailsState.issuerDid} attributes={schemaDetailsState.attributes} created={schemaDetailsState.createdDateTime}
onClickCallback={schemaSelectionCallback} />
</div>
}
</div>

<div className="mb-4 col-span-full xl:mb-2 pt-5">
Expand All @@ -133,7 +137,7 @@ const CredDefSelection = () => {
setError(null)
}}
/>
<DataTable header={header} data={credDefList} loading={loading} callback={selectCredDef}></DataTable>
<DataTable header={header} data={credDefList} loading={loading} callback={selectCredDef} displaySelect={true}></DataTable>
</div>
)
}
Expand Down
9 changes: 6 additions & 3 deletions src/components/Issuance/Issuance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface Attributes {
value: string
}
interface IssuanceFormPayload {
userName: string,
userName?: string,
connectionId: string,
attributes: Attributes[],
credentialDefinitionId: string,
Expand Down Expand Up @@ -71,7 +71,8 @@ const IssueCred = () => {
const attrObj = attributes.map(attr => ({ name: attr, value: '' }))
const issuancePayload = selectedUsers.map(user => {
return {
userName: user.userName, connectionId: user.connectionId,
// userName: user.userName,
connectionId: user.connectionId,
attributes: attrObj, credentialDefinitionId: credDefId, orgId
}
})
Expand Down Expand Up @@ -147,7 +148,9 @@ const IssueCred = () => {
</h1>
</div>
{!schemaLoader ?
<Card className='transform transition duration-500 hover:scale-105 hover:bg-gray-50' style={{ width: '470px', height: '140px', maxWidth: '100%', maxHeight: '100%', overflow: 'auto' }}>
<Card
// className='transform transition duration-500 hover:scale-105 hover:bg-gray-50'
style={{ width: '470px', height: '140px', maxWidth: '100%', maxHeight: '100%', overflow: 'auto' }}>
<div className="flex justify-between items-start">
<div>
<h5 className="text-xl font-bold leading-none text-primary dark:text-white">
Expand Down

0 comments on commit c0ccc16

Please sign in to comment.