File size: 1,182 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
import React from 'react'
import { CurrentUserNav, Box, CurrentUserNavProps } from '@adminjs/design-system'
import { CurrentAdmin } from '../../../current-admin.interface.js'
import { useTranslation } from '../../hooks/index.js'
import allowOverride from '../../hoc/allow-override.js'
export type LoggedInProps = {
session: CurrentAdmin;
paths: {
logoutPath: string;
};
}
const LoggedIn: React.FC<LoggedInProps> = (props) => {
const { session, paths } = props
const { translateButton } = useTranslation()
const dropActions: CurrentUserNavProps['dropActions'] = [{
label: translateButton('logout'),
onClick: (event: Event): void => {
event.preventDefault()
window.location.href = paths.logoutPath
},
icon: 'LogOut',
}]
return (
<Box flexShrink={0} data-css="logged-in">
<CurrentUserNav
name={session.email}
title={session.title}
avatarUrl={session.avatarUrl}
dropActions={dropActions}
/>
</Box>
)
}
const OverridableLoggedIn = allowOverride(LoggedIn, 'LoggedIn')
export {
OverridableLoggedIn as default,
OverridableLoggedIn as LoggedIn,
LoggedIn as OriginalLoggedIn,
}
|