fix: dialog state
This commit is contained in:
parent
6119a4b965
commit
f09897e4b6
4 changed files with 24 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { useEffect, useState } from "react";
|
import { useState } from "react";
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
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 [newPassword, setNewPassword] = useState("");
|
||||||
const [newPasswordAgain, setNewPasswordAgain] = useState("");
|
const [newPasswordAgain, setNewPasswordAgain] = useState("");
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
// do nth
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleCloseBtnClick = () => {
|
const handleCloseBtnClick = () => {
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ function CreateIdentityProviderDialog({ open, onOpenChange, identityProvider, on
|
||||||
setOAuth2Scopes(oauth2Config.scopes.join(" "));
|
setOAuth2Scopes(oauth2Config.scopes.join(" "));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, []);
|
}, [identityProvider]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isCreating) {
|
if (!isCreating) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
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 requestState = useLoading(false);
|
||||||
const isCreating = !initialShortcut;
|
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<HTMLInputElement>) => {
|
const onShortcutTitleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
setShortcut({ ...shortcut, title: e.target.value });
|
setShortcut({ ...shortcut, title: e.target.value });
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
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 requestState = useLoading(false);
|
||||||
const isCreating = !initialUser;
|
const isCreating = !initialUser;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (initialUser) {
|
||||||
|
setUser(User.fromPartial(initialUser));
|
||||||
|
} else {
|
||||||
|
setUser(User.fromPartial({}));
|
||||||
|
}
|
||||||
|
}, [initialUser]);
|
||||||
|
|
||||||
const setPartialUser = (state: Partial<User>) => {
|
const setPartialUser = (state: Partial<User>) => {
|
||||||
setUser({
|
setUser({
|
||||||
...user,
|
...user,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue