import React from "react";
import {BrowserRouter as Router, Navigate, Route, Routes} from "react-router-dom";
import { Provider } from 'react-redux';
import { store } from './store';
import MainNavigation from "./components/Navigations/MainNavigation";
import SideNavigation from "./components/Navigations/SideNavigation";
import MarkdownContent from "./components/Markdowns/MarkdownContent";
import MarkdownEditor from "./components/Markdowns/MarkdownEditor";
import StandaloneMarkdownPage from "./components/Markdowns/StandaloneMarkdownPage";
import "./App.css";
import Callback from "./components/KeycloakCallbacks/Callback";
import Footer from "./components/Footer";
import PopupCallback from "./components/KeycloakCallbacks/PopupCallback";
import SilentCallback from "./components/KeycloakCallbacks/SilentCallback";
import MarkdownTemplateEditor from "./components/MarkdownTemplate/MarkdownTemplateEditor";
import { TooltipProvider } from "./components/ui/misc";

const App = () => {
    return (
        <Provider store={store}>
            <TooltipProvider delayDuration={200}>
                <Router>
                    <Routes>
                        <Route path="/pg/*" element={<StandaloneMarkdownPage />} />
                        <Route path="*" element={
                            <div className="relative z-10 flex h-screen flex-col">
                                <MainNavigation />
                                <div className="flex flex-1 overflow-hidden">
                                    <SideNavigation />
                                    <main className="flex-1 overflow-y-auto">
                                        <div className="mx-auto w-full max-w-5xl px-6 py-8 pb-28">
                                            <Routes>
                                                <Route
                                                    path="/"
                                                    element={<Navigate to="/markdown/1" />}
                                                />
                                                <Route path="/markdown/:strId" element={<MarkdownContent />} />
                                                <Route path="/callback" element={<Callback />} />
                                                <Route path="/markdown/create" element={<MarkdownEditor />} />
                                                <Route path="/markdown/edit/:strId" element={<MarkdownEditor />} />
                                                <Route path="/popup_callback" element={<PopupCallback />} />
                                                <Route path="/silent_callback" element={<SilentCallback />} />
                                                <Route path="/template/create" element={<MarkdownTemplateEditor />} />
                                                <Route path="/template/edit/:strId" element={<MarkdownTemplateEditor />} />
                                            </Routes>
                                        </div>
                                    </main>
                                </div>
                                <Footer />
                            </div>
                        } />
                    </Routes>
                </Router>
            </TooltipProvider>
        </Provider>
    );
};

export default App;
