31 lines
688 B
TypeScript
31 lines
688 B
TypeScript
import { $axios } from "@/lib/axios";
|
|
import { useQuery } from "@tanstack/react-query";
|
|
|
|
export type Wishlist = {
|
|
uuid: string;
|
|
name: string;
|
|
description: string;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
};
|
|
|
|
export const useUserWishlistsQuery = () => {
|
|
return useQuery({
|
|
queryKey: ["wishlists"],
|
|
queryFn: async () => {
|
|
const resp = await $axios.get<Wishlist[]>("/user/wishlists");
|
|
return resp.data;
|
|
},
|
|
});
|
|
};
|
|
|
|
export const useWishlistQuery = (uuid: string) => {
|
|
return useQuery({
|
|
queryKey: ["wishlists", uuid],
|
|
queryFn: async () => {
|
|
const resp = await $axios.get<Wishlist>(`/wishlists/${uuid}`);
|
|
return resp.data;
|
|
},
|
|
});
|
|
};
|