|
@ -430,13 +430,11 @@ |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script lang="ts"> |
|
|
<script lang="ts"> |
|
|
import { AxiosError } from "axios"; |
|
|
|
|
|
import * as yaml from "js-yaml"; |
|
|
import * as yaml from "js-yaml"; |
|
|
import * as R from "ramda"; |
|
|
import * as R from "ramda"; |
|
|
import { Component, Vue } from "vue-facing-decorator"; |
|
|
import { Component, Vue } from "vue-facing-decorator"; |
|
|
import { useClipboard } from "@vueuse/core"; |
|
|
import { useClipboard } from "@vueuse/core"; |
|
|
import { RouteLocationNormalizedLoaded, Router } from "vue-router"; |
|
|
import { RouteLocationNormalizedLoaded, Router } from "vue-router"; |
|
|
import { GenericVerifiableCredential } from "../interfaces"; |
|
|
|
|
|
import QuickNav from "../components/QuickNav.vue"; |
|
|
import QuickNav from "../components/QuickNav.vue"; |
|
|
import { NotificationIface } from "../constants/app"; |
|
|
import { NotificationIface } from "../constants/app"; |
|
|
import { db, retrieveSettingsForActiveAccount } from "../db/index"; |
|
|
import { db, retrieveSettingsForActiveAccount } from "../db/index"; |
|
@ -445,16 +443,16 @@ import * as serverUtil from "../libs/endorserServer"; |
|
|
import { GiveSummaryRecord } from "../interfaces"; |
|
|
import { GiveSummaryRecord } from "../interfaces"; |
|
|
import { displayAmount } from "../libs/endorserServer"; |
|
|
import { displayAmount } from "../libs/endorserServer"; |
|
|
import * as libsUtil from "../libs/util"; |
|
|
import * as libsUtil from "../libs/util"; |
|
|
import { isGiveAction, retrieveAccountDids } from "../libs/util"; |
|
|
import { retrieveAccountDids } from "../libs/util"; |
|
|
import TopMessage from "../components/TopMessage.vue"; |
|
|
import TopMessage from "../components/TopMessage.vue"; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* ConfirmGiftView Component |
|
|
* ConfirmGiftView Component |
|
|
* |
|
|
* |
|
|
* Displays details about a gift claim and allows users to confirm it if eligible. |
|
|
* Displays details about a gift claim and allows users to confirm it if eligible. |
|
|
* Shows gift details including giver, recipient, amount, description, and confirmation status. |
|
|
* Shows gift details including giver, recipient, amount, description, and confirmation status. |
|
|
* Handles visibility of hidden DIDs and provides access to detailed claim information. |
|
|
* Handles visibility of hidden DIDs and provides access to detailed claim information. |
|
|
* |
|
|
* |
|
|
* Key features: |
|
|
* Key features: |
|
|
* - Gift confirmation workflow |
|
|
* - Gift confirmation workflow |
|
|
* - Detailed gift information display |
|
|
* - Detailed gift information display |
|
@ -504,7 +502,7 @@ export default class ConfirmGiftView extends Vue { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Initializes the view with gift claim information |
|
|
* Initializes the view with gift claim information |
|
|
* |
|
|
* |
|
|
* Workflow: |
|
|
* Workflow: |
|
|
* 1. Retrieves active account settings |
|
|
* 1. Retrieves active account settings |
|
|
* 2. Loads gift claim details from ID in URL |
|
|
* 2. Loads gift claim details from ID in URL |
|
@ -534,7 +532,7 @@ export default class ConfirmGiftView extends Vue { |
|
|
this.allContacts = await db.contacts.toArray(); |
|
|
this.allContacts = await db.contacts.toArray(); |
|
|
this.isRegistered = settings.isRegistered || false; |
|
|
this.isRegistered = settings.isRegistered || false; |
|
|
this.allMyDids = await retrieveAccountDids(); |
|
|
this.allMyDids = await retrieveAccountDids(); |
|
|
|
|
|
|
|
|
// Check share capability |
|
|
// Check share capability |
|
|
// When Chrome compatibility is fixed https://developer.mozilla.org/en-US/docs/Web/API/Web_Share_API#api.navigator.canshare |
|
|
// When Chrome compatibility is fixed https://developer.mozilla.org/en-US/docs/Web/API/Web_Share_API#api.navigator.canshare |
|
|
// then use this truer check: navigator.canShare && navigator.canShare() |
|
|
// then use this truer check: navigator.canShare && navigator.canShare() |
|
@ -545,7 +543,9 @@ export default class ConfirmGiftView extends Vue { |
|
|
* Loads and processes claim from URL parameters |
|
|
* Loads and processes claim from URL parameters |
|
|
*/ |
|
|
*/ |
|
|
private async loadClaimFromUrl() { |
|
|
private async loadClaimFromUrl() { |
|
|
const pathParam = window.location.pathname.substring("/confirm-gift/".length); |
|
|
const pathParam = window.location.pathname.substring( |
|
|
|
|
|
"/confirm-gift/".length, |
|
|
|
|
|
); |
|
|
if (!pathParam) { |
|
|
if (!pathParam) { |
|
|
throw new Error("No claim ID was provided."); |
|
|
throw new Error("No claim ID was provided."); |
|
|
} |
|
|
} |
|
@ -563,7 +563,8 @@ export default class ConfirmGiftView extends Vue { |
|
|
group: "alert", |
|
|
group: "alert", |
|
|
type: "danger", |
|
|
type: "danger", |
|
|
title: "Error", |
|
|
title: "Error", |
|
|
text: error instanceof Error ? error.message : "No claim ID was provided.", |
|
|
text: |
|
|
|
|
|
error instanceof Error ? error.message : "No claim ID was provided.", |
|
|
}, |
|
|
}, |
|
|
3000, |
|
|
3000, |
|
|
); |
|
|
); |
|
@ -571,7 +572,7 @@ export default class ConfirmGiftView extends Vue { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Loads claim details and associated give information |
|
|
* Loads claim details and associated give information |
|
|
* |
|
|
* |
|
|
* @param claimId - ID of claim to load |
|
|
* @param claimId - ID of claim to load |
|
|
* @param userDid - User's DID |
|
|
* @param userDid - User's DID |
|
|
*/ |
|
|
*/ |
|
@ -596,7 +597,7 @@ export default class ConfirmGiftView extends Vue { |
|
|
try { |
|
|
try { |
|
|
const headers = await serverUtil.getHeaders(userDid); |
|
|
const headers = await serverUtil.getHeaders(userDid); |
|
|
const resp = await this.axios.get(url, { headers }); |
|
|
const resp = await this.axios.get(url, { headers }); |
|
|
|
|
|
|
|
|
if (resp.status === 200) { |
|
|
if (resp.status === 200) { |
|
|
this.veriClaim = resp.data; |
|
|
this.veriClaim = resp.data; |
|
|
this.veriClaimDump = yaml.dump(this.veriClaim); |
|
|
this.veriClaimDump = yaml.dump(this.veriClaim); |
|
@ -619,11 +620,11 @@ export default class ConfirmGiftView extends Vue { |
|
|
*/ |
|
|
*/ |
|
|
private async fetchGiveDetails(claimId: string, userDid: string) { |
|
|
private async fetchGiveDetails(claimId: string, userDid: string) { |
|
|
const giveUrl = `${this.apiServer}/api/v2/report/gives?handleId=${encodeURIComponent(claimId)}`; |
|
|
const giveUrl = `${this.apiServer}/api/v2/report/gives?handleId=${encodeURIComponent(claimId)}`; |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
const headers = await serverUtil.getHeaders(userDid); |
|
|
const headers = await serverUtil.getHeaders(userDid); |
|
|
const resp = await this.axios.get(giveUrl, { headers }); |
|
|
const resp = await this.axios.get(giveUrl, { headers }); |
|
|
|
|
|
|
|
|
if (resp.status === 200) { |
|
|
if (resp.status === 200) { |
|
|
this.giveDetails = resp.data.data[0]; |
|
|
this.giveDetails = resp.data.data[0]; |
|
|
} else { |
|
|
} else { |
|
@ -683,7 +684,10 @@ export default class ConfirmGiftView extends Vue { |
|
|
if (this.giveDetails?.fullClaim.image) { |
|
|
if (this.giveDetails?.fullClaim.image) { |
|
|
this.urlForNewGive += `&image=${encodeURIComponent(this.giveDetails.fullClaim.image)}`; |
|
|
this.urlForNewGive += `&image=${encodeURIComponent(this.giveDetails.fullClaim.image)}`; |
|
|
} |
|
|
} |
|
|
if (this.giveDetails?.type === "Offer" && this.giveDetails?.fulfillsHandleId) { |
|
|
if ( |
|
|
|
|
|
this.giveDetails?.type === "Offer" && |
|
|
|
|
|
this.giveDetails?.fulfillsHandleId |
|
|
|
|
|
) { |
|
|
this.urlForNewGive += `&offerId=${encodeURIComponent(this.giveDetails.fulfillsHandleId)}`; |
|
|
this.urlForNewGive += `&offerId=${encodeURIComponent(this.giveDetails.fulfillsHandleId)}`; |
|
|
} |
|
|
} |
|
|
if (this.giveDetails?.fulfillsPlanHandleId) { |
|
|
if (this.giveDetails?.fulfillsPlanHandleId) { |
|
@ -701,7 +705,7 @@ export default class ConfirmGiftView extends Vue { |
|
|
this.veriClaim.issuer, |
|
|
this.veriClaim.issuer, |
|
|
userDid, |
|
|
userDid, |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
if (confirmerInfo) { |
|
|
if (confirmerInfo) { |
|
|
this.confirmerIdList = confirmerInfo.confirmerIdList; |
|
|
this.confirmerIdList = confirmerInfo.confirmerIdList; |
|
|
this.confsVisibleToIdList = confirmerInfo.confsVisibleToIdList; |
|
|
this.confsVisibleToIdList = confirmerInfo.confsVisibleToIdList; |
|
@ -714,7 +718,7 @@ export default class ConfirmGiftView extends Vue { |
|
|
/** |
|
|
/** |
|
|
* Calculates total number of confirmers for the gift |
|
|
* Calculates total number of confirmers for the gift |
|
|
* Includes both direct confirmers and those visible through network |
|
|
* Includes both direct confirmers and those visible through network |
|
|
* |
|
|
* |
|
|
* @returns Total number of confirmers |
|
|
* @returns Total number of confirmers |
|
|
*/ |
|
|
*/ |
|
|
totalConfirmers(): number { |
|
|
totalConfirmers(): number { |
|
@ -725,21 +729,10 @@ export default class ConfirmGiftView extends Vue { |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Formats display amount with proper unit |
|
|
|
|
|
* |
|
|
|
|
|
* @param unit - Currency or unit code |
|
|
|
|
|
* @param amount - Numeric amount |
|
|
|
|
|
* @returns Formatted amount string |
|
|
|
|
|
*/ |
|
|
|
|
|
displayAmount(unit: string, amount: number): string { |
|
|
|
|
|
return displayAmount(unit, amount); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Retrieves human-readable name for a DID |
|
|
* Retrieves human-readable name for a DID |
|
|
* Falls back to DID if no name available |
|
|
* Falls back to DID if no name available |
|
|
* |
|
|
* |
|
|
* @param did - DID to get name for |
|
|
* @param did - DID to get name for |
|
|
* @returns Human-readable name |
|
|
* @returns Human-readable name |
|
|
*/ |
|
|
*/ |
|
@ -754,7 +747,7 @@ export default class ConfirmGiftView extends Vue { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Copies text to clipboard and shows notification |
|
|
* Copies text to clipboard and shows notification |
|
|
* |
|
|
* |
|
|
* @param description - Description of copied content |
|
|
* @param description - Description of copied content |
|
|
* @param text - Text to copy |
|
|
* @param text - Text to copy |
|
|
*/ |
|
|
*/ |
|
@ -776,7 +769,7 @@ export default class ConfirmGiftView extends Vue { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Navigates to claim page for detailed view |
|
|
* Navigates to claim page for detailed view |
|
|
* |
|
|
* |
|
|
* @param claimId - ID of claim to view |
|
|
* @param claimId - ID of claim to view |
|
|
*/ |
|
|
*/ |
|
|
showClaimPage(claimId: string): void { |
|
|
showClaimPage(claimId: string): void { |
|
@ -826,15 +819,12 @@ export default class ConfirmGiftView extends Vue { |
|
|
/** |
|
|
/** |
|
|
* Formats type string for display by adding spaces before capitals |
|
|
* Formats type string for display by adding spaces before capitals |
|
|
* Optionally adds a prefix |
|
|
* Optionally adds a prefix |
|
|
* |
|
|
* |
|
|
* @param text - Text to format |
|
|
* @param text - Text to format |
|
|
* @param prefix - Optional prefix to add |
|
|
* @param prefix - Optional prefix to add |
|
|
* @returns Formatted string |
|
|
* @returns Formatted string |
|
|
*/ |
|
|
*/ |
|
|
capitalizeAndInsertSpacesBeforeCapsWithAPrefix( |
|
|
capitalizeAndInsertSpacesBeforeCapsWithAPrefix(text: string): string { |
|
|
text: string, |
|
|
|
|
|
prefix?: string |
|
|
|
|
|
): string { |
|
|
|
|
|
const word = this.capitalizeAndInsertSpacesBeforeCaps(text); |
|
|
const word = this.capitalizeAndInsertSpacesBeforeCaps(text); |
|
|
if (word) { |
|
|
if (word) { |
|
|
// if the word starts with a vowel, use "an" instead of "a" |
|
|
// if the word starts with a vowel, use "an" instead of "a" |
|
|