Skip to content

Commit fa18810

Browse files
committed
fix: handles register loading
1 parent 1041858 commit fa18810

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/components/common/RoundButton.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ const RoundButtonBlock = styled.button<RoundButtonBlockProps>`
7878
box-shadow: 0px 2px 12px #00000030;
7979
}
8080
cursor: pointer;
81+
&:disabled {
82+
background: ${themedPalette.bg_element2};
83+
}
8184
`;
8285

8386
type ButtonProps = React.DetailedHTMLProps<

src/components/register/RegisterForm.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ export interface RegisterFormProps {
3535
displayName: string;
3636
username: string;
3737
} | null;
38+
loading: boolean;
3839
}
3940

4041
const RegisterForm: React.FC<RegisterFormProps> = ({
4142
onSubmit,
4243
fixedEmail,
4344
error,
4445
defaultInfo,
46+
loading,
4547
}) => {
4648
const [form, onChange] = useInputs({
4749
displayName: defaultInfo ? defaultInfo.displayName : '',
@@ -99,6 +101,7 @@ const RegisterForm: React.FC<RegisterFormProps> = ({
99101
onSubmit({ ...form, email: fixedEmail || form.email })
100102
}
101103
size="LARGE"
104+
disabled={loading}
102105
>
103106
다음
104107
</RoundButton>

src/containers/register/RegisterFormContainer.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const RegisterFormContainer: React.FC<RegisterFormContainerProps> = ({
2828
ignoreQueryPrefix: true,
2929
});
3030
const client = useApolloClient();
31+
const [loading, setLoading] = useState(false);
3132

3233
const [error, setError] = useState<null | string>(null);
3334
const [socialProfile, setSocialProfile] = useState<SocialProfile | null>(
@@ -97,6 +98,7 @@ const RegisterFormContainer: React.FC<RegisterFormContainerProps> = ({
9798
}
9899

99100
try {
101+
setLoading(true);
100102
if (query.code) {
101103
// local email register
102104
const formWithoutEmail = { ...form } as Partial<RegisterFormType>;
@@ -114,6 +116,7 @@ const RegisterFormContainer: React.FC<RegisterFormContainerProps> = ({
114116
});
115117
}
116118
} catch (e) {
119+
setLoading(false);
117120
if ((e as any).response.status === 409) {
118121
setError('이미 존재하는 아이디입니다.');
119122
return;
@@ -139,6 +142,7 @@ const RegisterFormContainer: React.FC<RegisterFormContainerProps> = ({
139142

140143
return (
141144
<RegisterForm
145+
loading={loading}
142146
onSubmit={onSubmit}
143147
fixedEmail={
144148
(registerToken && registerToken.email) ||

0 commit comments

Comments
 (0)