fix: fixed status select when deal form cleared
This commit is contained in:
@ -51,6 +51,10 @@ const GeneralTab: FC<Props> = ({ project, deal, dealsCrud, onClose }) => {
|
|||||||
<BoardSelect
|
<BoardSelect
|
||||||
label={"Доска"}
|
label={"Доска"}
|
||||||
{...form.getInputProps("board")}
|
{...form.getInputProps("board")}
|
||||||
|
onChange={board => {
|
||||||
|
form.setFieldValue("board", board ?? undefined);
|
||||||
|
form.setFieldValue("status", undefined);
|
||||||
|
}}
|
||||||
projectId={project?.id}
|
projectId={project?.id}
|
||||||
/>
|
/>
|
||||||
<StatusSelect
|
<StatusSelect
|
||||||
|
|||||||
@ -64,6 +64,7 @@ const DealsTableFiltersModal = ({
|
|||||||
{...filtersForm.getInputProps("status")}
|
{...filtersForm.getInputProps("status")}
|
||||||
boardId={filtersForm.values.board?.id}
|
boardId={filtersForm.values.board?.id}
|
||||||
clearable
|
clearable
|
||||||
|
clearOnBoardChange
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -5,22 +5,24 @@ import ObjectSelect, {
|
|||||||
ObjectSelectProps,
|
ObjectSelectProps,
|
||||||
} from "@/components/selects/ObjectSelect/ObjectSelect";
|
} from "@/components/selects/ObjectSelect/ObjectSelect";
|
||||||
import useStatusesList from "@/hooks/lists/useStatusesList";
|
import useStatusesList from "@/hooks/lists/useStatusesList";
|
||||||
import { BoardSchema } from "@/lib/client";
|
import { StatusSchema } from "@/lib/client";
|
||||||
|
|
||||||
type Props = Omit<
|
type Props = Omit<
|
||||||
ObjectSelectProps<BoardSchema | null>,
|
ObjectSelectProps<StatusSchema | null>,
|
||||||
"data" | "getLabelFn" | "getValueFn"
|
"data" | "getLabelFn" | "getValueFn"
|
||||||
> & {
|
> & {
|
||||||
boardId?: number;
|
boardId?: number;
|
||||||
|
clearOnBoardChange?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const StatusSelect: FC<Props> = ({ boardId, ...props }) => {
|
const StatusSelect: FC<Props> = ({ boardId, clearOnBoardChange, ...props }) => {
|
||||||
const [isInitial, setIsInitial] = useState<boolean>(true);
|
const [isInitial, setIsInitial] = useState<boolean>(true);
|
||||||
const onClear = () => props.onChange(null);
|
const onClear = () => props.onChange(null);
|
||||||
|
|
||||||
const { statuses } = useStatusesList({ boardId });
|
const { statuses } = useStatusesList({ boardId });
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!clearOnBoardChange) return;
|
||||||
if (isInitial) {
|
if (isInitial) {
|
||||||
setIsInitial(false);
|
setIsInitial(false);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user