Skip to content

Commit

Permalink
refactor schema api
Browse files Browse the repository at this point in the history
Signed-off-by: karan <[email protected]>
  • Loading branch information
16-karan committed Sep 20, 2023
1 parent ad89c21 commit cff3d0f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 14 deletions.
5 changes: 2 additions & 3 deletions src/api/Schema.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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',
Expand Down Expand Up @@ -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: {
Expand Down
6 changes: 2 additions & 4 deletions src/api/issuance.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 = {
Expand Down
5 changes: 3 additions & 2 deletions src/components/Resources/Schema/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ import React from 'react';

return (
<>
<div className="d-flex justify-content-center align-items-center mb-1">
Attributes <span className="text-red-600">*</span>
<div className="dark:text-white d-flex justify-content-center align-items-center mb-1">
Attributes <span className="dark:text-white text-red-600">*</span>

</div>
<div className="flex flex-col">
Expand Down Expand Up @@ -540,6 +540,7 @@ import React from 'react';
No, cancel
</button>
<Button
data-modal-hide="popup-modal"
type="submit"
isProcessing={createloader}
disabled={createloader}
Expand Down
2 changes: 1 addition & 1 deletion src/components/organization/CreateOrgFormModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const CreateOrgFormModal = (props: { openModal: boolean; setMessage: (message: s
description: yup
.string()
.min(2, 'Description must be at least 2 characters')
.max(600, 'Description must be at most 600 characters')
.max(255, 'Description must be at most 255 characters')
.required('Description is required')
})}
validateOnBlur
Expand Down
14 changes: 10 additions & 4 deletions src/components/organization/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,15 @@ const Dashboard = () => {
<div
className="mt-4 flex flex-wrap items-center justify-between p-4 bg-white border border-gray-200 rounded-lg shadow-sm sm:flex dark:border-gray-700 sm:p-6 dark:bg-gray-800"
>

<div
className="items-center flex flex-wrap"
>
<div className='mr-4'>
{(orgData?.logoUrl) ? <CustomAvatar size='60' src={orgData?.logoUrl} /> : <CustomAvatar size='60' name={orgData?.name} />}

<div className='mr-4'>
{(orgData?.logoUrl) ? <CustomAvatar size='80' src={orgData?.logoUrl} /> : <CustomAvatar size='90' name={orgData?.name} />}
</div>
{orgData ?
<div>
<h3 className="mb-1 text-xl font-bold text-gray-900 dark:text-white">
{orgData?.name}
Expand All @@ -157,14 +159,18 @@ const Dashboard = () => {
</p>

<p className='mb-1 text-base font-normal text-gray-900 dark:text-white'>
Public view :
Profile view :
<span className='font-semibold'>
{orgData?.publicProfile ? " Public" : "Private"}
</span>
</p>

</div>
:
<CustomSpinner/>
}
</div>

{
(userRoles.includes(Roles.OWNER) || userRoles.includes(Roles.ADMIN))
&& <div className="inline-flex items-center">
Expand Down
3 changes: 3 additions & 0 deletions src/config/apiRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export const apiRoutes = {
agentDedicatedSpinup: '/agents/spinup',
agentSharedSpinup: '/agents/wallet'
},
Platform: {
getAllSchemaFromPlatform: '/platform/schemas',
},
public:{
organizations: '/organization/public-profiles',
users:'/users/public-profiles',
Expand Down

0 comments on commit cff3d0f

Please sign in to comment.