fix: bug fix related to fetching dropdown options for the profile issue (#2246)

This commit is contained in:
Anmol Singh Bhatia 2023-09-25 12:18:35 +05:30 committed by GitHub
parent e8d303dd10
commit 68c8741f93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 45 additions and 21 deletions

View file

@ -25,6 +25,7 @@ import { getStatesList } from "helpers/state.helper";
type Props = {
value: IState;
onChange: (data: any, states: IState[] | undefined) => void;
projectId: string;
className?: string;
buttonClassName?: string;
optionsClassName?: string;
@ -35,6 +36,7 @@ type Props = {
export const StateSelect: React.FC<Props> = ({
value,
onChange,
projectId,
className = "",
buttonClassName = "",
optionsClassName = "",
@ -50,12 +52,12 @@ export const StateSelect: React.FC<Props> = ({
const [fetchStates, setFetchStates] = useState<boolean>(false);
const router = useRouter();
const { workspaceSlug, projectId } = router.query;
const { workspaceSlug } = router.query;
const { data: stateGroups } = useSWR(
workspaceSlug && projectId && fetchStates ? STATES_LIST(projectId as string) : null,
workspaceSlug && projectId && fetchStates ? STATES_LIST(projectId) : null,
workspaceSlug && projectId && fetchStates
? () => stateService.getStates(workspaceSlug as string, projectId as string)
? () => stateService.getStates(workspaceSlug as string, projectId)
: null
);