mosaicmap/lib/admin-fetchers.ts
2025-08-14 21:34:16 +08:00

49 lines
1.1 KiB
TypeScript

import { gql, GraphQLClient } from "graphql-request";
import { getBaseUrl } from "./gr-client";
// const CategoriesQuery = gql`
// query Categories {
// settingCategories {
// page {
// id
// title
// slug
// }
// }
// }
// `;
export type CategoryPage = {
id: string;
title: string;
slug: string;
};
export type SettingCategory = {
page: CategoryPage;
};
export type CategoriesData = {
settingCategories: SettingCategory[];
};
// export async function fetchCategories(jwt?: string): Promise<CategoriesData | null> {
// const client = new GraphQLClient(getBaseUrl());
// if (jwt) {
// client.setHeader('Authorization', `Bearer ${jwt}`);
// }
// try {
// const response: any = await client.request(CategoriesQuery);
// if (response?.settingCategories) {
// return response;
// }
// return null;
// } catch (error) {
// console.error('Failed to fetch categories:', error);
// return null;
// }
// }