decord/alpha/source/modules/checkout/native/useGiftCardMobileConsumptionHalfsheet.tsx

189 lines
6.3 KiB
TypeScript
Raw Normal View History

2026-10-09 10:00:15 +00:00
// Module ID: 7090
// Function ID: 7091
2026-07-20 16:05:17 +00:00
// Name: useGiftCardMobileConsumptionHalfsheet
2026-10-09 10:00:15 +00:00
// Dependencies: [32, 19, 7091, 4731, 2061, 1096, 7092, 504, 2049, 7093, 5721, 584, 7097, 2000, 5055, 2]
2026-07-20 16:05:17 +00:00
// Exports: useGiftCardMobileConsumptionHalfsheet
2026-10-09 10:00:15 +00:00
// Module 7090 (useGiftCardMobileConsumptionHalfsheet)
2026-10-03 08:58:59 +00:00
import DispatcherDefault from "Dispatcher" /* 584 */;
import Constants from "Constants" /* 1096 */;
2026-10-09 10:00:15 +00:00
import dismissible_content from "dismissible_content" /* 2049 */;
import DismissibleContentConstants from "DismissibleContentConstants" /* 2061 */;
import ActionSheetActionCreatorsDefault from "ActionSheetActionCreators" /* 5055 */;
import actions_BillingActionCreators from "actions/BillingActionCreators" /* 5721 */;
2026-10-03 08:58:59 +00:00
import _slicedToArray from "_slicedToArray" /* 32 */;
import react_mod from "react" /* 19 */;
2026-10-09 10:00:15 +00:00
import WalletBalanceStore from "WalletBalanceStore" /* 7091 */;
import PaymentSourceStore from "PaymentSourceStore" /* 4731 */;
2026-10-03 08:58:59 +00:00
import size from "module_2" /* 2 */;
2026-07-21 22:01:30 +00:00
2026-10-03 08:58:59 +00:00
let Idle, dependencyMap;
let tmp;
2026-10-09 10:00:15 +00:00
const asyncRequire = tmp(2000);
2026-10-03 08:58:59 +00:00
let react = react_mod;
const ContentDismissActionType = DismissibleContentConstants.ContentDismissActionType;
const PaymentSourceTypes = Constants.PaymentSourceTypes;
2026-07-29 08:29:29 +00:00
const GiftCardMobileConsumptionActionSheet = "GiftCardMobileConsumptionActionSheet";
2026-07-23 10:11:24 +00:00
let obj = { Idle: "idle", Opening: "opening", Opened: "opened" };
let Opening = obj.Idle;
const result = size.fileFinishedImporting("modules/checkout/native/useGiftCardMobileConsumptionHalfsheet.tsx");
2026-07-20 16:05:17 +00:00
export const useGiftCardMobileConsumptionHalfsheet = function useGiftCardMobileConsumptionHalfsheet() {
2026-10-03 08:58:59 +00:00
let closure_2;
let current;
let enabled;
let first;
let markAsDismissed;
let ref;
2026-07-29 08:29:29 +00:00
let tmp = enabled;
2026-10-03 08:58:59 +00:00
let tmp2 = dependencyMap;
2026-10-09 10:00:15 +00:00
obj = enabled(7092);
2026-10-03 08:58:59 +00:00
enabled = obj.useGiftCardsExperimentConfig({ location: "useGiftCardMobileConsumptionHalfsheet" }).enabled;
let obj2 = enabled(504);
let items = [markAsDismissed];
2026-07-23 10:11:24 +00:00
let items1 = [enabled];
2026-10-03 08:58:59 +00:00
const stateFromStores = obj2.useStateFromStores(items, () => {
const tmp = enabled;
if (tmp) {
2026-07-20 16:05:17 +00:00
const _Object = Object;
const values = Object.values(PaymentSourceStore.paymentSources);
2026-07-29 08:29:29 +00:00
for (const item10013 of values) {
if (item10013.type === PaymentSourceTypes.TDS_WALLET) {
2026-10-03 08:58:59 +00:00
let id = item10013.id;
2026-07-29 08:29:29 +00:00
obj.return();
2026-10-03 08:58:59 +00:00
return id;
2026-07-20 16:05:17 +00:00
}
}
return null;
} else {
return null;
}
}, items1);
2026-10-03 08:58:59 +00:00
let obj3 = enabled(504);
const items2 = [ref];
2026-07-20 16:05:17 +00:00
const items3 = [stateFromStores];
2026-10-03 08:58:59 +00:00
const stateFromStores1 = obj3.useStateFromStores(items2, () => {
2026-07-20 16:05:17 +00:00
let balance = null;
if (null != stateFromStores) {
balance = WalletBalanceStore.getBalance(tmp);
2026-07-20 16:05:17 +00:00
}
return balance;
}, items3);
const items4 = [ref];
2026-07-20 16:05:17 +00:00
const items5 = [stateFromStores];
2026-07-29 08:29:29 +00:00
let tmp6 = enabled;
2026-10-03 08:58:59 +00:00
const obj4 = enabled(504);
const stateFromStores2 = obj4.useStateFromStores(items4, () => {
const isFetching = null != stateFromStores && WalletBalanceStore.getIsFetching(tmp);
2026-07-20 16:05:17 +00:00
return isFetching;
}, items5);
if (enabled) {
2026-07-29 08:29:29 +00:00
tmp6 = null != stateFromStores;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp6) {
tmp6 = !stateFromStores2;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp6) {
2026-10-03 08:58:59 +00:00
let tmp8 = null;
2026-07-29 08:29:29 +00:00
tmp6 = null != stateFromStores1;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp6) {
tmp6 = stateFromStores1.amount > 0;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
dependencyMap = tmp6;
2026-07-29 08:29:29 +00:00
const items6 = [tmp6];
2026-10-03 08:58:59 +00:00
const memo = react.useMemo(() => {
let items1;
const tmp = closure_2;
if (tmp) {
const items = [dismissible_content.DismissibleContent.GIFT_CARD_MOBILE_CONSUMPTION_UNAVAILABLE_HALFSHEET];
2026-10-03 08:58:59 +00:00
items1 = items;
2026-07-20 16:05:17 +00:00
} else {
items1 = [];
}
return items1;
}, items6);
2026-10-09 10:00:15 +00:00
const tmpResult = tmp(7093);
let tmp10 = first(tmpResult.useSelectedDismissibleContent(memo, { bypassAutoDismiss: true }), 2);
2026-07-29 08:29:29 +00:00
first = tmp10[0];
2026-10-03 08:58:59 +00:00
react = tmp12;
ref = react.useRef(tmp12);
2026-07-29 08:29:29 +00:00
const items7 = [tmp10[1]];
2026-10-03 08:58:59 +00:00
const effect = react.useEffect(() => {
ref.current = current;
2026-07-20 16:05:17 +00:00
}, items7);
2026-10-03 08:58:59 +00:00
markAsDismissed = react.useCallback((AUTO_DISMISS) => {
2026-07-29 08:29:29 +00:00
ref.current(AUTO_DISMISS);
2026-07-20 16:05:17 +00:00
}, []);
const items8 = [enabled];
2026-10-03 08:58:59 +00:00
const effect1 = react.useEffect(() => {
const tmp = enabled;
if (tmp) {
obj = actions_BillingActionCreators;
const paymentSources = obj.fetchPaymentSources();
2026-07-20 16:05:17 +00:00
}
}, items8);
const items9 = [stateFromStores];
2026-10-03 08:58:59 +00:00
const effect2 = react.useEffect(() => {
2026-07-20 16:05:17 +00:00
if (null != stateFromStores) {
2026-10-03 08:58:59 +00:00
obj = actions_BillingActionCreators;
const walletInformation = obj.fetchWalletInformation(tmp);
2026-07-20 16:05:17 +00:00
}
}, items9);
const items10 = [first, markAsDismissed];
2026-10-03 08:58:59 +00:00
const effect3 = react.useEffect(() => {
2026-07-20 16:05:17 +00:00
function handleShow(key) {
2026-10-03 08:58:59 +00:00
const tmp = c0 || key.key !== closure_2_9;
2026-07-20 16:05:17 +00:00
if (!tmp) {
2026-10-03 08:58:59 +00:00
Idle = closure_2_10.Opened;
2026-07-20 16:05:17 +00:00
}
}
2026-10-03 08:58:59 +00:00
let tmp = require;
const tmp2 = dependencyMap;
if (first === dismissible_content.DismissibleContent.GIFT_CARD_MOBILE_CONSUMPTION_UNAVAILABLE_HALFSHEET) {
if (Opening === obj.Idle) {
Opening = obj.Opening;
2026-10-03 08:58:59 +00:00
let c0 = false;
obj = DispatcherDefault;
2026-07-20 16:05:17 +00:00
const subscription = obj.subscribe("SHOW_ACTION_SHEET", handleShow);
2026-10-09 10:00:15 +00:00
const promise = asyncRequire(7097, tmp2.paths);
2026-07-20 16:05:17 +00:00
promise.catch(() => {
2026-10-03 08:58:59 +00:00
const tmp = c0 || Idle !== closure_2_10.Opening;
2026-07-20 16:05:17 +00:00
if (!tmp) {
2026-10-03 08:58:59 +00:00
Idle = closure_2_10.Idle;
2026-07-20 16:05:17 +00:00
}
});
const obj2 = ActionSheetActionCreatorsDefault;
const obj3 = { markAsDismissed };
obj2.openLazy(promise, GiftCardMobileConsumptionActionSheet, obj3, "stack");
2026-07-20 16:05:17 +00:00
return () => {
2026-08-24 06:08:38 +00:00
c0 = true;
2026-10-03 08:58:59 +00:00
obj = stateFromStores(closure_2_2[11]);
obj.unsubscribe("SHOW_ACTION_SHEET", handleShow);
if (Idle === closure_2_10.Opening) {
Idle = closure_2_10.Idle;
2026-07-20 16:05:17 +00:00
}
};
}
}
}, items10);
const items11 = [first];
2026-10-03 08:58:59 +00:00
const effect4 = react.useEffect(() => {
2026-07-20 16:05:17 +00:00
function handleHide(key) {
if (key.key === GiftCardMobileConsumptionActionSheet) {
ref.current(constants.USER_DISMISS);
2026-07-20 16:05:17 +00:00
}
}
2026-10-03 08:58:59 +00:00
const tmp = closure_2;
if (first === enabled(closure_2[8]).DismissibleContent.GIFT_CARD_MOBILE_CONSUMPTION_UNAVAILABLE_HALFSHEET) {
2026-10-03 08:58:59 +00:00
obj = stateFromStores(tmp[11]);
const subscription = obj.subscribe("HIDE_ACTION_SHEET", handleHide);
2026-07-20 16:05:17 +00:00
return () => {
2026-10-03 08:58:59 +00:00
obj = DispatcherDefault;
obj.unsubscribe("HIDE_ACTION_SHEET", handleHide);
2026-07-20 16:05:17 +00:00
};
}
}, items11);
};