31 lines
889 B
TypeScript
31 lines
889 B
TypeScript
// Metro module 11626 (f11627).
|
|
import { useState, useCallback } from "react";
|
|
import { enablePowerupForGuild, disablePowerupForGuild } from "../GuildPowerupsActionCreators";
|
|
export default function useGuildPowerupOnToggle(a0, a1) {
|
|
let c19037_0 = a0;
|
|
const [isLoading, setState] = useState(false);
|
|
const [error, setState2] = useState(void 0);
|
|
return {
|
|
isLoading,
|
|
error,
|
|
onToggle: useCallback((a0) => {
|
|
if (a1 == null) {
|
|
return Promise.resolve();
|
|
}
|
|
const r11 = a0 ? enablePowerupForGuild : disablePowerupForGuild;
|
|
setState(true);
|
|
setState2(void 0);
|
|
return r11(c19037_0, a1.skuId).catch((error) => {
|
|
let r7 = error.body?.message;
|
|
if (r7 == null) {
|
|
r7 = void 0;
|
|
}
|
|
setState2(r7);
|
|
throw error;
|
|
}).finally(() => {
|
|
setState(false);
|
|
});
|
|
}, [a0, a1])
|
|
};
|
|
};
|