feat(drafts): implement drafts feature structure

- Add draft API request functions
- Add custom hooks for draft data fetching
- Update React Query to use @tanstack/react-query
- Follow established development pattern
This commit is contained in:
hosseintaromi 2025-07-18 13:06:15 +03:30
parent 64a63e01fb
commit 0833a6180a
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,17 @@
import { QUERY_KEYS } from "@/utils/query-key";
import { useQuery } from "@tanstack/react-query";
import { getDiscountDraftDetail, getDraftDetail } from "./_requests";
export const useDiscountDraftDetail = (id: string) => {
return useQuery({
queryKey: [QUERY_KEYS.GET_DISCOUNT_DETAIL, id],
queryFn: () => getDiscountDraftDetail(id),
});
};
export const useDraftDetail = (id: string) => {
return useQuery({
queryKey: [QUERY_KEYS.GET_DRAFT_DETAIL, id],
queryFn: () => getDraftDetail(id),
});
};

View File

@ -0,0 +1,16 @@
import { APIUrlGenerator, httpGetRequest } from "@/utils/baseHttpService";
import { API_ROUTES } from "@/constant/routes";
export const getDiscountDraftDetail = async (id: string) => {
const response = await httpGetRequest(
APIUrlGenerator(API_ROUTES.GET_DISCOUNT_DETAIL(id))
);
return response.data;
};
export const getDraftDetail = async (id: string) => {
const response = await httpGetRequest(
APIUrlGenerator(API_ROUTES.GET_DRAFT_DETAIL(id))
);
return response.data;
};