feat(navigation): integrate product management into app navigation
- Add product management section to sidebar with nested menu items - Include routes for products, categories, and product-options - Update API routes constants with all new endpoints - Add corresponding query keys for React Query caching - Organize navigation with proper icons and hierarchy
This commit is contained in:
parent
87213732a2
commit
8c896c1855
28
src/App.tsx
28
src/App.tsx
|
|
@ -31,6 +31,18 @@ import AdminUserFormPage from './pages/admin-users/admin-user-form/AdminUserForm
|
|||
import PermissionsListPage from './pages/permissions/permissions-list/PermissionsListPage';
|
||||
import PermissionFormPage from './pages/permissions/permission-form/PermissionFormPage';
|
||||
|
||||
// Product Options Pages
|
||||
import ProductOptionsListPage from './pages/product-options/product-options-list/ProductOptionsListPage';
|
||||
import ProductOptionFormPage from './pages/product-options/product-option-form/ProductOptionFormPage';
|
||||
|
||||
// Categories Pages
|
||||
import CategoriesListPage from './pages/categories/categories-list/CategoriesListPage';
|
||||
import CategoryFormPage from './pages/categories/category-form/CategoryFormPage';
|
||||
|
||||
// Products Pages
|
||||
import ProductsListPage from './pages/products/products-list/ProductsListPage';
|
||||
import ProductFormPage from './pages/products/product-form/ProductFormPage';
|
||||
|
||||
const ProtectedRoute = ({ children }: { children: any }) => {
|
||||
const { user, isLoading } = useAuth();
|
||||
|
||||
|
|
@ -56,7 +68,7 @@ const AppRoutes = () => {
|
|||
}>
|
||||
<Route index element={<Dashboard />} />
|
||||
<Route path="users" element={<Users />} />
|
||||
<Route path="products" element={<Products />} />
|
||||
<Route path="products" element={<ProductsListPage />} />
|
||||
<Route path="orders" element={<Orders />} />
|
||||
<Route path="reports" element={<Reports />} />
|
||||
<Route path="notifications" element={<Notifications />} />
|
||||
|
|
@ -77,6 +89,20 @@ const AppRoutes = () => {
|
|||
<Route path="permissions" element={<PermissionsListPage />} />
|
||||
<Route path="permissions/create" element={<PermissionFormPage />} />
|
||||
<Route path="permissions/:id/edit" element={<PermissionFormPage />} />
|
||||
|
||||
{/* Product Options Routes */}
|
||||
<Route path="product-options" element={<ProductOptionsListPage />} />
|
||||
<Route path="product-options/create" element={<ProductOptionFormPage />} />
|
||||
<Route path="product-options/:id/edit" element={<ProductOptionFormPage />} />
|
||||
|
||||
{/* Categories Routes */}
|
||||
<Route path="categories" element={<CategoriesListPage />} />
|
||||
<Route path="categories/create" element={<CategoryFormPage />} />
|
||||
<Route path="categories/:id/edit" element={<CategoryFormPage />} />
|
||||
|
||||
{/* Products Routes */}
|
||||
<Route path="products/create" element={<ProductFormPage />} />
|
||||
<Route path="products/:id/edit" element={<ProductFormPage />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@ import {
|
|||
Key,
|
||||
LogOut,
|
||||
ChevronDown,
|
||||
ChevronRight
|
||||
ChevronRight,
|
||||
Package,
|
||||
FolderOpen,
|
||||
Sliders
|
||||
} from 'lucide-react';
|
||||
import { useAuth } from '../../contexts/AuthContext';
|
||||
import { PermissionWrapper } from '../common/PermissionWrapper';
|
||||
|
|
@ -27,6 +30,27 @@ const menuItems: MenuItem[] = [
|
|||
icon: Home,
|
||||
path: '/',
|
||||
},
|
||||
{
|
||||
title: 'مدیریت محصولات',
|
||||
icon: Package,
|
||||
children: [
|
||||
{
|
||||
title: 'محصولات',
|
||||
icon: Package,
|
||||
path: '/products',
|
||||
},
|
||||
{
|
||||
title: 'دستهبندیها',
|
||||
icon: FolderOpen,
|
||||
path: '/categories',
|
||||
},
|
||||
{
|
||||
title: 'گزینههای محصول',
|
||||
icon: Sliders,
|
||||
path: '/product-options',
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'مدیریت سیستم',
|
||||
icon: Settings,
|
||||
|
|
@ -55,7 +79,7 @@ const menuItems: MenuItem[] = [
|
|||
|
||||
export const Sidebar = () => {
|
||||
const { user, logout, hasPermission } = useAuth();
|
||||
const [expandedItems, setExpandedItems] = React.useState<string[]>(['مدیریت سیستم']);
|
||||
const [expandedItems, setExpandedItems] = React.useState<string[]>(['مدیریت محصولات', 'مدیریت سیستم']);
|
||||
|
||||
const toggleExpanded = (title: string) => {
|
||||
setExpandedItems(prev =>
|
||||
|
|
|
|||
|
|
@ -35,4 +35,45 @@ export const API_ROUTES = {
|
|||
CREATE_PERMISSION: "api/v1/admin/permissions",
|
||||
UPDATE_PERMISSION: (id: string) => `api/v1/admin/permissions/${id}`,
|
||||
DELETE_PERMISSION: (id: string) => `api/v1/admin/permissions/${id}`,
|
||||
|
||||
// Product Options APIs
|
||||
GET_PRODUCT_OPTIONS: "api/v1/product-options",
|
||||
GET_PRODUCT_OPTION: (id: string) => `api/v1/product-options/${id}`,
|
||||
CREATE_PRODUCT_OPTION: "api/v1/products/options",
|
||||
UPDATE_PRODUCT_OPTION: (id: string) => `api/v1/products/options/${id}`,
|
||||
DELETE_PRODUCT_OPTION: (id: string) => `api/v1/product-options/${id}`,
|
||||
|
||||
// Categories APIs
|
||||
GET_CATEGORIES: "api/v1/products/categories",
|
||||
GET_CATEGORY: (id: string) => `api/v1/products/categories/${id}`,
|
||||
CREATE_CATEGORY: "api/v1/products/categories",
|
||||
UPDATE_CATEGORY: (id: string) => `api/v1/products/categories/${id}`,
|
||||
DELETE_CATEGORY: (id: string) => `api/v1/products/categories/${id}`,
|
||||
|
||||
// Products APIs
|
||||
GET_PRODUCTS: "api/v1/products",
|
||||
GET_PRODUCT: (id: string) => `api/v1/products/${id}`,
|
||||
CREATE_PRODUCT: "api/v1/products",
|
||||
UPDATE_PRODUCT: (id: string) => `api/v1/products/${id}`,
|
||||
DELETE_PRODUCT: (id: string) => `api/v1/products/${id}`,
|
||||
GET_PRODUCT_VARIANTS: (id: string) => `api/v1/products/${id}/variants`,
|
||||
CREATE_PRODUCT_VARIANT: (id: string) => `api/v1/products/${id}/variants`,
|
||||
UPDATE_PRODUCT_VARIANT: (variantId: string) =>
|
||||
`api/v1/products/variants/${variantId}`,
|
||||
DELETE_PRODUCT_VARIANT: (variantId: string) =>
|
||||
`api/v1/products/variants/${variantId}`,
|
||||
|
||||
// Files APIs
|
||||
GET_FILES: "api/v1/admin/files",
|
||||
UPLOAD_FILE: "api/v1/admin/files",
|
||||
GET_FILE: (id: string) => `api/v1/admin/files/${id}`,
|
||||
UPDATE_FILE: (id: string) => `api/v1/admin/files/${id}`,
|
||||
DELETE_FILE: (id: string) => `api/v1/admin/files/${id}`,
|
||||
DOWNLOAD_FILE: (serveKey: string) => `api/v1/files/${serveKey}`,
|
||||
|
||||
// Images APIs
|
||||
GET_IMAGES: "api/v1/images",
|
||||
CREATE_IMAGE: "api/v1/images",
|
||||
UPDATE_IMAGE: (imageId: string) => `api/v1/products/images/${imageId}`,
|
||||
DELETE_IMAGE: (imageId: string) => `api/v1/products/images/${imageId}`,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,4 +29,42 @@ export const QUERY_KEYS = {
|
|||
CREATE_PERMISSION: "create_permission",
|
||||
UPDATE_PERMISSION: "update_permission",
|
||||
DELETE_PERMISSION: "delete_permission",
|
||||
|
||||
// Product Options
|
||||
GET_PRODUCT_OPTIONS: "get_product_options",
|
||||
GET_PRODUCT_OPTION: "get_product_option",
|
||||
CREATE_PRODUCT_OPTION: "create_product_option",
|
||||
UPDATE_PRODUCT_OPTION: "update_product_option",
|
||||
DELETE_PRODUCT_OPTION: "delete_product_option",
|
||||
|
||||
// Categories
|
||||
GET_CATEGORIES: "get_categories",
|
||||
GET_CATEGORY: "get_category",
|
||||
CREATE_CATEGORY: "create_category",
|
||||
UPDATE_CATEGORY: "update_category",
|
||||
DELETE_CATEGORY: "delete_category",
|
||||
|
||||
// Products
|
||||
GET_PRODUCTS: "get_products",
|
||||
GET_PRODUCT: "get_product",
|
||||
CREATE_PRODUCT: "create_product",
|
||||
UPDATE_PRODUCT: "update_product",
|
||||
DELETE_PRODUCT: "delete_product",
|
||||
GET_PRODUCT_VARIANTS: "get_product_variants",
|
||||
CREATE_PRODUCT_VARIANT: "create_product_variant",
|
||||
UPDATE_PRODUCT_VARIANT: "update_product_variant",
|
||||
DELETE_PRODUCT_VARIANT: "delete_product_variant",
|
||||
|
||||
// Files
|
||||
GET_FILES: "get_files",
|
||||
UPLOAD_FILE: "upload_file",
|
||||
GET_FILE: "get_file",
|
||||
UPDATE_FILE: "update_file",
|
||||
DELETE_FILE: "delete_file",
|
||||
|
||||
// Images
|
||||
GET_IMAGES: "get_images",
|
||||
CREATE_IMAGE: "create_image",
|
||||
UPDATE_IMAGE: "update_image",
|
||||
DELETE_IMAGE: "delete_image",
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue