import React from "react";
import { Button } from "react-native";
import { useAuth } from "../../context";
import { useAuthHeader } from "../../graphql/client";

export default function SignOutButton(): React.JSX.Element {
	const { logOut } = useAuth();
	const { setAuthHeader } = useAuthHeader();

	const handleSignOut = async () => {
		await logOut();
		setAuthHeader({ key: "Authorization", value: "" });
	};

	return <Button title={"Sign out"} onPress={handleSignOut} />;
}
