forked from jsnbuchanan/crowd-funder-for-time-pwa
update offer dialog to allow other units
This commit is contained in:
@@ -32,7 +32,8 @@ export interface GiverOutputInfo {
|
||||
action: string;
|
||||
giver?: GiverInputInfo;
|
||||
description?: string;
|
||||
hours?: number;
|
||||
amount?: number;
|
||||
unitCode?: string;
|
||||
}
|
||||
|
||||
export interface ClaimResult {
|
||||
@@ -311,17 +312,17 @@ export type CreateAndSubmitClaimResult = SuccessResult | ErrorResult;
|
||||
* @param identity
|
||||
* @param fromDid may be null
|
||||
* @param toDid
|
||||
* @param description may be null; should have this or hours
|
||||
* @param hours may be null; should have this or description
|
||||
* @param description may be null; should have this or amount
|
||||
* @param amount may be null; should have this or description
|
||||
*/
|
||||
export async function createAndSubmitGive(
|
||||
axios: Axios,
|
||||
apiServer: string,
|
||||
identity: IIdentifier,
|
||||
fromDid?: string,
|
||||
fromDid?: string | null,
|
||||
toDid?: string,
|
||||
description?: string,
|
||||
hours?: number,
|
||||
amount?: number,
|
||||
unitCode?: string,
|
||||
fulfillsProjectHandleId?: string,
|
||||
fulfillsOfferHandleId?: string,
|
||||
@@ -333,8 +334,8 @@ export async function createAndSubmitGive(
|
||||
recipient: toDid ? { identifier: toDid } : undefined,
|
||||
agent: fromDid ? { identifier: fromDid } : undefined,
|
||||
description: description || undefined,
|
||||
object: hours
|
||||
? { amountOfThisGood: hours, unitCode: unitCode || "HUR" }
|
||||
object: amount
|
||||
? { amountOfThisGood: amount, unitCode: unitCode || "HUR" }
|
||||
: undefined,
|
||||
fulfills: [{ "@type": isTrade ? "TradeAction" : "DonateAction" }],
|
||||
};
|
||||
@@ -364,8 +365,8 @@ export async function createAndSubmitGive(
|
||||
* For result, see https://api.endorser.ch/api-docs/#/claims/post_api_v2_claim
|
||||
*
|
||||
* @param identity
|
||||
* @param description may be null; should have this or hours
|
||||
* @param hours may be null; should have this or description
|
||||
* @param description may be null; should have this or amount
|
||||
* @param amount may be null; should have this or description
|
||||
* @param expirationDate ISO 8601 date string YYYY-MM-DD (may be null)
|
||||
* @param fulfillsProjectHandleId ID of project to which this contributes (may be null)
|
||||
*/
|
||||
@@ -374,7 +375,8 @@ export async function createAndSubmitOffer(
|
||||
apiServer: string,
|
||||
identity: IIdentifier,
|
||||
description?: string,
|
||||
hours?: number,
|
||||
amount?: number,
|
||||
unitCode?: string,
|
||||
expirationDate?: string,
|
||||
fulfillsProjectHandleId?: string,
|
||||
): Promise<CreateAndSubmitClaimResult> {
|
||||
@@ -384,10 +386,10 @@ export async function createAndSubmitOffer(
|
||||
offeredBy: { identifier: identity.did },
|
||||
validThrough: expirationDate || undefined,
|
||||
};
|
||||
if (hours) {
|
||||
if (amount) {
|
||||
vcClaim.includesObject = {
|
||||
amountOfThisGood: hours,
|
||||
unitCode: "HUR",
|
||||
amountOfThisGood: amount,
|
||||
unitCode: unitCode || "HUR",
|
||||
};
|
||||
}
|
||||
if (description) {
|
||||
|
||||
Reference in New Issue
Block a user