diff --git a/web/src/components/ChangeMemberPasswordDialog.tsx b/web/src/components/ChangeMemberPasswordDialog.tsx index 1fd43b6e3..696da195b 100644 --- a/web/src/components/ChangeMemberPasswordDialog.tsx +++ b/web/src/components/ChangeMemberPasswordDialog.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react"; +import { useState } from "react"; import { toast } from "react-hot-toast"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog"; @@ -20,10 +20,6 @@ function ChangeMemberPasswordDialog({ open, onOpenChange, user, onSuccess }: Pro const [newPassword, setNewPassword] = useState(""); const [newPasswordAgain, setNewPasswordAgain] = useState(""); - useEffect(() => { - // do nth - }, []); - const handleCloseBtnClick = () => { onOpenChange(false); }; diff --git a/web/src/components/CreateIdentityProviderDialog.tsx b/web/src/components/CreateIdentityProviderDialog.tsx index a50d0cc85..776bb30ce 100644 --- a/web/src/components/CreateIdentityProviderDialog.tsx +++ b/web/src/components/CreateIdentityProviderDialog.tsx @@ -142,7 +142,7 @@ function CreateIdentityProviderDialog({ open, onOpenChange, identityProvider, on setOAuth2Scopes(oauth2Config.scopes.join(" ")); } } - }, []); + }, [identityProvider]); useEffect(() => { if (!isCreating) { diff --git a/web/src/components/CreateShortcutDialog.tsx b/web/src/components/CreateShortcutDialog.tsx index da2127b82..dd0383536 100644 --- a/web/src/components/CreateShortcutDialog.tsx +++ b/web/src/components/CreateShortcutDialog.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { toast } from "react-hot-toast"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog"; @@ -30,6 +30,18 @@ function CreateShortcutDialog({ open, onOpenChange, shortcut: initialShortcut, o const requestState = useLoading(false); const isCreating = !initialShortcut; + useEffect(() => { + if (initialShortcut) { + setShortcut({ + name: initialShortcut.name, + title: initialShortcut.title, + filter: initialShortcut.filter, + }); + } else { + setShortcut({ name: "", title: "", filter: "" }); + } + }, [initialShortcut]); + const onShortcutTitleChange = (e: React.ChangeEvent) => { setShortcut({ ...shortcut, title: e.target.value }); }; diff --git a/web/src/components/CreateUserDialog.tsx b/web/src/components/CreateUserDialog.tsx index e1d9c8329..b99cdf5c9 100644 --- a/web/src/components/CreateUserDialog.tsx +++ b/web/src/components/CreateUserDialog.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import { toast } from "react-hot-toast"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog"; @@ -23,6 +23,14 @@ function CreateUserDialog({ open, onOpenChange, user: initialUser, onSuccess }: const requestState = useLoading(false); const isCreating = !initialUser; + useEffect(() => { + if (initialUser) { + setUser(User.fromPartial(initialUser)); + } else { + setUser(User.fromPartial({})); + } + }, [initialUser]); + const setPartialUser = (state: Partial) => { setUser({ ...user,