decord/source/modules/virtual_currency/hooks/useRedeemVirtualCurrency.tsx

128 lines
3.8 KiB
TypeScript
Raw Normal View History

2026-07-24 07:16:23 +00:00
// Module ID: 8767
// Function ID: 69281
2026-07-20 16:05:17 +00:00
// Name: useRedeemVirtualCurrency
2026-07-24 07:16:23 +00:00
// Dependencies: [5, 57, 31, 4113, 8768, 3798, 5625, 3791, 8766, 1212, 2]
2026-07-20 16:05:17 +00:00
// Exports: useRedeemVirtualCurrency
2026-07-24 07:16:23 +00:00
// Module 8767 (useRedeemVirtualCurrency)
2026-07-23 10:11:24 +00:00
import _isNativeReflectConstruct from "_isNativeReflectConstruct";
import _slicedToArray from "_slicedToArray";
import result from "result";
import { OrderStatus } from "CustomCheckoutFlow";
let closure_5;
let closure_6;
let closure_7;
const require = arg1;
({ useState: closure_5, useEffect: closure_6, useCallback: closure_7 } = result);
result = require("result").fileFinishedImporting("modules/virtual_currency/hooks/useRedeemVirtualCurrency.tsx");
2026-07-20 16:05:17 +00:00
export const useRedeemVirtualCurrency = function useRedeemVirtualCurrency(order) {
2026-07-23 10:11:24 +00:00
let require;
2026-07-20 16:05:17 +00:00
let tmp2;
2026-07-23 10:11:24 +00:00
[tmp2, require] = callback(callback2(""), 2);
2026-07-20 16:05:17 +00:00
const tmp3 = callback(callback2([]), 2);
const entitlements = tmp3[0];
2026-07-23 10:11:24 +00:00
const dependencyMap = tmp3[1];
2026-07-20 16:05:17 +00:00
const tmp5 = callback(callback2(null), 2);
const error = tmp5[0];
2026-07-23 10:11:24 +00:00
callback = tmp5[1];
2026-07-20 16:05:17 +00:00
const isSubmitting = callback(callback2(false), 2);
2026-07-23 10:11:24 +00:00
callback2 = isSubmitting[1];
2026-07-20 16:05:17 +00:00
const tmp = callback(callback2(""), 2);
2026-07-24 07:16:23 +00:00
const enabled = entitlements(8768).useConfig({ location: "orb_checkout_modal" }).enabled;
2026-07-20 16:05:17 +00:00
order = undefined;
if (null != order) {
order = order.order;
}
let tmp9 = null;
if (null != order) {
tmp9 = order;
}
2026-07-23 10:11:24 +00:00
const callback3 = tmp9;
2026-07-20 16:05:17 +00:00
let onSignFailure;
if (null != order) {
onSignFailure = order.onSignFailure;
}
const items = [tmp9, onSignFailure];
2026-07-23 10:11:24 +00:00
const tmp11 = callback3((() => {
2026-07-20 16:05:17 +00:00
// CreateGeneratorClosureLongIndex (0x67)
let closure_0 = error(tmp);
return function(arg0, arg1, arg2) {
return callback(...arguments);
};
2026-07-23 10:11:24 +00:00
})(), items);
let closure_9 = tmp11;
const tmp12 = callback3((skuId, loadId) => {
let closure_0 = arg2;
2026-07-24 07:16:23 +00:00
let obj = outer1_0(8766);
2026-07-20 16:05:17 +00:00
obj = {
skuId,
loadId,
onRedeemStart() {
2026-07-23 10:11:24 +00:00
outer1_5(true);
outer1_4(null);
2026-07-20 16:05:17 +00:00
},
onRedeemSucceed(arg0) {
2026-07-23 10:11:24 +00:00
outer1_2(arg0);
outer1_5(false);
if (null != callback) {
callback(arg0);
2026-07-20 16:05:17 +00:00
}
},
onRedeemFail(arg0) {
2026-07-23 10:11:24 +00:00
outer1_4(arg0);
outer1_5(false);
2026-07-20 16:05:17 +00:00
}
};
return obj.redeemVirtualCurrencyForSKU(obj);
}, []);
2026-07-23 10:11:24 +00:00
let closure_10 = tmp12;
2026-07-20 16:05:17 +00:00
const items1 = [enabled, tmp11, tmp12];
const items2 = [entitlements, error];
2026-07-23 10:11:24 +00:00
const redeemVirtualCurrency = callback3((arg0, arg1, arg2) => {
2026-07-20 16:05:17 +00:00
if (enabled) {
tmp11(arg0, arg1, arg2);
} else {
tmp12(arg0, arg1, arg2);
}
}, items1);
enabled(() => {
if (null == error) {
if (null != entitlements) {
if (entitlements.length > 0) {
const mapped = entitlements.map((sku) => {
sku = sku.sku;
let name;
if (null != sku) {
name = sku.name;
}
return name;
});
2026-07-23 10:11:24 +00:00
const intl2 = outer1_0(1212).intl;
2026-07-20 16:05:17 +00:00
let obj = { amountDescription: "1 orb" };
let str4 = "SKUs";
if (1 === mapped.length) {
str4 = "SKU";
}
const joined = mapped.join(", ");
let str6 = "IDs";
if (1 === entitlements.length) {
str6 = "ID";
}
const mapped1 = entitlements.map((id) => id.id);
const _HermesInternal = HermesInternal;
obj.redeemedItemDescription = "" + str4 + ": " + joined + ". Entitlement " + str6 + ": " + mapped1.join(", ");
2026-07-23 10:11:24 +00:00
callback(intl2.format(outer1_0(1212).t.JxNFav, obj));
2026-07-20 16:05:17 +00:00
}
}
callback("");
} else {
2026-07-23 10:11:24 +00:00
const intl = outer1_0(1212).intl;
2026-07-20 16:05:17 +00:00
obj = { amount: "1 orb", errorMessage: error.message };
2026-07-23 10:11:24 +00:00
callback(intl.format(outer1_0(1212).t["7gHWrd"], obj));
2026-07-20 16:05:17 +00:00
}
}, items2);
return { entitlements, error, isSubmitting: isSubmitting[0], responseMessage, redeemVirtualCurrency };
};