import { useParams } from "@tanstack/react-router";
import { DealPageContextProvider, useDealPageContext } from "../../LeadsPage/contexts/DealPageContext.tsx";
import ProductAndServiceTab from "../../LeadsPage/tabs/ProductAndServiceTab/ProductAndServiceTab.tsx";
import { FC, useEffect } from "react";
import { DealService } from "../../../client";

export type Props = {
    dealId: number;
};
const DealPageContent: FC<Props> = ({ dealId }) => {
    const { setSelectedDeal } = useDealPageContext();
    useEffect(() => {
        DealService.getDealById({ dealId }).then(deal => {
            setSelectedDeal(deal);
        });
    }, []);
    return <ProductAndServiceTab />;
};
const DealPageWrapper: FC<{ children: React.ReactNode }> = ({ children }) => {
    return <DealPageContextProvider refetchDeals={async () => {
    }}>{children}</DealPageContextProvider>;
};
export const DealPage = () => {
    const { dealId } = useParams({ strict: false });
    return (
        <DealPageWrapper>
            <DealPageContent dealId={parseInt(dealId || "-1")} />
        </DealPageWrapper>
    );
};
