forked from jsnbuchanan/crowd-funder-for-time-pwa
add ability to give to fulfill an offer; adjust visibility of claim actions
This commit is contained in:
@@ -52,6 +52,7 @@ export interface GenericServerRecord extends GenericVerifiableCredential {
|
||||
issuer?: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
claim: Record<any, any>;
|
||||
claimType?: string;
|
||||
}
|
||||
export const BLANK_GENERIC_SERVER_RECORD: GenericServerRecord = {
|
||||
"@context": SCHEMA_ORG_CONTEXT,
|
||||
@@ -259,8 +260,8 @@ export function removeVisibleToDids(input: any): any {
|
||||
Similar logic is found in endorser-mobile.
|
||||
**/
|
||||
export function didInfo(
|
||||
did: string,
|
||||
activeDid: string,
|
||||
did: string | undefined,
|
||||
activeDid: string | undefined,
|
||||
allMyDids: string[],
|
||||
contacts: Contact[],
|
||||
): string {
|
||||
@@ -312,6 +313,7 @@ export async function createAndSubmitGive(
|
||||
hours?: number,
|
||||
unitCode?: string,
|
||||
fulfillsProjectHandleId?: string,
|
||||
fulfillsOfferHandleId?: string,
|
||||
isTrade: boolean = false,
|
||||
): Promise<CreateAndSubmitClaimResult> {
|
||||
const vcClaim: GiveVerifiableCredential = {
|
||||
@@ -332,6 +334,13 @@ export async function createAndSubmitGive(
|
||||
identifier: fulfillsProjectHandleId,
|
||||
});
|
||||
}
|
||||
if (fulfillsOfferHandleId) {
|
||||
vcClaim.fulfills = vcClaim.fulfills || []; // weird that it won't typecheck without this
|
||||
vcClaim.fulfills.push({
|
||||
"@type": "Offer",
|
||||
identifier: fulfillsOfferHandleId,
|
||||
});
|
||||
}
|
||||
return createAndSubmitClaim(
|
||||
vcClaim as GenericServerRecord,
|
||||
identity,
|
||||
@@ -437,7 +446,7 @@ export async function createAndSubmitClaim(
|
||||
return { type: "success", response };
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (error: any) {
|
||||
console.log("Error creating claim:", error);
|
||||
console.error("Error creating claim:", error);
|
||||
const errorMessage: string =
|
||||
error.response?.data?.error?.message || error.message || "Unknown error";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user