manage variant producy
This commit is contained in:
@@ -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;
|
||||
};
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user