import { fetchJson } from '@/lib/utils/server';
import type { LiveChannelListResponse } from '@/types/response/channel/live-list';
import LiveExplorer from './LiveExplorer';
import '../_components/home.scss';
import './live.scss';

const PAGE_SIZE = 24;

export const metadata = {
	title: '생방송'
};

export default async function LivePage()
{
	const res = await fetchJson<LiveChannelListResponse>(`/api/channel/live-list?limit=${PAGE_SIZE}&offset=0&sort=viewers`, { method: 'GET' });
	const initialChannels = res.success && res.data ? res.data.channels : [];
	const initialTotal = res.success && res.data ? res.data.total : 0;

	return (
		<div className="home">
			<div className="home__inner">
				<LiveExplorer initialChannels={initialChannels} initialTotal={initialTotal} pageSize={PAGE_SIZE} />
			</div>
		</div>
	);
}