Skip to content

Commit

Permalink
Merge pull request #339 from credebl/feat-sign-endorsement
Browse files Browse the repository at this point in the history
feat:sign endorsement
  • Loading branch information
nishad-ayanworks authored Oct 12, 2023
2 parents a450081 + 2206149 commit 1695058
Show file tree
Hide file tree
Showing 7 changed files with 565 additions and 387 deletions.
19 changes: 17 additions & 2 deletions src/api/ecosystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export interface GetEndorsementListParameter {
status: string
}


export const createEcosystems = async (dataPayload: CreateEcosystemPayload) => {
const orgId = await getFromLocalStorage(storageKeys.ORG_ID);

Expand Down Expand Up @@ -66,7 +65,6 @@ export const updateEcosystem = async (dataPayload: CreateEcosystemPayload) => {
}
}


export const getEcosystem = async (orgId: string) => {
const url = `${apiRoutes.Ecosystem.root}/${orgId}`

Expand Down Expand Up @@ -139,6 +137,23 @@ export const createCredDefRequest = async (data: object, ecosystemId: string, or
}
}

export const SignEndorsementRequest = async ( ecosystemId: string, orgId: string, endorsementId: string) => {

const url = `${apiRoutes.Ecosystem.root}/${ecosystemId}/${orgId}${apiRoutes.Ecosystem.endorsements.signRequest}${endorsementId}`

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

export const getEcosystemDashboard = async (ecosystemId: string, orgId: string) => {

const url = `${apiRoutes.Ecosystem.root}/${ecosystemId}/${orgId}/dashboard`
Expand Down
9 changes: 4 additions & 5 deletions src/common/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ export enum EndorsementType {
}

export enum EndorsementStatus {
all = "all",
approved = "approved",
rejected = "rejected",
requested = "requested",
submitted = "submitted"
signed = "signed",
rejected = "declined",
requested = "requested",
submitted = "submited"
}

export enum EcosystemRoles {
Expand Down
7 changes: 6 additions & 1 deletion src/commonComponents/StatusTabletTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface IStatusTabletTag {
const StatusTabletTag = ({ status }: IStatusTabletTag) => {
const color = () => {
switch (true) {
case status === EndorsementStatus.approved:
case status === EndorsementStatus.signed || status === EndorsementStatus.submitted:
return {
style: `bg-[#70ffa01a] text-[#28C76F]`,
title: "Accepted"
Expand All @@ -22,6 +22,11 @@ const StatusTabletTag = ({ status }: IStatusTabletTag) => {
style: `bg-[#EEE] text-[#7D7D7D]`,
title: "Requested"
}
case status === EndorsementStatus.submitted:
return {
style: `bg-[#70ffa01a] text-[#28C76F] `,
title: "Submitted"
}
default:
return {
style: `bg-[#FFE4E4] text-[#EA5455]`,
Expand Down
3 changes: 1 addition & 2 deletions src/components/Ecosystem/Endorsement/EndorsementCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ const EndorsementCard = ({ fromEndorsementList, data, onClickCallback, cardTrans
checkEcosystemData();
}, [])

const enableAction = (!fromEndorsementList && data?.status === EndorsementStatus.signed) || Boolean(fromEndorsementList)
const isSchema = data?.type === EndorsementType.schema

const enableAction = (!fromEndorsementList && data?.status === EndorsementStatus.approved) || Boolean(fromEndorsementList)

const requestPayload = data?.requestPayload && JSON.parse(data?.requestPayload)

const requestData = isSchema ? requestPayload?.operation?.data : requestPayload?.operation
Expand Down
325 changes: 209 additions & 116 deletions src/components/Ecosystem/Endorsement/EndorsementPopup.tsx

Large diffs are not rendered by default.

Loading

0 comments on commit 1695058

Please sign in to comment.