@equinor/mad-core
Version:
Core library for the Mobile App Delivery team
37 lines (34 loc) • 1.01 kB
JavaScript
import {
useDemoMode
} from "./chunk-UZ6YMQV2.js";
import {
CoreRoutes
} from "./chunk-UKAZW3CQ.js";
import {
useCoreStackNavigation
} from "./chunk-BIMOM43W.js";
// src/components/screens/settings/useSignOut.ts
import { useCallback } from "react";
import { ExpoAuthSession } from "@equinor/mad-auth";
import { alert } from "@equinor/mad-components";
var useSignOut = () => {
const navigation = useCoreStackNavigation();
const demoMode = useDemoMode();
const signOutFn = useCallback(() => {
try {
const result = ExpoAuthSession.signOut();
if (!demoMode.isEnabled && !result) throw new Error("Unable to sign out");
demoMode.disableDemoMode();
navigation.navigate(CoreRoutes.LOGIN);
} catch (_) {
alert("Error", "Unable to sign out", [
{ text: "Try again", isPreferred: true, onPress: () => void signOutFn() },
{ text: "Cancel", onPress: () => void 0 }
]);
}
}, [navigation, demoMode]);
return signOutFn;
};
export {
useSignOut
};