ts-ignore

This commit is contained in:
2026-04-02 21:25:12 +05:30
parent ff3094cf09
commit c7095ed481
4 changed files with 13 additions and 4 deletions

View File

@@ -11,6 +11,7 @@ export function useResource<T = any>(config: ResourceConfig) {
useQuery({
queryKey: [name, "list", params],
queryFn: async () => {
// @ts-ignore
const res = await api.get<T[]>(endpoint, { params });
return res.data;
}
@@ -22,6 +23,7 @@ export function useResource<T = any>(config: ResourceConfig) {
queryKey: [name, "detail", id],
queryFn: async () => {
if (!id) return null;
// @ts-ignore
const res = await api.get<T>(`${endpoint}/${id}`);
return res.data;
},
@@ -32,6 +34,7 @@ export function useResource<T = any>(config: ResourceConfig) {
const useCreate = () =>
useMutation({
mutationFn: async (data: Partial<T>) => {
// @ts-ignore
const res = await api.post<T>(endpoint, data);
return res.data;
},
@@ -44,6 +47,7 @@ export function useResource<T = any>(config: ResourceConfig) {
const useUpdate = () =>
useMutation({
mutationFn: async ({ id, data }: { id: string; data: Partial<T> }) => {
// @ts-ignore
const res = await api.put<T>(`${endpoint}/${id}`, data);
return res.data;
},
@@ -71,6 +75,7 @@ export function useResource<T = any>(config: ResourceConfig) {
const getListQueryOptions = (params?: any) => ({
queryKey: [name, "list", params],
queryFn: async () => {
// @ts-ignore
const res = await api.get<T[]>(endpoint, { params });
return res.data;
},