Skip to content

Commit

Permalink
remove local storage path after sign out
Browse files Browse the repository at this point in the history
  • Loading branch information
sar-mko committed Oct 19, 2024
1 parent 7a851ee commit a01ad89
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/api/useAuth.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
import { auth } from './config.js';
import { GoogleAuthProvider, signInWithPopup } from 'firebase/auth';
import { addUserToDatabase } from './firebase.js';
import { useStateWithStorage } from '../utils/hooks.js';

/**
* A button that signs the user in using Google OAuth. When clicked,
Expand All @@ -24,7 +25,11 @@ export const SignInButton = ({ styles }) => (
export const SignOutButton = () => (
<button
type="button"
onClick={() => auth.signOut() && window.location.reload()}
onClick={() =>
auth.signOut() &&
window.location.reload() &&
useStateWithStorage('tcl-shopping-list-path', null)
}
className="m-0 bg-accent text-black font-bold hover:text-black hover:bg-third "
>
Sign Out
Expand Down
4 changes: 3 additions & 1 deletion src/views/List.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useVoiceToText } from '../utils';
import SearchRoundedIcon from '@mui/icons-material/SearchRounded';
import AddBoxRoundedIcon from '@mui/icons-material/AddBoxRounded';
import KeyboardVoiceIcon from '@mui/icons-material/KeyboardVoice';
import { SignInButton } from '../api';

export function List({ data, userId, path }) {
const [filterVal, setFilterVal] = useState('');
Expand Down Expand Up @@ -136,8 +137,9 @@ export function List({ data, userId, path }) {
) : (
<div className="flex flex-col h-[80vh] my-8 p-8 rounded-3xl overflow-hidden mx-auto place-content-center items-center ">
<h2 className="text-center my-8 text-neutral text-6xl">
Please login or add items to your list
Please login to view items
</h2>
<SignInButton styles={'bg-neutral text-white btn-lg text-2xl'} />
</div>
)}
</>
Expand Down

0 comments on commit a01ad89

Please sign in to comment.