Skip to content

Commit 0aa2cd5

Browse files
fix: don't redirect to lichess when not logged in
1 parent 0a55add commit 0aa2cd5

File tree

3 files changed

+55
-90
lines changed

3 files changed

+55
-90
lines changed

src/components/Common/Header.tsx

Lines changed: 45 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -103,45 +103,35 @@ export const Header: React.FC = () => {
103103
<h2 className="text-2xl font-bold">Maia Chess</h2>
104104
</Link>
105105
<div className="hidden flex-row gap-1 *:px-2 *:py-1 md:flex">
106-
{user?.lichessId ? (
107-
<div
108-
className={`${router.pathname.startsWith('/play') && 'bg-background-1'} group relative`}
109-
>
110-
<button className="uppercase">Play</button>
111-
<div className="absolute left-0 top-[100%] z-30 hidden w-48 flex-col items-start bg-background-1 group-hover:flex">
112-
<button
113-
onClick={() => startGame('againstMaia')}
114-
className="flex w-full items-center justify-start px-3 py-2 hover:bg-background-2"
115-
>
116-
Play Maia
117-
</button>
106+
<div
107+
className={`${router.pathname.startsWith('/play') && 'bg-background-1'} group relative`}
108+
>
109+
<button className="uppercase">Play</button>
110+
<div className="absolute left-0 top-[100%] z-30 hidden w-48 flex-col items-start bg-background-1 group-hover:flex">
111+
<button
112+
onClick={() => startGame('againstMaia')}
113+
className="flex w-full items-center justify-start px-3 py-2 hover:bg-background-2"
114+
>
115+
Play Maia
116+
</button>
118117

119-
<button
120-
onClick={() => startGame('handAndBrain')}
121-
className="flex w-full items-center justify-start px-3 py-2 hover:bg-background-2"
122-
>
123-
Play Hand and Brain
124-
</button>
125-
<a
126-
className="flex w-full items-center justify-start px-3 py-2 hover:bg-background-2"
127-
href="https://lichess.org/@/maia1"
128-
target="_blank"
129-
rel="noreferrer"
130-
>
131-
Play Maia on Lichess
132-
</a>
133-
</div>
118+
<button
119+
onClick={() => startGame('handAndBrain')}
120+
className="flex w-full items-center justify-start px-3 py-2 hover:bg-background-2"
121+
>
122+
Play Hand and Brain
123+
</button>
124+
<a
125+
className="flex w-full items-center justify-start px-3 py-2 hover:bg-background-2"
126+
href="https://lichess.org/@/maia1"
127+
target="_blank"
128+
rel="noreferrer"
129+
>
130+
Play Maia on Lichess
131+
</a>
134132
</div>
135-
) : (
136-
<a
137-
target="_blank"
138-
rel="noreferrer"
139-
href="https://lichess.org/@/maia1"
140-
className="uppercase"
141-
>
142-
Play
143-
</a>
144-
)}
133+
</div>
134+
)
145135
<Link
146136
href="/analysis"
147137
className={`${router.pathname.startsWith('/analysis') && 'bg-background-1'} uppercase hover:bg-background-1`}
@@ -248,35 +238,26 @@ export const Header: React.FC = () => {
248238
</button>
249239
</div>
250240
<div className="flex flex-col gap-6 px-12">
251-
{user?.lichessId ? (
252-
<div className="flex flex-col items-start justify-center gap-6">
253-
<button>PLAY</button>
254-
<div className="flex flex-col items-start justify-center gap-4">
255-
<button onClick={() => startGame('againstMaia')}>
256-
Play Maia
257-
</button>
241+
<div className="flex flex-col items-start justify-center gap-6">
242+
<button>PLAY</button>
243+
<div className="flex flex-col items-start justify-center gap-4">
244+
<button onClick={() => startGame('againstMaia')}>
245+
Play Maia
246+
</button>
258247

259-
<button onClick={() => startGame('handAndBrain')}>
260-
Play Hand and Brain
261-
</button>
262-
<a
263-
href="https://lichess.org/@/maia1"
264-
target="_blank"
265-
rel="noreferrer"
266-
>
267-
Play Maia on Lichess
268-
</a>
269-
</div>
248+
<button onClick={() => startGame('handAndBrain')}>
249+
Play Hand and Brain
250+
</button>
251+
<a
252+
href="https://lichess.org/@/maia1"
253+
target="_blank"
254+
rel="noreferrer"
255+
>
256+
Play Maia on Lichess
257+
</a>
270258
</div>
271-
) : (
272-
<a
273-
target="_blank"
274-
rel="noreferrer"
275-
href="https://lichess.org/@/maia1"
276-
>
277-
Play
278-
</a>
279-
)}
259+
</div>
260+
280261
<Link href="/analysis" className="uppercase">
281262
Analysis
282263
</Link>

src/components/Home/HomeHero.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,7 @@ export const HomeHero: React.FC<Props> = ({ scrollHandler }: Props) => {
181181
icon={<RegularPlayIcon />}
182182
title="Play Maia"
183183
description="Play chess against the human-like Maia engine"
184-
{...(user?.lichessId
185-
? { onClick: () => startGame('againstMaia') }
186-
: { href: 'https://lichess.org/@/maia1', external: true })}
184+
onClick={() => startGame('againstMaia')}
187185
index={0}
188186
featureKey="play_maia"
189187
/>

src/components/Home/Sections/PlaySection.tsx

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,29 +67,15 @@ export const PlaySection = ({ id }: PlaySectionProps) => {
6767
Trained on millions of human games, Maia plays with human chess
6868
intuition and decision-making style.
6969
</p>
70-
{user?.lichessId ? (
71-
<motion.button
72-
onClick={startGame}
73-
className="flex items-center justify-center rounded-md bg-human-3 px-6 py-3 font-medium text-white"
74-
whileHover={{ scale: 1.04 }}
75-
whileTap={{ scale: 0.95 }}
76-
transition={{ duration: 0.2 }}
77-
>
78-
Play Now
79-
</motion.button>
80-
) : (
81-
<motion.a
82-
href="https://lichess.org/@/maia1"
83-
target="_blank"
84-
rel="noreferrer"
85-
className="flex items-center justify-center rounded-md bg-human-3 px-6 py-3 font-medium text-white"
86-
whileHover={{ scale: 1.04 }}
87-
whileTap={{ scale: 0.95 }}
88-
transition={{ duration: 0.2 }}
89-
>
90-
Play on Lichess
91-
</motion.a>
92-
)}
70+
<motion.button
71+
onClick={startGame}
72+
className="flex items-center justify-center rounded-md bg-human-3 px-6 py-3 font-medium text-white"
73+
whileHover={{ scale: 1.04 }}
74+
whileTap={{ scale: 0.95 }}
75+
transition={{ duration: 0.2 }}
76+
>
77+
Play Now
78+
</motion.button>
9379
</div>
9480
<motion.div
9581
className="relative w-full md:w-1/2"

0 commit comments

Comments
 (0)