"use client";

import React, {useEffect, useState} from "react";

import FetchService from "./help/fetch-service";
import Donut from "./components/donut";
import DateInput from "./components/date-input";

export default function Page() {
  const [donutValues, setDonutValues] = useState([]);

  useEffect(() => {
    (async () => {
      const data = await FetchService.getDonutContent();
      const formattedData = data.map((x) => ({
        id: x.region,
        count: x.occurences
      }));
      setDonutValues(formattedData);
    })();
  }, []);

  return (
    <>
      <p>Coucou</p>
      <DateInput/>
      <Donut data={donutValues}/>
    </>
  );
}
