21 lines
516 B
TypeScript
21 lines
516 B
TypeScript
import { GET_BRAND_BY_SLUG } from '@graphql/queries/standalone/brands';
|
|
import type { IBrandsResponse } from '@types';
|
|
|
|
export async function useBrandBySlug(slug: string) {
|
|
const brand = computed(() => data.value?.brands.edges[0]?.node ?? null);
|
|
|
|
const { data, error } = await useAsyncQuery<IBrandsResponse>(GET_BRAND_BY_SLUG, {
|
|
slug,
|
|
});
|
|
|
|
watch(error, (err) => {
|
|
if (err) {
|
|
console.error('useBrandsBySlug error:', err);
|
|
}
|
|
});
|
|
|
|
return {
|
|
brand,
|
|
seoMeta: computed(() => brand.value?.seoMeta),
|
|
};
|
|
}
|