Files
discord-decomp/modules/collectibles/native/useHandleUseNow.tsx
T
2026-11-01 12:12:55 +02:00

55 lines
2.0 KiB
TypeScript

// Metro module 9796 (f9797).
import { useCallback } from "react";
import { RootNavigatorScreen } from "../../main_tabs_v2/native/MainTabsConstants";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
import ModalActionCreators from "../../../actions/ModalActionCreators";
import { getRootNavigationRef } from "../../main_tabs_v2/RootNavigationRef.native";
import ToastActionCreators from "../../toast/native/ToastActionCreators";
import { intl, t } from "../../../intl/index.native";
import * as _useHandleUseNow from "../hooks/useHandleUseNow";
import useOpenProfileSettings from "../../profile_customization/useOpenProfileSettings";
export function useHandleUseNow({ product, onSuccess, analyticsLocations }) {
let c17499_1;
c17499_1 = void 0;
const handleUseNow = _useHandleUseNow.useHandleUseNow({
product,
onSuccess: useCallback(() => {
if (onSuccess == null) {
ActionSheetActionCreators.hideActionSheet();
ModalActionCreators.popAll();
const rootNavigationRef = getRootNavigationRef();
if (rootNavigationRef != null && rootNavigationRef.isReady()) {
rootNavigationRef.navigate(RootNavigatorScreen.YOU);
}
} else {
onSuccess();
}
}, [onSuccess]),
onError: useCallback(() => {
ToastActionCreators.open({
key: "collectible shop apply error",
content: intl.string(t.CKsXk3)
});
}, [])
});
const { handleUseNow: handleUseNow2, isApplying, canUseNow } = handleUseNow;
const openProfileSettings = useOpenProfileSettings({
analyticsLocations
});
c17499_1 = openProfileSettings;
return {
handleUseNow: handleUseNow2,
isApplying,
canUseNow,
handleEditProfile: useCallback(() => {
c17499_1();
if (onSuccess == null) {
ActionSheetActionCreators.hideActionSheet();
ModalActionCreators.popAll();
} else {
onSuccess();
}
}, [openProfileSettings, onSuccess])
};
}