diff --git a/package.json b/package.json index 553e0d8..36f8d3d 100755 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "font-awesome": "^4.7.0", "history": "^4.7.2", "i18n-iso-countries": "^3.7.8", + "lodash": "^4.17.11", "prop-types": "^15.5.10", "query-string": "^5.1.1", "react": "^16.2.0", diff --git a/src/actions/preferences.js b/src/actions/preferences.js new file mode 100644 index 0000000..fef10e7 --- /dev/null +++ b/src/actions/preferences.js @@ -0,0 +1,51 @@ +import AsyncActionType from './AsyncActionType'; + + +export const FETCH_PREFERENCES = new AsyncActionType('PROFILE', 'FETCH_PREFERENCES'); +export const SAVE_PREFERENCES = new AsyncActionType('PROFILE', 'SAVE_PREFERENCES'); + +export const fetchPreferencesBegin = () => ({ + type: FETCH_PREFERENCES.BEGIN, +}); + +export const fetchPreferencesSuccess = preferences => ({ + type: FETCH_PREFERENCES.SUCCESS, + preferences, +}); + +export const fetchPreferencesFailure = error => ({ + type: FETCH_PREFERENCES.FAILURE, + payload: { error }, +}); + +export const fetchPreferencesReset = () => ({ + type: FETCH_PREFERENCES.RESET, +}); + +export const fetchPreferences = username => ({ + type: FETCH_PREFERENCES.BASE, + payload: { username }, +}); + + +export const savePreferencesBegin = () => ({ + type: SAVE_PREFERENCES.BEGIN, +}); + +export const savePreferencesSuccess = () => ({ + type: SAVE_PREFERENCES.SUCCESS, +}); + +export const savePreferencesFailure = error => ({ + type: SAVE_PREFERENCES.FAILURE, + payload: { error }, +}); + +export const savePreferencesReset = () => ({ + type: SAVE_PREFERENCES.RESET, +}); + +export const savePreferences = (username, preferences) => ({ + type: SAVE_PREFERENCES.BASE, + payload: { username, preferences }, +}); diff --git a/src/actions/profile.js b/src/actions/profile.js index a2a95c7..b7538b3 100644 --- a/src/actions/profile.js +++ b/src/actions/profile.js @@ -6,8 +6,6 @@ export const FETCH_PROFILE = new AsyncActionType('PROFILE', 'FETCH_PROFILE'); export const SAVE_PROFILE = new AsyncActionType('PROFILE', 'SAVE_PROFILE'); export const SAVE_PROFILE_PHOTO = new AsyncActionType('PROFILE', 'SAVE_PROFILE_PHOTO'); export const DELETE_PROFILE_PHOTO = new AsyncActionType('PROFILE', 'DELETE_PROFILE_PHOTO'); -export const FETCH_PREFERENCES = new AsyncActionType('PROFILE', 'FETCH_PREFERENCES'); -export const SAVE_PREFERENCES = new AsyncActionType('PROFILE', 'SAVE_PREFERENCES'); export const openEditableField = fieldName => ({ type: EDITABLE_FIELD_OPEN, @@ -116,50 +114,3 @@ export const deleteProfilePhoto = username => ({ username, }, }); - - -export const fetchPreferencesBegin = () => ({ - type: FETCH_PREFERENCES.BEGIN, -}); - -export const fetchPreferencesSuccess = preferences => ({ - type: FETCH_PREFERENCES.SUCCESS, - preferences, -}); - -export const fetchPreferencesFailure = error => ({ - type: FETCH_PREFERENCES.FAILURE, - payload: { error }, -}); - -export const fetchPreferencesReset = () => ({ - type: FETCH_PREFERENCES.RESET, -}); - -export const fetchPreferences = username => ({ - type: FETCH_PREFERENCES.BASE, - payload: { username }, -}); - - -export const savePreferencesBegin = () => ({ - type: SAVE_PREFERENCES.BEGIN, -}); - -export const savePreferencesSuccess = () => ({ - type: SAVE_PREFERENCES.SUCCESS, -}); - -export const savePreferencesFailure = error => ({ - type: SAVE_PREFERENCES.FAILURE, - payload: { error }, -}); - -export const savePreferencesReset = () => ({ - type: SAVE_PREFERENCES.RESET, -}); - -export const savePreferences = (username, preferences) => ({ - type: SAVE_PREFERENCES.BASE, - payload: { username, preferences }, -}); diff --git a/src/components/UserProfile/Bio.jsx b/src/components/UserProfile/Bio.jsx index 526d488..423e832 100644 --- a/src/components/UserProfile/Bio.jsx +++ b/src/components/UserProfile/Bio.jsx @@ -11,6 +11,7 @@ import SwitchContent from './elements/SwitchContent'; function Bio({ bio, + visibility, editMode, onEdit, onChange, @@ -37,7 +38,7 @@ function Bio({ onCancel={() => onCancel('bio')} onSave={() => onSave('bio')} saveState={saveState} - visibility="Everyone" + visibility={visibility} onVisibilityChange={e => onVisibilityChange('bio', e.target.value)} /> @@ -49,7 +50,7 @@ function Bio({ showEditButton onClickEdit={() => onEdit('bio')} showVisibility={Boolean(bio)} - visibility="Everyone" + visibility={visibility} />
{bio}
@@ -83,12 +84,14 @@ Bio.propTypes = { onVisibilityChange: PropTypes.func.isRequired, saveState: PropTypes.string, bio: PropTypes.string, + visibility: PropTypes.oneOf(['private', 'all_users']), }; Bio.defaultProps = { editMode: 'static', saveState: null, bio: null, + visibility: 'private', }; diff --git a/src/components/UserProfile/Education.jsx b/src/components/UserProfile/Education.jsx index 1f090d1..94cb6e1 100644 --- a/src/components/UserProfile/Education.jsx +++ b/src/components/UserProfile/Education.jsx @@ -12,6 +12,7 @@ import EDUCATION from '../../constants/education'; function Education({ education, + visibility, editMode, onEdit, onChange, @@ -43,7 +44,7 @@ function Education({ onCancel={() => onCancel('education')} onSave={() => onSave('education')} saveState={saveState} - visibility="Everyone" + visibility={visibility} onVisibilityChange={e => onVisibilityChange('education', e.target.value)} /> @@ -55,7 +56,7 @@ function Education({ showEditButton onClickEdit={() => onEdit('education')} showVisibility={Boolean(education)} - visibility="Everyone" + visibility={visibility} />