diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts
index 667083bf..ca8a9e97 100644
--- a/src/libs/endorserServer.ts
+++ b/src/libs/endorserServer.ts
@@ -1313,6 +1313,28 @@ export const capitalizeAndInsertSpacesBeforeCaps = (text: string) => {
: text[0].toUpperCase() + text.substr(1).replace(/([A-Z])/g, " $1");
};
+/**
+ * Formats type string for display by adding spaces before capitals
+ * and optionally adds an appropriate article prefix (a/an)
+ *
+ * @param text - Text to format
+ * @returns Formatted string with article prefix
+ */
+export const capitalizeAndInsertSpacesBeforeCapsWithAPrefix = (
+ text: string,
+): string => {
+ const word = capitalizeAndInsertSpacesBeforeCaps(text);
+ if (word) {
+ // if the word starts with a vowel, use "an" instead of "a"
+ const firstLetter = word[0].toLowerCase();
+ const vowels = ["a", "e", "i", "o", "u"];
+ const particle = vowels.includes(firstLetter) ? "an" : "a";
+ return particle + " " + word;
+ } else {
+ return "";
+ }
+};
+
/**
return readable summary of claim, or something generic
diff --git a/src/libs/util.ts b/src/libs/util.ts
index dfd3dde5..c64916cc 100644
--- a/src/libs/util.ts
+++ b/src/libs/util.ts
@@ -160,6 +160,41 @@ export const isGiveAction = (
return isGiveClaimType(veriClaim.claimType);
};
+export interface OfferFulfillment {
+ offerHandleId: string;
+ offerType: string;
+}
+
+/**
+ * Extract offer fulfillment information from the fulfills field
+ * Handles both array and single object cases
+ */
+export const extractOfferFulfillment = (fulfills: any): OfferFulfillment | null => {
+ if (!fulfills) {
+ return null;
+ }
+
+ // Handle both array and single object cases
+ let offerFulfill = null;
+
+ if (Array.isArray(fulfills)) {
+ // Find the Offer in the fulfills array
+ offerFulfill = fulfills.find((item) => item["@type"] === "Offer");
+ } else if (fulfills["@type"] === "Offer") {
+ // fulfills is a single Offer object
+ offerFulfill = fulfills;
+ }
+
+ if (offerFulfill) {
+ return {
+ offerHandleId: offerFulfill.identifier,
+ offerType: offerFulfill["@type"],
+ };
+ }
+
+ return null;
+};
+
export const shortDid = (did: string) => {
if (did.startsWith("did:peer:")) {
return (
diff --git a/src/views/ClaimView.vue b/src/views/ClaimView.vue
index f594dc9b..2c441687 100644
--- a/src/views/ClaimView.vue
+++ b/src/views/ClaimView.vue
@@ -24,7 +24,9 @@
{{
- capitalizeAndInsertSpacesBeforeCaps(veriClaim.claimType || "")
+ serverUtil.capitalizeAndInsertSpacesBeforeCaps(
+ veriClaim.claimType || "",
+ )
}}
+
+
+
+
+ This fulfills a bigger plan
+
+
+
-
-
-
- This fulfills a bigger plan
-
-
-
-
-
-
-
- This fulfills
- {{
- capitalizeAndInsertSpacesBeforeCapsWithAPrefix(
- giveDetails?.fulfillsType || "",
- )
- }}
-
-
+
+
+
+
+ This fulfills
+ {{
+ serverUtil.capitalizeAndInsertSpacesBeforeCapsWithAPrefix(
+ giveDetailsOfferFulfillment.offerType || "Offer",
+ )
+ }}
+
+
+
@@ -493,6 +493,11 @@ export default class ConfirmGiftView extends Vue {
confsVisibleErrorMessage = "";
confsVisibleToIdList: string[] = []; // list of DIDs that can see any confirmer
giveDetails?: GiveSummaryRecord;
+ // Additional offer information extracted from the fulfills array
+ giveDetailsOfferFulfillment: {
+ offerHandleId?: string;
+ offerType?: string;
+ } | null = null;
giverName = "";
issuerName = "";
isLoading = false;
@@ -648,6 +653,8 @@ export default class ConfirmGiftView extends Vue {
if (resp.status === 200) {
this.giveDetails = resp.data.data[0];
+ // Extract offer information from the fulfills array
+ this.extractOfferFulfillment();
} else {
throw new Error("Error getting detailed give info: " + resp.status);
}
@@ -707,6 +714,15 @@ export default class ConfirmGiftView extends Vue {
}
}
+ /**
+ * Extract offer fulfillment information from the fulfills array
+ */
+ private extractOfferFulfillment() {
+ this.giveDetailsOfferFulfillment = libsUtil.extractOfferFulfillment(
+ this.giveDetails?.fullClaim?.fulfills
+ );
+ }
+
/**
* Fetches confirmer information for the claim
*/
@@ -849,27 +865,6 @@ export default class ConfirmGiftView extends Vue {
);
}
- /**
- * Formats type string for display by adding spaces before capitals
- * Optionally adds a prefix
- *
- * @param text - Text to format
- * @param prefix - Optional prefix to add
- * @returns Formatted string
- */
- capitalizeAndInsertSpacesBeforeCapsWithAPrefix(text: string): string {
- const word = this.capitalizeAndInsertSpacesBeforeCaps(text);
- if (word) {
- // if the word starts with a vowel, use "an" instead of "a"
- const firstLetter = word[0].toLowerCase();
- const vowels = ["a", "e", "i", "o", "u"];
- const particle = vowels.includes(firstLetter) ? "an" : "a";
- return particle + " " + word;
- } else {
- return "";
- }
- }
-
/**
* Initiates sharing of claim information
* Handles share functionality based on platform capabilities
@@ -894,11 +889,5 @@ export default class ConfirmGiftView extends Vue {
this.veriClaim = serverUtil.BLANK_GENERIC_SERVER_RECORD;
this.veriClaimDump = "";
}
-
- capitalizeAndInsertSpacesBeforeCaps(text: string) {
- return !text
- ? ""
- : text[0].toUpperCase() + text.substr(1).replace(/([A-Z])/g, " $1");
- }
}