From 8fafc878eb444bff7d944e4bace0a680ce904cc8 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Thu, 23 Jun 2022 19:21:58 +0200 Subject: [PATCH] fix(ui) - login check --- frontend/app/components/Alerts/AlertForm.js | 2 +- frontend/app/components/Header/Header.js | 20 +++++++++++--------- frontend/app/components/ui/Form/Form.tsx | 8 +++++++- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/frontend/app/components/Alerts/AlertForm.js b/frontend/app/components/Alerts/AlertForm.js index 6e48e6278..bd90f41df 100644 --- a/frontend/app/components/Alerts/AlertForm.js +++ b/frontend/app/components/Alerts/AlertForm.js @@ -66,7 +66,7 @@ const AlertForm = props => { const writeQuery = ({ target: { value, name } }) => { const { query } = instance; - props.edit({ query: { ...query, [name] : value.value } }); + props.edit({ query: { ...query, [name] : value } }); } const metric = (instance && instance.query.left) ? triggerOptions.find(i => i.value === instance.query.left) : null; diff --git a/frontend/app/components/Header/Header.js b/frontend/app/components/Header/Header.js index 8dbc74396..293799976 100644 --- a/frontend/app/components/Header/Header.js +++ b/frontend/app/components/Header/Header.js @@ -43,7 +43,7 @@ const Header = (props) => { const { sites, location, account, onLogoutClick, siteId, - boardingCompletion = 100, fetchSiteList, showAlerts = false + boardingCompletion = 100, fetchSiteList, showAlerts = false, } = props; const name = account.get('name').split(" ")[0]; @@ -53,15 +53,17 @@ const Header = (props) => { let activeSite = null; useEffect(() => { - if (initialDataFetched) return; + if (!account.id || initialDataFetched) return; - Promise.all([ - userStore.fetchLimits(), - notificationStore.fetchNotificationsCount(), - ]).then(() => { - userStore.updateKey('initialDataFetched', true); - }); - }, []); + setTimeout(() => { + Promise.all([ + userStore.fetchLimits(), + notificationStore.fetchNotificationsCount(), + ]).then(() => { + userStore.updateKey('initialDataFetched', true); + }); + }, 0); + }, [account]); useEffect(() => { activeSite = sites.find(s => s.id == siteId); diff --git a/frontend/app/components/ui/Form/Form.tsx b/frontend/app/components/ui/Form/Form.tsx index 185ce1aaf..c9ab7c036 100644 --- a/frontend/app/components/ui/Form/Form.tsx +++ b/frontend/app/components/ui/Form/Form.tsx @@ -2,6 +2,7 @@ import React from 'react'; interface Props { children: React.ReactNode; + onSubmit?: any [x: string]: any } @@ -23,7 +24,12 @@ function FormField (props: FormFieldProps) { function Form(props: Props) { const { children, ...rest } = props; return ( -
+ { + e.preventDefault(); + if (props.onSubmit) { + props.onSubmit(e); + } + }}> {children}
);