import { cn } from '@bem-react/classname';
import { useKeycloakAuth } from '../keycloak';
import React from 'react';

import './withAuth.scss';

const name = cn('NotAuthenticated');

export function withAuth(Cmp: React.FC) {
    return () => {
        const { authenticated } = useKeycloakAuth();

        return authenticated ? <Cmp /> : <div className={name()}>
            Not authenticated
        </div>
    }
}
