Skip to content

Commit

Permalink
Merge pull request #95 from credebl/161-issuance-ledger
Browse files Browse the repository at this point in the history
161 issuance ledger
  • Loading branch information
tipusinghaw authored Aug 16, 2023
2 parents 4643055 + c780512 commit fdc8be3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/api/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const createCredentialDefinition = async (payload: createCredDeffFieldNam

try {
const response = await axiosPost(details)

return response
}
catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/commonComponents/SchemaCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const SchemaCard = (props: { schemaName: string, version: string, schemaId: stri
<span className="font-semibold">Issuer DID:</span> {props.issuerDid}
</p>
<p className="truncate text-sm font-medium text-gray-900 dark:text-white">
<span className="font-semibold">Ledger:</span> {props.issuerDid?.split(':')[2]}
<span className="font-semibold">Ledger:</span> {props.issuerDid.split(":")[2]}
</p>
</div>

Expand Down
2 changes: 2 additions & 0 deletions src/commonComponents/datatable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ const DataTable: React.FC<DataTableProps> = ({ header,displaySelect, data, loadi
</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' : ''}`} 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>
Expand Down
29 changes: 11 additions & 18 deletions src/components/Issuance/CredDefSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ const CredDefSelection = () => {
const [schemaLoader, setSchemaLoader] = useState<boolean>(true)
const [error, setError] = useState<string | null>(null)
const [credDefList, setCredDefList] = useState<TableData[]>([])
const [schemaDetailsState, setSchemaDetailsState] = useState<SchemaState>({ schemaId: '', issuerDid: '', attributes: [], createdDateTime: '' })
const [schemaDetailsState, setSchemaDetailsState] = useState<SchemaState>({ schemaId: '', issuerDid: '', attributes: [], createdDateTime: ''})


useEffect(() => {
getSchemaAndCredDef()
}, []);

const getSchemaAndCredDef = async () => {
const schemaId = await getFromLocalStorage(storageKeys.SCHEMA_ID)

if (schemaId) {
getSchemaDetails(schemaId)
getCredDefs(schemaId)
Expand All @@ -44,19 +46,14 @@ const CredDefSelection = () => {

const getSchemaDetails = async (schemaId: string) => {
setSchemaLoader(true)
const orgId = await getFromLocalStorage(storageKeys.ORG_ID)
const schemaDetails = await getSchemaById(schemaId, Number(orgId))
const { data } = schemaDetails as AxiosResponse

if (data?.statusCode === apiStatusCodes.API_STATUS_SUCCESS) {
if (data.data.response) {
const { response } = data.data
setSchemaDetailsState({ schemaId: response?.schemaId, issuerDid: response?.schema?.issuerId, attributes: response.schema.attrNames, createdDateTime: 'string' })

}
const schemaDid = await getFromLocalStorage(storageKeys.SCHEMA_ATTR)
const schemaDidObject = JSON.parse(schemaDid)
if (schemaDidObject) {
setSchemaDetailsState({ schemaId: schemaId, issuerDid: schemaDidObject?.issuerDid, attributes: schemaDidObject?.attribute, createdDateTime: schemaDidObject?.createdDate })
}
setSchemaLoader(false)
}


const header = [
{ columnName: 'Name' },
Expand Down Expand Up @@ -117,12 +114,8 @@ const CredDefSelection = () => {
color="info"
/>
</div>
:
<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>
}
: <SchemaCard schemaName={schemaState?.schemaName} version={schemaState?.version} schemaId={schemaDetailsState.schemaId} issuerDid={schemaDetailsState.issuerDid} attributes={schemaDetailsState.attributes} created={schemaDetailsState.createdDateTime}
onClickCallback={schemaSelectionCallback} />}
</div>

<div className="mb-4 col-span-full xl:mb-2 pt-5">
Expand All @@ -137,7 +130,7 @@ const CredDefSelection = () => {
setError(null)
}}
/>
<DataTable header={header} data={credDefList} loading={loading} callback={selectCredDef} displaySelect={true}></DataTable>
<DataTable header={header} data={credDefList} loading={loading} callback={selectCredDef}></DataTable>
</div>
)
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Issuance/SchemaSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import SchemaList from "../Resources/Schema/SchemasList";

const SchemaSelection = () => {

const schemaSelectionCallback = async (schemaId: string) => {
const schemaSelectionCallback = async (schemaId: string,attributes:any) => {
await setToLocalStorage(storageKeys.SCHEMA_ATTR, attributes)
await setToLocalStorage(storageKeys.SCHEMA_ID, schemaId)
window.location.href = `${pathRoutes.organizations.Issuance.credDef}`
}
Expand Down

0 comments on commit fdc8be3

Please sign in to comment.