From bd4acab694b9d9a5c7f80fbb41e5e3af896913d0 Mon Sep 17 00:00:00 2001 From: Logan Hernandez Date: Thu, 14 Apr 2022 22:26:16 -0700 Subject: [PATCH 1/3] test(view-orders): add test for #2 --- .../components/view-orders/ordersList.test.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/application/src/components/view-orders/ordersList.test.js b/application/src/components/view-orders/ordersList.test.js index 8872c71..93fdef6 100644 --- a/application/src/components/view-orders/ordersList.test.js +++ b/application/src/components/view-orders/ordersList.test.js @@ -55,4 +55,29 @@ describe('Orders List', () => { expect(screen.getByText(/^.*888.*$/gm)).toBeInTheDocument(); }); + + test('formats time correctly', () => { + const orders = [ + { + order_item: "Food", + quantity: "777", + _id: 1, + createdAt: "2022-04-15T04:17:00.390Z" + }, + { + order_item: "Drink", + quantity: "888", + _id: 2, + createdAt: "2022-04-15T07:15:53.276Z" + } + ]; + render( + + ) + expect(screen.getByText(/^.*21:17:00.*$/gm)).toBeInTheDocument(); + expect(screen.getByText(/^.*00:15:53.*$/gm)).toBeInTheDocument(); + + }); }) \ No newline at end of file From b65d15cf3fa9f862f400ecd716eff68240e874b8 Mon Sep 17 00:00:00 2001 From: Logan Hernandez Date: Thu, 14 Apr 2022 22:48:11 -0700 Subject: [PATCH 2/3] Revert "test(view-orders): add test for #2" This reverts commit bd4acab694b9d9a5c7f80fbb41e5e3af896913d0. --- .../components/view-orders/ordersList.test.js | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/application/src/components/view-orders/ordersList.test.js b/application/src/components/view-orders/ordersList.test.js index 93fdef6..8872c71 100644 --- a/application/src/components/view-orders/ordersList.test.js +++ b/application/src/components/view-orders/ordersList.test.js @@ -55,29 +55,4 @@ describe('Orders List', () => { expect(screen.getByText(/^.*888.*$/gm)).toBeInTheDocument(); }); - - test('formats time correctly', () => { - const orders = [ - { - order_item: "Food", - quantity: "777", - _id: 1, - createdAt: "2022-04-15T04:17:00.390Z" - }, - { - order_item: "Drink", - quantity: "888", - _id: 2, - createdAt: "2022-04-15T07:15:53.276Z" - } - ]; - render( - - ) - expect(screen.getByText(/^.*21:17:00.*$/gm)).toBeInTheDocument(); - expect(screen.getByText(/^.*00:15:53.*$/gm)).toBeInTheDocument(); - - }); }) \ No newline at end of file From fa46e7795f9464f56057ae2de3f042b14f55c6cf Mon Sep 17 00:00:00 2001 From: Logan Hernandez Date: Fri, 15 Apr 2022 15:55:04 -0700 Subject: [PATCH 3/3] feat(appRouter): add route guarding #6 --- application/src/router/appRouter.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/application/src/router/appRouter.js b/application/src/router/appRouter.js index 2768997..dc88454 100644 --- a/application/src/router/appRouter.js +++ b/application/src/router/appRouter.js @@ -1,14 +1,30 @@ import React from 'react'; -import { BrowserRouter as Router, Route } from 'react-router-dom'; +import { BrowserRouter as Router, Redirect, Route } from 'react-router-dom'; import { Main, Login, OrderForm, ViewOrders} from '../components'; +import { useSelector } from 'react-redux'; + const AppRouter = (props) => { + const auth = useSelector((state) => state.auth); + return ( - - - + ( + auth.email + ? + : + )}/> + ( + auth.email + ? + : + )}/> + ( + auth.email + ? + : + )}/> ); }