import React from "react";
import {
Box,
Typography,
Button,
Chip,
Stack,
Paper,
CircularProgress,
} from "@mui/material";
import HFLogo from "../Logo/HFLogo";
import { useAuth } from "../../hooks/useAuth";
import LogoutIcon from "@mui/icons-material/Logout";
import { useNavigate } from "react-router-dom";
function AuthContainer({ actionText = "DO_ACTION" }) {
const { isAuthenticated, user, login, logout, loading } = useAuth();
const navigate = useNavigate();
const handleLogout = () => {
if (isAuthenticated && logout) {
logout();
navigate("/", { replace: true });
window.location.reload();
}
};
if (loading) {
return (
);
}
if (!isAuthenticated) {
return (
Login to {actionText}
You need to be logged in with your Hugging Face account to{" "}
{actionText.toLowerCase()}
);
}
return (
Connected as {user?.username}
}
color="primary"
sx={{
minWidth: 120,
height: 36,
textTransform: "none",
fontSize: "0.9375rem",
}}
>
Logout
);
}
export default AuthContainer;