Issues_Aug_2W #371
@ -1,5 +1,5 @@
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import React, { useState,useCallback } from "react";
|
||||
import React, { useState, useCallback, useEffect } from "react";
|
||||
import { FormProvider, useForm, useFormContext } from "react-hook-form";
|
||||
import { defaultFilterValues, filterSchema } from "./TenantSchema";
|
||||
import Label from "../common/Label";
|
||||
@ -8,9 +8,10 @@ import { useIndustries } from "../../hooks/useTenant";
|
||||
import { reference, TENANT_STATUS } from "../../utils/constants";
|
||||
import { DateRangePicker1 } from "../common/DateRangePicker";
|
||||
import moment from "moment";
|
||||
import { useLocation } from "react-router-dom";
|
||||
|
||||
const TenantFilterPanel = ({onApply}) => {
|
||||
const [resetKey, setResetKey] = useState(0);
|
||||
const TenantFilterPanel = ({ onApply }) => {
|
||||
const [resetKey, setResetKey] = useState(0);
|
||||
|
||||
const methods = useForm({
|
||||
resolver: zodResolver(filterSchema),
|
||||
@ -36,6 +37,13 @@ const [resetKey, setResetKey] = useState(0);
|
||||
[onApply, handleClosePanel]
|
||||
);
|
||||
|
||||
|
||||
// ✅ Close popup when navigating to another component
|
||||
const location = useLocation();
|
||||
useEffect(() => {
|
||||
handleClosePanel();
|
||||
}, [location]);
|
||||
|
||||
const onClear = useCallback(() => {
|
||||
reset(defaultFilterValues);
|
||||
setResetKey((prev) => prev + 1); // triggers DateRangePicker reset
|
||||
|
Loading…
x
Reference in New Issue
Block a user