import { fetchJson } from '../../../lib/api';
import type { Product } from '../../../features/inventory/types';
import MergePreviewForm from '../../admin/products/MergePreviewForm';
import AdminProductList from '../../admin/products/AdminProductList';
import ExpandableCreateProductSection from '../../admin/products/ExpandableCreateProductSection';
import ResetProductsButton from '../../admin/products/ResetProductsButton';

export default async function DatabsTab() {
  const products = await fetchJson<Product[]>('/api/products');

  return (
    <div>
      <p style={{ color: '#555', marginBottom: '1.5rem' }}>
        Granska och standardisera produktnamn, slå ihop dubbletter och hantera kategorier.
      </p>
      <ExpandableCreateProductSection />
      <ResetProductsButton />
      <MergePreviewForm products={products} />
      <AdminProductList products={products} />
    </div>
  );
}
