Skip to content

Commit b075942

Browse files
committed
fix: disable form when loading
todo: make a spinner with button. How did I not make that in the past????
1 parent 7b8e93b commit b075942

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/components/setting/SettingEmailRow.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function SettingEmailRow({
2222
}: SettingEmailRowProps) {
2323
const [edit, setEdit] = useState(false);
2424
const [value, onChange] = useInput(email ?? '');
25+
const [isLoading, setIsLoading] = useState(false);
2526

2627
const onSubmit = async (e: React.FormEvent) => {
2728
e.preventDefault();
@@ -36,6 +37,7 @@ function SettingEmailRow({
3637
return;
3738
}
3839

40+
setIsLoading(true);
3941
const response = await client.query<{ emailExists: boolean }>({
4042
query: EMAIL_EXISTS,
4143
fetchPolicy: 'network-only',
@@ -44,11 +46,13 @@ function SettingEmailRow({
4446

4547
if (response.data.emailExists) {
4648
toast.error('동일한 이메일이 존재합니다.');
49+
setIsLoading(false);
4750
return;
4851
}
4952

5053
await onChangeEmail(value);
5154
setEdit(false);
55+
setIsLoading(false);
5256
};
5357

5458
return (
@@ -66,8 +70,9 @@ function SettingEmailRow({
6670
value={value}
6771
onChange={onChange}
6872
placeholder="이메일"
73+
disabled={isLoading}
6974
/>
70-
<Button>변경</Button>
75+
<Button disabled={isLoading}>변경</Button>
7176
</Form>
7277
) : isEmailSent ? (
7378
<SettingEmailSuccess />

0 commit comments

Comments
 (0)