"use client";
import UpdateConfigsForm from "@/components/forms/configs/ConfigsForm";
import Loader from "@/components/Loader";
import {useGetAllConfigs, useUpdateConfigs} from "@/hooks/configs";
import {useRouter} from "next/navigation";
import React, {Suspense} from "react";

export default function Page() {
  const router = useRouter();
  const {data} = useGetAllConfigs();
  const {mutateAsync, isPending} = useUpdateConfigs();
  return (
    <div>
      <Suspense fallback={<Loader />}>
        {data && data?.data?.length && (
          <UpdateConfigsForm
            router={router}
            initialData={data?.data}
            onSubmit={mutateAsync}
            updatePending={isPending}
          />
        )}
      </Suspense>
    </div>
  );
}
