Skip to content

Commit a290f83

Browse files
committed
fix: 사용자 이름 변경 최소 길이 제한 3글자로 수정
1 parent fedd86e commit a290f83

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

components/pages/mypage/user/username-card.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import LoadingIcon from "@icons/loading-icon";
1313
import { useRouter } from "next/navigation";
1414
import { useState } from "react";
1515

16+
const MIN_USERNAME_LENGTH = 3;
17+
1618
interface UsernameCardProps {
1719
user: User;
1820
}
@@ -35,6 +37,12 @@ const UsernameCard = ({ user }: UsernameCardProps) => {
3537
setLoading(false);
3638
return;
3739
}
40+
41+
if (username.value.length < MIN_USERNAME_LENGTH) {
42+
setEditError("사용자 이름은 최소 3자 이상이어야 합니다.");
43+
setLoading(false);
44+
return;
45+
}
3846
const response = await updateUserName(username.value);
3947

4048
if (!response.ok) {
@@ -80,7 +88,7 @@ const UsernameCard = ({ user }: UsernameCardProps) => {
8088
<Button
8189
onClick={changeUsername}
8290
className="text-sm w-14 h-8 p-0 flex items-center justify-center"
83-
disabled={username.value.length < 2 || loading}
91+
disabled={loading}
8492
>
8593
{loading ? (
8694
<LoadingIcon size="sm" className="text-white m-0" />

0 commit comments

Comments
 (0)