diff --git a/app/(auth)/_widgets/.gitkeep b/app/(auth)/_widgets/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
diff --git a/app/(auth)/signin/page.json b/app/(auth)/signin/page.json
index 0de4a55fd..c34ade41f 100644
--- a/app/(auth)/signin/page.json
+++ b/app/(auth)/signin/page.json
@@ -1,8 +1,8 @@
[
{
- "id": "이메일", "type": "email", "pattern": "[^@\\s]+@[^@\\s]+\\.[^@\\s]+", "required": true, "placeholder": "이메일을 입력해주세요", "autocomplete": "email"
+ "id": "email", "label": "이메일", "type": "email", "pattern": "[^@\\s]+@[^@\\s]+\\.[^@\\s]+", "required": true, "placeholder": "이메일을 입력해주세요", "autocomplete": "email"
},
{
- "id": "비밀번호", "type": "password", "minlength": 8, "maxlength": 16, "required": true, "placeholder": "비밀번호를 입력해주세요", "autocomplete": "password"
+ "id": "password", "label": "비밀번호", "type": "password", "minlength": 8, "maxlength": 16, "required": true, "placeholder": "비밀번호를 입력해주세요", "autocomplete": "password"
}
]
diff --git a/app/(auth)/signin/page.tsx b/app/(auth)/signin/page.tsx
index 2c91abf42..623d40903 100644
--- a/app/(auth)/signin/page.tsx
+++ b/app/(auth)/signin/page.tsx
@@ -1,5 +1,7 @@
"use client";
+import API from "@/app/_api";
+
import json from "./page.json";
import Link from "next/link";
@@ -9,15 +11,27 @@ import useForm, { Cause, Trigger } from "@/app/_hooks/useForm";
export default function Page()
{
- const { errors, verify, disabled } = useForm("signin",
- // onSubmit
- (data) =>
+ const signin = useForm("signin", [Trigger.BLUR, Trigger.CHANGE], (data) =>
{
- console.log(data);
- },
- // onCheck
- (input, values, causes) =>
+ API["auth/signIn"].POST(
+ {
+ email: data.get("이메일") as string,
+ password: data.get("비밀번호") as string,
+ })
+ .then((response) =>
+ {
+ document.cookie = response.accessToken;
+ })
+ .catch((error) =>
+ {
+ console.error(error);
+ });
+ });
+
+ signin.verify(({ input, trigger }) =>
{
+ const causes = signin.causes(input);
+
if (causes.has(Cause.REQUIRED))
{
return `${input.name}을(를) 입력해주세요`;
@@ -35,9 +49,7 @@ export default function Page()
return `${input.name}을(를) ${input.maxLength}자 이하 입력해주세요`;
}
return null;
- },
- // triggers
- [Trigger.BLUR, Trigger.INPUT]);
+ });
return (
<>
@@ -49,11 +61,11 @@ export default function Page()
-
+
{
args.type === "password" &&
{
@@ -78,12 +90,12 @@ export default function Page()
}
{
- errors[args.id] &&
{errors[args.id]}
+ signin.errors[args.label] &&
{signin.errors[args.label]}
}
))}
-