Skip to content

Commit

Permalink
Add trashcan icon
Browse files Browse the repository at this point in the history
  • Loading branch information
fjosue4 committed Jan 25, 2024
1 parent 65ba9e8 commit 17d4a93
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/pages/Chat/Header/Header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
display: flex;
align-items: center;
gap: 18px;
.github-icon {
.github-icon, .clear-icon {
cursor: pointer;
}
}
Expand Down
13 changes: 10 additions & 3 deletions src/pages/Chat/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import { Icon } from '@iconify/react';
import { Icon } from '@iconify/react'
import { useSelector } from 'react-redux'
import './Header.scss'
import Logout from '../../../components/Logout/Logout';
import { RootState } from '../../../store/index';
import Logout from '../../../components/Logout/Logout'
import { RootState } from '../../../store/index'
import { useDispatch } from 'react-redux'
import { clearChat } from '../../../store/user/userSlice'

function Header() {
const { name } = useSelector((state: RootState) => state.user)

const dispatch = useDispatch()

const openGithub = () => {
window.open('https://github.com/fjosue4/google-gemini-ui')
}

return (
<div className='header'>
<span>Hello, {name}</span>
<div className='header-buttons'>
<Icon className='github-icon' icon='mdi:github' height={28} onClick={openGithub} />
<Icon className='clear-icon' icon='mdi:trashcan-outline' height={28} onClick={() => dispatch(clearChat())} />
<Logout />
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/store/user/userSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const userSlice = createSlice({
state.API_KEY = initialUserState.API_KEY
state.conversation = initialUserState.conversation
},
clearChat: (state) => {
state.conversation = initialUserState.conversation
},
},
extraReducers: (builder) => {
builder
Expand Down Expand Up @@ -62,5 +65,5 @@ const userSlice = createSlice({
},
})

export const { setUser, clearUser } = userSlice.actions
export const { setUser, clearUser, clearChat } = userSlice.actions
export default userSlice.reducer

0 comments on commit 17d4a93

Please sign in to comment.