fix: remove duplicate endpoints.ts, fix Login imports
- Remove web/src/api/endpoints.ts (redundant with index.ts) - Fix Login.tsx to use useLogin hook - Simplify Dockerfile (use CI-built artifacts)
This commit is contained in:
+7
-10
@@ -1,27 +1,24 @@
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import { login } from '@/api/endpoints'
|
||||
import { useLogin } from '@/api/hooks'
|
||||
import { Lock, User, AlertCircle } from 'lucide-react'
|
||||
|
||||
export default function Login() {
|
||||
const navigate = useNavigate()
|
||||
const loginMutation = useLogin()
|
||||
const [username, setUsername] = useState('')
|
||||
const [password, setPassword] = useState('')
|
||||
const [error, setError] = useState('')
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault()
|
||||
setError('')
|
||||
setLoading(true)
|
||||
|
||||
try {
|
||||
await login(username, password)
|
||||
await loginMutation.mutateAsync({ username, password })
|
||||
navigate({ to: '/' })
|
||||
} catch (err: any) {
|
||||
setError(err.message || 'Login failed')
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +127,7 @@ export default function Login() {
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
disabled={loading}
|
||||
disabled={loginMutation.isPending}
|
||||
style={{
|
||||
width: '100%',
|
||||
padding: 12,
|
||||
@@ -140,11 +137,11 @@ export default function Login() {
|
||||
color: 'white',
|
||||
fontSize: 14,
|
||||
fontWeight: 500,
|
||||
cursor: loading ? 'not-allowed' : 'pointer',
|
||||
opacity: loading ? 0.7 : 1,
|
||||
cursor: loginMutation.isPending ? 'not-allowed' : 'pointer',
|
||||
opacity: loginMutation.isPending ? 0.7 : 1,
|
||||
}}
|
||||
>
|
||||
{loading ? 'Signing in...' : 'Sign In'}
|
||||
{loginMutation.isPending ? 'Signing in...' : 'Sign In'}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user