fix: scrolls and context for deal prefilling
This commit is contained in:
		@@ -1,19 +1,9 @@
 | 
			
		||||
import { createContext, Dispatch, FC, SetStateAction, useContext, useState } from "react";
 | 
			
		||||
import { DealSchema, DealService } from "../../../client";
 | 
			
		||||
import { useDisclosure } from "@mantine/hooks";
 | 
			
		||||
import { createContext, FC, useContext, useState } from "react";
 | 
			
		||||
import { DealSchema } from "../../../client";
 | 
			
		||||
 | 
			
		||||
type DealPageContextState = {
 | 
			
		||||
    selectedDeal?: DealSchema;
 | 
			
		||||
    setSelectedDeal: (deal: DealSchema | undefined) => void;
 | 
			
		||||
 | 
			
		||||
    prefillOpened: boolean;
 | 
			
		||||
    prefillOnClose: () => void;
 | 
			
		||||
    prefillOnOpen: () => void;
 | 
			
		||||
 | 
			
		||||
    selectedPrefillDeal?: DealSchema;
 | 
			
		||||
    selectPrefillDeal: (dealId: number) => void;
 | 
			
		||||
    prefillDeal?: DealSchema;
 | 
			
		||||
    setPrefillDeal: Dispatch<SetStateAction<DealSchema | undefined>>;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const DealPageContext = createContext<DealPageContextState | undefined>(
 | 
			
		||||
@@ -23,34 +13,10 @@ const useDealPageContextState = () => {
 | 
			
		||||
    const [selectedDeal, setSelectedDeal] = useState<DealSchema | undefined>(
 | 
			
		||||
        undefined
 | 
			
		||||
    );
 | 
			
		||||
    const [selectedPrefillDeal, setSelectedPrefillDeal] = useState<DealSchema | undefined>(
 | 
			
		||||
        undefined,
 | 
			
		||||
    );
 | 
			
		||||
    const [prefillDeal, setPrefillDeal] = useState<DealSchema | undefined>(
 | 
			
		||||
        undefined,
 | 
			
		||||
    );
 | 
			
		||||
    const [prefillOpened, { open, close }] = useDisclosure(false);
 | 
			
		||||
    const prefillOnClose = close;
 | 
			
		||||
    const prefillOnOpen = open;
 | 
			
		||||
 | 
			
		||||
    const selectPrefillDeal = (dealId: number) => {
 | 
			
		||||
        DealService.getDealById({ dealId }).then(deal => {
 | 
			
		||||
            setSelectedPrefillDeal(deal);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return {
 | 
			
		||||
        selectedDeal,
 | 
			
		||||
        setSelectedDeal,
 | 
			
		||||
 | 
			
		||||
        prefillOpened,
 | 
			
		||||
        prefillOnClose,
 | 
			
		||||
        prefillOnOpen,
 | 
			
		||||
 | 
			
		||||
        selectedPrefillDeal,
 | 
			
		||||
        selectPrefillDeal,
 | 
			
		||||
        prefillDeal,
 | 
			
		||||
        setPrefillDeal,
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user