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 ProductsList from '@/pages/product/List'
import { Pages } from '@/config/Pages'
import CreateProduct from '@/pages/product/Create'
import UpdateProduct from '@/pages/product/Update'
import CategoryProduct from '@/pages/product/Category'
import CustomersList from '@/pages/customers/List'
import CustomerDetails from '@/pages/customers/Details'
import CreateCustomer from '@/pages/customers/Create'
import OrdersList from '@/pages/orders/List'
import OrderDetails from '@/pages/orders/Details'
import CommentsList from '@/pages/comments/List'
import CommentsDetails from '@/pages/comments/Details'
import ScheduleList from '@/pages/schedule/List'
import CreateSchedule from '@/pages/schedule/Create'
import RolesList from '@/pages/roles/List'
import CreateRole from '@/pages/roles/Create'
import UpdateRole from '@/pages/roles/Update'
import UpdateSchedule from '@/pages/schedule/Update'
import Setting from '@/pages/settings/Setting'
import PaymentMethodsList from '@/pages/paymentMethods/List'
import CreatePaymentMethod from '@/pages/paymentMethods/Create'
import UpdatePaymentMethod from '@/pages/paymentMethods/Update'
import AdminList from '@/pages/admin/List'
import CreateAdmin from '@/pages/admin/Create'
import UpdateAdmin from '@/pages/admin/Update'
import ShipmentMethodList from '@/pages/shipmentMethod/List'
import CreateShipmentMethod from '@/pages/shipmentMethod/Create'
import UpdateShipmentMethod from '@/pages/shipmentMethod/Update'
import CouponsList from '@/pages/coupon/List'
import CreateCoupon from '@/pages/coupon/Create'
import UpdateCoupon from '@/pages/coupon/Update'
import ReviewsList from '@/pages/review/List'
import DetailReview from '@/pages/review/Detail'
import PagersList from '@/pages/pager/List'
import NotificationsList from '@/pages/notifications/List'
import Notification from '@/components/Notification'
import ReportsList from '@/pages/report/List'
import Statistics from '@/pages/statistics/Statistics'
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] transition-all duration-300',
                hasSubMenu && 'xl:ms-[305px]',
            )}>
                <div className={clx(
                    `overflow-auto w-[${window.innerWidth}] max-h-[calc(100vh-113px)]`,
                )}>
                    <div className='pb-20'>
                        <Routes>
                            <Route path={'/'} element={<Statistics />} />
                            <Route path={Pages.dashboard} element={<Statistics />} />

                            <Route path={Pages.products.list} element={<ProductsList />} />
                            <Route path={Pages.products.add} element={<CreateProduct />} />
                            <Route path={Pages.products.update + ':id'} element={<UpdateProduct />} />
                            <Route path={Pages.products.category} element={<CategoryProduct />} />
                            <Route path={Pages.customers.list} element={<CustomersList />} />
                            <Route path={Pages.customers.detail + ':id'} element={<CustomerDetails />} />
                            <Route path={Pages.customers.add} element={<CreateCustomer />} />
                            <Route path={Pages.orders.list} element={<OrdersList />} />
                            <Route path={Pages.orders.detail + ':id'} element={<OrderDetails />} />
                            <Route path={Pages.comments.list} element={<CommentsList />} />
                            <Route path={Pages.comments.detail + ':id'} element={<CommentsDetails />} />
                            <Route path={Pages.schedule.list} element={<ScheduleList />} />
                            <Route path={Pages.schedule.create} element={<CreateSchedule />} />
                            <Route path={Pages.schedule.update + ':id'} element={<UpdateSchedule />} />
                            <Route path={Pages.roles.list} element={<RolesList />} />
                            <Route path={Pages.roles.add} element={<CreateRole />} />
                            <Route path={Pages.roles.update + ':id'} element={<UpdateRole />} />
                            <Route path={Pages.setting} element={<Setting />} />

                            <Route path={Pages.payment_methods.list} element={<PaymentMethodsList />} />
                            <Route path={Pages.payment_methods.add} element={<CreatePaymentMethod />} />
                            <Route path={Pages.payment_methods.update + ':id'} element={<UpdatePaymentMethod />} />

                            <Route path={Pages.admins.list} element={<AdminList />} />
                            <Route path={Pages.admins.add} element={<CreateAdmin />} />
                            <Route path={Pages.admins.update + ':id'} element={<UpdateAdmin />} />

                            <Route path={Pages.shipment_methods.list} element={<ShipmentMethodList />} />
                            <Route path={Pages.shipment_methods.add} element={<CreateShipmentMethod />} />
                            <Route path={Pages.shipment_methods.update + ':id'} element={<UpdateShipmentMethod />} />

                            <Route path={Pages.coupons.list} element={<CouponsList />} />
                            <Route path={Pages.coupons.add} element={<CreateCoupon />} />
                            <Route path={Pages.coupons.update + ':id'} element={<UpdateCoupon />} />

                            <Route path={Pages.reviews.list} element={<ReviewsList />} />
                            <Route path={Pages.reviews.detail + ':id'} element={<DetailReview />} />

                            <Route path={Pages.pagers.list} element={<PagersList />} />

                            <Route path={Pages.notifications.list} element={<NotificationsList />} />

                            <Route path={Pages.reports.list} element={<ReportsList />} />

                            <Route path={Pages.statistics.list} element={<Statistics />} />
                        </Routes>
                    </div>
                </div>
            </div>
            <Footer />

            <Notification />
        </div>
    )
}

export default MainRouter