forked from trent_larson/crowd-funder-for-time-pwa
Refactoring for cleanup
This commit is contained in:
@@ -112,15 +112,23 @@ export function isHiddenDid(did: string) {
|
||||
/**
|
||||
always returns text, maybe UNNAMED_VISIBLE or UNKNOWN_ENTITY
|
||||
**/
|
||||
export function didInfo(did: string, activeDid: string, allMyDids: string[], contacts: Contact[]): string {
|
||||
export function didInfo(
|
||||
did: string,
|
||||
activeDid: string,
|
||||
allMyDids: string[],
|
||||
contacts: Contact[],
|
||||
): string {
|
||||
const myId = R.find(R.equals(did), allMyDids);
|
||||
if (myId) return `You${myId !== activeDid ? " (Alt ID)" : ""}`;
|
||||
|
||||
const contact = R.find(c => c.did === did, contacts);
|
||||
return contact ? contact.name || "Someone Unnamed in Contacts" :
|
||||
!did ? "Unspecified Person" :
|
||||
isHiddenDid(did) ? "Someone Not In Network" :
|
||||
"Someone Not In Contacts";
|
||||
const contact = R.find((c) => c.did === did, contacts);
|
||||
return contact
|
||||
? contact.name || "Someone Unnamed in Contacts"
|
||||
: !did
|
||||
? "Unspecified Person"
|
||||
: isHiddenDid(did)
|
||||
? "Someone Not In Network"
|
||||
: "Someone Not In Contacts";
|
||||
}
|
||||
|
||||
export interface ResultWithType {
|
||||
@@ -166,7 +174,9 @@ export async function createAndSubmitGive(
|
||||
agent: fromDid ? { identifier: fromDid } : undefined,
|
||||
description: description || undefined,
|
||||
object: hours ? { amountOfThisGood: hours, unitCode: "HUR" } : undefined,
|
||||
fulfills: fulfillsProjectHandleId ? { "@type": "PlanAction", identifier: fulfillsProjectHandleId } : undefined,
|
||||
fulfills: fulfillsProjectHandleId
|
||||
? { "@type": "PlanAction", identifier: fulfillsProjectHandleId }
|
||||
: undefined,
|
||||
};
|
||||
|
||||
const vcPayload = {
|
||||
@@ -209,20 +219,21 @@ export async function createAndSubmitGive(
|
||||
});
|
||||
|
||||
return { type: "success", response };
|
||||
|
||||
} catch (error: unknown) {
|
||||
const errorMessage: string =
|
||||
error instanceof Error ? error.message :
|
||||
(typeof error === "object" && error?.message) ? error.message :
|
||||
"Unknown error";
|
||||
const errorMessage: string =
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: typeof error === "object" && "message" in error
|
||||
? (error as { message: string }).message
|
||||
: "Unknown error";
|
||||
|
||||
return {
|
||||
type: "error",
|
||||
error: {
|
||||
error: errorMessage,
|
||||
userMessage: "Failed to create and submit the claim."
|
||||
}
|
||||
};
|
||||
userMessage: "Failed to create and submit the claim.",
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user