import CryptoPageContent from '@/app/component/crypto/CryptoPageContent';
import { fetchJson } from '@/lib/utils/server';
import type { ResultDto } from '@/types/response/common';
import type { TickerRestData } from '@/types/crypto';

export default async function Home() {
	let initialTickers: TickerRestData[] = [];

	try {
		const res: ResultDto<TickerRestData[]> = await fetchJson('/api/crypto/tickers?quote=KRW', {
			method: 'GET',
		});
		if (res.success && res.data) {
			initialTickers = res.data;
		}
	} catch {
		// 백엔드 미연결 시 빈 배열
	}

	return (
		<CryptoPageContent initialTickers={initialTickers} />
	);
}