feat: projects and boards
This commit is contained in:
		
							
								
								
									
										40
									
								
								src/components/DealStatusSelect/DealStatusSelect.tsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/components/DealStatusSelect/DealStatusSelect.tsx
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
			
		||||
import ObjectSelect, { ObjectSelectProps } from "../ObjectSelect/ObjectSelect.tsx";
 | 
			
		||||
import { FC, useEffect, useState } from "react";
 | 
			
		||||
import { BoardSchema, StatusSchema } from "../../client";
 | 
			
		||||
 | 
			
		||||
type OtherProps = {
 | 
			
		||||
    board: BoardSchema | null;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type SelectProps = Omit<ObjectSelectProps<StatusSchema | null>, "data" | "getLabelFn" | "getValueFn">;
 | 
			
		||||
 | 
			
		||||
type Props = OtherProps & SelectProps;
 | 
			
		||||
 | 
			
		||||
const DealStatusSelect: FC<Props> = ({ board, ...props}) => {
 | 
			
		||||
    const [isInitial, setIsInitial] = useState<boolean>(true);
 | 
			
		||||
 | 
			
		||||
    const filteredData = board?.dealStatuses.filter(
 | 
			
		||||
        status => !status.isDeleted,
 | 
			
		||||
    ) ?? [];
 | 
			
		||||
 | 
			
		||||
    const onClear = () => props.onChange(null);
 | 
			
		||||
 | 
			
		||||
    useEffect(() => {
 | 
			
		||||
        if (isInitial) {
 | 
			
		||||
            setIsInitial(false);
 | 
			
		||||
        } else {
 | 
			
		||||
            onClear();
 | 
			
		||||
        }
 | 
			
		||||
    }, [board?.id]);
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
        <ObjectSelect
 | 
			
		||||
            data={filteredData}
 | 
			
		||||
            searchable
 | 
			
		||||
            placeholder={"Выберите статус"}
 | 
			
		||||
            onClear={onClear}
 | 
			
		||||
            {...props}
 | 
			
		||||
        />
 | 
			
		||||
    );
 | 
			
		||||
};
 | 
			
		||||
export default DealStatusSelect;
 | 
			
		||||
		Reference in New Issue
	
	Block a user