95 lines
3.2 KiB
TypeScript
95 lines
3.2 KiB
TypeScript
// Metro module 6225 (f6226).
|
|
import ActionSheetStore from "../../action_sheet/native/ActionSheetStore";
|
|
import { PREMIUM_PLAN_SELECTION_ACTION_SHEET_KEY, PremiumTypes } from "../PremiumConstants";
|
|
import { create } from "../../../_bundle/Module644";
|
|
import { batchUpdates } from "../../../_bundle/Module705";
|
|
import openPremiumPlanSelectionActionSheet from "./openPremiumPlanSelectionActionSheet";
|
|
import AnalyticsLocation from "../../app_analytics/AnalyticsLocation";
|
|
let c3953_6 = create(() => ({
|
|
productId: "",
|
|
initiatedPurchaseFromNewFlow: false,
|
|
isPaymentSuccess: false,
|
|
mobileWebRedirectCheckoutStatus: null
|
|
}));
|
|
export { c3953_6 as usePremiumPlanPurchasedStore };
|
|
export function setInitiatedPurchaseFromNewFlow({ productId, onPaymentSuccess, onPaymentDismiss }) {
|
|
batchUpdates(() => {
|
|
c3953_6.setState({
|
|
productId,
|
|
initiatedPurchaseFromNewFlow: true,
|
|
onPaymentSuccess,
|
|
onPaymentDismiss
|
|
});
|
|
});
|
|
}
|
|
export function setPaymentSuccess() {
|
|
if (c3953_6.getState().initiatedPurchaseFromNewFlow) {
|
|
const state = c3953_6.getState();
|
|
const { productId: productId2, onPaymentSuccess: onPaymentSuccess2 } = state;
|
|
batchUpdates(() => c3953_6.setState({
|
|
isPaymentSuccess: true
|
|
}));
|
|
if (onPaymentSuccess2 != null) {
|
|
onPaymentSuccess2(productId2);
|
|
}
|
|
}
|
|
}
|
|
export function setMobileWebRedirectCheckoutStatus(mobileWebRedirectCheckoutStatus) {
|
|
batchUpdates(() => c3953_6.setState({
|
|
mobileWebRedirectCheckoutStatus
|
|
}));
|
|
}
|
|
export function handleMobileWebCheckoutStatus(a0) {
|
|
const mobileWebRedirectCheckoutStatus2 = a0;
|
|
if (a0 === "succeeded") {
|
|
const state = c3953_6.getState();
|
|
const { productId: productId2, onPaymentSuccess: onPaymentSuccess2 } = state;
|
|
if (state.mobileWebRedirectCheckoutStatus === "dismissed") {
|
|
return void 0;
|
|
}
|
|
if (ActionSheetStore.getKey() !== PREMIUM_PLAN_SELECTION_ACTION_SHEET_KEY) {
|
|
openPremiumPlanSelectionActionSheet({
|
|
premiumType: PremiumTypes.TIER_2,
|
|
analyticsLocations: [AnalyticsLocation.DEEPLINK],
|
|
analyticsLocation: {}
|
|
});
|
|
}
|
|
batchUpdates(() => c3953_6.setState({
|
|
isPaymentSuccess: true,
|
|
mobileWebRedirectCheckoutStatus: mobileWebRedirectCheckoutStatus2
|
|
}));
|
|
if (onPaymentSuccess2 != null) {
|
|
onPaymentSuccess2(productId2);
|
|
}
|
|
}
|
|
}
|
|
export function showOldPaymentFlowSuccess(a0) {
|
|
if (c3953_6.getState().initiatedPurchaseFromNewFlow) {
|
|
batchUpdates(() => c3953_6.setState({
|
|
isPaymentSuccess: true
|
|
}));
|
|
} else {
|
|
a0();
|
|
}
|
|
}
|
|
export function reset() {
|
|
const state = c3953_6.getState();
|
|
const { productId: productId2, isPaymentSuccess, onPaymentDismiss: onPaymentDismiss2, mobileWebRedirectCheckoutStatus: mobileWebRedirectCheckoutStatus3 } = state;
|
|
if (onPaymentDismiss2 != null) {
|
|
onPaymentDismiss2({
|
|
productId: productId2,
|
|
isSuccess: isPaymentSuccess
|
|
});
|
|
}
|
|
batchUpdates(() => {
|
|
c3953_6.setState({
|
|
productId: "",
|
|
initiatedPurchaseFromNewFlow: false,
|
|
isPaymentSuccess: false,
|
|
mobileWebRedirectCheckoutStatus: mobileWebRedirectCheckoutStatus3 != null ? mobileWebRedirectCheckoutStatus3 !== "in_mobile_web" ? "dismissed" : null : null,
|
|
onPaymentSuccess: void 0,
|
|
onPaymentDismiss: void 0
|
|
});
|
|
});
|
|
}
|