From e089457c1a2ab1423d7568f0ddb3ea387b0245c7 Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Wed, 15 May 2024 13:49:40 -0300 Subject: [PATCH] chore: react warnings and login issues (#307) --- .../src/components/BCHeaderwSide/index.tsx | 14 +---- .../src/components/BarChartGrouped/index.jsx | 17 +++++- .../src/components/DonutChartView/index.jsx | 16 +++++- .../src/components/FavouriteCard/index.tsx | 8 +-- .../OpeningScreenDataTable/index.jsx | 55 ++++++++----------- frontend/src/screens/Landing/index.tsx | 20 ++++++- frontend/src/screens/Opening/index.tsx | 8 +-- frontend/src/services/AuthService.ts | 24 ++++---- 8 files changed, 90 insertions(+), 72 deletions(-) diff --git a/frontend/src/components/BCHeaderwSide/index.tsx b/frontend/src/components/BCHeaderwSide/index.tsx index e1771927..8a9d3117 100644 --- a/frontend/src/components/BCHeaderwSide/index.tsx +++ b/frontend/src/components/BCHeaderwSide/index.tsx @@ -74,8 +74,6 @@ const BCHeaderwSide = () => { const [myProfile, setMyProfile] = useState(false); const [notifications, setNotifications] = useState(false); - const [goToURL, setGoToURL] = useState(''); - const [goTo, setGoTo] = useState(false); const handleNotificationsPanel = useCallback((): void => { if (notifications) { @@ -105,13 +103,6 @@ const BCHeaderwSide = () => { const navigate = useNavigate(); - useEffect(() => { - if (goTo) { - setGoTo(false); - navigate(goToURL); - } - }, [goTo, goToURL, navigate]); - return ( ( @@ -164,10 +155,7 @@ const BCHeaderwSide = () => { { - setGoToURL(subItem.link); - setGoTo(true); - }} + onClick={() => navigate(subItem.link)} isActive={window.location.pathname === subItem.link} > {subItem.name} diff --git a/frontend/src/components/BarChartGrouped/index.jsx b/frontend/src/components/BarChartGrouped/index.jsx index 2d19b90e..863a6069 100644 --- a/frontend/src/components/BarChartGrouped/index.jsx +++ b/frontend/src/components/BarChartGrouped/index.jsx @@ -132,10 +132,22 @@ const BarChartGrouped = () => {
- item ? item.text : ''} /> + item ? item.text : ''} + titleText={windowWidth<=1584?"District":"Filter by district"} + />
- item ? item.text : ''} /> + item ? item.text : ''} + titleText={windowWidth<=1584?"Status":"Filter by status"} + />
@@ -143,6 +155,7 @@ const BarChartGrouped = () => { id="date-picker-input-id" placeholder="mm/dd/yyyy" size="md" + labelText="Label text" />
diff --git a/frontend/src/components/DonutChartView/index.jsx b/frontend/src/components/DonutChartView/index.jsx index 61b566f0..1514dadd 100644 --- a/frontend/src/components/DonutChartView/index.jsx +++ b/frontend/src/components/DonutChartView/index.jsx @@ -66,10 +66,22 @@ const DonutChartView = () => {
- item ? item.text : ''} /> + item ? item.text : ''} + titleText={windowWidth<=1584?"District":"Filter by district"} + />
- item ? item.text : ''} /> + item ? item.text : ''} + titleText={windowWidth<=1584?"Client Number":"Filter by client number"} + />
diff --git a/frontend/src/components/FavouriteCard/index.tsx b/frontend/src/components/FavouriteCard/index.tsx index 65dcf6c2..8c273e7d 100644 --- a/frontend/src/components/FavouriteCard/index.tsx +++ b/frontend/src/components/FavouriteCard/index.tsx @@ -8,9 +8,9 @@ import './styles.scss'; interface FavouriteCardProps { index: number, - title: String, - link: String, - icon:String, + title: string, + link: string, + icon: string, description:String } @@ -29,7 +29,7 @@ const FavouriteCard = ({ navigate('/')} + onClick={() => navigate(link)} >
diff --git a/frontend/src/components/OpeningScreenDataTable/index.jsx b/frontend/src/components/OpeningScreenDataTable/index.jsx index 4fda603c..4d3022f3 100644 --- a/frontend/src/components/OpeningScreenDataTable/index.jsx +++ b/frontend/src/components/OpeningScreenDataTable/index.jsx @@ -33,26 +33,26 @@ export const batchActionClick = (selectedRows) => () => { export const buttonsCol = ( <> -
); -} \ No newline at end of file +} diff --git a/frontend/src/screens/Landing/index.tsx b/frontend/src/screens/Landing/index.tsx index 4c1e5654..7141871f 100644 --- a/frontend/src/screens/Landing/index.tsx +++ b/frontend/src/screens/Landing/index.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useCallback } from "react"; import BCGovLogo from "../../components/BCGovLogo"; import { Button, InlineNotification } from "@carbon/react"; import { Login } from '@carbon/icons-react'; @@ -8,6 +8,7 @@ import '../../custom.scss'; import { useLottie } from "lottie-react"; import silvaLottie from "../../assets/lotties/silva-logo-lottie-1.json" import ThemeToggle from "../../components/ThemeToggle"; +import { useNavigate } from "react-router-dom"; const Landing: React.FC = () => { // Adding the Lottie Loader and loading the View for lottie with initial options @@ -16,6 +17,19 @@ const Landing: React.FC = () => { loop: true }; const { View } = useLottie(options); + const navigate = useNavigate(); + const login = useCallback(async (provider: string) => { + try { + await signIn(provider) + } catch(e) { + if (e && typeof e === "object" && "message" in e) { + const messageError = e.message as string; + if (messageError === 'There is already a signed in user.') { + navigate('/dashboard'); + } + } + } + }, []); return ( <>
@@ -67,7 +81,7 @@ const Landing: React.FC = () => {