"use client";

import React from "react";
import { Card } from "@/components/ui/card";
import { FulfillmentGoodsTab } from "./fulfillment-goods-tab";
import { RealSupplyOrdersTab } from "./real-supply-orders-tab";
import { SellerSupplyOrdersTab } from "./seller-supply-orders-tab";
import { useAuth } from "@/hooks/useAuth";

interface AllSuppliesTabProps {
  pendingSupplyOrders?: number;
}

export function AllSuppliesTab({
  pendingSupplyOrders = 0,
}: AllSuppliesTabProps) {
  const { user } = useAuth();

  // Определяем тип организации для выбора правильного компонента
  const isWholesale = user?.organization?.type === "WHOLESALE";

  return (
    <div className="h-full overflow-hidden space-y-4">
      {/* Секция товаров */}
      <Card className="bg-white/10 backdrop-blur border-white/20 p-4">
        <h3 className="text-white font-semibold text-lg mb-3">Товары</h3>
        <div className="h-64 overflow-hidden">
          <FulfillmentGoodsTab />
        </div>
      </Card>

      {/* Секция расходников */}
      <Card className="bg-white/10 backdrop-blur border-white/20 p-4">
        <h3 className="text-white font-semibold text-lg mb-3">Расходники</h3>
        <div className="h-64 overflow-hidden">
          {isWholesale ? <RealSupplyOrdersTab /> : <SellerSupplyOrdersTab />}
        </div>
      </Card>
    </div>
  );
}
