ts-ignore
This commit is contained in:
@@ -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;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user