Files
discord-decomp/modules/premium/native/hooks/useSelectPremiumGift.tsx
T
2026-11-01 12:12:55 +02:00

74 lines
2.6 KiB
TypeScript

// Metro module 9702 (f9703).
import { useCallback } from "react";
import { useNavigation } from "../../../../design/components/Navigator/native/useNavigation.native";
import { useNativeGiftContext } from "../../../payments/native/NativeGiftContext";
import { useCreateOrReuseGiftOrder } from "../../../payments/native/utils/createOrReuseGiftOrder";
import { getPlanIdForPremiumType } from "../../../../utils/PremiumUtils";
import { getProductIdForGift } from "../ProductIds.android";
import AlertActionCreators from "../../../../actions/native/AlertActionCreators";
import { intl, t } from "../../../../intl/index.native";
import { PremiumGiftScreens } from "../gifting/PremiumGiftModal";
let env6419 = {};
export function useSelectPremiumGift(a0) {
let env17416 = {
$parent: env6419
};
const navigation = useNavigation();
env17416[0] = navigation;
const nativeGiftContext = useNativeGiftContext();
const setPremiumType = nativeGiftContext.setPremiumType;
env17416[1] = setPremiumType;
const recipientUserId = nativeGiftContext.recipientUserId;
env17416[2] = recipientUserId;
const planInterval = nativeGiftContext.planInterval;
env17416[3] = planInterval;
const setOrder = nativeGiftContext.setOrder;
env17416[4] = setOrder;
const createOrReuseGiftOrder2 = useCreateOrReuseGiftOrder(a0);
env17416[5] = createOrReuseGiftOrder2;
let c17417_0 = async (c30136_0) => {
let c30136_3 = 0;
let c31511_0;
try {
c31511_0 = void 0;
(0, env17416[4])(void 0);
(0, env17416[1])(c30136_0);
const planIdForPremiumType = getPlanIdForPremiumType(c30136_0, env17416[3]);
const productIdForGift = getProductIdForGift(planIdForPremiumType);
c30136_3 = 1;
c31511_0 = await (0, env17416[5])({
planId: planIdForPremiumType,
recipientUserId: env17416[2],
productId: productIdForGift
});
c30136_3 = 0;
(0, env17416[4])(c31511_0);
env17416[0].navigate(PremiumGiftScreens.CUSTOMIZATION);
} catch ($e) {
let r28 = $e;
if (c30136_3 !== 0) {
while (true) {
try {
c30136_3 = 0;
AlertActionCreators.show({
title: intl.string(t.R0RpRX),
body: intl.string(t.CKsXk3)
});
} catch ($e) {
r28 = $e;
if (c30136_3 === 0) {
break;
}
continue;
}
return void 0;
}
}
throw r28;
}
};
return useCallback(function() {
return c17417_0.apply(this, arguments);
}, [setPremiumType, planInterval, createOrReuseGiftOrder2, recipientUserId, setOrder, navigation]);
}