import { useState } from 'react';

import { Topic } from '../types';

import FavDimensionView from './FavDimensionView';
import FavorabilityListDashboard from './FavListDashboard';

const SatisfactionTab = () => {
  const [selectedDimension, setSelectedDimension] = useState<Topic | null>(
    null,
  );

  const handleGoBack = () => setSelectedDimension(null);

  if (selectedDimension) {
    return (
      <FavDimensionView
        dimension={selectedDimension}
        onGoBack={handleGoBack}
      />
    );
  }

  return <FavorabilityListDashboard onSelectDimension={setSelectedDimension} />;
};

export default SatisfactionTab;
