update(front): front 폴더명 frontend로 변경
This commit is contained in:
1 parent
698d4e72d4
commit
16848e9f63
85 files changed
No files matched your search
@@ -0,0 +1,60 @@
|
||||
import { Button, Input } from '@/components'
|
||||
import { useLogin } from '@/features/auth/hooks/useLogin'
|
||||
|
||||
const inputClassName = 'h-12 rounded-md px-4 text-base'
|
||||
|
||||
export function LoginForm() {
|
||||
const {
|
||||
id,
|
||||
password,
|
||||
errorMessage,
|
||||
isLoading,
|
||||
onIdChange,
|
||||
onPasswordChange,
|
||||
onLogin,
|
||||
} = useLogin()
|
||||
|
||||
return (
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault()
|
||||
onLogin()
|
||||
}}
|
||||
className="flex w-full flex-col justify-center gap-6"
|
||||
>
|
||||
<div className="flex flex-col gap-3">
|
||||
<Input
|
||||
type="text"
|
||||
aria-label="아이디"
|
||||
placeholder="아이디를 입력해주세요."
|
||||
value={id}
|
||||
onChange={(e) => onIdChange(e.target.value)}
|
||||
autoComplete="username"
|
||||
className={inputClassName}
|
||||
/>
|
||||
<Input
|
||||
type="password"
|
||||
aria-label="비밀번호"
|
||||
placeholder="비밀번호를 입력해주세요."
|
||||
value={password}
|
||||
onChange={(e) => onPasswordChange(e.target.value)}
|
||||
autoComplete="current-password"
|
||||
className={inputClassName}
|
||||
/>
|
||||
<p
|
||||
className="text-sm tracking-[-0.28px] text-destructive"
|
||||
role="alert"
|
||||
aria-live="polite"
|
||||
>
|
||||
{errorMessage || ' '}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Button type="submit" size="lg" className="w-full" disabled={isLoading}>
|
||||
{isLoading ? '로그인 중…' : '로그인'}
|
||||
</Button>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
|
||||
export default LoginForm
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Button } from '@/components'
|
||||
|
||||
// 사이드바 하단: 공급사명 + 로그아웃
|
||||
export function SidebarFooter() {
|
||||
return (
|
||||
<div className="flex w-full h-[60px] py-3 px-8 gap-3 items-center">
|
||||
<div className="flex-1 flex items-center min-w-0 text-sm text-foreground">
|
||||
{/* TODO: 공급사명 (auth store 연동) */}
|
||||
<span className="truncate">-</span>
|
||||
</div>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
className="w-[61px] px-2 rounded-[4px] text-xs flex-shrink-0"
|
||||
// TODO: 로그아웃 mutation 연동
|
||||
>
|
||||
로그아웃
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router'
|
||||
import { useLoginMutation } from '@/features/auth/hooks/useLoginMutation'
|
||||
|
||||
export function useLogin() {
|
||||
const navigate = useNavigate()
|
||||
const loginMutation = useLoginMutation()
|
||||
const [id, setId] = useState('')
|
||||
const [password, setPassword] = useState('')
|
||||
const [errorMessage, setErrorMessage] = useState('')
|
||||
|
||||
const onIdChange = (value: string) => {
|
||||
setId(value)
|
||||
if (errorMessage) setErrorMessage('')
|
||||
}
|
||||
|
||||
const onPasswordChange = (value: string) => {
|
||||
setPassword(value)
|
||||
if (errorMessage) setErrorMessage('')
|
||||
}
|
||||
|
||||
const onLogin = () => {
|
||||
if (!id || !password) {
|
||||
setErrorMessage('아이디와 비밀번호를 입력해주세요.')
|
||||
return
|
||||
}
|
||||
|
||||
loginMutation.mutate(
|
||||
{ id, password },
|
||||
{
|
||||
onSuccess: () => {
|
||||
setErrorMessage('')
|
||||
navigate('/list')
|
||||
},
|
||||
onError: (error) => {
|
||||
setErrorMessage(
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: '아이디 또는 비밀번호가 올바르지 않습니다.',
|
||||
)
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
id,
|
||||
password,
|
||||
errorMessage,
|
||||
isLoading: loginMutation.isPending,
|
||||
onIdChange,
|
||||
onPasswordChange,
|
||||
onLogin,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
|
||||
export interface LoginParams {
|
||||
id: string
|
||||
password: string
|
||||
}
|
||||
|
||||
// 임시 stub (검증만 통과하면 성공). TODO: 로그인 API 연동
|
||||
export function useLoginMutation() {
|
||||
return useMutation<void, Error, LoginParams>({
|
||||
mutationFn: async () => {},
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export { LoginForm } from '@/features/auth/components/LoginForm'
|
||||
export { SidebarFooter } from '@/features/auth/components/SidebarFooter'
|
||||
Reference in new issue
Block a user