import React from 'react';
import { ChakraProvider } from '@chakra-ui/react';
import Layout from './components/common/Layout';
import Dashboard from './components/dashboard/index';
import Products from './components/products/index';

const App = () => {
  const [currentPage, setCurrentPage] = React.useState('dashboard');

  const renderPage = () => {
    switch (currentPage) {
      case 'products':
        return <Products />;
      default:
        return <Dashboard />;
    }
  };

  return (
    <ChakraProvider>
      <Layout currentPage={currentPage} onNavigate={setCurrentPage}>
        {renderPage()}
      </Layout>
    </ChakraProvider>
  );
};

export default App;