+
diff --git a/src/services/userService.ts b/src/services/userService.ts
index a550c0b8..9f4c5c50 100644
--- a/src/services/userService.ts
+++ b/src/services/userService.ts
@@ -1,4 +1,4 @@
-import { UNAUTHORIZED } from "@/utils/errorStatus";
+import { BAD_REQUEST } from "@/utils/errorStatus";
import { api } from "./api";
type Role = "DREAMER" | "MAKER";
@@ -135,8 +135,8 @@ const userService = {
try {
await api.patch("/users/update", payload);
} catch (error: any) {
- if (error.response && error.response.status === UNAUTHORIZED) {
- throw new Error("기존 비밀번호와 일치하지 않습니다.");
+ if (error.response && error.response.status === BAD_REQUEST) {
+ throw new Error(error.response.data.message || "알 수 없는 오류가 발생했습니다.");
}
}
},
@@ -191,8 +191,10 @@ const userService = {
try {
const response = await api.get(`/users/profile/${makerId}`);
return response;
- } catch (error) {
- console.error("메이커 프로필 조회 실패", error);
+ } catch (error: any) {
+ if (error.response && error.response.status === BAD_REQUEST) {
+ throw new Error("존재하지 않은 사이트입니다!");
+ }
}
},
diff --git a/src/utils/validate.ts b/src/utils/validate.ts
index 18bd6b37..cedc6410 100644
--- a/src/utils/validate.ts
+++ b/src/utils/validate.ts
@@ -99,12 +99,28 @@ export const editMakerSchema = z
export type EditMakerData = z.infer;
-export const signUpOAuthSchema = z.object({
- nickName: z.string().min(1, { message: "닉네임을 입력해 주세요." }),
- phoneNumber: z
- .string()
- .regex(/^010\d{8}$/, { message: "010으로 시작하고 숫자만 입력해 주세요." }),
- role: z.enum(["MAKER", "DREAMER"], { message: "역할을 선택해 주세요." }),
-});
+export const signUpOAuthSchema = z
+ .object({
+ nickName: z.string().min(1, { message: "닉네임을 입력해 주세요." }),
+ phoneNumber: z
+ .string()
+ .regex(/^010\d{8}$/, { message: "010으로 시작하고 숫자만 입력해 주세요." }),
+ role: z.enum(["MAKER", "DREAMER"], { message: "역할을 선택해 주세요." }),
+ password: z.string().optional(),
+ newPassword: z.string().optional(),
+ newConfirmPassword: z.string().optional(),
+ })
+ .refine((data) => !data.newPassword || data.password, {
+ path: ["password"],
+ message: "새 비밀번호를 설정하려면 현재 비밀번호를 입력해 주세요.",
+ })
+ .refine((data) => !data.newPassword || data.newPassword.length >= 6, {
+ path: ["newPassword"],
+ message: "새 비밀번호는 최소 6자 이상이어야 합니다.",
+ })
+ .refine((data) => !data.newPassword || data.newPassword === data.newConfirmPassword, {
+ path: ["newConfirmPassword"],
+ message: "새 비밀번호가 일치하지 않습니다.",
+ });
export type SignUpOAuthData = z.infer;