Skip to content

Commit 7df652b

Browse files
authored
Merge pull request #177 from part3-4team-Taskify/feature/Gnb
[Fix, Refactor] Profile: 이미지 업로드 제한 용량 초과 시 에러 처리 / Input: Props 미전달 콘솔 에러 처리
2 parents 145e85e + 8f4eb36 commit 7df652b

File tree

5 files changed

+20
-13
lines changed

5 files changed

+20
-13
lines changed

src/components/card/ChangePassword.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function ChangePassword() {
1212
const [isSubmitting, setIsSubmitting] = useState(false);
1313

1414
const isPasswordMismatch =
15-
newPassword && checkNewpassword && newPassword !== checkNewpassword;
15+
!!checkNewpassword && checkNewpassword !== newPassword;
1616
const isDisabled =
1717
!password ||
1818
!newPassword ||
@@ -88,10 +88,15 @@ export default function ChangePassword() {
8888
placeholder="새 비밀번호 입력"
8989
value={checkNewpassword}
9090
onChange={(value) => setCheckNewPassword(value)}
91-
forceInvalid={!!checkNewpassword && checkNewpassword !== newPassword}
91+
forceInvalid={isPasswordMismatch}
9292
invalidMessage="비밀번호가 일치하지 않습니다."
9393
className="max-w-[624px]"
9494
/>
95+
{checkNewpassword && checkNewpassword !== newPassword && (
96+
<p className="font-14r block text-[var(--color-red)]">
97+
비밀번호가 일치하지 않습니다.
98+
</p>
99+
)}
95100

96101
<button
97102
className={`w-full h-[54px]
@@ -106,12 +111,6 @@ export default function ChangePassword() {
106111
>
107112
변경
108113
</button>
109-
110-
{checkNewpassword && checkNewpassword !== newPassword && (
111-
<p className="font-14r block text-[var(--color-red)]">
112-
비밀번호가 일치하지 않습니다.
113-
</p>
114-
)}
115114
</div>
116115
</div>
117116
);

src/components/card/Profile.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,16 @@ export default function ProfileCard() {
2626
const handleImageUpload = async (
2727
event: React.ChangeEvent<HTMLInputElement>
2828
) => {
29+
const MAX_IMAGE_SIZE = 3.5 * 1024 * 1024;
30+
2931
if (event.target.files && event.target.files[0]) {
3032
const file = event.target.files[0];
33+
34+
if (file.size > MAX_IMAGE_SIZE) {
35+
toast.error("3.5MB 이하의 이미지만 업로드할 수 있습니다.");
36+
return;
37+
}
38+
3139
setPreview(URL.createObjectURL(file)); // 미리보기
3240

3341
try {
@@ -42,6 +50,7 @@ export default function ProfileCard() {
4250
}
4351
}
4452
};
53+
4554
const handleSave = async () => {
4655
if (!nickname || !image) return;
4756

src/components/common/CustomToastContainer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ const CustomToastContainer = () => {
66
return (
77
<ToastContainer
88
position="top-center"
9-
autoClose={1500}
9+
autoClose={3000}
10+
newestOnTop
1011
closeButton={false}
1112
pauseOnHover={false}
12-
newestOnTop
13+
hideProgressBar={true}
1314
transition={Slide}
1415
/>
1516
);

src/components/input/Input.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default function Input(props: InputProps) {
3939
className,
4040
labelClassName,
4141
wrapperClassName,
42+
forceInvalid,
4243
...rest
4344
} = props as SignInputProps;
4445

src/pages/login.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { getUserInfo } from "@/api/users";
55
import { postAuthData } from "@/api/auth";
66
import Link from "next/link";
77
import Input from "@/components/input/Input";
8-
import { apiRoutes } from "@/api/apiRoutes";
98
import { toast } from "react-toastify";
109

1110
export default function LoginPage() {
@@ -28,8 +27,6 @@ export default function LoginPage() {
2827
const { email, password } = values;
2928

3029
try {
31-
// 배포 테스트
32-
console.log("로그인 요청 URL:", apiRoutes.login());
3330
const response = await postAuthData({ email, password });
3431
const token = response.accessToken;
3532
localStorage.setItem("accessToken", token);

0 commit comments

Comments
 (0)