Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production 2024-02-20_02 #97

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Header/HeaderClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import FancyRectangle from '../FancyRectangle';
import { Links, MenuLinks } from './components/Links';
import LogoTitle from './components/LogoTitle';
import ScrollShader from './components/ScrollShader';
import SignInJoin from './components/SignInJoin';
import { SignInJoin } from './components/SignInJoin';

function UserButton({ data }: { data: HeaderData }) {
const [isMenuOpen, setMenuOpen] = useState(false);
Expand Down
23 changes: 20 additions & 3 deletions src/components/Header/HeaderMobileClient.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import { useClerk } from '@clerk/clerk-react';
import Link from 'next/link';
import { useState } from 'react';
import { IoMdClose, IoMdMenu } from 'react-icons/io';
Expand All @@ -8,6 +9,7 @@ import FancyRectangle from '../FancyRectangle';
import { Links, MenuLinks } from './components/Links';
import LogoTitle from './components/LogoTitle';
import ScrollShader from './components/ScrollShader';
import { SignInJoinMobile } from './components/SignInJoin';

export default function HeaderMobileClient({
data,
Expand All @@ -24,6 +26,12 @@ export default function HeaderMobileClient({
setIsMenuOpen(false);
};

const { signOut } = useClerk();
const handleSignOut = async () => {
await signOut();
setIsMenuOpen(false);
};

return (
<div
className={`${className} fixed z-[9999] w-full transition-all ${isMenuOpen ? 'h-full bg-white/95' : ''}`}
Expand All @@ -50,7 +58,7 @@ export default function HeaderMobileClient({
) : (
<IoMdMenu aria-label="Menu" />
)}
{data.nextStep !== null && !isMenuOpen && (
{data.isSignedIn && data.nextStep !== null && !isMenuOpen && (
<span className="absolute -right-2 -top-2 z-50 flex h-3 w-3">
<div className="absolute inline-flex h-full w-full animate-ping rounded-full bg-red-400 opacity-75" />
<div className="relative inline-flex h-3 w-3 rounded-full bg-red-500" />
Expand All @@ -65,7 +73,7 @@ export default function HeaderMobileClient({
<div className="mt-12 flex flex-col items-center gap-8 text-4xl text-grey">
<Links onClick={closeMenu} />
<div className="mt-4 h-0.5 w-full bg-grey" />
{data.nextStep === 'signup' && (
{data.isSignedIn && data.nextStep === 'signup' && (
<Link
href="/join"
className="block font-bold underline"
Expand All @@ -74,7 +82,7 @@ export default function HeaderMobileClient({
Continue Signing Up
</Link>
)}
{data.nextStep === 'payment' && (
{data.isSignedIn && data.nextStep === 'payment' && (
<Link
href="/settings"
className="block font-bold underline"
Expand All @@ -83,7 +91,16 @@ export default function HeaderMobileClient({
Continue to payment
</Link>
)}

<MenuLinks data={data} onClick={closeMenu} />

{/* Links for sign up, sign in, sign out */}
{!data.isSignedIn && <SignInJoinMobile onClick={closeMenu} />}
{data.isSignedIn && (
<Link href="/" onClick={handleSignOut}>
Sign Out
</Link>
)}
</div>
</>
)}
Expand Down
8 changes: 5 additions & 3 deletions src/components/Header/components/Links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ export function MenuLinks({ data, onClick }: { data: HeaderData; onClick?: () =>
CS Club Drive
</Link>
)}
<Link href="/settings" className="block hover:underline" onClick={onClick}>
Settings
</Link>
{data.isSignedIn && (
<Link href="/settings" className="block hover:underline" onClick={onClick}>
Settings
</Link>
)}
{data.isAdmin && (
<Link href="/admin" className="block hover:underline" onClick={onClick}>
Admin Panel
Expand Down
16 changes: 15 additions & 1 deletion src/components/Header/components/SignInJoin.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Link from 'next/link';
import Button from '../../Button';

export default function SignInJoin() {
export function SignInJoin() {
return (
<>
<Button colour="orange" href="/signin">
Expand All @@ -12,3 +13,16 @@ export default function SignInJoin() {
</>
);
}

export function SignInJoinMobile({ onClick }: { onClick?: () => void }) {
return (
<>
<Link onClick={onClick} href="/signin">
Sign In
</Link>
<Link onClick={onClick} href="/join">
Join Us
</Link>
</>
);
}
Loading