import { ProviderProps } from '@/utils/HookFormTypes';
import { useRouter } from 'next/router';
import AuthLayout from '../Layouts/AuthLayout';
import DashboardLayout from '../Layouts/DashboardLayout';
import SimpleLayout from '../Layouts/SimpleLayout';

const Provider = ({ children }: ProviderProps) => {
  const router = useRouter();

  const simpleLayoutPaths = [
    '/what-are-you-moving',
    'date-and-time',
    'vehicle-category',
  ];

  if (router.pathname.includes('storage')) {
    return <>{children}</>;
  }

  // Check if the current pathname is in the simpleLayoutPaths array
  if (simpleLayoutPaths.some((path) => router.pathname.includes(path))) {
    return <SimpleLayout>{children}</SimpleLayout>;
  }

  if (router.pathname.includes('auth') || router.pathname.includes('user/edit-profile') || router.pathname.includes('user/select-category') || router.pathname.includes('carrier/edit-profile')) {
    return <AuthLayout AuthContainerStyle="authLayout">{children}</AuthLayout>;
  }

  if (router.pathname.includes('user') || router.pathname.includes('carrier')) {
    return <DashboardLayout>{children}</DashboardLayout>;
  }

  return <>{children}</>; // Default case if none of the above match
};

export default Provider;
