import { QueryClientProvider } from "@tanstack/react-query";
import { Route, Switch } from "wouter";
import { Toaster } from "@/components/ui/toaster";
import { TooltipProvider } from "@/components/ui/tooltip";
import AuthorProfile from "@/pages/authors/AuthorProfile";
import Authors from "@/pages/authors/Authors";
import { BlogCreate, BlogDetail, BlogList } from "@/pages/blog";
import Collections from "@/pages/collections/Collections";
import CreateCollection from "@/pages/collections/CreateCollection";
import BlogEdit from "@/pages/dashboard/BlogEdit";
import BlogManagement from "@/pages/dashboard/BlogManagement";
// Dashboard pages
import Dashboard from "@/pages/dashboard/Dashboard";
import Explore from "@/pages/Explore";
import Home from "@/pages/Home";
import NotFound from "@/pages/not-found";
import Search from "@/pages/Search";
import Submit from "@/pages/Submit";
import Profile from "@/pages/user/Profile";
import SimpleWorkReading from "@/pages/works/SimpleWorkReading";
import { queryClient } from "./lib/queryClient";

function Router() {
	return (
		<Switch>
			<Route path="/" component={Home} />
			<Route path="/explore" component={Explore} />
			<Route path="/search" component={Search} />
			<Route path="/authors" component={Authors} />
			<Route path="/authors/:slug" component={AuthorProfile} />
			<Route path="/works/:slug" component={SimpleWorkReading} />
			<Route path="/collections" component={Collections} />
			<Route path="/collections/create" component={CreateCollection} />
			<Route path="/profile" component={Profile} />
			<Route path="/submit" component={Submit} />
			<Route path="/blog" component={BlogList} />
			<Route path="/blog/create" component={BlogCreate} />
			<Route path="/blog/:slug" component={BlogDetail} />

			{/* Dashboard Routes */}
			<Route path="/dashboard" component={Dashboard} />
			<Route path="/dashboard/blog" component={BlogManagement} />
			<Route path="/dashboard/blog/edit/:id" component={BlogEdit} />

			<Route component={NotFound} />
		</Switch>
	);
}

function App() {
	return (
		<QueryClientProvider client={queryClient}>
			<TooltipProvider>
				<Toaster />
				<Router />
			</TooltipProvider>
		</QueryClientProvider>
	);
}

export default App;
