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

117 lines
4.7 KiB
TypeScript

// Metro module 9789 (f9790).
import { useCallback } from "react";
import { View } from "react-native";
import { isAvatarDecorationRecord } from "../../../collectibles/records/AvatarDecorationRecord";
import { isNameplateRecord } from "../../../collectibles/records/NameplateRecord";
import UserStore from "../../../../stores/UserStore";
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../_bundle/Module712";
import { useStateFromStores } from "../../../../_bundle/Module589";
import { useNativeGiftContext } from "../../../payments/native/NativeGiftContext";
import { useNavigation } from "../../../../design/components/Navigator/native/useNavigation.native";
import { GiftingBadgeExperiment } from "../../gifting/experiments/GiftingBadgeExperiment";
import { useFetchCollectiblesProduct } from "../../../collectibles/hooks/useFetchCollectiblesProduct";
import { PremiumGiftScreens } from "./PremiumGiftModal";
import ProductPurchaseSuccessActionCreators from "../../../collectibles/native/ProductPurchaseSuccessActionCreators";
import Nameplate from "../../../collectibles/nameplates/native/Nameplate";
import { getNameplateData } from "../../../collectibles/nameplates/utils";
import { Avatar, AvatarSizes } from "../../../../design/void/native";
import GiftingRewardPreviewAvatar from "../../gifting/native/views/GiftingRewardPreviewAvatar";
import { Button } from "../../../../design/components/Button/native/Button.native";
import { intl, t } from "../../../../intl/index.native";
const useStyles = createStyles({
container: {
flexDirection: "column",
alignItems: "center",
gap: Module712.space.PX_16
},
nameplateContainer: {
width: 234,
height: 40,
flexDirection: "row",
alignItems: "center",
position: "relative",
borderRadius: Module712.radii.sm,
overflow: "hidden"
},
nameplateWrapper: {
position: "absolute",
left: 0,
right: 0,
top: 0,
bottom: 0,
borderRadius: Module712.radii.sm,
overflow: "hidden"
},
singleAvatarContainer: {
flexDirection: "row",
paddingRight: 15,
justifyContent: "center",
alignItems: "center",
marginLeft: 5
}
});
export default function PremiumGiftingPromotionSuccessActions(props) {
let onClose, prePurchaseGiftingBadgeProgress, navigation, enabled, product, callback;
const purchase = props.purchase;
onClose = void 0;
prePurchaseGiftingBadgeProgress = void 0;
navigation = void 0;
enabled = void 0;
product = void 0;
callback = void 0;
const styles = useStyles();
const stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
const nativeGiftContext = useNativeGiftContext();
onClose = nativeGiftContext.onClose;
prePurchaseGiftingBadgeProgress = nativeGiftContext.prePurchaseGiftingBadgeProgress;
navigation = useNavigation();
enabled = GiftingBadgeExperiment.useConfig({
location: "PremiumGiftingPromotionSuccessActions"
}).enabled;
const fetchCollectiblesProduct = useFetchCollectiblesProduct(purchase.skuId);
product = fetchCollectiblesProduct.product;
const isFetching = fetchCollectiblesProduct.isFetching;
callback = useCallback(() => {
let r1 = enabled;
if (enabled) {
r1 = prePurchaseGiftingBadgeProgress != null;
}
if (r1) {
navigation.navigate(PremiumGiftScreens.GIFTING_BADGE, {
currentProgress: prePurchaseGiftingBadgeProgress
});
}
}, [enabled, prePurchaseGiftingBadgeProgress, navigation]);
const callback2 = useCallback(() => {
L6: {
if (product != null) {
ProductPurchaseSuccessActionCreators.open({
product,
onCancel: callback
});
} else {
if (enabled && prePurchaseGiftingBadgeProgress != null) {
navigation.navigate(PremiumGiftScreens.GIFTING_BADGE, {
currentProgress: prePurchaseGiftingBadgeProgress
});
break L6;
}
onClose();
}
}
}, [product, onClose, callback, enabled, prePurchaseGiftingBadgeProgress, navigation]);
const r19 = purchase.items[0];
return <View style={styles.container}>
{isNameplateRecord(r19) ? <View style={styles.nameplateContainer}>
<View style={styles.nameplateWrapper}>
<Nameplate nameplate={getNameplateData(r19)} fullOpacity animate />
</View>
<View style={styles.singleAvatarContainer}>
<Avatar user={stateFromStores} guildId={void 0} size={AvatarSizes.SMALL} aria-hidden />
</View>
</View> : isAvatarDecorationRecord(r19) ? <GiftingRewardPreviewAvatar size={AvatarSizes.LARGE} asset={r19.asset} /> : void 0}
<Button grow text={intl.string(t.kMYVwv)} loading={isFetching} onPress={callback2} />
</View>;
};