Skip to content

Commit

Permalink
chore: Upgrade to 24.4.0.alpha22
Browse files Browse the repository at this point in the history
  • Loading branch information
mshabarov committed Apr 18, 2024
1 parent c5b59e3 commit 5c1a445
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/main/frontend/views/login.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
import { LoginOverlay } from '@vaadin/react-components/LoginOverlay.js';
import { useState } from 'react';
import { Navigate } from 'react-router-dom';
import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { useAuth } from 'Frontend/auth';
import { ViewConfig } from "@vaadin/hilla-file-router/types.js";

export const config: ViewConfig = {
menu: { exclude: true}
}

const NavigateAndReload = ({ to }) => {
const navigate = useNavigate();

useEffect(() => {
navigate(to, { replace: true });
// reload a page on log in to update the menu items
window.location.reload();
}, [navigate, to]);

return null;
};

/**
* Login views in Hilla
Expand All @@ -13,7 +30,7 @@ export default function Login() {

if (state.user && url) {
const path = new URL(url, document.baseURI).pathname;
return <Navigate to={path} replace />;
return <NavigateAndReload to={path} />;
}

return (
Expand Down

0 comments on commit 5c1a445

Please sign in to comment.