121 lines
4.6 KiB
TypeScript
121 lines
4.6 KiB
TypeScript
// Metro module 15146 (f15147).
|
|
import { useCallback } from "react";
|
|
import GuildBoostSlotStore from "../../../../../stores/billing/GuildBoostSlotStore";
|
|
import { GuildPowerupType, BoostPurchaseIntent } from "../../constants/GuildPowerupsConstants";
|
|
import { AnalyticsObjects, AnalyticsObjectTypes } from "../../../../../Constants";
|
|
import useGuildBoostPurchaseHandler from "../../../../guild_boosting/native/hooks/useGuildBoostPurchaseHandler";
|
|
import useAnalyticsLocations from "../../../../app_analytics/useAnalyticsLocations";
|
|
import BillingActionCreators from "../../../../../actions/native/BillingActionCreators";
|
|
import { fetchGuildBoostSlots } from "../../../../../actions/BoostingActionCreators";
|
|
import { getAvailableGuildBoostSlots } from "../../../../../utils/GuildBoostingUtils";
|
|
import { openTransferModal } from "../../../../../actions/native/BoostingActionCreators";
|
|
import { launchGuildBoostFlowOrAlert } from "../../../../guild_boosting/native/GuildBoostPurchasingUtils";
|
|
function $mk116890($env) {
|
|
return () => {
|
|
const availableGuildBoostSlots = getAvailableGuildBoostSlots(GuildBoostSlotStore.boostSlots);
|
|
const length = availableGuildBoostSlots.length;
|
|
const r14 = $env.$parent;
|
|
const r8 = r14[2];
|
|
if (length >= r8) {
|
|
const r15 = $env;
|
|
openTransferModal({
|
|
guildBoostSlots: availableGuildBoostSlots.slice(0, r8),
|
|
guildId: r14[0],
|
|
intent: r15[0]
|
|
});
|
|
}
|
|
};
|
|
}
|
|
let env10746 = {};
|
|
export default function useGuildPowerupsBoostAction(a0, a1, a2, a3, a4) {
|
|
let env21708 = {
|
|
$parent: env10746
|
|
};
|
|
env21708[0] = a0;
|
|
env21708[1] = a1;
|
|
env21708[2] = a2;
|
|
env21708[3] = a4;
|
|
const guildBoostPurchaseHandler = useGuildBoostPurchaseHandler(a3);
|
|
const shouldUseMobileWebRedirectCheckout = guildBoostPurchaseHandler.shouldUseMobileWebRedirectCheckout;
|
|
env21708[4] = shouldUseMobileWebRedirectCheckout;
|
|
const handleMobileWebRedirectCheckout = guildBoostPurchaseHandler.handleMobileWebRedirectCheckout;
|
|
env21708[5] = handleMobileWebRedirectCheckout;
|
|
const analyticsLocations = useAnalyticsLocations().analyticsLocations;
|
|
env21708[6] = analyticsLocations;
|
|
return useCallback(async () => {
|
|
let c27953_0, c27953_1;
|
|
L28: {
|
|
L21: {
|
|
let env30848;
|
|
const r8 = env21708;
|
|
c27953_1 = r8;
|
|
const r9 = env30848 = {
|
|
$parent: r8
|
|
};
|
|
c27953_0 = r9;
|
|
env30848[0] = void 0;
|
|
env30848[1] = void 0;
|
|
if (env21708[1] == null) {
|
|
break L28;
|
|
}
|
|
if (env21708[2] <= 0) {
|
|
break L28;
|
|
}
|
|
if (GuildBoostSlotStore.hasFetched) {
|
|
env30848[0] = env21708[1].type === GuildPowerupType.PERK ? BoostPurchaseIntent.PERK : void 0;
|
|
env30848[1] = getAvailableGuildBoostSlots(GuildBoostSlotStore.boostSlots);
|
|
if (env30848[1].length >= env21708[2]) {
|
|
openTransferModal({
|
|
guildBoostSlots: env30848[1].slice(0, env21708[2]),
|
|
guildId: env21708[0],
|
|
intent: env30848[0]
|
|
});
|
|
break L28;
|
|
}
|
|
if (env21708[4]) {
|
|
(0, env21708[5])(env21708[6], env21708[0]);
|
|
break L28;
|
|
}
|
|
launchGuildBoostFlowOrAlert({
|
|
source: {
|
|
...env21708[3],
|
|
object: AnalyticsObjects.BUTTON_CTA,
|
|
objectType: AnalyticsObjectTypes.BUY
|
|
},
|
|
analyticsLocations: env21708[6],
|
|
guildId: env21708[0],
|
|
onPaymentSuccess: $mk116890(c27953_0)
|
|
});
|
|
break L28;
|
|
}
|
|
await Promise.all([BillingActionCreators.init(), fetchGuildBoostSlots()]);
|
|
env30848[0] = env21708[1].type === GuildPowerupType.PERK ? BoostPurchaseIntent.PERK : void 0;
|
|
env30848[1] = getAvailableGuildBoostSlots(GuildBoostSlotStore.boostSlots);
|
|
if (env30848[1].length >= env21708[2]) {
|
|
openTransferModal({
|
|
guildBoostSlots: env30848[1].slice(0, env21708[2]),
|
|
guildId: env21708[0],
|
|
intent: env30848[0]
|
|
});
|
|
break L21;
|
|
}
|
|
if (env21708[4]) {
|
|
(0, env21708[5])(env21708[6], env21708[0]);
|
|
break L21;
|
|
}
|
|
launchGuildBoostFlowOrAlert({
|
|
source: {
|
|
...env21708[3],
|
|
object: AnalyticsObjects.BUTTON_CTA,
|
|
objectType: AnalyticsObjectTypes.BUY
|
|
},
|
|
analyticsLocations: env21708[6],
|
|
guildId: env21708[0],
|
|
onPaymentSuccess: $mk116890(c27953_0)
|
|
});
|
|
}
|
|
return void 0;
|
|
}
|
|
}, [a1, a2, a0, a4, shouldUseMobileWebRedirectCheckout, handleMobileWebRedirectCheckout, analyticsLocations]);
|
|
};
|