Skip to content

Deployment: Compare and merging develop branch to main branch #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
85 changes: 44 additions & 41 deletions src/client/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import MonthlyArrivalsPageContainer from './containers/MonthlyArrivalsPage/Month
import AboutpageContainer from './containers/AboutPage/AboutPage.Container';
import ContactpageContainer from './containers/ContactPage/ContactPage.Container';
import CartPageContainer from './containers/CartPage/CartPage.Container';
import ScrollToTop from './ScrollToTop';

function App() {
const { isLoading, isAuthenticated } = useFirebase();
Expand All @@ -29,50 +30,52 @@ function App() {
return (
<Router history={reactRouterHistory}>
<Menu isAuthenticated={isAuthenticated} />
<Switch>
<Route exact path="/">
<LandingPageContainer />
</Route>
<Route exact path="/about-us">
<AboutpageContainer />
</Route>
<Route exact path="/contact-us">
<ContactpageContainer />
</Route>
<Route exact path="/product/:id">
<ProductPageContainer isAuthenticated={isAuthenticated} />
</Route>
<Route exact path="/monthly-arrivals">
<MonthlyArrivalsPageContainer isAuthenticated={isAuthenticated} />
</Route>
<Route exact path="/category/:name">
<CategoryPage />
</Route>
<Route exact path="/cart">
<CartPageContainer isAuthenticated={isAuthenticated} />
</Route>
<ScrollToTop>
<Switch>
<Route exact path="/">
<LandingPageContainer />
</Route>
<Route exact path="/about-us">
<AboutpageContainer />
</Route>
<Route exact path="/contact-us">
<ContactpageContainer />
</Route>
<Route exact path="/product/:id">
<ProductPageContainer isAuthenticated={isAuthenticated} />
</Route>
<Route exact path="/monthly-arrivals">
<MonthlyArrivalsPageContainer isAuthenticated={isAuthenticated} />
</Route>
<Route exact path="/category/:name">
<CategoryPage />
</Route>
<Route exact path="/cart">
<CartPageContainer isAuthenticated={isAuthenticated} />
</Route>

{/* All routes below are authenticated routes - a user must login first */}
<AuthenticatedRoute exact path="/order/:id">
<OrderPageContainer isAuthenticated={isAuthenticated} />
</AuthenticatedRoute>
<AuthenticatedRoute exact path="/order-confirmation/:id">
<ConfirmationPageContainer isAuthenticated={isAuthenticated} />
</AuthenticatedRoute>
<AuthenticatedRoute exact path="/profile">
<ProfilePage isAuthenticated={isAuthenticated} />
</AuthenticatedRoute>
{/* All routes below are authenticated routes - a user must login first */}
<AuthenticatedRoute exact path="/order/:id">
<OrderPageContainer isAuthenticated={isAuthenticated} />
</AuthenticatedRoute>
<AuthenticatedRoute exact path="/order-confirmation/:id">
<ConfirmationPageContainer isAuthenticated={isAuthenticated} />
</AuthenticatedRoute>
<AuthenticatedRoute exact path="/profile">
<ProfilePage isAuthenticated={isAuthenticated} />
</AuthenticatedRoute>

{/* Favorites page */}
<AuthenticatedRoute exact path="/favorites">
<FavoritesPageContainer isAuthenticated={isAuthenticated} />
</AuthenticatedRoute>
{/* Favorites page */}
<AuthenticatedRoute exact path="/favorites">
<FavoritesPageContainer isAuthenticated={isAuthenticated} />
</AuthenticatedRoute>

{/* Make sure to keep wildcard "*" routes in the bottom of the Switch */}
<Route path="*">
<Page404Container />
</Route>
</Switch>
{/* Make sure to keep wildcard "*" routes in the bottom of the Switch */}
<Route path="*">
<Page404Container />
</Route>
</Switch>
</ScrollToTop>
<Footer />
</Router>
);
Expand Down
13 changes: 13 additions & 0 deletions src/client/ScrollToTop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

const ScrollToTop = (props) => {
const location = useLocation();
useEffect(() => {
window.scrollTo(0, 0);
}, [location]);

return <>{props.children}</>;
};

export default ScrollToTop;
20 changes: 12 additions & 8 deletions src/client/containers/LandingPage/LandingPage.Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ import Loader from '../../components/Loader/Loader.component';
const LandingPageContainer = () => {
const products = useFetchApi('products');
const categories = useFetchApi('categories');
const monthlyArrivals = useFetchApi('products?daysBeforeToday=30');

const compareMonth = (date) => {
return new Date().getMonth() === new Date(date).getMonth();
};
const imageArray = monthlyArrivals.data.filter((product) =>
compareMonth(product.created_at) ? product : false,
);
// Monthly arrival removed from frontend.
// Because the database will not update anymore with new products.

// const monthlyArrivals = useFetchApi('products?daysBeforeToday=30');

// const compareMonth = (date) => {
// return new Date().getMonth() === new Date(date).getMonth();
// };
// const imageArray = products.data.filter((product) =>
// compareMonth(product.created_at) ? product : false,
// );

return (
<main>
Expand All @@ -29,7 +33,7 @@ const LandingPageContainer = () => {
<Loader />
) : (
<Carousel
imageArray={imageArray.map((product) => product.picture)}
imageArray={products.data.map((product) => product.picture)}
products={products.data}
show={3}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import Loader from '../../components/Loader/Loader.component';
import ButtonComponent2 from '../../components/ButtonV2/ButtonV2.component';

const MonthlyArrivalsPageContainer = ({ isAuthenticated }) => {
const monthlyArrivals = useFetchApi('products?daysBeforeToday=30');
// Monthly arrival removed from frontend.
// Because the database will not update anymore with new products.
// const monthlyArrivals = useFetchApi('products?daysBeforeToday=30');
const monthlyArrivals = useFetchApi('products');

const id =
(isAuthenticated && JSON.parse(localStorage.getItem('user')).uid) || ' ';
const history = useHistory();
const history = useHistory();
return (
<div className="monthlyArrivalsPage">
<h1>MONTHLY ARRIVALS</h1>
Expand Down