Skip to content

Commit

Permalink
generate theme without login
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoLuglio committed Oct 13, 2024
1 parent d7fecff commit 0150e88
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/(private)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default async function PrivateLayout({
}: {
children: React.ReactNode
}) {
auth().protect()
// auth().protect()

return <section>{children}</section>
}
2 changes: 2 additions & 0 deletions src/app/(private)/saved-themes/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export default async function SavedThemesPage() {
const { userId } = auth()
const themes = userId ? await getThemesByUserId(userId) : []

auth().protect()

return (
<main className="mx-auto p-20">
{themes.length === 0 ? (
Expand Down
2 changes: 1 addition & 1 deletion src/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const Navigation = () => {
</Link>
<div className="flex gap-4 items-center ">
<Link href="/discover">Discover</Link>
<Link href="/generator">Create</Link>
<SignedIn>
<Link href="/generator">Create</Link>
<Link href="/saved-themes">Your Themes</Link>
<UserButton />
</SignedIn>
Expand Down
2 changes: 2 additions & 0 deletions src/components/ThemeLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export const ThemeLoader: React.FC<ThemeLoaderProps> = ({
}
}, [currentThemeId, handleLoad])

if (savedThemes.length === 0) return null

return (
<div className="flex gap-4">
<div className="flex-1">
Expand Down
7 changes: 5 additions & 2 deletions src/components/ThemeSaver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ const ThemeSaver: React.FC<ThemeSaverProps> = ({
}

const handleSave = () => {
if (!user) return

if (!user) {
alert('You must be logged in to save and/or download created themes.')
return
}
startTransition(async () => {
if (currentThemeId) {
// Handle update case
Expand Down Expand Up @@ -147,6 +149,7 @@ const ThemeSaver: React.FC<ThemeSaverProps> = ({
checked={isPublic}
onCheckedChange={(checked) => handlePublicToggle(checked)}
id="public-switch"
disabled={!user}
/>
<label htmlFor="public-switch">Make theme public</label>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server'

// Define routes that should be protected
const isProtectedRoute = createRouteMatcher([
'/generator(.*)',
// '/generator(.*)',
'/saved-themes(.*)',
]) // Protect generator and its subroutes

Expand Down

0 comments on commit 0150e88

Please sign in to comment.