123 lines
5.1 KiB
TypeScript
123 lines
5.1 KiB
TypeScript
// Metro module 9787 (f9788).
|
|
import { useCallback } from "react";
|
|
import { View } from "react-native";
|
|
import SKUStore from "../../../../stores/game_store/SKUStore";
|
|
import { SubscriptionIntervalTypes } from "../../PremiumConstants";
|
|
import { AnalyticsSections } from "../../../../Constants";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import { useNativeGiftContext } from "../../../payments/native/NativeGiftContext";
|
|
import { useNavigation } from "../../../../design/components/Navigator/native/useNavigation.native";
|
|
import { GiftingBadgeExperiment } from "../../gifting/experiments/GiftingBadgeExperiment";
|
|
import { getGiftCodeURL, trackGiftCodeCopy } from "../../../../utils/GiftCodeUtils";
|
|
import { PremiumGiftScreens } from "./PremiumGiftModal";
|
|
import { showShareActionSheet } from "../../../action_sheet/native/showShareActionSheet";
|
|
import { Button } from "../../../../design/components/Button/native/Button.native";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import PremiumUtils, { getPlanIdForPremiumType } from "../../../../utils/PremiumUtils";
|
|
import { copy } from "../../../../utils/ClipboardUtils.native";
|
|
import { presentCopiedToClipboard } from "../../../toast/native/ToastUtils";
|
|
import PremiumGiftBackgroundAnimation_android from "./PremiumGiftBackgroundAnimation.android";
|
|
import { Text } from "../../../../design/components/Text/native/Text";
|
|
import { InputButton } from "../../../../design/components/experimental/native";
|
|
import Module4138 from "../../../../_bundle/Module4138";
|
|
const useStyles = createStyles({
|
|
disclaimer: {
|
|
marginTop: Module712.space.PX_4,
|
|
marginBottom: Module712.space.PX_16
|
|
},
|
|
title: {
|
|
marginTop: Module712.space.PX_24,
|
|
textAlign: "center"
|
|
},
|
|
description: {
|
|
marginTop: Module712.space.PX_8,
|
|
textAlign: "center"
|
|
},
|
|
input: {
|
|
marginTop: Module712.space.PX_24
|
|
},
|
|
inputLabel: {
|
|
marginBottom: Module712.space.PX_4
|
|
}
|
|
});
|
|
export default function PremiumGiftSuccessBody(props) {
|
|
const giftCodeRecord = props.giftCodeRecord;
|
|
const styles = useStyles();
|
|
const nativeGiftContext = useNativeGiftContext();
|
|
const { premiumType, planInterval } = nativeGiftContext;
|
|
let giftStyle = nativeGiftContext.giftStyle;
|
|
const giftCodeURL = getGiftCodeURL(giftCodeRecord.code);
|
|
if (giftCodeRecord.giftStyle != null) {
|
|
giftStyle = giftCodeRecord.giftStyle;
|
|
}
|
|
const r33 = giftCodeRecord.subscriptionPlanId != null ? giftCodeRecord.subscriptionPlanId : getPlanIdForPremiumType(premiumType, planInterval);
|
|
const tierDisplayNameByPlanId = PremiumUtils.getTierDisplayNameByPlanId(r33);
|
|
const intervalType = PremiumUtils.getInterval(r33).intervalType;
|
|
const YEAR = SubscriptionIntervalTypes.YEAR;
|
|
const callback = useCallback(() => {
|
|
const r7 = SKUStore.get(giftCodeRecord.skuId);
|
|
if (r7 != null) {
|
|
trackGiftCodeCopy(giftCodeRecord, r7);
|
|
}
|
|
copy(giftCodeURL);
|
|
presentCopiedToClipboard();
|
|
}, [giftCodeRecord, giftCodeURL]);
|
|
return <>
|
|
{[<View>
|
|
<PremiumGiftBackgroundAnimation_android giftStyle={giftStyle} />
|
|
</View>, <Text style={styles.title} variant="heading-lg/bold">
|
|
{intl.string(t["/s1xR7"])}
|
|
</Text>, <Text style={styles.description} variant="text-md/medium">
|
|
{intl.format(intervalType === YEAR ? t.rli5ey : t.bUdTqI, {
|
|
intervalCount: 1,
|
|
name: tierDisplayNameByPlanId
|
|
})}
|
|
</Text>, <View style={styles.input}>
|
|
<Text style={styles.inputLabel} variant="heading-md/bold">
|
|
{intl.string(t["qS+yMo"])}
|
|
</Text>
|
|
<InputButton text={giftCodeURL} icon={Module4138} iconPosition="end" onPress={callback} />
|
|
</View>, <Text style={styles.disclaimer} variant="text-xs/normal">
|
|
{intl.string(t.As9eLl)}
|
|
</Text>]}
|
|
</>;
|
|
};
|
|
export function PremiumGiftSuccessActions(props) {
|
|
const giftCodeRecord2 = props.giftCodeRecord;
|
|
const nativeGiftContext = useNativeGiftContext();
|
|
const { onClose, prePurchaseGiftingBadgeProgress } = nativeGiftContext;
|
|
const navigation = useNavigation();
|
|
const enabled = GiftingBadgeExperiment.useConfig({
|
|
location: "PremiumGiftSuccessActions"
|
|
}).enabled;
|
|
const giftCodeURL2 = getGiftCodeURL(giftCodeRecord2.code);
|
|
const callback = useCallback(() => {
|
|
if (enabled && prePurchaseGiftingBadgeProgress != null) {
|
|
navigation.navigate(PremiumGiftScreens.GIFTING_BADGE, {
|
|
currentProgress: prePurchaseGiftingBadgeProgress
|
|
});
|
|
} else {
|
|
onClose();
|
|
}
|
|
}, [enabled, prePurchaseGiftingBadgeProgress, navigation, onClose]);
|
|
const callback2 = useCallback(() => {
|
|
showShareActionSheet({
|
|
url: giftCodeURL2
|
|
}, AnalyticsSections.PREMIUM_GIFT_SUCCESS_MODAL);
|
|
let r14 = enabled;
|
|
if (enabled) {
|
|
r14 = prePurchaseGiftingBadgeProgress != null;
|
|
}
|
|
if (r14) {
|
|
navigation.navigate(PremiumGiftScreens.GIFTING_BADGE, {
|
|
currentProgress: prePurchaseGiftingBadgeProgress
|
|
});
|
|
}
|
|
}, [giftCodeURL2, enabled, prePurchaseGiftingBadgeProgress, navigation]);
|
|
return <>
|
|
<Button variant="primary" text={intl.string(t.RDE0Sc)} onPress={callback2} />
|
|
<Button variant="secondary" text={intl.string(t.cpT0Cq)} onPress={callback} />
|
|
</>;
|
|
}
|