Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem committed Dec 5, 2023
1 parent fddb741 commit 223efa7
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 77 deletions.
6 changes: 0 additions & 6 deletions databox/client/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ import DisplayProvider from './Media/DisplayProvider';
import uploaderClient from '../api/uploader-client';
import {zIndex} from '../themes/zIndex';
import AttributeFormatProvider from './Media/Asset/Attribute/Format/AttributeFormatProvider';
import {routes} from '../routes.ts';
import {useRequestErrorHandler} from '@alchemy/api';
import {useAuth} from '@alchemy/auth';
import {MatomoRouteProxy, RouterProvider} from '@alchemy/navigation';

const AppProxy = React.memo(() => {
const isSmallView = useMediaQuery((theme: Theme) =>
Expand Down Expand Up @@ -101,10 +99,6 @@ export default function App() {
return (
<>
<ToastContainer />
<RouterProvider
routes={routes}
RouteProxyComponent={MatomoRouteProxy}
/>
<AppProxy />
</>
);
Expand Down
6 changes: 3 additions & 3 deletions databox/client/src/components/Layout/MainAppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Container from '@mui/material/Container';
import Avatar from '@mui/material/Avatar';
import Tooltip from '@mui/material/Tooltip';
import MenuItem from '@mui/material/MenuItem';
import {UserContext} from '../Security/UserContext';
import {useTranslation} from 'react-i18next';
import {Divider, ListItemIcon, ListItemText} from '@mui/material';
import LogoutIcon from '@mui/icons-material/Logout';
Expand All @@ -21,6 +20,7 @@ import AccountBoxIcon from '@mui/icons-material/AccountBox';
import ChangeTheme from './ChangeTheme';
import {zIndex} from '../../themes/zIndex';
import {useKeycloakUrls} from '../../lib/keycloak';
import {useUser} from "../../hooks/useUser.ts";

export const menuHeight = 42;

Expand All @@ -32,7 +32,7 @@ type Props = {
export default function MainAppBar({onToggleLeftPanel}: Props) {
const {t} = useTranslation();
const [changeTheme, setChangeTheme] = useState(false);
const userContext = useContext(UserContext);
const userContext = useUser();
const [anchorElUser, setAnchorElUser] = React.useState<null | HTMLElement>(
null
);
Expand All @@ -49,7 +49,7 @@ export default function MainAppBar({onToggleLeftPanel}: Props) {
setAnchorElUser(null);
};

const username = userContext.user?.username;
const username = userContext.user?.preferred_username;

return (
<div
Expand Down
5 changes: 5 additions & 0 deletions databox/client/src/hooks/useUser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {UserInfoResponse, useUser as baseUseUser} from '@alchemy/auth';

export function useUser() {
return baseUseUser<UserInfoResponse>();
}
3 changes: 2 additions & 1 deletion lib/js/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import AuthenticationContext, {TAuthContext} from "./src/context/AuthenticationC
import AuthenticationProvider from "./src/components/AuthenticationProvider";
import KeycloakClient from "./src/client/KeycloakClient";
import {useAuth} from "./src/hooks/useAuth";
import {useUser} from "./src/hooks/useUser";
export {
OAuthClient,
configureClientAuthentication,
Expand All @@ -29,8 +30,8 @@ export {
AuthenticationProvider,
KeycloakClient,
useAuth,
useUser,
};

export type {
AuthEvent,
AuthEventHandler,
Expand Down
2 changes: 2 additions & 0 deletions lib/js/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"axios": "^1.6.2",
"react": "^18.2.0",
"react-router-dom": "^6.20.0",
"react-i18next": "^13.5.0",
"@mui/material": "^5.14.19"
},
"dependencies": {
Expand All @@ -30,6 +31,7 @@
"rimraf": "^2.7.1",
"ts-node": "^10.9.1",
"typescript": "^5.3.2",
"react-i18next": "^13.5.0",
"react-router-dom": "^6.20.0",
"@mui/material": "^5.14.19"
}
Expand Down
Loading

0 comments on commit 223efa7

Please sign in to comment.