import type { Metadata } from 'next';
import { serverFetch } from '@/lib/server-api';
import { buildJobShareMetadata } from '@/lib/share';

type Props = {
  params: Promise<{ id: string }>;
};

export async function generateMetadata({ params }: Props): Promise<Metadata> {
  const { id } = await params;

  try {
    const job = await serverFetch<Record<string, unknown>>(`/jobs/${id}`);
    return buildJobShareMetadata(job);
  } catch {
    return {
      title: 'Job | eHandyHire',
      description: 'View job details on eHandyHire',
    };
  }
}

export default function JobDetailLayout({ children }: { children: React.ReactNode }) {
  return children;
}
