import { Navigate } from 'react-router-dom';

import useFeatureFlag from 'src/hooks/useFeatureFlag';
import { FeatureFlags } from 'src/types/featureFlags';

import { settingsRoutes } from '../../routes';

import CertificatesRoutes from './CertificatesRoutes';

const CertificatesEntry = () => {
  const isCertificatesEnabled = useFeatureFlag(
    FeatureFlags.MANAGE_LEARNING_CERTIFICATES,
  );
  return isCertificatesEnabled ? (
    <CertificatesRoutes />
  ) : (
    <Navigate
      to={settingsRoutes.base()}
      replace
    />
  );
};

export default CertificatesEntry;
