11'use client'
22
3+ import { useRouter } from 'next/navigation'
4+
35import React from 'react'
46import { SubmitHandler , useForm } from 'react-hook-form'
5- import { SignInRequest , SignInResponse } from '@/types/auth.types'
6- import { useRouter } from 'next/navigation'
77
8+ import { SignInRequest , SignInResponse } from '@/types/auth.types'
89
910export default function LoginPage ( ) : JSX . Element {
1011 const {
@@ -13,30 +14,29 @@ export default function LoginPage(): JSX.Element {
1314 formState : { errors } ,
1415 } = useForm < SignInRequest > ( )
1516
16-
17- const onSubmit : SubmitHandler < SignInRequest > = async ( data ) => {
17+ const onSubmit : SubmitHandler < SignInRequest > = async data => {
1818 try {
19- const response = await fetch ( `/api/auth/sign-in` , {
20- method : 'POST' ,
21- headers : { 'Content-Type' : 'application/json' } ,
22- body : JSON . stringify ( data ) ,
23- } )
19+ const response = await fetch ( `/api/auth/sign-in` , {
20+ method : 'POST' ,
21+ headers : { 'Content-Type' : 'application/json' } ,
22+ body : JSON . stringify ( data ) ,
23+ } )
2424
25- if ( ! response . ok ) {
26- console . error ( 'Login failed' )
27- alert ( '로그인 실패 프록시 전달' )
28- return
29- }
25+ if ( ! response . ok ) {
26+ console . error ( 'Login failed' )
27+ alert ( '로그인 실패 프록시 전달' )
28+ return
29+ }
3030
31- const result = await response . json ( )
32- console . log ( 'Login successful:' , result )
33- alert ( '로그인 성공' )
34- } catch ( error ) {
35- console . error ( 'Login error' , error )
36- alert ( '로그인 요청 중 오류 발생' )
37- }
31+ const result = await response . json ( )
32+ console . log ( 'Login successful:' , result )
33+ alert ( '로그인 성공' )
34+ } catch ( error ) {
35+ console . error ( 'Login error' , error )
36+ alert ( '로그인 요청 중 오류 발생' )
37+ }
3838 }
39-
39+
4040 return (
4141 < div >
4242 < h1 > 로그인</ h1 >
0 commit comments