import isNil from 'lodash-es/isNil';

import { usePerformanceReview } from '../../PerformanceReviewContext';

import ReviewDetailView from './ReviewDetailView';
import ShareResultsDetail from './ShareResultsDetail';
import ShareResultsUserList from './ShareResultsUserList';

const ShareResults = () => {
  const { userToShareId, viewingReviewId } = usePerformanceReview();

  if (isNil(userToShareId)) {
    return <ShareResultsUserList />;
  }

  if (!isNil(viewingReviewId)) {
    return <ReviewDetailView />;
  }

  return <ShareResultsDetail />;
};

export default ShareResults;
