import useAuthContext from "@/components/providers/auth-provider/hook";
import { ButtonText } from "@/components/ui/button";
import ButtonSection from "@/components/ui/button-section";
import Content from "@/components/ui/content";
import { Divider } from "@/components/ui/divider";
import UserHeader from "@/components/user-header";
import { router } from "expo-router";

export default function MeScreen() {
  const { user, logout, isAuthorized } = useAuthContext();

  return (
    <Content>
      <UserHeader user={user} />

      <Divider className="mt-3 mb-3" />

      {isAuthorized && (
        <>
          <ButtonSection onPress={() => router.push('/me/user-tests')}>
            <ButtonText>My Tests</ButtonText>
          </ButtonSection>

          <Divider className="mt-3 mb-3" />

          <ButtonSection
            action="negative"
            onPress={() => logout()}
            variant="solid"
          >
            <ButtonText>Logout</ButtonText>
          </ButtonSection>
        </>
      )}
    </Content>
  );
}
