import { useState } from "react";
import { useApp } from "@/pages/app/AppContext";
import { BackHeader } from "@/pages/app/components/ui";
import { Toggle } from "@/pages/app/components/bo/BoUI";
import { BizOpportunityRows, bizOpportunityTarget } from "@/pages/app/components/biz/BizUI";
import { bizOpportunities } from "@/mocks/dshnBizOwner";

/** No current opportunity: seek-investor toggle off + previous opportunities (section 2.7). */
export default function BizOpportunitiesEmpty() {
  const { goBack, navigate } = useApp();
  const [seeking, setSeeking] = useState(false);
  const previous = bizOpportunities.filter((o) => o.status !== "published" && o.status !== "review");

  const onToggle = (v: boolean) => {
    setSeeking(v);
    if (v) navigate("bizOpportunityForm");
  };

  return (
    <div className="min-h-full pb-8">
      <BackHeader title="فرص الاستثمار" onBack={goBack} />

      <div className="px-4 py-5 space-y-5">
        <div className="rounded-[20px] bg-background-100 border border-background-200 p-4">
          <Toggle
            checked={seeking}
            onChange={onToggle}
            label="البحث عن مستثمر"
            desc="فعّل البحث عن مستثمر لنشر فرصة استثمارية لمنشأتك."
          />
        </div>

        <div>
          <h2 className="text-[15px] font-semibold text-foreground-950 mb-2.5">الفرص السابقة</h2>
          <BizOpportunityRows items={previous} onOpen={(op) => navigate(bizOpportunityTarget(op))} />
        </div>
      </div>
    </div>
  );
}