"use client";

import { useGetAbout } from "@/app/[name]/(Main)/about/hooks/useAboutData";
import { useParams } from "next/navigation";

type Props = {
  children: React.ReactNode;
};

export default function RestaurantNotFoundGuard({ children }: Props) {
  const { name } = useParams<{ name: string }>();
  const { isError, isLoading, isFetching } = useGetAbout();

  if (!name) {
    return <>{children}</>;
  }

  if (isLoading || isFetching) {
    return <>{children}</>;
  }

  if (isError) {
    return (
      <div className="flex min-h-[50vh] items-center justify-center px-6 text-center">
        <p className="text-disabled-text">رستوران یافت نشد</p>
      </div>
    );
  }

  return <>{children}</>;
}
