|
@ -1,6 +1,6 @@ |
|
|
import React, { FC } from 'react' |
|
|
import React, { FC } from 'react' |
|
|
import { useSelector, useDispatch } from 'react-redux' |
|
|
import { useSelector, useDispatch } from 'react-redux' |
|
|
import { Link, useHistory } from 'react-router-dom' |
|
|
|
|
|
|
|
|
import { useHistory } from 'react-router-dom' |
|
|
import { faDoorOpen, faCheckCircle, faIdCard, faEnvelope, faUserShield, faUserCircle } from '@fortawesome/free-solid-svg-icons' |
|
|
import { faDoorOpen, faCheckCircle, faIdCard, faEnvelope, faUserShield, faUserCircle } from '@fortawesome/free-solid-svg-icons' |
|
|
|
|
|
|
|
|
import { unauthenticate, updateSelf } from 'src/actions/authentication' |
|
|
import { unauthenticate, updateSelf } from 'src/actions/authentication' |
|
@ -10,7 +10,7 @@ import { getForm } from 'src/selectors/forms' |
|
|
|
|
|
|
|
|
import { handleApiError } from 'src/api/errors' |
|
|
import { handleApiError } from 'src/api/errors' |
|
|
import { PRIVACY_OPTIONS } from 'src/constants' |
|
|
import { PRIVACY_OPTIONS } from 'src/constants' |
|
|
import { useAuthenticationCheck, useDeepCompareEffect, useTheme } from 'src/hooks' |
|
|
|
|
|
|
|
|
import { useAuthenticationCheck, useDeepCompareEffect } from 'src/hooks' |
|
|
import { setTitle, valueFromForm } from 'src/utils' |
|
|
import { setTitle, valueFromForm } from 'src/utils' |
|
|
import { AppState, User, Form } from 'src/types' |
|
|
import { AppState, User, Form } from 'src/types' |
|
|
|
|
|
|
|
@ -31,7 +31,6 @@ import ThemeField from 'src/components/controls/theme-field' |
|
|
import StaticField from 'src/components/controls/static-field' |
|
|
import StaticField from 'src/components/controls/static-field' |
|
|
|
|
|
|
|
|
const Self: FC = () => { |
|
|
const Self: FC = () => { |
|
|
const theme = useTheme() |
|
|
|
|
|
const dispatch = useDispatch() |
|
|
const dispatch = useDispatch() |
|
|
const history = useHistory() |
|
|
const history = useHistory() |
|
|
|
|
|
|
|
@ -47,6 +46,8 @@ const Self: FC = () => { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const handleUpdate = () => { |
|
|
const handleUpdate = () => { |
|
|
|
|
|
if (!user) return |
|
|
|
|
|
const settings = user.settings ?? {} |
|
|
const name = valueFromForm<string>(form, 'name', '') |
|
|
const name = valueFromForm<string>(form, 'name', '') |
|
|
const about = valueFromForm<string>(form, 'about', '') |
|
|
const about = valueFromForm<string>(form, 'about', '') |
|
|
const requiresApproval = valueFromForm<boolean>(form, 'requiresApproval', true) |
|
|
const requiresApproval = valueFromForm<boolean>(form, 'requiresApproval', true) |
|
@ -54,6 +55,7 @@ const Self: FC = () => { |
|
|
const imageUrl = valueFromForm<string>(form, 'image', '') |
|
|
const imageUrl = valueFromForm<string>(form, 'image', '') |
|
|
const coverImageUrl = valueFromForm<string>(form, 'coverImage', '') |
|
|
const coverImageUrl = valueFromForm<string>(form, 'coverImage', '') |
|
|
const theme = valueFromForm<string>(form, 'theme', '') |
|
|
const theme = valueFromForm<string>(form, 'theme', '') |
|
|
|
|
|
const allowThemeChange = valueFromForm<boolean>(form, 'allowThemeChange', true) |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
dispatch(updateSelf({ |
|
|
dispatch(updateSelf({ |
|
@ -64,6 +66,10 @@ const Self: FC = () => { |
|
|
imageUrl, |
|
|
imageUrl, |
|
|
coverImageUrl, |
|
|
coverImageUrl, |
|
|
theme, |
|
|
theme, |
|
|
|
|
|
settings: { |
|
|
|
|
|
...settings, |
|
|
|
|
|
allowThemeChange, |
|
|
|
|
|
} |
|
|
})) |
|
|
})) |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
handleApiError(err, dispatch, history) |
|
|
handleApiError(err, dispatch, history) |
|
@ -82,6 +88,7 @@ const Self: FC = () => { |
|
|
dispatch(initField('image', user.imageUrl || '')) |
|
|
dispatch(initField('image', user.imageUrl || '')) |
|
|
dispatch(initField('coverImage', user.coverImageUrl || '')) |
|
|
dispatch(initField('coverImage', user.coverImageUrl || '')) |
|
|
dispatch(initField('theme', user.theme)) |
|
|
dispatch(initField('theme', user.theme)) |
|
|
|
|
|
dispatch(initField('allowThemeChange', user.settings.allowThemeChange)) |
|
|
} |
|
|
} |
|
|
}, [user]) |
|
|
}, [user]) |
|
|
|
|
|
|
|
@ -108,6 +115,11 @@ const Self: FC = () => { |
|
|
<CheckboxField name="requiresApproval"> |
|
|
<CheckboxField name="requiresApproval"> |
|
|
Approve each Subscription request from other users. |
|
|
Approve each Subscription request from other users. |
|
|
</CheckboxField> |
|
|
</CheckboxField> |
|
|
|
|
|
<br /> |
|
|
|
|
|
|
|
|
|
|
|
<CheckboxField name="allowThemeChange"> |
|
|
|
|
|
Allow theme changes on User and Community pages. |
|
|
|
|
|
</CheckboxField> |
|
|
|
|
|
|
|
|
<HorizontalRule /> |
|
|
<HorizontalRule /> |
|
|
|
|
|
|
|
|