"use client";
import UpdateDefaultForm from "@/components/forms/default/UpdateDefaultsForm";
import Loader from "@/components/Loader";
import {useGetAllDefaults, useUpdateDefaults} from "@/hooks/defaults";
import { useGetLanguages } from "@/hooks/languages";
import {useRouter} from "next/navigation";
import React, {Suspense} from "react";

export default function Page() {
  const router = useRouter();

  const {data, isLoading} = useGetAllDefaults();
  const {mutateAsync, isPending} = useUpdateDefaults();
  const {
    data: languages,
  } = useGetLanguages();
  return (
    <div>
      <Suspense fallback={<Loader />}>
        {data && languages && (
          <UpdateDefaultForm
            router={router}
            languages={languages?.data}
            updateFn={mutateAsync}
            updatePending={isPending}
            preValues={data?.data}
            preValuesLoading={isLoading}
          />
        )}
      </Suspense>
    </div>
  );
}
