From 1731f2443be3662ac8d575bda2d4a7286cf3c6f4 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Wed, 17 Jan 2024 20:50:35 -0700 Subject: [PATCH] update offer dialog to allow other units --- src/components/GiftedDialog.vue | 41 +++++++--------------- src/components/OfferDialog.vue | 61 ++++++++++++++++++++++++--------- src/libs/endorserServer.ts | 28 ++++++++------- src/libs/util.ts | 26 +++++++++++--- 4 files changed, 94 insertions(+), 62 deletions(-) diff --git a/src/components/GiftedDialog.vue b/src/components/GiftedDialog.vue index 633ff46..6120c7a 100644 --- a/src/components/GiftedDialog.vue +++ b/src/components/GiftedDialog.vue @@ -12,10 +12,10 @@ />
- {{ UNIT_SHORT[unitCode] }} + {{ libsUtil.UNIT_SHORT[unitCode] }}
= { - "BTC": "BTC", - "ETH": "ETH", - "HUR": "Hours", - "USD": "US $", - }; - /* eslint-enable prettier/prettier */ - - /* eslint-disable prettier/prettier */ - UNIT_LONG: Record = { - "BTC": "Bitcoin", - "ETH": "Ethereum", - "HUR": "hours", - "USD": "dollars", - }; - /* eslint-enable prettier/prettier */ + libsUtil = libsUtil; async created() { try { @@ -177,7 +162,7 @@ export default class GiftedDialog extends Vue { } changeUnitCode() { - const units = Object.keys(this.UNIT_SHORT); + const units = Object.keys(this.libsUtil.UNIT_SHORT); const index = units.indexOf(this.unitCode); this.unitCode = units[(index + 1) % units.length]; } @@ -203,6 +188,7 @@ export default class GiftedDialog extends Vue { this.giver = undefined; this.givenToUser = this.showGivenToUser; this.amountInput = "0"; + this.unitCode = "HUR"; } async confirm() { @@ -218,7 +204,7 @@ export default class GiftedDialog extends Vue { ); // this is asynchronous, but we don't need to wait for it to complete await this.recordGive( - this.giver?.did as string | undefined, + (this.giver?.did as string) || null, this.description, parseFloat(this.amountInput), this.unitCode, @@ -248,12 +234,13 @@ export default class GiftedDialog extends Vue { * @param giverDid may be null * @param description may be an empty string * @param amountInput may be 0 + * @param unitCode may be omitted, defaults to "HUR" */ public async recordGive( - giverDid?: string, - description?: string, - amountInput?: number, - unitCode?: string, + giverDid: string | null, + description: string, + amountInput: number, + unitCode: string = "HUR", ) { if (!this.activeDid) { this.$notify( @@ -274,9 +261,7 @@ export default class GiftedDialog extends Vue { group: "alert", type: "danger", title: "Error", - text: `You must enter a description or some number of ${ - this.UNIT_LONG[this.unitCode] - }.`, + text: `You must enter a description or some number of ${this.libsUtil.UNIT_LONG[unitCode]}.`, }, -1, ); diff --git a/src/components/OfferDialog.vue b/src/components/OfferDialog.vue index 84d6666..e163cfc 100644 --- a/src/components/OfferDialog.vue +++ b/src/components/OfferDialog.vue @@ -8,22 +8,24 @@ placeholder="Description, prerequisites, terms, etc." v-model="description" /> -
+
- Hours + {{ libsUtil.UNIT_SHORT[amountUnitCode] }}
-
+
@@ -45,7 +47,9 @@ v-model="expirationDateInput" />
-

Sign & Send to publish to the world

+

+ Sign & Send to publish to the world +