import { Metadata } from 'next';
import Navigation from '../Navigation';
import ImportTabsClient from './ImportTabsClient';

type Props = {
  searchParams: Promise<{ tab?: string }>;
};

export async function generateMetadata({ searchParams }: Props): Promise<Metadata> {
  const { tab } = await searchParams;
  if (tab === 'recept') return { title: 'Importera recept' };
  return { title: 'Importera kvitto' };
}

export default async function ImportPage({ searchParams }: Props) {
  const { tab } = await searchParams;
  const activeTab = tab === 'recept' ? 'recept' : 'kvitto';
  return (
    <>
      <Navigation />
      <ImportTabsClient activeTab={activeTab} />
    </>
  );
}
