import fs from "node:fs";
import { HourChart } from "./(charts)/hour";
import { DayChart } from "./(charts)/day";
import { MinuteChart } from "./(charts)/minute";

export default async function Home() {
	const file = await fs.promises.readFile("./output.txt");

	const lines = file.toString().split("\n");

	const data = lines.map((line) => {
		const [timestamp, event, value] = line.split(",");
		return {
			timestamp: Math.round(parseFloat(timestamp) * 1000),
			foldtime: parseFloat(value),
		};
	});

	console.log(data);

	return (
		<main className="flex-grow w-full flex flex-col justify-center gap-4 items-center p-4">
			<MinuteChart data={data} />
			<HourChart data={data} />
			<DayChart data={data} />
		</main>
	);
}
