Skip to content

Commit

Permalink
darkmode and sign out button
Browse files Browse the repository at this point in the history
  • Loading branch information
auraticabhi committed Mar 26, 2024
1 parent 461afa0 commit 4f233c4
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const Navbar = ({}: Props) => {
const searchParams = useSearchParams();
const isGuest = searchParams.get('isGuest');
const [newPost, setNewPost] = useState(false);
//const [user, loading] = useAuthState(auth);
const [imageUpload , setImageUpload] = useState<File | null>(null);
const [imageUrl, setImageUrl] = useState<string | null>(null);
const [progress , setProgress] = useState<number | null>(0);
Expand Down Expand Up @@ -276,6 +277,13 @@ const Navbar = ({}: Props) => {

const [user, loading] = useAuthState(auth);

const signoutHandler = ()=>{
auth.signOut();
if(user?.isAnonymous){
router.push("/auth");
}
}

//fetching real-time notifications
useEffect(() => {
if (user) {
Expand Down Expand Up @@ -587,20 +595,15 @@ useEffect(() => {
</DropdownMenuItem>
</Link>
<div className="mt-1 ml-2 mb-2">
<div className="flex items-center space-x-2">
<Switch id="airplane-mode" onCheckedChange={toggleTheme} checked={theme==='dark'}/>
<div className="flex items-center justify-between pr-1 space-x-2">
<Label htmlFor="airplane-mode">Dark Mode</Label>
<Switch id="airplane-mode" onCheckedChange={toggleTheme} checked={theme==='dark'}/>
</div>
</div>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuItem onClick={
() => {
auth.signOut();
//router.push("/auth");
}
}>
Log out
<DropdownMenuItem onClick={signoutHandler}>
{`${user.isAnonymous?"Sign Up":"Log Out"}`}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
Expand Down

0 comments on commit 4f233c4

Please sign in to comment.