structure category product
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
|
VITE_API_BASE_URL = 'http://172.27.64.88:4000'
|
||||||
VITE_TOKEN_NAME = 'negareh_t'
|
VITE_TOKEN_NAME = 'negareh_t'
|
||||||
VITE_REFRESH_TOKEN_NAME = 'negareh_rt'
|
VITE_REFRESH_TOKEN_NAME = 'negareh_rt'
|
||||||
Generated
+11
@@ -22,6 +22,7 @@
|
|||||||
"react-infinite-scroll-component": "^6.1.0",
|
"react-infinite-scroll-component": "^6.1.0",
|
||||||
"react-loading-skeleton": "^3.5.0",
|
"react-loading-skeleton": "^3.5.0",
|
||||||
"react-multi-date-picker": "^4.5.2",
|
"react-multi-date-picker": "^4.5.2",
|
||||||
|
"react-otp-input": "^3.1.1",
|
||||||
"react-router-dom": "^7.9.4",
|
"react-router-dom": "^7.9.4",
|
||||||
"react-spinners": "^0.17.0",
|
"react-spinners": "^0.17.0",
|
||||||
"react-toastify": "^11.0.5",
|
"react-toastify": "^11.0.5",
|
||||||
@@ -4493,6 +4494,16 @@
|
|||||||
"react-dom": ">=16.8.0"
|
"react-dom": ">=16.8.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/react-otp-input": {
|
||||||
|
"version": "3.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-otp-input/-/react-otp-input-3.1.1.tgz",
|
||||||
|
"integrity": "sha512-bjPavgJ0/Zmf/AYi4onj8FbH93IjeD+e8pWwxIJreDEWsU1ILR5fs8jEJmMGWSBe/yyvPP6X/W6Mk9UkOCkTPw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">=16.8.6 || ^17.0.0 || ^18.0.0",
|
||||||
|
"react-dom": ">=16.8.6 || ^17.0.0 || ^18.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/react-refresh": {
|
"node_modules/react-refresh": {
|
||||||
"version": "0.17.0",
|
"version": "0.17.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.17.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.17.0.tgz",
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
"react-infinite-scroll-component": "^6.1.0",
|
"react-infinite-scroll-component": "^6.1.0",
|
||||||
"react-loading-skeleton": "^3.5.0",
|
"react-loading-skeleton": "^3.5.0",
|
||||||
"react-multi-date-picker": "^4.5.2",
|
"react-multi-date-picker": "^4.5.2",
|
||||||
|
"react-otp-input": "^3.1.1",
|
||||||
"react-router-dom": "^7.9.4",
|
"react-router-dom": "^7.9.4",
|
||||||
"react-spinners": "^0.17.0",
|
"react-spinners": "^0.17.0",
|
||||||
"react-toastify": "^11.0.5",
|
"react-toastify": "^11.0.5",
|
||||||
|
|||||||
@@ -4,7 +4,11 @@ export const Paths = {
|
|||||||
},
|
},
|
||||||
product: {
|
product: {
|
||||||
list: '/product/list',
|
list: '/product/list',
|
||||||
create: '/product/create'
|
create: '/product/create',
|
||||||
|
category: {
|
||||||
|
create: '/product/category/create',
|
||||||
|
list: '/product/category/list',
|
||||||
|
}
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
list: '/order/list'
|
list: '/order/list'
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ import axios from "axios";
|
|||||||
import { getToken } from "./func";
|
import { getToken } from "./func";
|
||||||
|
|
||||||
const instance = axios.create({
|
const instance = axios.create({
|
||||||
baseURL: import.meta.env.VITE_API_URL || "http://localhost:3000/api",
|
baseURL: import.meta.env.VITE_API_BASE_URL || "http://localhost:3000/api",
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { type FC } from 'react'
|
||||||
|
|
||||||
|
const ProductCategory: FC = () => {
|
||||||
|
return (
|
||||||
|
<div className='mt-5'>
|
||||||
|
<h1 className='text-lg font-light'>دسته بندی محصولات</h1>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ProductCategory
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { type FC } from 'react'
|
||||||
|
import { useGetCategory } from '../hooks/useProductData'
|
||||||
|
import Table from '@/components/Table'
|
||||||
|
import type { RowDataType } from '@/components/types/TableTypes'
|
||||||
|
import type { CategoryType } from '../types/Types'
|
||||||
|
|
||||||
|
const CategoryList: FC = () => {
|
||||||
|
|
||||||
|
const { data } = useGetCategory()
|
||||||
|
|
||||||
|
const column = [{
|
||||||
|
title: 'عنوان',
|
||||||
|
key: 'title',
|
||||||
|
}]
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='mt-5'>
|
||||||
|
<h1 className='text-lg font-light'>دسته بندی محصولات</h1>
|
||||||
|
|
||||||
|
<Table
|
||||||
|
columns={column}
|
||||||
|
data={data?.data || [] as (CategoryType & RowDataType)[]}
|
||||||
|
/>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CategoryList
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import * as api from "../service/ProductService";
|
||||||
|
|
||||||
|
export const useGetCategory = () => {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["category"],
|
||||||
|
queryFn: api.getCategory,
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import axios from "@/config/axios";
|
||||||
|
import { type CategoriesResponse } from "../types/Types";
|
||||||
|
|
||||||
|
export const getCategory = async () => {
|
||||||
|
const { data } = await axios.get<CategoriesResponse>("/admin/category");
|
||||||
|
return data;
|
||||||
|
};
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import type { RowDataType } from "@/components/types/TableTypes";
|
||||||
|
import { type BaseResponse } from "@/shared/types/Types";
|
||||||
|
|
||||||
|
export interface CategoryType extends RowDataType {
|
||||||
|
avatarUrl: string | null;
|
||||||
|
children: CategoryType[];
|
||||||
|
createdAt: string;
|
||||||
|
deletedAt: string | null;
|
||||||
|
id: string;
|
||||||
|
isActive: boolean;
|
||||||
|
order: number | null;
|
||||||
|
parent: CategoryType | null;
|
||||||
|
title: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type CategoriesResponse = BaseResponse<CategoryType[]>;
|
||||||
@@ -25,6 +25,8 @@ import CriticismsDetail from '@/pages/criticisms/Detail'
|
|||||||
import LearningList from '@/pages/learning/List'
|
import LearningList from '@/pages/learning/List'
|
||||||
import LearningCreate from '@/pages/learning/Create'
|
import LearningCreate from '@/pages/learning/Create'
|
||||||
import LearningCategory from '@/pages/learning/Category'
|
import LearningCategory from '@/pages/learning/Category'
|
||||||
|
import CategoryList from '@/pages/product/category/List'
|
||||||
|
import CreateCategory from '@/pages/learning/components/CreateCategory'
|
||||||
const MainRouter: FC = () => {
|
const MainRouter: FC = () => {
|
||||||
return (
|
return (
|
||||||
<div className='p-4 overflow-hidden'>
|
<div className='p-4 overflow-hidden'>
|
||||||
@@ -40,8 +42,12 @@ const MainRouter: FC = () => {
|
|||||||
<Route path={Paths.perfomaInvoice.list} element={<ProformaInvoice />} />
|
<Route path={Paths.perfomaInvoice.list} element={<ProformaInvoice />} />
|
||||||
<Route path={Paths.perfomaInvoice.detail + ':id'} element={<DetailPerfomaInvoice />} />
|
<Route path={Paths.perfomaInvoice.detail + ':id'} element={<DetailPerfomaInvoice />} />
|
||||||
<Route path={Paths.requests.list} element={<RequestList />} />
|
<Route path={Paths.requests.list} element={<RequestList />} />
|
||||||
|
|
||||||
<Route path={Paths.product.list} element={<ProductList />} />
|
<Route path={Paths.product.list} element={<ProductList />} />
|
||||||
<Route path={Paths.product.create} element={<CreateProduct />} />
|
<Route path={Paths.product.create} element={<CreateProduct />} />
|
||||||
|
<Route path={Paths.product.category.list} element={<CategoryList />} />
|
||||||
|
<Route path={Paths.product.category.create} element={<CreateCategory />} />
|
||||||
|
|
||||||
<Route path={Paths.order.list} element={<OrdersList />} />
|
<Route path={Paths.order.list} element={<OrdersList />} />
|
||||||
<Route path={Paths.features.list} element={<FeaturesList />} />
|
<Route path={Paths.features.list} element={<FeaturesList />} />
|
||||||
<Route path={Paths.features.create} element={<CreateFeature />} />
|
<Route path={Paths.features.create} element={<CreateFeature />} />
|
||||||
|
|||||||
@@ -2,3 +2,15 @@ export type SharedStoreType = {
|
|||||||
openSidebar: boolean;
|
openSidebar: boolean;
|
||||||
setOpenSidebar: (open: boolean) => void;
|
setOpenSidebar: (open: boolean) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface BaseResponse<T> {
|
||||||
|
success: boolean;
|
||||||
|
statusCode: number;
|
||||||
|
data: T;
|
||||||
|
meta?: {
|
||||||
|
limit: number;
|
||||||
|
page: number;
|
||||||
|
total: number;
|
||||||
|
totalPages: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user