feat: assignment of employees to deals
This commit is contained in:
		@@ -5,6 +5,7 @@ type DealPageContextState = {
 | 
			
		||||
    selectedDeal?: DealSchema;
 | 
			
		||||
    setSelectedDeal: (deal: DealSchema | undefined) => void;
 | 
			
		||||
    refetchDeals: () => Promise<void>;
 | 
			
		||||
    refetchDeal: () => void;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const DealPageContext = createContext<DealPageContextState | undefined>(
 | 
			
		||||
@@ -22,18 +23,24 @@ const useDealPageContextState = (props: DealPageContextStateProps) => {
 | 
			
		||||
        undefined,
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    useEffect(() => {
 | 
			
		||||
        if (!defaultDealId)
 | 
			
		||||
            return;
 | 
			
		||||
        DealService.getDealById({ dealId: defaultDealId }).then(deal => {
 | 
			
		||||
            setSelectedDeal(deal);
 | 
			
		||||
    const refetchDeal = () => {
 | 
			
		||||
        const dealId = selectedDeal?.id ?? defaultDealId;
 | 
			
		||||
        if (!dealId) return;
 | 
			
		||||
 | 
			
		||||
        DealService.getDealById({ dealId }).then(deal => {
 | 
			
		||||
            setSelectedDeal(deal);
 | 
			
		||||
        });
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    useEffect(() => {
 | 
			
		||||
        refetchDeal();
 | 
			
		||||
    }, []);
 | 
			
		||||
 | 
			
		||||
    return {
 | 
			
		||||
        selectedDeal,
 | 
			
		||||
        setSelectedDeal,
 | 
			
		||||
        refetchDeals,
 | 
			
		||||
        refetchDeal,
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user