@@ -8,29 +8,23 @@ import {
8
8
FormMessage ,
9
9
} from "@follow/components/ui/form/index.js"
10
10
import { Input } from "@follow/components/ui/input/Input.js"
11
+ import type { LoginRuntime } from "@follow/shared/auth"
11
12
import { loginHandler , signUp } from "@follow/shared/auth"
13
+ import { env } from "@follow/shared/env"
12
14
import { zodResolver } from "@hookform/resolvers/zod"
13
15
import { useForm } from "react-hook-form"
14
16
import { useTranslation } from "react-i18next"
15
- import { Link } from "react-router"
16
17
import { toast } from "sonner"
17
18
import { z } from "zod"
18
19
19
20
import { useCurrentModal , useModalStack } from "~/components/ui/modal/stacked/hooks"
20
21
21
- async function onSubmit ( values : z . infer < typeof formSchema > ) {
22
- const res = await loginHandler ( "credential" , "browser" , values )
23
- if ( res ?. error ) {
24
- toast . error ( res . error . message )
25
- return
26
- }
27
- window . location . reload ( )
28
- }
29
22
const formSchema = z . object ( {
30
23
email : z . string ( ) . email ( ) ,
31
24
password : z . string ( ) . max ( 128 ) ,
32
25
} )
33
- export function LoginWithPassword ( ) {
26
+
27
+ export function LoginWithPassword ( { runtime } : { runtime ?: LoginRuntime } ) {
34
28
const { t } = useTranslation ( "app" )
35
29
const form = useForm < z . infer < typeof formSchema > > ( {
36
30
resolver : zodResolver ( formSchema ) ,
@@ -44,6 +38,15 @@ export function LoginWithPassword() {
44
38
const { present } = useModalStack ( )
45
39
const { dismiss } = useCurrentModal ( )
46
40
41
+ async function onSubmit ( values : z . infer < typeof formSchema > ) {
42
+ const res = await loginHandler ( "credential" , runtime ?? "browser" , values )
43
+ if ( res ?. error ) {
44
+ toast . error ( res . error . message )
45
+ return
46
+ }
47
+ window . location . reload ( )
48
+ }
49
+
47
50
return (
48
51
< Form { ...form } >
49
52
< form onSubmit = { form . handleSubmit ( onSubmit ) } className = "space-y-4" >
@@ -73,9 +76,14 @@ export function LoginWithPassword() {
73
76
</ FormItem >
74
77
) }
75
78
/>
76
- < Link to = "/forget-password" className = "block py-1 text-xs text-accent hover:underline" >
79
+ < a
80
+ href = { `${ env . VITE_WEB_URL } /forget-password` }
81
+ target = "_blank"
82
+ rel = "noreferrer"
83
+ className = "block py-1 text-xs text-accent hover:underline"
84
+ >
77
85
{ t ( "login.forget_password.note" ) }
78
- </ Link >
86
+ </ a >
79
87
< Button
80
88
type = "submit"
81
89
className = "w-full"
0 commit comments