trepa-uploader/src/guards/AccountGuard.tsx
2024-08-11 22:33:12 +02:00

26 lines
525 B
TypeScript

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>
)}
</>
);
}