import { type FC } from 'react'
import SideBar from '../shared/SideBar'
import Header from '../shared/Header'
import { Route, Routes } from 'react-router-dom'
import Footer from '../shared/Footer'
import { clx } from '../helpers/utils'
import { useSharedStore } from '../shared/store/sharedStore'
import Create from '../pages/category/Create'
import List from '../pages/category/List'
import Update from '../pages/category/Update'
import { Pages } from '../config/Pages'
import Variant from '../pages/category/Variant'
import Attributes from '../pages/category/Attributes'
import CreateProduct from '../pages/products/Create'
import ListProduct from '../pages/products/List'
import UpdateProduct from '../pages/products/Update'
import ProductVariant from '@/pages/products/ProductVariant'
import BrandList from '@/pages/brand/List'
import BrandCreate from '@/pages/brand/Create'
import WarrantyList from '@/pages/warranty/List'
import CreateWarranty from '@/pages/warranty/Create'
import Native from '@/pages/orders/Native'
import OrdersSeller from '@/pages/orders/Seller'
import CancellationCategories from '@/pages/orders/CancellationCategories'
import ReturnCategories from '@/pages/orders/ReturnCategories'
import OrderDetail from '@/pages/orders/Detail'
import BlogsList from '@/pages/blogs/List'
import CreateBlog from '@/pages/blogs/Create'
import UpdateBlog from '@/pages/blogs/Update'
import BlogCategory from '@/pages/blogs/Category'
import ShippingList from '@/pages/shipment/List'
import CreateShipment from '@/pages/shipment/Create'
import CouponList from '@/pages/Coupon/List'
import CreateCoupon from '@/pages/Coupon/Create'
import UpdateCoupon from '@/pages/Coupon/Update'
import UsersList from '@/pages/user/List'
import AdminList from '@/pages/admin/List'
import AdminCreate from '@/pages/admin/Create'
import UpdateBrand from '@/pages/brand/Update'
import UpdateWarranty from '@/pages/warranty/Update'
import PaymentList from '@/pages/payment/List'
import UpdateShipment from '@/pages/shipment/Update'
import CreateFine from '@/pages/payment/CreateFine'
import Fines from '@/pages/payment/Fines'
import TicketsList from '@/pages/ticket/TicketsList'
import ProductReport from '@/pages/report/ProductReport'
import CategoryReport from '@/pages/report/Category'
import AboutUsList from '@/pages/setting/AboutUsList'
import AboutUsCreate from '@/pages/setting/AboutUsCreate'
import FaqList from '@/pages/setting/FaqList'
import FaqCreate from '@/pages/setting/FaqCreate'
import FaqUpdate from '@/pages/setting/FaqUpdate'
import ShipmentPage from '@/pages/setting/ShipmentPage'
import PrivacyPage from '@/pages/setting/PrivacyPage'
import ReturnPolicyPage from '@/pages/setting/ReturnPolicyPage'
import JobsPage from '@/pages/setting/JobsPage'
import ManageDocument from '@/pages/setting/ManageDocument'
import Pricing from '@/pages/setting/Pricing'
import Shop from '@/pages/setting/Shop'
import Banners from '@/pages/setting/Banners'
import Sliders from '@/pages/setting/Sliders'
import SiteSetting from '@/pages/setting/SiteSetting'
import JobsList from '@/pages/jobs/List'
import Resumes from '@/pages/jobs/Resume'
import ContactUsList from '@/pages/contactUs/List'
import Dashboard from '@/pages/dashboard/Dashboard'
import SellerList from '@/pages/seller/List'
import WholeSaleRequest from '@/pages/seller/WholeSaleRequest'
import WithdrawalRequestPage from '@/pages/seller/WithdrawalRequest'
import Annoncement from '@/pages/seller/Annoncement'
import RequestCreateProduct from '@/pages/seller/RequestCreateProduct'
import CategoryLearning from '@/pages/seller/CategoryLearning'
import Learning from '@/pages/seller/Learning'
import CreateLearning from '@/pages/seller/CreateLearning'
import UpdateLearning from '@/pages/seller/UpdateLearning'
import ContractPage from '@/pages/seller/Contract'
import Category from '@/pages/ticket/Category'
import CreateCategory from '@/pages/ticket/Create'
import UpdateCategory from '@/pages/ticket/Update'
import TicketMessages from '@/pages/ticket/TicketMessages'
import Reviews from '@/pages/products/Reviews'
import Questions from '@/pages/products/Questions'
import Returns from '@/pages/orders/Returns'
import ReturnDetails from '@/pages/orders/ReturnDetails'
import Cancels from '@/pages/orders/Cancels'
import ThemeList from '@/pages/theme/List'
import CreateTheme from '@/pages/theme/Create'
import UpdateTheme from '@/pages/theme/Update'
const MainRouter: FC = () => {

    const { hasSubMenu } = useSharedStore()

    return (
        <div className='p-4 overflow-hidden'>
            <SideBar />
            <Header />
            <div className={clx(
                'flex-1 xl:ms-[269px] mt-[68px] xl:mt-[81px]',
                hasSubMenu && 'xl:ms-[305px]',
            )}>
                <div className={clx(
                    `overflow-auto w-[${window.innerWidth}] max-h-[calc(100vh-113px)]`,
                )}>
                    <div className='pb-20'>
                        <Routes>
                            <Route path={Pages.category.create} element={<Create />} />
                            <Route path={Pages.category.list} element={<List />} />
                            <Route path={`${Pages.category.update}:id`} element={<Update />} />
                            <Route path={`${Pages.category.variant}:id`} element={<Variant />} />
                            <Route path={`${Pages.category.attributes}:id`} element={<Attributes />} />
                            <Route path={Pages.products.create} element={<CreateProduct />} />
                            <Route path={Pages.products.list} element={<ListProduct />} />
                            <Route path={`${Pages.products.update}:id`} element={<UpdateProduct />} />
                            <Route path={`${Pages.products.variants}:id`} element={<ProductVariant />} />
                            <Route path={Pages.products.brands.list} element={<BrandList />} />
                            <Route path={Pages.products.brands.create} element={<BrandCreate />} />
                            <Route path={`${Pages.products.brands.update}:id`} element={<UpdateBrand />} />
                            <Route path={Pages.products.warranty.list} element={<WarrantyList />} />
                            <Route path={Pages.products.warranty.create} element={<CreateWarranty />} />
                            <Route path={`${Pages.products.warranty.update}:id`} element={<UpdateWarranty />} />

                            <Route path={Pages.orders.native} element={<Native />} />
                            <Route path={Pages.orders.sellers} element={<OrdersSeller />} />
                            <Route path={Pages.orders.completed} element={<Native />} />
                            <Route path={Pages.orders.cancelled} element={<Native />} />
                            <Route path={Pages.orders.pending} element={<Native />} />
                            <Route path={`${Pages.orders.detailUser}:id`} element={<OrderDetail />} />
                            <Route path={Pages.orders.cancellationCategories} element={<CancellationCategories />} />
                            <Route path={Pages.orders.returnCategories} element={<ReturnCategories />} />

                            <Route path={Pages.blog.list} element={<BlogsList />} />
                            <Route path={Pages.blog.create} element={<CreateBlog />} />
                            <Route path={`${Pages.blog.detail}:id`} element={<UpdateBlog />} />
                            <Route path={Pages.blog.category} element={<BlogCategory />} />

                            <Route path={Pages.shipment.list} element={<ShippingList />} />
                            <Route path={Pages.shipment.create} element={<CreateShipment />} />
                            <Route path={`${Pages.shipment.update}:id`} element={<UpdateShipment />} />

                            <Route path={Pages.coupon.list} element={<CouponList />} />
                            <Route path={Pages.coupon.create} element={<CreateCoupon />} />
                            <Route path={`${Pages.coupon.detail}:id`} element={<UpdateCoupon />} />

                            <Route path={Pages.buyUsers.list} element={<UsersList />} />

                            <Route path={Pages.admin.list} element={<AdminList />} />
                            <Route path={Pages.admin.create} element={<AdminCreate />} />

                            <Route path={Pages.financial.list} element={<PaymentList />} />
                            <Route path={Pages.financial.createFine} element={<CreateFine />} />
                            <Route path={Pages.financial.fines} element={<Fines />} />

                            <Route path={Pages.ticket.list} element={<TicketsList />} />
                            <Route path={`${Pages.ticket.detail}:id`} element={<TicketMessages />} />
                            <Route path={Pages.ticket.category.list} element={<Category />} />
                            <Route path={Pages.ticket.category.create} element={<CreateCategory />} />
                            <Route path={`${Pages.ticket.category.update}:id`} element={<UpdateCategory />} />

                            <Route path={Pages.report.product} element={<ProductReport />} />
                            <Route path={Pages.report.category} element={<CategoryReport />} />

                            <Route path={Pages.pages.aboutUs} element={<AboutUsList />} />
                            <Route path={Pages.pages.aboutUsCreate} element={<AboutUsCreate />} />
                            <Route path={Pages.pages.faq} element={<FaqList />} />
                            <Route path={Pages.pages.faqCreate} element={<FaqCreate />} />
                            <Route path={`${Pages.pages.faqUpdate}:id`} element={<FaqUpdate />} />
                            <Route path={Pages.pages.shipment} element={<ShipmentPage />} />
                            <Route path={Pages.pages.privacy} element={<PrivacyPage />} />
                            <Route path={Pages.pages.returnPolicy} element={<ReturnPolicyPage />} />
                            <Route path={Pages.pages.jobs} element={<JobsPage />} />
                            <Route path={Pages.pages.documents} element={<ManageDocument />} />
                            <Route path={Pages.pages.incomeTariff} element={<Pricing />} />
                            <Route path={Pages.setting.shop} element={<Shop />} />
                            <Route path={Pages.setting.banners} element={<Banners />} />
                            <Route path={Pages.setting.sliders} element={<Sliders />} />
                            <Route path={Pages.setting.siteSetting} element={<SiteSetting />} />

                            <Route path={Pages.jobs.list} element={<JobsList />} />
                            <Route path={Pages.jobs.resumes} element={<Resumes />} />

                            <Route path={Pages.contactUs.list} element={<ContactUsList />} />

                            <Route path={Pages.dashboard} element={<Dashboard />} />
                            <Route path="/dashboard/product-stats" element={<Dashboard />} />
                            <Route path="/dashboard/order-stats" element={<Dashboard />} />
                            <Route path="/dashboard/unread-comments" element={<Dashboard />} />
                            <Route path="/dashboard/user-stats" element={<Dashboard />} />
                            <Route path="/dashboard/order-chart" element={<Dashboard />} />

                            <Route path={Pages.sellers.list} element={<SellerList />} />
                            <Route path={Pages.sellers.wholesaleRequests} element={<WholeSaleRequest />} />
                            <Route path={Pages.sellers.withdrawalRequests} element={<WithdrawalRequestPage />} />
                            <Route path={Pages.sellers.announcement} element={<Annoncement />} />
                            <Route path={Pages.sellers.requestCreateProduct} element={<RequestCreateProduct />} />
                            <Route path={Pages.sellers.learningCategory} element={<CategoryLearning />} />
                            <Route path={Pages.sellers.learning} element={<Learning />} />
                            <Route path={Pages.sellers.learningCreate} element={<CreateLearning />} />
                            <Route path={`${Pages.sellers.learningUpdate}:id`} element={<UpdateLearning />} />
                            <Route path={Pages.sellers.contract} element={<ContractPage />} />

                            <Route path={Pages.products.reviews.list} element={<Reviews />} />
                            <Route path={Pages.products.questions.list} element={<Questions />} />

                            <Route path={Pages.blog.category} element={<BlogCategory />} />

                            <Route path={Pages.orders.return} element={<Returns />} />
                            <Route path={`${Pages.orders.returnDetails}:id`} element={<ReturnDetails />} />
                            <Route path={Pages.orders.cancels} element={<Cancels />} />

                            <Route path={Pages.products.theme.list} element={<ThemeList />} />
                            <Route path={Pages.products.theme.create} element={<CreateTheme />} />
                            <Route path={`${Pages.products.theme.update}:id`} element={<UpdateTheme />} />
                        </Routes>
                    </div>
                </div>
            </div>
            <Footer />
        </div>
    )
}

export default MainRouter