Skip to content

Commit a8e1a89

Browse files
Brandon ChenBrandon Chen
authored andcommitted
fix: show sign in button if user is not signed in
1 parent 0856633 commit a8e1a89

File tree

5 files changed

+36
-33
lines changed

5 files changed

+36
-33
lines changed

web/src/app/login/page.tsx

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
'use client'
22

33
import { BackgroundBeams } from '@/components/ui/background-beams'
4-
import { SignInButton } from '@/components/navbar/sign-in-button'
54
import { useSearchParams } from 'next/navigation'
65
import {
76
Card,
87
CardHeader,
98
CardTitle,
109
CardDescription,
11-
CardFooter,
1210
} from '@/components/ui/card'
1311
import CardWithBeams from '@/components/card-with-beams'
12+
import { SignInCardFooter } from '@/components/sign-in/sign-in-card-footer'
1413

1514
const Home = () => {
1615
const searchParams = useSearchParams()
@@ -55,16 +54,7 @@ const Home = () => {
5554
averted, phew!)
5655
</CardDescription>
5756
</CardHeader>
58-
<CardFooter className="flex flex-col space-y-2">
59-
<SignInButton
60-
providerDomain="github.com"
61-
providerName="github"
62-
/>
63-
{/* <SignInButton
64-
providerDomain="google.com"
65-
providerName="google"
66-
/> */}
67-
</CardFooter>
57+
<SignInCardFooter />
6858
</Card>
6959
) : (
7060
<Card>
@@ -74,16 +64,7 @@ const Home = () => {
7464
Increased rate limits, priority support, and more!
7565
</CardDescription>
7666
</CardHeader>
77-
<CardFooter className="flex flex-col space-y-2">
78-
<SignInButton
79-
providerDomain="github.com"
80-
providerName="github"
81-
/>
82-
{/* <SignInButton
83-
providerDomain="google.com"
84-
providerName="google"
85-
/> */}
86-
</CardFooter>
67+
<SignInCardFooter />
8768
</Card>
8869
)}
8970
</div>

web/src/app/referrals/page.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import { useSession } from 'next-auth/react'
44
import { useQuery } from '@tanstack/react-query'
55
import { Button } from '@/components/ui/button'
66
import { Input } from '@/components/ui/input'
7-
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
7+
import {
8+
Card,
9+
CardContent,
10+
CardDescription,
11+
CardHeader,
12+
CardTitle,
13+
} from '@/components/ui/card'
814
import { toast } from '@/components/ui/use-toast'
915
import { ReferralData } from '@/app/api/referrals/route'
1016
import { Skeleton } from '@/components/ui/skeleton'
@@ -15,6 +21,7 @@ import { Separator } from '@/components/ui/separator'
1521
import Link from 'next/link'
1622
import { CREDITS_REFERRAL_BONUS } from 'common/constants'
1723
import { getReferralLink } from 'common/util/referral'
24+
import { SignInCardFooter } from '@/components/sign-in/sign-in-card-footer'
1825

1926
const copyReferral = (link: string) => {
2027
navigator.clipboard.writeText(link)
@@ -64,8 +71,10 @@ const ReferralsPage = () => {
6471
<Card className="mb-6">
6572
<CardHeader>
6673
<CardTitle>You&apos;re not logged in.</CardTitle>
74+
<CardDescription>No code for you!</CardDescription>
6775
</CardHeader>
68-
<CardContent>No referral code for you!</CardContent>
76+
<CardContent>Log in here to get a referral code</CardContent>
77+
<SignInCardFooter />
6978
</Card>
7079
)
7180
}

web/src/components/navbar/navbar.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ export const Navbar = async () => {
2020
<Link href="/pricing" className="hover:text-blue-400 transition-colors">
2121
Pricing
2222
</Link>
23-
{session && (
24-
<Link href="/referrals" className="hover:text-blue-400 transition-colors">
25-
Referrals
26-
</Link>
27-
)}
23+
<Link
24+
href="/referrals"
25+
className="hover:text-blue-400 transition-colors"
26+
>
27+
Referrals
28+
</Link>
2829
</nav>
2930
<div className="flex items-center space-x-4">
3031
{session ? (

web/src/components/navbar/sign-in-button.tsx renamed to web/src/components/sign-in/sign-in-button.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
'use client'
22

3-
import { useState, useTransition } from 'react'
3+
import { useTransition } from 'react'
44
import { signIn } from 'next-auth/react'
55

66
import { Icons } from '@/components/icons'
77
import { Button } from '@/components/ui/button'
88
import { OAuthProviderType } from 'next-auth/providers/oauth-types'
99
import { sleep } from 'common/util/helpers'
1010
import { toast } from '../ui/use-toast'
11-
import Image from 'next/image'
1211

1312
export const SignInButton = ({
1413
providerName,
@@ -38,10 +37,9 @@ export const SignInButton = ({
3837
className="flex items-center gap-2"
3938
>
4039
{isPending && <Icons.loader className="mr-2 size-4 animate-spin" />}
41-
<Image
40+
<img
4241
src={`https://s2.googleusercontent.com/s2/favicons?domain=${providerDomain}`}
4342
className="rounded-full"
44-
alt={providerName + ' logo'}
4543
/>
4644
Continue with{' '}
4745
{providerName.charAt(0).toUpperCase() + providerName.slice(1)}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { SignInButton } from './sign-in-button'
2+
import { CardFooter } from '../ui/card'
3+
4+
export const SignInCardFooter = () => {
5+
return (
6+
<CardFooter className="flex flex-col space-y-2">
7+
<SignInButton providerDomain="github.com" providerName="github" />
8+
{/* <SignInButton
9+
providerDomain="google.com"
10+
providerName="google"
11+
/> */}
12+
</CardFooter>
13+
)
14+
}

0 commit comments

Comments
 (0)