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
label={"Доска"}
{...form.getInputProps("board")}
onChange={board => {
form.setFieldValue("board", board ?? undefined);
form.setFieldValue("status", undefined);
}}
projectId={project?.id}
/>
<StatusSelect

View File

@ -64,6 +64,7 @@ const DealsTableFiltersModal = ({
{...filtersForm.getInputProps("status")}
boardId={filtersForm.values.board?.id}
clearable
clearOnBoardChange
/>
</>
)}

View File

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