28 lines
551 B
TypeScript
28 lines
551 B
TypeScript
import { getCombinedSearch } from '@graphql/queries/combined/searchPage';
|
|
import type { ISearchCombinedResponse } from '@types';
|
|
|
|
export async function useSearchCombined(name: string) {
|
|
const { document, variables } = getCombinedSearch(
|
|
{
|
|
productName: name,
|
|
},
|
|
{
|
|
categoryName: name,
|
|
},
|
|
{
|
|
brandName: name,
|
|
},
|
|
);
|
|
|
|
const { data, error } = await useAsyncQuery<ISearchCombinedResponse>(document, variables);
|
|
|
|
watch(error, (err) => {
|
|
if (err) {
|
|
console.error('useSearchCombined error:', err);
|
|
}
|
|
});
|
|
|
|
return {
|
|
data,
|
|
};
|
|
}
|