filter search + primary color + logo + ...
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import * as api from "../service/CouponService";
|
||||
import type { CreateCouponType } from "../types/Types";
|
||||
|
||||
import { useSharedStore } from "@/shared/store/sharedStore";
|
||||
export const useGetCoupons = (page: number = 1) => {
|
||||
const { search } = useSharedStore();
|
||||
return useQuery({
|
||||
queryKey: ["coupons", page],
|
||||
queryFn: () => api.getCoupons(page),
|
||||
queryKey: ["coupons", page, search],
|
||||
queryFn: () => api.getCoupons(page, search),
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -7,9 +7,12 @@ import type {
|
||||
} from "../types/Types";
|
||||
|
||||
export const getCoupons = async (
|
||||
page: number = 1
|
||||
page: number = 1,
|
||||
search: string
|
||||
): Promise<CouponsResponse> => {
|
||||
const { data } = await axios.get(`/admin/coupon/native?page=${page}`);
|
||||
const { data } = await axios.get(
|
||||
`/admin/coupon/native?page=${page}&q=${search}`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
|
||||
@@ -7,11 +7,12 @@ import type {
|
||||
UpdateBlogType,
|
||||
BlogCategoriesResponse,
|
||||
} from "../types/Types";
|
||||
|
||||
import { useSharedStore } from "@/shared/store/sharedStore";
|
||||
export const useGetBlogs = (page: number = 1) => {
|
||||
const { search } = useSharedStore();
|
||||
return useQuery<GetBlogsResult>({
|
||||
queryKey: ["blogs", page],
|
||||
queryFn: () => api.getBlogs(page),
|
||||
queryKey: ["blogs", page, search],
|
||||
queryFn: () => api.getBlogs(page, search),
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -9,8 +9,13 @@ import type {
|
||||
BlogDetailResponse,
|
||||
} from "../types/Types";
|
||||
|
||||
export const getBlogs = async (page: number = 1): Promise<GetBlogsResult> => {
|
||||
const { data } = await axios.get<BlogsResponse>(`/blogs?page=${page}`);
|
||||
export const getBlogs = async (
|
||||
page: number = 1,
|
||||
search: string
|
||||
): Promise<GetBlogsResult> => {
|
||||
const { data } = await axios.get<BlogsResponse>(
|
||||
`/blogs?page=${page}&q=${search}`
|
||||
);
|
||||
return data.results;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import * as api from "../service/BrandService";
|
||||
import { useSharedStore } from "@/shared/store/sharedStore";
|
||||
|
||||
export const useGetBrands = (page: number = 1, limit: number = 10) => {
|
||||
const { search } = useSharedStore();
|
||||
return useQuery({
|
||||
queryKey: ["brands", page, limit],
|
||||
queryFn: () => api.getBrands(page, limit),
|
||||
queryKey: ["brands", page, limit, search],
|
||||
queryFn: () => api.getBrands(page, limit, search),
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ import axios from "../../../config/axios";
|
||||
import { type BrandsResponseType, type CreateBrandType } from "../types/Types";
|
||||
import { type IBrandResponse } from "../../../types/response.types";
|
||||
|
||||
export const getBrands = async (page: number = 1, limit: number = 10): Promise<BrandsResponseType> => {
|
||||
export const getBrands = async (page: number = 1, limit: number = 10, search: string): Promise<BrandsResponseType> => {
|
||||
const { data } = await axios.get(`/brand`, {
|
||||
params: { page, limit }
|
||||
params: { page, limit, q: search }
|
||||
});
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useMutation, useQuery } from '@tanstack/react-query';
|
||||
import * as api from '../service/CategoryService';
|
||||
import { type CategoryType, type CreateCategoryAttributeType, type CategoryAttributesResponseType } from '../types/Types';
|
||||
import { useSharedStore } from '@/shared/store/sharedStore';
|
||||
|
||||
export const useCreateCategory = () => {
|
||||
return useMutation({
|
||||
@@ -9,9 +10,10 @@ export const useCreateCategory = () => {
|
||||
};
|
||||
|
||||
export const useGetCategories = () => {
|
||||
const { search } = useSharedStore();
|
||||
return useQuery({
|
||||
queryKey: ['categories'],
|
||||
queryFn: api.getCategories,
|
||||
queryKey: ['categories', search],
|
||||
queryFn: () => api.getCategories(search),
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ export const createCategory = async (params: CategoryType) => {
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getCategories = async (): Promise<CategoriesResponseType> => {
|
||||
const { data } = await axios.get(`/category`);
|
||||
export const getCategories = async (search: string): Promise<CategoriesResponseType> => {
|
||||
const { data } = await axios.get(`/category?q=${search}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import * as api from "../service/OrderService";
|
||||
import { useSharedStore } from "@/shared/store/sharedStore";
|
||||
|
||||
export const useGetNativeOrders = (
|
||||
page: number = 1,
|
||||
status: string = "all"
|
||||
) => {
|
||||
const { search } = useSharedStore();
|
||||
const { data, isLoading, error } = useQuery({
|
||||
queryKey: ["orders", page, status],
|
||||
queryFn: () => api.getNativeOrders(page, status),
|
||||
queryKey: ["orders", page, status, search],
|
||||
queryFn: () => api.getNativeOrders(page, status, search),
|
||||
});
|
||||
return { data, isLoading, error };
|
||||
};
|
||||
@@ -16,9 +18,10 @@ export const useGetSellerOrders = (
|
||||
page: number = 1,
|
||||
status: string = "all"
|
||||
) => {
|
||||
const { search } = useSharedStore();
|
||||
const { data, isLoading, error } = useQuery({
|
||||
queryKey: ["orders", page, status],
|
||||
queryFn: () => api.getSellerOrders(page, status),
|
||||
queryKey: ["orders", page, status, search],
|
||||
queryFn: () => api.getSellerOrders(page, status, search),
|
||||
});
|
||||
return { data, isLoading, error };
|
||||
};
|
||||
|
||||
@@ -10,20 +10,22 @@ import type {
|
||||
|
||||
export const getNativeOrders = async (
|
||||
page: number = 1,
|
||||
status: string
|
||||
status: string,
|
||||
search: string
|
||||
): Promise<NativeOrdersResponseType> => {
|
||||
const { data } = await axios.get("/admin/orders/native", {
|
||||
params: { page, status },
|
||||
params: { page, status, q: search },
|
||||
});
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getSellerOrders = async (
|
||||
page: number = 1,
|
||||
status: string
|
||||
status: string,
|
||||
search: string
|
||||
): Promise<NativeOrdersResponseType> => {
|
||||
const { data } = await axios.get("/admin/orders/seller", {
|
||||
params: { page, status },
|
||||
params: { page, status, q: search },
|
||||
});
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -89,7 +89,7 @@ const List: FC = () => {
|
||||
<tbody>
|
||||
{products.length === 0 ? (
|
||||
<tr className='tr'>
|
||||
<td colSpan={8} className="text-center py-8 text-gray-500">
|
||||
<td colSpan={9} className="text-center py-8 text-gray-500">
|
||||
هیچ محصولی یافت نشد
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
type UpdateProductAttributeRequestType,
|
||||
type UpdateProductRequestType
|
||||
} from "../types/Types";
|
||||
import { useSharedStore } from '@/shared/store/sharedStore';
|
||||
|
||||
export const useCreateProductDetail = () => {
|
||||
return useMutation({
|
||||
@@ -29,9 +30,10 @@ export const useSaveProduct = () => {
|
||||
};
|
||||
|
||||
export const useGetProducts = (page: number = 1, limit: number = 10) => {
|
||||
const { search } = useSharedStore();
|
||||
return useQuery({
|
||||
queryKey: ['products', page, limit],
|
||||
queryFn: () => api.getProducts(page, limit),
|
||||
queryKey: ['products', page, limit, search],
|
||||
queryFn: () => api.getProducts(page, limit, search),
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ const SellerList: FC = () => {
|
||||
<tbody>
|
||||
{sellers.length === 0 ? (
|
||||
<tr className='tr'>
|
||||
<td colSpan={9} className="text-center py-8 text-gray-500">
|
||||
<td colSpan={10} className="text-center py-8 text-gray-500">
|
||||
هیچ فروشندهای یافت نشد
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -5,11 +5,13 @@ import type {
|
||||
CreateCategoryLearning,
|
||||
CreateLearningType,
|
||||
} from "../types/Types";
|
||||
import { useSharedStore } from "@/shared/store/sharedStore";
|
||||
|
||||
export const useGetSellers = (page: number = 1, enabled: boolean = true) => {
|
||||
const { search } = useSharedStore();
|
||||
return useQuery({
|
||||
queryKey: ["sellers", page],
|
||||
queryFn: () => api.getSellers(page),
|
||||
queryKey: ["sellers", page, search],
|
||||
queryFn: () => api.getSellers(page, search),
|
||||
enabled,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -16,9 +16,10 @@ import type {
|
||||
} from "../types/Types";
|
||||
|
||||
export const getSellers = async (
|
||||
page: number = 1
|
||||
page: number = 1,
|
||||
search: string
|
||||
): Promise<SellersResponse> => {
|
||||
const { data } = await axios.get(`/admin/sellers?page=${page}`);
|
||||
const { data } = await axios.get(`/admin/sellers?page=${page}&q=${search}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import * as api from "../service/UserService";
|
||||
import { useSharedStore } from "@/shared/store/sharedStore";
|
||||
|
||||
export const useGetUsers = (page: number = 1, limit: number = 10) => {
|
||||
const { search } = useSharedStore();
|
||||
return useQuery({
|
||||
queryKey: ["users", page, limit],
|
||||
queryFn: () => api.getUsers(page, limit),
|
||||
queryKey: ["users", page, limit, search],
|
||||
queryFn: () => api.getUsers(page, limit, search),
|
||||
});
|
||||
};
|
||||
|
||||
@@ -4,10 +4,11 @@ import type { UserResponse } from "../types/Types";
|
||||
|
||||
export const getUsers = async (
|
||||
page: number = 1,
|
||||
limit: number = 10
|
||||
limit: number = 10,
|
||||
search: string
|
||||
): Promise<UserResponse> => {
|
||||
const { data } = await axios.get("/admin/users", {
|
||||
params: { page, limit },
|
||||
params: { page, limit, q: search },
|
||||
});
|
||||
return data;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user