import { useContext } from "react";
import { AccountContext } from "../contexts/AccountContext";
import LoginForm from "../forms/LoginForm";
import { Col, Row } from "reactstrap";

interface AccountGuardProps {
	children: JSX.Element | JSX.Element[];
}

export default function AccountGuard({ children }: AccountGuardProps) {
	const { account } = useContext(AccountContext);

	return (
		<>
			{account ? (
				<>{children}</>
			) : (
				<Row>
					<Col xs={6}>
						<LoginForm />
					</Col>
				</Row>
			)}
		</>
	);
}
