Skip to content
Merged
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
4 changes: 1 addition & 3 deletions src/ui/components/Navbars/DashboardNavbarLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ const DashboardNavbarLinks: React.FC = () => {
const [openProfile, setOpenProfile] = useState<HTMLElement | null>(null);
const [, setAuth] = useState<boolean>(true);
const [, setIsLoading] = useState<boolean>(true);
const [errorMessage, setErrorMessage] = useState<string>('');
const [user, setUser] = useState<PublicUser | null>(null);

useEffect(() => {
getUser(setIsLoading, setUser, setAuth, setErrorMessage);
getUser(setIsLoading, setUser, setAuth);
}, []);

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

return (
<div>
{errorMessage && <div className={classes.errorMessage}>{errorMessage}</div>}
<div className={classes.manager}>
<Button
color={window.innerWidth > 959 ? 'transparent' : 'white'}
Expand Down
8 changes: 6 additions & 2 deletions src/ui/views/User/UserProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { LogoGithubIcon } from '@primer/octicons-react';
import CloseRounded from '@material-ui/icons/CloseRounded';
import { Check, Save } from '@material-ui/icons';
import { TextField, Theme } from '@material-ui/core';
import Danger from '../../components/Typography/Danger';

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

if (isLoading) return <div>Loading...</div>;
if (errorMessage) return <div>{errorMessage}</div>;

if (!auth && window.location.pathname === '/dashboard/profile') {
return <Navigate to='/login' />;
}

if (errorMessage) return <Danger>{errorMessage}</Danger>;

if (!user) return <div>No user data available</div>;

const updateProfile = async (): Promise<void> => {
const updatedData = {
...user,
gitAccount: escapeHTML(gitAccount),
};
//does not reject and will display any errors that occur

// Does not reject and will display any errors that occur
await updateUser(updatedData, setErrorMessage, setIsLoading);
setUser(updatedData);
navigate(`/dashboard/profile`);
Expand Down
Loading