Skip to content

Commit

Permalink
remove isLoggedIn prop from NavColumn and Header
Browse files Browse the repository at this point in the history
  • Loading branch information
kylezryr committed Dec 8, 2024
1 parent 314d8f9 commit 5857e04
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
12 changes: 9 additions & 3 deletions components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import CONFIG from '@/lib/configs';
import { useAuth } from '@/utils/AuthProvider';
import { useProfile } from '@/utils/ProfileProvider';
import Icon from '../Icon';
import { Container, HamburgerButton } from './styles';

interface HeaderProps {
toggleNavColumn: () => void;
isLoggedIn: boolean;
}

export default function Header({ toggleNavColumn, isLoggedIn }: HeaderProps) {
export default function Header({ toggleNavColumn }: HeaderProps) {
const currentPath = usePathname();
const { profileReady, profileData } = useProfile();
const { userId } = useAuth();
const [isLoggedIn, setIsLoggedIn] = useState(false);

useEffect(() => {
setIsLoggedIn(userId !== null);
}, [userId]);

const onNavColumnClick = () => {
toggleNavColumn();
Expand Down
20 changes: 8 additions & 12 deletions components/NavColumn/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useEffect, useState } from 'react';
import Link from 'next/link';
import { usePathname, useRouter } from 'next/navigation';
import CONFIG from '@/lib/configs';
Expand Down Expand Up @@ -32,7 +32,6 @@ import {
interface NavColumnProps {
isOpen: boolean;
onClose: () => void;
isLoggedIn: boolean;
}

type NavLink = {
Expand All @@ -50,26 +49,23 @@ const navLinks: NavLink[] = [
},
];

export default function NavColumn({
isOpen,
onClose,
isLoggedIn,
}: NavColumnProps) {
export default function NavColumn({ isOpen, onClose }: NavColumnProps) {
const currentPath = usePathname();
const { signOut } = useAuth();
const { signOut, userId } = useAuth();
const router = useRouter();
const { profileData, profileReady } = useProfile();
const [isLoggedIn, setIsLoggedIn] = useState(false);

useEffect(() => {
setIsLoggedIn(userId !== null);
}, [userId]);

const handleSignOut = () => {
router.push(CONFIG.login);
onClose();
signOut();
};

useEffect(() => {
console.log('profileData', profileData);
}, [profileData]);

return (
<>
{isOpen && (
Expand Down
3 changes: 1 addition & 2 deletions components/NavSystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ export default function NavSystem() {

return (
<>
<Header toggleNavColumn={toggleNavColumn} isLoggedIn={userId !== null} />
<Header toggleNavColumn={toggleNavColumn} />
<NavColumn
isOpen={isNavColumnOpen}
onClose={() => setIsNavColumnOpen(false)}
isLoggedIn={userId !== null}
/>
</>
);
Expand Down

0 comments on commit 5857e04

Please sign in to comment.