Compare commits

..
6 changed files with 31 additions and 42 deletions

No files matched your search

@@ -16,17 +16,18 @@ export default function HomeLayout() {
screenOptions={({ route }) => ({
...baseOptions,
title: tabStackScreenTitles[route.name] ?? "Home",
headerRight: route.name === "settings" ? undefined : () => <ProfileHeaderButton />,
headerRight:
route.name === "index" ? () => <ProfileHeaderButton /> : undefined,
unstable_headerRightItems:
route.name === "settings"
? undefined
: () => [
route.name === "index"
? () => [
{
type: "custom",
element: <ProfileHeaderButton />,
hidesSharedBackground: true,
},
],
]
: undefined,
})}
/>
)
@@ -16,17 +16,18 @@ export default function LibraryLayout() {
screenOptions={({ route }) => ({
...baseOptions,
title: tabStackScreenTitles[route.name] ?? "Library",
headerRight: route.name === "settings" ? undefined : () => <ProfileHeaderButton />,
headerRight:
route.name === "index" ? () => <ProfileHeaderButton /> : undefined,
unstable_headerRightItems:
route.name === "settings"
? undefined
: () => [
route.name === "index"
? () => [
{
type: "custom",
element: <ProfileHeaderButton />,
hidesSharedBackground: true,
},
],
]
: undefined,
})}
/>
)
@@ -16,17 +16,18 @@ export default function SearchLayout() {
screenOptions={({ route }) => ({
...baseOptions,
title: tabStackScreenTitles[route.name] ?? "Search",
headerRight: route.name === "settings" ? undefined : () => <ProfileHeaderButton />,
headerRight:
route.name === "index" ? () => <ProfileHeaderButton /> : undefined,
unstable_headerRightItems:
route.name === "settings"
? undefined
: () => [
route.name === "index"
? () => [
{
type: "custom",
element: <ProfileHeaderButton />,
hidesSharedBackground: true,
},
],
]
: undefined,
})}
/>
)
+4 -10
View File
@@ -1,13 +1,7 @@
import { fetchQuery } from "convex/nextjs"
import { connection } from "next/server"
"use client"
import { AuthForm } from "@/components/auth-form"
import { api } from "@otunes/convex/_generated/api"
export default async function SignInPage() {
await connection()
const { disableAccountCreation } = await fetchQuery(api.users.getAppSettings)
return (
<AuthForm flow="signIn" accountCreationDisabled={disableAccountCreation} />
)
export default function SignInPage() {
return <AuthForm flow="signIn" />
}
+4 -10
View File
@@ -1,13 +1,7 @@
import { fetchQuery } from "convex/nextjs"
import { connection } from "next/server"
"use client"
import { AuthForm } from "@/components/auth-form"
import { api } from "@otunes/convex/_generated/api"
export default async function SignUpPage() {
await connection()
const { disableAccountCreation } = await fetchQuery(api.users.getAppSettings)
return (
<AuthForm flow="signUp" accountCreationDisabled={disableAccountCreation} />
)
export default function SignUpPage() {
return <AuthForm flow="signUp" />
}
+5 -7
View File
@@ -4,8 +4,10 @@ import { useState } from "react"
import { useRouter } from "next/navigation"
import Link from "next/link"
import { useAuthActions } from "@convex-dev/auth/react"
import { useQuery } from "convex/react"
import { Button } from "@/components/ui/button"
import { api } from "@otunes/convex/_generated/api"
import {
Card,
CardContent,
@@ -48,19 +50,15 @@ const copy: Record<
},
}
export function AuthForm({
flow,
accountCreationDisabled,
}: {
flow: AuthFlow
accountCreationDisabled: boolean
}) {
export function AuthForm({ flow }: { flow: AuthFlow }) {
const { signIn } = useAuthActions()
const router = useRouter()
const appSettings = useQuery(api.users.getAppSettings)
const [error, setError] = useState<string | null>(null)
const [submitting, setSubmitting] = useState(false)
const text = copy[flow]
const accountCreationDisabled = appSettings?.disableAccountCreation ?? false
const signupsDisabled = flow === "signUp" && accountCreationDisabled
const hideSignUpLink = flow === "signIn" && accountCreationDisabled