forked from trent_larson/crowd-funder-for-time-pwa
fix: from merge
This commit is contained in:
@@ -165,18 +165,26 @@ export interface OfferFulfillment {
|
||||
offerType: string;
|
||||
}
|
||||
|
||||
interface FulfillmentItem {
|
||||
"@type": string;
|
||||
identifier?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract offer fulfillment information from the fulfills field
|
||||
* Handles both array and single object cases
|
||||
*/
|
||||
export const extractOfferFulfillment = (fulfills: any): OfferFulfillment | null => {
|
||||
export const extractOfferFulfillment = (
|
||||
fulfills: FulfillmentItem | FulfillmentItem[] | null | undefined,
|
||||
): 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");
|
||||
@@ -184,14 +192,14 @@ export const extractOfferFulfillment = (fulfills: any): OfferFulfillment | null
|
||||
// fulfills is a single Offer object
|
||||
offerFulfill = fulfills;
|
||||
}
|
||||
|
||||
|
||||
if (offerFulfill) {
|
||||
return {
|
||||
offerHandleId: offerFulfill.identifier,
|
||||
offerHandleId: offerFulfill.identifier || "",
|
||||
offerType: offerFulfill["@type"],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user