mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-29 06:15:29 -04:00
Correct use selector (#515)
This commit is contained in:
parent
971421925a
commit
a41d3d1515
20 changed files with 74 additions and 205 deletions
|
@ -10,9 +10,9 @@ import { ProfileChangePassword } from './settings/profile-change-password'
|
|||
import { ProfileDisplayName } from './settings/profile-display-name'
|
||||
|
||||
export const ProfilePage: React.FC = () => {
|
||||
const user = useSelector((state: ApplicationState) => state.user)
|
||||
const userProvider = useSelector((state: ApplicationState) => state.user?.provider)
|
||||
|
||||
if (!user) {
|
||||
if (!userProvider) {
|
||||
return (
|
||||
<Redirect to={'/login'}/>
|
||||
)
|
||||
|
@ -23,7 +23,7 @@ export const ProfilePage: React.FC = () => {
|
|||
<Row className="h-100 flex justify-content-center">
|
||||
<Col lg={6}>
|
||||
<ProfileDisplayName/>
|
||||
<ShowIf condition={user.provider === LoginProvider.INTERNAL}>
|
||||
<ShowIf condition={userProvider === LoginProvider.INTERNAL}>
|
||||
<ProfileChangePassword/>
|
||||
</ShowIf>
|
||||
<ProfileAccountManagement/>
|
||||
|
|
|
@ -9,18 +9,18 @@ import { getAndSetUser } from '../../login-page/auth/utils'
|
|||
export const ProfileDisplayName: React.FC = () => {
|
||||
const regexInvalidDisplayName = /^\s*$/
|
||||
const { t } = useTranslation()
|
||||
const user = useSelector((state: ApplicationState) => state.user)
|
||||
const userName = useSelector((state: ApplicationState) => state.user?.name)
|
||||
const [submittable, setSubmittable] = useState(false)
|
||||
const [error, setError] = useState(false)
|
||||
const [displayName, setDisplayName] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
if (user) {
|
||||
setDisplayName(user.name)
|
||||
if (userName !== undefined) {
|
||||
setDisplayName(userName)
|
||||
}
|
||||
}, [user])
|
||||
}, [userName])
|
||||
|
||||
if (!user) {
|
||||
if (!userName) {
|
||||
return <Alert variant={'danger'}>User not logged in</Alert>
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue