Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Remove search box from /login, /register, and /forgotpassword routes #89

Merged
merged 3 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions frontend/src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { FiPhoneCall, FiUser } from 'react-icons/fi'
import { FaCircle } from 'react-icons/fa'
import SearchBox from './SearchBox'
import { Route } from 'react-router'
import { useLocation } from 'react-router'

const Header = () => {
const dispatch = useDispatch()
Expand All @@ -18,6 +19,8 @@ const Header = () => {
const logoutHandler = () => {
dispatch(logout())
}
const location = useLocation()

return (
<header>
<Navbar bg="light" variant="light" expand="lg" collapseOnSelect>
Expand All @@ -37,11 +40,7 @@ const Header = () => {
<LinkContainer to="/cart">
<Nav.Link data-rb-event-key="cart">
<BsCart size="1.5em" />
{cartItems.length > 0 ? (
<FaCircle className="cart-circle" />
) : (
''
)}
{cartItems.length > 0 && <FaCircle className="cart-circle" />}
</Nav.Link>
</LinkContainer>
</Nav>
Expand Down Expand Up @@ -87,7 +86,15 @@ const Header = () => {
</Navbar.Collapse>
</Container>
</Navbar>
<Route render={({ history }) => <SearchBox history={history} />} />

{location.pathname === '/login' ||
location.pathname === '/register' ||
location.pathname === '/forgotpassword' ||
location.pathname === '/forgotpassword/:email' ? (
''
) : (
<Route render={({ history }) => <SearchBox history={history} />} />
)}
</header>
)
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/reducers/productReducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const productDetailsReducer = (state = { product: {} }, action) => {
case PRODUCT_DETAILS_FAIL:
return { loading: false, error: action.payload }
case PRODUCT_DETAILS_RESET:
return {product: {}}
return { product: {} }
default:
return state
}
Expand Down