(email: string)
| 28 | }; |
| 29 | |
| 30 | async function signInWithEmail(email: string) { |
| 31 | setIsLoading(true) |
| 32 | const redirectUrl = |
| 33 | redirect === "sharing" |
| 34 | ? window.location.href |
| 35 | : window.location.origin + redirect |
| 36 | |
| 37 | const { data, error } = await supabase.auth.signInWithOtp({ |
| 38 | email: email, |
| 39 | options: { |
| 40 | shouldCreateUser: true, |
| 41 | emailRedirectTo: redirectUrl, |
| 42 | }, |
| 43 | }) |
| 44 | setIsLoading(false) |
| 45 | setEmail("") |
| 46 | if (error) { |
| 47 | toast({ |
| 48 | title: "Failed to send magic link", |
| 49 | description: error.message, |
| 50 | }) |
| 51 | } else { |
| 52 | toast({ |
| 53 | title: "Magic link sent to " + email, |
| 54 | description: "Please click the link in your email to continue", |
| 55 | }) |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | return ( |
| 60 | <> |
no test coverage detected