37 lines
1.7 KiB
TypeScript
37 lines
1.7 KiB
TypeScript
// Metro module 11624 (f11625).
|
|
import { useMemo } from "react";
|
|
import GuildPowerupsStore from "../GuildPowerupsStore";
|
|
import { PowerupActiveStatusType } from "../constants/GuildPowerupsConstants";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import usePowerupActiveStatus from "./usePowerupActiveStatus";
|
|
import { intl } from "../../../../intl/index.native";
|
|
import GuildPowerups_messages from "../GuildPowerups.messages";
|
|
export default function useCanGuildPowerupBeToggled(a0, a1, a2) {
|
|
let c19035_4;
|
|
const stateFromStores = useStateFromStores([GuildPowerupsStore], () => GuildPowerupsStore.getStateForGuild(a0));
|
|
const powerupActiveStatus = usePowerupActiveStatus(a0, a1);
|
|
c19035_4 = powerupActiveStatus;
|
|
return useMemo(() => {
|
|
if (stateFromStores == null) {
|
|
return {
|
|
disabled: true,
|
|
reason: void 0
|
|
};
|
|
}
|
|
if (c19035_4.type !== PowerupActiveStatusType.LEVEL_ACTIVATED && c19035_4.type !== PowerupActiveStatusType.TIER_OVERRIDE_ACTIVATED) {
|
|
const { allPowerups, unlockedPowerups } = stateFromStores;
|
|
const r21 = a2 ? Object.values(unlockedPowerups).find((item) => item.sku?.dependent_sku_id === a1.skuId)?.sku_id : a1.dependencies.find((dependency) => unlockedPowerups[dependency] == null);
|
|
return {
|
|
disabled: r21 != null,
|
|
reason: r21 != null ? allPowerups[r21] != null ? intl.formatToPlainString(a2 ? GuildPowerups_messages.vCEBiS : GuildPowerups_messages["1B8AZr"], {
|
|
perk: allPowerups[r21]?.title
|
|
}) : void 0 : void 0
|
|
};
|
|
}
|
|
return {
|
|
disabled: true,
|
|
reason: void 0
|
|
};
|
|
}, [stateFromStores, a1.skuId, a1.dependencies, a2, powerupActiveStatus.type]);
|
|
};
|