fix: fixed status select when deal form cleared
This commit is contained in:
@ -5,22 +5,24 @@ import ObjectSelect, {
|
||||
ObjectSelectProps,
|
||||
} from "@/components/selects/ObjectSelect/ObjectSelect";
|
||||
import useStatusesList from "@/hooks/lists/useStatusesList";
|
||||
import { BoardSchema } from "@/lib/client";
|
||||
import { StatusSchema } from "@/lib/client";
|
||||
|
||||
type Props = Omit<
|
||||
ObjectSelectProps<BoardSchema | null>,
|
||||
ObjectSelectProps<StatusSchema | null>,
|
||||
"data" | "getLabelFn" | "getValueFn"
|
||||
> & {
|
||||
boardId?: number;
|
||||
clearOnBoardChange?: boolean;
|
||||
};
|
||||
|
||||
const StatusSelect: FC<Props> = ({ boardId, ...props }) => {
|
||||
const StatusSelect: FC<Props> = ({ boardId, clearOnBoardChange, ...props }) => {
|
||||
const [isInitial, setIsInitial] = useState<boolean>(true);
|
||||
const onClear = () => props.onChange(null);
|
||||
|
||||
const { statuses } = useStatusesList({ boardId });
|
||||
|
||||
useEffect(() => {
|
||||
if (!clearOnBoardChange) return;
|
||||
if (isInitial) {
|
||||
setIsInitial(false);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user