fix: fixed status select when deal form cleared

This commit is contained in:
2025-09-02 19:48:22 +04:00
parent dca7d5f6a5
commit 492b7ac32e
3 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -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
/> />
</> </>
)} )}

View File

@ -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 {