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
|
||||
label={"Доска"}
|
||||
{...form.getInputProps("board")}
|
||||
onChange={board => {
|
||||
form.setFieldValue("board", board ?? undefined);
|
||||
form.setFieldValue("status", undefined);
|
||||
}}
|
||||
projectId={project?.id}
|
||||
/>
|
||||
<StatusSelect
|
||||
|
||||
@ -64,6 +64,7 @@ const DealsTableFiltersModal = ({
|
||||
{...filtersForm.getInputProps("status")}
|
||||
boardId={filtersForm.values.board?.id}
|
||||
clearable
|
||||
clearOnBoardChange
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
@ -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