Skip to content

Commit 034d94e

Browse files
committed
Move sign in button from header to /profile
1 parent 6513909 commit 034d94e

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

app/Header.tsx

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
"use client";
22

3-
import { useState, useEffect } from "react";
3+
import {useEffect, useState} from "react";
44
import Link from "next/link";
5-
import { signOut, useSession } from "next-auth/react";
5+
import {useSession} from "next-auth/react";
66
import ThemeToggle from "@/lib/client/theme";
77
import FavIcon from "@/components/FavIcon";
88

99
export default function Header() {
10-
const { data: session } = useSession();
10+
const {data: session} = useSession();
1111
const [isSmallScreen, setIsSmallScreen] = useState(false);
1212

1313
useEffect(() => {
1414
const checkScreenSize = () => {
1515
setIsSmallScreen(window.innerWidth < 640); // Tailwind's 'sm' breakpoint is 640px
1616
};
17-
17+
1818
// Initial check
1919
checkScreenSize();
20-
20+
2121
// Add event listener for window resize
2222
window.addEventListener('resize', checkScreenSize);
23-
23+
2424
// Clean up the event listener when the component unmounts
2525
return () => window.removeEventListener('resize', checkScreenSize);
2626
}, []);
@@ -32,8 +32,8 @@ export default function Header() {
3232
{/*shadow-md*/}
3333
py-5 px-8 xs:px-4">
3434
<nav className="flex justify-between items-center">
35-
<Link
36-
href="/"
35+
<Link
36+
href="/"
3737
className="text-4xl font-bold hover:text-blue-600 transition-colors flex items-center"
3838
aria-label={isSmallScreen ? "Home" : "Compass"}
3939
>
@@ -71,17 +71,12 @@ export default function Header() {
7171
{/*>*/}
7272
{/* Dashboard*/}
7373
{/*</Link>*/}
74-
<button
75-
onClick={() => signOut({callbackUrl: "/"})}
76-
className={`${fontStyle} bg-red-500 text-white rounded-full hover:bg-red-600`}
77-
>
78-
Sign Out
79-
</button>
8074
</div>
8175
</>
8276
) : (
8377
<>
84-
<Link href="/login" className={`${fontStyle} bg-gray-200 dark:bg-gray-600 text-gray-800 dark:text-white rounded-full hover:bg-gray-300 dark:hover:bg-gray-500`}>
78+
<Link href="/login"
79+
className={`${fontStyle} bg-gray-200 dark:bg-gray-600 text-gray-800 dark:text-white rounded-full hover:bg-gray-300 dark:hover:bg-gray-500`}>
8580
Sign In
8681
</Link>
8782
{/*<Link href="/register"

app/profile/page.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Link from 'next/link';
44
import {usePathname, useRouter} from "next/navigation";
55
import {Profile} from "@/lib/client/profile";
66
import {useEffect} from "react";
7-
import {useSession} from "next-auth/react";
7+
import {signOut, useSession} from "next-auth/react";
88

99
export default function ProfilePage() {
1010
const pathname = usePathname(); // Get the current route
@@ -30,10 +30,16 @@ export default function ProfilePage() {
3030
</div>
3131
<Link
3232
href={`/complete-profile?redirect=${encodeURIComponent(pathname)}`}
33-
className="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
33+
className="mx-1 transition px-2 py-2 text-sm font-medium xs:text-xs bg-blue-500 text-white rounded-full hover:bg-blue-600 min-w-20"
3434
>
3535
Edit Profile
3636
</Link>
37+
<button
38+
onClick={() => signOut({callbackUrl: "/"})}
39+
className="mx-1 transition px-2 py-2 text-sm font-medium xs:text-xs bg-red-500 text-white rounded-full hover:bg-red-600 min-w-20"
40+
>
41+
Sign Out
42+
</button>
3743
</div>
3844
)
3945

0 commit comments

Comments
 (0)