import React from 'react';
import { AuthView } from './auth-view';
import { useUnit } from 'effector-react';
import {$isAuthenticated} from './auth-model';

type Props = {
    children: React.ReactNode;
}
export const AuthGuard: React.FC<Props> = (props) => {
    const isAuthenticated = useUnit($isAuthenticated);
    if (isAuthenticated) {
        return props.children
    } else {
        return <AuthView/>
    }
}