schon/storefront/app/composables/brands/useBrandBySlug.ts
2026-02-27 21:59:51 +03:00

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),
};
}