import { ResultDto } from '@/types/response/common';
import { FaqCategoryResponse, FaqItemsResponse } from '@/types/response/page/faq';
import { fetchJson } from '@/lib/utils/server';

export async function fetchFaqCategories(): Promise<ResultDto<FaqCategoryResponse|null>> {
	return await fetchJson<FaqCategoryResponse>('/api/faq/categories', {
		method: 'GET',
		headers: { 'Content-Type': 'application/json' },
	});
}

export async function fetchFaqItems(code: string = ''): Promise<ResultDto<FaqItemsResponse|null>> {
	return await fetchJson<FaqItemsResponse>('/api/faq/items', {
		method: 'POST',
		headers: { 'Content-Type': 'application/json' },
		body: JSON.stringify({ Code: code }),
	});
}