structure category product
This commit is contained in:
@@ -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[]>;
|
||||
Reference in New Issue
Block a user