manage variant producy

This commit is contained in:
hamid zarghami
2025-09-23 15:44:14 +03:30
parent f8ff05357d
commit a71d521c7c
16 changed files with 1186 additions and 15 deletions
@@ -0,0 +1,10 @@
import { useQuery } from "@tanstack/react-query";
import * as api from "../service/WarrantyService";
import type { WarrantyResponse } from "../types/Types";
export const useGetWarranties = () => {
return useQuery<WarrantyResponse>({
queryKey: ["warranties"],
queryFn: () => api.getWarranties(),
});
};
@@ -0,0 +1,9 @@
import axios from "../../../config/axios";
import type { GetWarrantiesParams, WarrantyResponse } from "../types/Types";
export const getWarranties = async (
params?: GetWarrantiesParams
): Promise<WarrantyResponse> => {
const { data } = await axios.get("/warranty", { params });
return data;
};
+35
View File
@@ -0,0 +1,35 @@
export interface Warranty {
_id: number;
name: string;
status: string;
duration: string;
logoUrl: string;
deleted: boolean;
createdAt: string;
updatedAt: string;
}
export interface Pager {
page: number;
limit: number;
totalItems: number;
totalPages: number;
prevPage: boolean;
nextPage: boolean;
}
export interface WarrantyResults {
warranties: Warranty[];
pager: Pager;
}
export interface WarrantyResponse {
status: number;
success: boolean;
results: WarrantyResults;
}
export interface GetWarrantiesParams {
page?: number;
limit?: number;
}