Skip to content
Snippets Groups Projects
Commit c2e2202e authored by Daniel Sandu's avatar Daniel Sandu
Browse files

refactor(menucountry): refactored code and updated old menu country field boxes

parent 33e30422
No related branches found
No related tags found
3 merge requests!196S25 - EiC submit revision,!189S25,!175Hin 1138 filter
...@@ -4,14 +4,7 @@ import styled from 'styled-components' ...@@ -4,14 +4,7 @@ import styled from 'styled-components'
import { th } from '@pubsweet/ui-toolkit' import { th } from '@pubsweet/ui-toolkit'
import { required } from 'xpub-validators' import { required } from 'xpub-validators'
import { reduxForm, Field } from 'redux-form' import { reduxForm, Field } from 'redux-form'
import { import { H3, ValidatedField, TextField, Checkbox, Spinner } from '@pubsweet/ui'
Menu,
H3,
ValidatedField,
TextField,
Checkbox,
Spinner,
} from '@pubsweet/ui'
import { import {
compose, compose,
withState, withState,
...@@ -20,7 +13,7 @@ import { ...@@ -20,7 +13,7 @@ import {
setDisplayName, setDisplayName,
} from 'recompose' } from 'recompose'
import { withCountries } from 'pubsweet-component-faraday-ui' import { MenuCountry } from 'pubsweet-component-faraday-ui'
import { Tag, Label, Row, Item, PersonInfo, IconButton, OpenModal } from './' import { Tag, Label, Row, Item, PersonInfo, IconButton, OpenModal } from './'
import { validators } from './helpers' import { validators } from './helpers'
...@@ -129,7 +122,6 @@ const AuthorTitle = ({ ...@@ -129,7 +122,6 @@ const AuthorTitle = ({
// #region AuthorEdit // #region AuthorEdit
const AuthorEdit = ({ const AuthorEdit = ({
countries,
author, author,
editMode, editMode,
listIndex, listIndex,
...@@ -196,7 +188,7 @@ const AuthorEdit = ({ ...@@ -196,7 +188,7 @@ const AuthorEdit = ({
<Label required>Country</Label> <Label required>Country</Label>
<ValidatedField <ValidatedField
component={input => ( component={input => (
<Menu {...input} options={countries} placeholder="Please select" /> <MenuCountry {...input} placeholder="Please select" />
)} )}
data-test-id="author-card-country" data-test-id="author-card-country"
name="country" name="country"
...@@ -208,7 +200,6 @@ const AuthorEdit = ({ ...@@ -208,7 +200,6 @@ const AuthorEdit = ({
// #endregion // #endregion
const EnhancedAuthorEdit = compose( const EnhancedAuthorEdit = compose(
withCountries,
withProps(({ author }) => ({ withProps(({ author }) => ({
initialValues: author, initialValues: author,
})), })),
......
...@@ -5,7 +5,9 @@ import { reduxForm } from 'redux-form' ...@@ -5,7 +5,9 @@ import { reduxForm } from 'redux-form'
import { th } from '@pubsweet/ui-toolkit' import { th } from '@pubsweet/ui-toolkit'
import { required } from 'xpub-validators' import { required } from 'xpub-validators'
import { withModal } from 'pubsweet-component-modal/src/components' import { withModal } from 'pubsweet-component-modal/src/components'
import { Button, H4, Menu, TextField, ValidatedField } from '@pubsweet/ui' import { Button, H4, TextField, ValidatedField } from '@pubsweet/ui'
import { MenuCountry } from 'pubsweet-component-faraday-ui'
import { import {
Row, Row,
...@@ -15,10 +17,9 @@ import { ...@@ -15,10 +17,9 @@ import {
ItemOverrideAlert, ItemOverrideAlert,
withFetching, withFetching,
validators, validators,
withCountries,
} from '../' } from '../'
const InviteReviewers = ({ countries, handleSubmit, reset }) => ( const InviteReviewers = ({ handleSubmit, reset }) => (
<Root> <Root>
<Row justify="space-between" mb={2}> <Row justify="space-between" mb={2}>
<H4>Invite reviewer</H4> <H4>Invite reviewer</H4>
...@@ -82,7 +83,9 @@ const InviteReviewers = ({ countries, handleSubmit, reset }) => ( ...@@ -82,7 +83,9 @@ const InviteReviewers = ({ countries, handleSubmit, reset }) => (
<ItemOverrideAlert vertical> <ItemOverrideAlert vertical>
<Label required>Country</Label> <Label required>Country</Label>
<ValidatedField <ValidatedField
component={input => <Menu options={countries} {...input} />} component={input => (
<MenuCountry {...input} placeholder="Please select" />
)}
name="country" name="country"
validate={[required]} validate={[required]}
/> />
...@@ -93,7 +96,6 @@ const InviteReviewers = ({ countries, handleSubmit, reset }) => ( ...@@ -93,7 +96,6 @@ const InviteReviewers = ({ countries, handleSubmit, reset }) => (
export default compose( export default compose(
withFetching, withFetching,
withCountries,
withModal(({ isFetching, modalKey }) => ({ withModal(({ isFetching, modalKey }) => ({
modalKey, modalKey,
isFetching, isFetching,
......
...@@ -13,23 +13,6 @@ const filteredCountries = (countries, userInput) => ...@@ -13,23 +13,6 @@ const filteredCountries = (countries, userInput) =>
const firstFilteredCountry = props => const firstFilteredCountry = props =>
filteredCountries(props.countries, props.userInput)[0] filteredCountries(props.countries, props.userInput)[0]
const Input = styled.input`
width: 100%;
height: calc(${th('gridUnit')} * 4);
border: ${th('accordion.border')};
border-radius: ${th('borderRadius')};
padding: 0 ${th('gridUnit')};
::placeholder {
color: ${th('colorText')};
opacity: 1;
font-family: ${th('fontWriting')};
}
:focus {
border-color: ${th('action.colorActive')}
outline: none;
}
`
const CustomOpener = ({ const CustomOpener = ({
selected, selected,
userInput, userInput,
...@@ -79,3 +62,20 @@ const enhance = compose( ...@@ -79,3 +62,20 @@ const enhance = compose(
) )
export default enhance(MenuCountry) export default enhance(MenuCountry)
const Input = styled.input`
width: 100%;
height: calc(${th('gridUnit')} * 4);
border: ${th('accordion.border')};
border-radius: ${th('borderRadius')};
padding: 0 ${th('gridUnit')};
::placeholder {
color: ${th('colorText')};
opacity: 1;
font-family: ${th('fontWriting')};
}
:focus {
border-color: ${th('action.colorActive')}
outline: none;
}
`
...@@ -7,7 +7,7 @@ import { th } from '@pubsweet/ui-toolkit' ...@@ -7,7 +7,7 @@ import { th } from '@pubsweet/ui-toolkit'
import { required as requiredValidator } from 'xpub-validators' import { required as requiredValidator } from 'xpub-validators'
import { compose, withStateHandlers, withProps } from 'recompose' import { compose, withStateHandlers, withProps } from 'recompose'
import { H3, Spinner, ValidatedField, TextField, Menu } from '@pubsweet/ui' import { H3, Spinner, ValidatedField, TextField, Menu } from '@pubsweet/ui'
import { withCountries } from 'pubsweet-component-faraday-ui' import { withCountries, MenuCountry } from 'pubsweet-component-faraday-ui'
import { import {
Row, Row,
...@@ -179,7 +179,9 @@ const EditUserProfile = compose( ...@@ -179,7 +179,9 @@ const EditUserProfile = compose(
<Item ml={1} vertical> <Item ml={1} vertical>
<Label required>Country</Label> <Label required>Country</Label>
<ValidatedField <ValidatedField
component={input => <Menu {...input} options={countries} />} component={input => (
<MenuCountry {...input} placeholder="Please select" />
)}
name="country" name="country"
validate={[requiredValidator]} validate={[requiredValidator]}
/> />
......
...@@ -19,12 +19,13 @@ import { ...@@ -19,12 +19,13 @@ import {
Text, Text,
Item, Item,
Label, Label,
MenuCountry,
IconButton, IconButton,
RowOverrideAlert, RowOverrideAlert,
ItemOverrideAlert, ItemOverrideAlert,
} from 'pubsweet-component-faraday-ui' } from 'pubsweet-component-faraday-ui'
const AddUserForm = ({ roles, countries, titles }) => ( const AddUserForm = ({ roles, titles }) => (
<Fragment> <Fragment>
<Row alignItems="baseline" mb={1} mt={1}> <Row alignItems="baseline" mb={1} mt={1}>
<Item mr={1} vertical> <Item mr={1} vertical>
...@@ -72,7 +73,7 @@ const AddUserForm = ({ roles, countries, titles }) => ( ...@@ -72,7 +73,7 @@ const AddUserForm = ({ roles, countries, titles }) => (
<Label>Country</Label> <Label>Country</Label>
<ValidatedField <ValidatedField
component={input => ( component={input => (
<Menu options={countries} {...input} placeholder="Please select" /> <MenuCountry {...input} placeholder="Please select" />
)} )}
name="country" name="country"
/> />
...@@ -88,7 +89,7 @@ const AddUserForm = ({ roles, countries, titles }) => ( ...@@ -88,7 +89,7 @@ const AddUserForm = ({ roles, countries, titles }) => (
</Fragment> </Fragment>
) )
const EditForm = ({ titles, countries }) => ( const EditForm = ({ titles }) => (
<Fragment> <Fragment>
<Row alignItems="center" mb={2} mt={1}> <Row alignItems="center" mb={2} mt={1}>
<Item mr={1} vertical> <Item mr={1} vertical>
...@@ -115,7 +116,7 @@ const EditForm = ({ titles, countries }) => ( ...@@ -115,7 +116,7 @@ const EditForm = ({ titles, countries }) => (
<Label>Country</Label> <Label>Country</Label>
<ValidatedField <ValidatedField
component={input => ( component={input => (
<Menu options={countries} {...input} placeholder="Please select" /> <MenuCountry {...input} placeholder="Please select" />
)} )}
name="country" name="country"
/> />
...@@ -186,7 +187,6 @@ const FormModal = ({ ...@@ -186,7 +187,6 @@ const FormModal = ({
onClose, onClose,
subtitle, subtitle,
onConfirm, onConfirm,
countries,
modalError, modalError,
isFetching, isFetching,
handleSubmit, handleSubmit,
...@@ -198,9 +198,9 @@ const FormModal = ({ ...@@ -198,9 +198,9 @@ const FormModal = ({
<H2>{title}</H2> <H2>{title}</H2>
{edit && <Text secondary>{user.email}</Text>} {edit && <Text secondary>{user.email}</Text>}
{edit ? ( {edit ? (
<EditForm countries={countries} titles={titles} /> <EditForm titles={titles} />
) : ( ) : (
<AddUserForm countries={countries} roles={roles} titles={titles} /> <AddUserForm roles={roles} titles={titles} />
)} )}
{modalError && ( {modalError && (
<Row mb={1}> <Row mb={1}>
......
...@@ -9,7 +9,6 @@ import { ...@@ -9,7 +9,6 @@ import {
IconButton, IconButton,
withRoles, withRoles,
withFetching, withFetching,
withCountries,
} from 'pubsweet-component-faraday-ui' } from 'pubsweet-component-faraday-ui'
const AddUser = ({ edit, journal, handleSubmit, ...rest }) => ( const AddUser = ({ edit, journal, handleSubmit, ...rest }) => (
...@@ -32,6 +31,4 @@ const AddUser = ({ edit, journal, handleSubmit, ...rest }) => ( ...@@ -32,6 +31,4 @@ const AddUser = ({ edit, journal, handleSubmit, ...rest }) => (
</OpenModal> </OpenModal>
) )
export default compose(withJournal, withCountries, withRoles, withFetching)( export default compose(withJournal, withRoles, withFetching)(AddUser)
AddUser,
)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment