From cff3d0f7f04c01a9725cdbe23ac248d10cf56056 Mon Sep 17 00:00:00 2001 From: karan Date: Wed, 20 Sep 2023 18:45:45 +0530 Subject: [PATCH] refactor schema api Signed-off-by: karan --- src/api/Schema.ts | 5 ++--- src/api/issuance.ts | 6 ++---- src/components/Resources/Schema/Create.tsx | 5 +++-- src/components/organization/CreateOrgFormModal.tsx | 2 +- src/components/organization/Dashboard.tsx | 14 ++++++++++---- src/config/apiRoutes.ts | 3 +++ 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/api/Schema.ts b/src/api/Schema.ts index 866523732..a86d4b49a 100644 --- a/src/api/Schema.ts +++ b/src/api/Schema.ts @@ -1,5 +1,5 @@ import type { GetAllSchemaListParameter, createCredDeffFieldName, createSchema } from "../components/Resources/Schema/interfaces"; -import { axiosDelete, axiosGet, axiosPost } from "../services/apiRequests"; +import { axiosGet, axiosPost } from "../services/apiRequests"; import { apiRoutes } from "../config/apiRoutes"; import { getFromLocalStorage } from "./Auth"; @@ -8,7 +8,7 @@ import { storageKeys } from "../config/CommonConstant"; export const getAllSchemas = async ({itemPerPage, page, allSearch }: GetAllSchemaListParameter) => { const token = await getFromLocalStorage(storageKeys.TOKEN) const details = { - url: `${apiRoutes.Platform.getAllSchemaFromPlatform}?pageSize=${itemPerPage}&searchByText=${allSearch}&pageNumber=${page}`, + url: `${apiRoutes.Platform.getAllSchemaFromPlatform}?pageSize=${itemPerPage}&searchByText=${allSearch}&pageNumber=${page}`, config: { headers: { 'Content-type': 'application/json', @@ -52,7 +52,6 @@ export const getAllSchemasByOrgId = async ({ search, itemPerPage, page }: GetAll export const addSchema = async (payload: createSchema, orgId: number) => { const token = await getFromLocalStorage(storageKeys.TOKEN) const details = { - // url: apiRoutes.schema.create, url: `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.create}`, payload, config: { diff --git a/src/api/issuance.ts b/src/api/issuance.ts index 3c7d0be50..86ef44496 100644 --- a/src/api/issuance.ts +++ b/src/api/issuance.ts @@ -1,13 +1,12 @@ -import type { IssueCredential } from '../common/enums'; import { apiRoutes } from '../config/apiRoutes'; import { storageKeys } from '../config/CommonConstant'; import { getHeaderConfigs } from '../config/GetHeaderConfigs'; import { axiosGet, axiosPost } from '../services/apiRequests'; import { getFromLocalStorage } from './Auth'; -export const getIssuedCredentials = async (state: IssueCredential) => { +export const getIssuedCredentials = async (schemaId: string) => { const orgId = await getFromLocalStorage(storageKeys.ORG_ID); - const url = `${apiRoutes.Issuance.getIssuedCredentials}?orgId=${orgId}`; + const url= `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.getCredDefBySchemaId}/${schemaId}/cred-defs`; const axiosPayload = { url, @@ -24,7 +23,6 @@ export const getIssuedCredentials = async (state: IssueCredential) => { export const getCredentialDefinitions = async (schemaId: string) => { const orgId = await getFromLocalStorage(storageKeys.ORG_ID); - // const url = `${apiRoutes.Issuance.getCredDefBySchemaId}?schemaId=${schemaId}&orgId=${orgId}`; const url= `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.getCredDefBySchemaId}/${schemaId}/cred-defs`; const axiosPayload = { diff --git a/src/components/Resources/Schema/Create.tsx b/src/components/Resources/Schema/Create.tsx index e6a72c004..76f212f9d 100644 --- a/src/components/Resources/Schema/Create.tsx +++ b/src/components/Resources/Schema/Create.tsx @@ -201,8 +201,8 @@ import React from 'react'; return ( <> -
- Attributes * +
+ Attributes *
@@ -540,6 +540,7 @@ import React from 'react'; No, cancel