Skip to content

Commit

Permalink
fix: routes changes
Browse files Browse the repository at this point in the history
Signed-off-by: bhavanakarwade <[email protected]>
  • Loading branch information
bhavanakarwade committed Aug 26, 2024
2 parents c46f1af + 579d269 commit d2575a6
Show file tree
Hide file tree
Showing 64 changed files with 3,642 additions and 733 deletions.
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PUBLIC_CRYPTO_PRIVATE_KEY=
PUBLIC_SHOW_NAME_AS_LOGO= # Please provide true if you want to give platform name with logo

PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_ID= # Please sepcify your client id
PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRETE= # Please specify your client secrete
PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET= # Please specify your client secrete

PUBLIC_PLATFORM_NAME= # Please specify your paltform name
PUBLIC_PLATFORM_LOGO= # Please specify your logo file link
Expand Down
7 changes: 4 additions & 3 deletions src/api/BulkIssuance.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { SchemaTypes } from '../common/enums';
import { apiRoutes } from '../config/apiRoutes';
import { storageKeys } from '../config/CommonConstant';
import {
Expand All @@ -8,7 +9,7 @@ import { axiosGet, axiosPost } from '../services/apiRequests';
import { getFromLocalStorage } from './Auth';
import type { IConnectionListAPIParameter } from './connection';

export const getSchemaCredDef = async (schemaType: string) => {
export const getSchemaCredDef = async (schemaType: SchemaTypes) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.bulk.credefList}?schemaType=${schemaType}`;
const axiosPayload = {
Expand All @@ -24,7 +25,7 @@ export const getSchemaCredDef = async (schemaType: string) => {
}
};

export const DownloadCsvTemplate = async (templateId: string, schemaType: string) => {
export const DownloadCsvTemplate = async (templateId: string, schemaType: SchemaTypes) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.download}`;

Expand All @@ -48,7 +49,7 @@ export const DownloadCsvTemplate = async (templateId: string, schemaType: string
export const uploadCsvFile = async (
payload: { file: Uint8Array | Blob; fileName: string },
templateId: string,
schemaType: string
schemaType: SchemaTypes
) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.bulk.uploadCsv}?templateId=${templateId}&schemaType=${schemaType}`;
Expand Down
23 changes: 22 additions & 1 deletion src/api/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { getHeaderConfigs } from "../config/GetHeaderConfigs";
export const getAllSchemas = async ({itemPerPage, page, allSearch }: GetAllSchemaListParameter, schemaType?: string) => {
const token = await getFromLocalStorage(storageKeys.TOKEN)
const ledgerId = await getFromLocalStorage(storageKeys.LEDGER_ID)

const details = {
url: `${apiRoutes.Platform.getAllSchemaFromPlatform}?pageSize=${itemPerPage}&searchByText=${allSearch}&pageNumber=${page}&ledgerId=${ledgerId}&schemaType=${schemaType}`,
config: {
Expand Down Expand Up @@ -160,3 +159,25 @@ export const getCredDeffById = async (schemaId: string, orgId: string) => {
}
}

export const getCredDefDetailsByCredDefId = async (credDefId: string, orgId: string) => {
const token = await getFromLocalStorage(storageKeys.TOKEN)
const details = {
url: `${apiRoutes.organizations.root}/${orgId}${apiRoutes.schema.createCredentialDefinition}/${credDefId}`,
config: {
headers: {
'Content-type': 'application/json',
'Authorization': `Bearer ${token}`,
},
},
}

try {
const response = await axiosGet(details)
return response
}
catch (error) {
const err = error as Error
return err?.message
}
}

9 changes: 5 additions & 4 deletions src/api/issuance.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { CredentialType, SchemaType } from '../common/enums';
import { apiRoutes } from '../config/apiRoutes';
import { storageKeys } from '../config/CommonConstant';
import {
Expand Down Expand Up @@ -45,9 +46,9 @@ export const getCredentialDefinitions = async (schemaId: string) => {
}
};

export const issueCredential = async (data: object) => {
export const issueCredential = async (data: object, credentialType:SchemaType) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.issueCredential}`;
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.issueCredential}?credentialType=${credentialType}`;
const payload = data;

const axiosPayload = {
Expand All @@ -64,9 +65,9 @@ export const issueCredential = async (data: object) => {
}
};

export const issueOobEmailCredential = async (data: object) => {
export const issueOobEmailCredential = async (data: object, credentialType:CredentialType) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.issueOobEmailCredential}`;
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Issuance.issueOobEmailCredential}?credentialType=${credentialType}`;
const payload = data;

const axiosPayload = {
Expand Down
23 changes: 20 additions & 3 deletions src/api/verification.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
import type { IssueCredential } from '../common/enums';
import type { IssueCredential, RequestType } from '../common/enums';
import { apiRoutes } from '../config/apiRoutes';
import { storageKeys } from '../config/CommonConstant';
import { getHeaderConfigs } from '../config/GetHeaderConfigs';
import { axiosDelete, axiosGet, axiosPost } from '../services/apiRequests';
import { getFromLocalStorage } from './Auth';
import type { IConnectionListAPIParameter } from './connection';

export const verifyCredential = async (payload: any) => {
export const verifyCredential = async (payload: object, requestType:RequestType) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.verifyCredential}`;
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.verifyCredential}?requestType=${requestType}`;
const axiosPayload = {
url,
payload,
config: await getHeaderConfigs(),
};

try {
return await axiosPost(axiosPayload);
} catch (error) {
const err = error as Error;
return err?.message;
}
};

export const createOobProofRequest = async (payload: object, requestType: RequestType) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);
const url = `${apiRoutes.organizations.root}/${orgId}${apiRoutes.Verification.oobProofRequest}?requestType=${requestType}`;
const axiosPayload = {
url,
payload,
Expand Down
39 changes: 38 additions & 1 deletion src/common/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export enum ProofRequestStateUserText {

export enum SchemaType {
INDY = 'indy',
W3C = 'w3c'
W3C = 'json'
}
export enum IssueCredentialUserText {
offerSent = 'Offered',
Expand Down Expand Up @@ -124,4 +124,41 @@ export enum Ledgers {
INDY = 'indy',
POLYGON = 'polygon',
NO_LEDGER = 'noLedger'
}

export enum SchemaTypeValue {
INDY = 'indy',
POLYGON = 'polygon',
NO_LEDGER = 'no_ledger'
}

export enum SchemaTypes {
schema_INDY = 'indy',
schema_W3C = 'w3c'
}

export enum CredentialType {
INDY = 'indy',
JSONLD = 'jsonld',
}

export enum ProtocolVersion {
V1 = 'v1',
V2 = 'v2'
}

export enum AutoAccept {
ALWAYS = "always",
CONTENT_APPROVED = "contentApproved",
NEVER = "never"
}

export enum RequestType {
INDY = 'indy',
PRESENTATION_EXCHANGE = 'presentationExchange'
}

export enum ProofType {
polygon = 'EcdsaSecp256k1Signature2019',
no_ledger = 'Ed25519Signature2018'
}
2 changes: 1 addition & 1 deletion src/commonComponents/ConfirmationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface IProps {
openModal: boolean;
closeModal: (flag: boolean) => void;
onSuccess: (flag: boolean) => void;
message: string | ReactElement;
message: string | ReactElement |React.ReactNode;
isProcessing: boolean;
success: string | null;
failure: string | null;
Expand Down
80 changes: 80 additions & 0 deletions src/commonComponents/CustomCheckbox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import React, { useEffect, useState } from 'react';
import { setToLocalStorage } from '../api/Auth';
import { storageKeys } from '../config/CommonConstant';
import type { ICustomCheckboxProps, ISchemaData } from './interface';

const CustomCheckbox: React.FC<ICustomCheckboxProps> = ({ showCheckbox, isVerificationUsingEmail, onChange, schemaData }) => {
const [checked, setChecked] = useState<boolean>(false);

useEffect(() => {
if (schemaData) {
try {
const selectedSchemas = JSON.parse(localStorage.getItem('selectedSchemas') ?? '[]');
const isChecked = selectedSchemas.some((schema: ISchemaData) => schema.schemaId === schemaData.schemaId);
setChecked(isChecked);
} catch (error) {
console.error('Error parsing JSON from localStorage:', error);
}
}
}, [schemaData]);

const handleCheckboxChange = async () => {
const newChecked = !checked;
setChecked(newChecked);
onChange(newChecked, schemaData);

try {
const selectedSchemas = JSON.parse(localStorage.getItem('selectedSchemas') ?? '[]');

if (newChecked) {
selectedSchemas.push(schemaData);
} else {
const index = selectedSchemas.findIndex((schema: ISchemaData) => schema.schemaId === schemaData?.schemaId);
if (index > -1) {
selectedSchemas.splice(index, 1);
}
}
await setToLocalStorage(storageKeys.SELECTED_SCHEMAS, JSON.stringify(selectedSchemas));
} catch (error) {
console.error('Error updating localStorage:', error);
}
};

return (
<>
{showCheckbox && (
<button
className={`w-4 h-4 ${isVerificationUsingEmail ? 'flex items-center' : 'absolute bottom-8 right-4'}`}
onClick={handleCheckboxChange}
aria-label="Checkbox"
> <input
type="checkbox"
checked={checked}
onChange={handleCheckboxChange}
className="hidden"
/>
<div
className={`w-full h-full border-2 ${checked ? 'bg-primary-700' : ''}`}
style={{ borderColor: 'rgb(31 78 173 / var(--tw-bg-opacity))', position: 'relative' }}
>
{checked && (
<svg
className="absolute top-0 left-0 w-full h-full text-white"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="5"
strokeLinecap="round"
strokeLinejoin="round"
>
<polyline points="20 6 9 17 4 12" />
</svg>
)}
</div>
</button>
)}
</>
);
};

export default CustomCheckbox;
74 changes: 74 additions & 0 deletions src/commonComponents/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React from 'react';
import { Card } from 'flowbite-react';
import BackButton from '../commonComponents/backbutton';
import BreadCrumbs from '../components/BreadCrumbs'

const Dashboard = ({ title, options, backButtonPath }) => {
return (
<div className="px-4 pt-2 h-full h-[700px]">
<div className="mt-1">
<BreadCrumbs />
</div>
<div className="mb-2 flex justify-between items-center relative">
<h1 className="text-xl font-semibold text-gray-900 sm:text-2xl dark:text-white">
{title}
</h1>
<BackButton path={backButtonPath} />
</div>
<div className="px-6 pt-6 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 dark:bg-gray-800">
<p className="text-gray-900 text-xl text-start font-medium dark:text-white">
Select the appropriate action
</p>
<div className="grid grid-cols-1 lg:grid-cols-3 gap-8 pb-16 pt-12">
{options.map((option) => (
<Card
key={option.heading}
className={`${
option.path
? 'custom-card group transform transition duration-500 ease-in-out overflow-hidden overflow-ellipsis border border-gray-200 shadow-md hover:scale-105 cursor-pointer dark:hover:bg-primary-700 hover:bg-primary-700'
: 'cursor-not-allowed bg-gray-300 text-gray-500 dark:border-gray-600 dark:bg-gray-700'
}`}
style={{
maxHeight: '100%',
overflow: 'auto',
height: '168px',
color: 'inherit',
}}
onClick={() => option.path && (window.location.href = option.path)}
>
<div
className={`flex items-center min-[401px]:flex-nowrap flex-wrap ${
option.path ? 'group-hover:text-white' : ''
}`}
style={{ color: 'inherit' }}
>
<div className="ml-4">
<h5
className={`text-2xl font-semibold ${
option.path
? 'text-primary-700 dark:text-white group-hover:text-white'
: 'text-gray-500'
} pb-2`}
>
{option.heading}
</h5>
<p
className={`text-sm ${
option.path
? 'text-gray-700 dark:text-white group-hover:text-white'
: 'text-gray-500'
}`}
>
{option.description}
</p>
</div>
</div>
</Card>
))}
</div>
</div>
</div>
);
};

export default Dashboard;
Loading

0 comments on commit d2575a6

Please sign in to comment.