20 lines
512 B
TypeScript
20 lines
512 B
TypeScript
import { GET_WISHLIST } from '@graphql/queries/standalone/wishlist';
|
|
import type { IWishlistResponse } from '@types';
|
|
|
|
export async function useWishlist() {
|
|
const wishlistStore = useWishlistStore();
|
|
|
|
const { data, error } = await useAsyncQuery<IWishlistResponse>(GET_WISHLIST);
|
|
|
|
if (!error.value && data.value?.wishlists.edges[0]) {
|
|
wishlistStore.setWishlist(data.value.wishlists.edges[0].node);
|
|
}
|
|
|
|
watch(error, (err) => {
|
|
if (err) {
|
|
console.error('useWishlist error:', err);
|
|
}
|
|
});
|
|
|
|
return {};
|
|
}
|