Skip to content

Commit 2150064

Browse files
authored
Merge pull request finos#1353 from jescalada/user-auth-error-message
fix: error message on fetching auth'd user
2 parents 4a738dc + 498899f commit 2150064

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/ui/components/Navbars/DashboardNavbarLinks.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ const DashboardNavbarLinks: React.FC = () => {
2727
const [openProfile, setOpenProfile] = useState<HTMLElement | null>(null);
2828
const [, setAuth] = useState<boolean>(true);
2929
const [, setIsLoading] = useState<boolean>(true);
30-
const [errorMessage, setErrorMessage] = useState<string>('');
3130
const [user, setUser] = useState<PublicUser | null>(null);
3231

3332
useEffect(() => {
34-
getUser(setIsLoading, setUser, setAuth, setErrorMessage);
33+
getUser(setIsLoading, setUser, setAuth);
3534
}, []);
3635

3736
const handleClickProfile = (event: React.MouseEvent<HTMLElement>) => {
@@ -66,7 +65,6 @@ const DashboardNavbarLinks: React.FC = () => {
6665

6766
return (
6867
<div>
69-
{errorMessage && <div className={classes.errorMessage}>{errorMessage}</div>}
7068
<div className={classes.manager}>
7169
<Button
7270
color={window.innerWidth > 959 ? 'transparent' : 'white'}

src/ui/views/User/UserProfile.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { LogoGithubIcon } from '@primer/octicons-react';
1616
import CloseRounded from '@material-ui/icons/CloseRounded';
1717
import { Check, Save } from '@material-ui/icons';
1818
import { TextField, Theme } from '@material-ui/core';
19+
import Danger from '../../components/Typography/Danger';
1920

2021
const useStyles = makeStyles((theme: Theme) => ({
2122
root: {
@@ -52,19 +53,22 @@ export default function UserProfile(): React.ReactElement {
5253
}, [id]);
5354

5455
if (isLoading) return <div>Loading...</div>;
55-
if (errorMessage) return <div>{errorMessage}</div>;
5656

5757
if (!auth && window.location.pathname === '/dashboard/profile') {
5858
return <Navigate to='/login' />;
5959
}
60+
61+
if (errorMessage) return <Danger>{errorMessage}</Danger>;
62+
6063
if (!user) return <div>No user data available</div>;
6164

6265
const updateProfile = async (): Promise<void> => {
6366
const updatedData = {
6467
...user,
6568
gitAccount: escapeHTML(gitAccount),
6669
};
67-
//does not reject and will display any errors that occur
70+
71+
// Does not reject and will display any errors that occur
6872
await updateUser(updatedData, setErrorMessage, setIsLoading);
6973
setUser(updatedData);
7074
navigate(`/dashboard/profile`);

0 commit comments

Comments
 (0)