Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:sign endorsement #339

Merged
merged 7 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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