mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 09:49:28 +08:00
only show GitHub button / dialog during onboarding
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog'
|
||||
import { useState } from 'react'
|
||||
import { useCallback, useState } from 'react'
|
||||
import { AuthMethodsList, OAuth2AuthConfig } from 'pocketbase'
|
||||
import { Link } from '../router'
|
||||
|
||||
@@ -67,7 +67,8 @@ export function UserAuthForm({
|
||||
const [isOauthLoading, setIsOauthLoading] = useState<boolean>(false)
|
||||
const [errors, setErrors] = useState<Record<string, string | undefined>>({})
|
||||
|
||||
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
|
||||
const handleSubmit = useCallback(
|
||||
async (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault()
|
||||
setIsLoading(true)
|
||||
try {
|
||||
@@ -117,7 +118,9 @@ export function UserAuthForm({
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
}
|
||||
}
|
||||
},
|
||||
[isFirstRun]
|
||||
)
|
||||
|
||||
if (!authMethods) {
|
||||
return null
|
||||
@@ -225,6 +228,8 @@ export function UserAuthForm({
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
{(isFirstRun || authMethods.authProviders.length > 0) && (
|
||||
// only show 'continue with' during onboarding or if we have auth providers
|
||||
<div className="relative">
|
||||
<div className="absolute inset-0 flex items-center">
|
||||
<span className="w-full border-t" />
|
||||
@@ -233,6 +238,7 @@ export function UserAuthForm({
|
||||
<span className="bg-background px-2 text-muted-foreground">Or continue with</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -297,7 +303,8 @@ export function UserAuthForm({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!authMethods.authProviders.length && (
|
||||
{!authMethods.authProviders.length && isFirstRun && (
|
||||
// only show GitHub button / dialog during onboarding
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<button type="button" className={cn(buttonVariants({ variant: 'outline' }))}>
|
||||
|
Reference in New Issue
Block a user