Change Profile page dom

Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
soupette 2021-03-31 09:47:32 +02:00
parent 4ba04f8b10
commit 6394d33a6d
3 changed files with 104 additions and 146 deletions

View File

@ -1,11 +1,9 @@
import styled from 'styled-components'; import styled from 'styled-components';
import { Label, Text } from '@buffetjs/core'; import { Label } from '@buffetjs/core';
export const Title = styled(Text)` const ProfilePageLabel = styled(Label)`
text-transform: uppercase;
color: ${({ theme }) => theme.main.colors.grey};
`;
export const ProfilePageLabel = styled(Label)`
margin-bottom: 1rem; margin-bottom: 1rem;
padding-left: 15px;
`; `;
export default ProfilePageLabel;

View File

@ -1,23 +1,21 @@
import React, { useMemo } from 'react'; import React, { useMemo } from 'react';
import { BackHeader, BaselineAlignment, auth, Select, Option, Row } from 'strapi-helper-plugin'; import { BaselineAlignment, auth, Select, Option } from 'strapi-helper-plugin';
import { Padded, Text } from '@buffetjs/core'; import { Padded, Text } from '@buffetjs/core';
import { Col } from 'reactstrap'; import { Col } from 'reactstrap';
import { useHistory } from 'react-router-dom';
import { get } from 'lodash'; import { get } from 'lodash';
import { useIntl } from 'react-intl'; import { useIntl } from 'react-intl';
import { languages, languageNativeNames } from '../../i18n';
import ContainerFluid from '../../components/ContainerFluid'; import ContainerFluid from '../../components/ContainerFluid';
import PageTitle from '../../components/PageTitle'; import PageTitle from '../../components/PageTitle';
import SizedInput from '../../components/SizedInput'; import SizedInput from '../../components/SizedInput';
import { Header } from '../../components/Settings'; import { Header } from '../../components/Settings';
import FormBloc from '../../components/FormBloc';
import { useSettingsForm } from '../../hooks'; import { useSettingsForm } from '../../hooks';
import { form, schema } from './utils';
import useChangeLanguage from '../LanguageProvider/hooks/useChangeLanguage'; import useChangeLanguage from '../LanguageProvider/hooks/useChangeLanguage';
import { languages, languageNativeNames } from '../../i18n'; import ProfilePageLabel from './components';
import { Title, ProfilePageLabel } from './components'; import { form, schema } from './utils';
import Bloc from '../../components/Bloc';
const ProfilePage = () => { const ProfilePage = () => {
const { goBack } = useHistory();
const changeLanguage = useChangeLanguage(); const changeLanguage = useChangeLanguage();
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
@ -50,150 +48,111 @@ const ProfilePage = () => {
}, [modifiedData]); }, [modifiedData]);
return ( return (
<form onSubmit={handleSubmit}> <>
<PageTitle title="User profile" /> <PageTitle title="User profile" />
<BackHeader onClick={goBack} /> <form onSubmit={handleSubmit}>
<ContainerFluid padding="18px 30px 0 30px">
<BaselineAlignment top size="2px" /> <Header
isLoading={showHeaderLoader}
<ContainerFluid padding="18px 30px 0 30px"> initialData={initialData}
<Header label={headerLabel}
isLoading={showHeaderLoader} modifiedData={modifiedData}
initialData={initialData} onCancel={handleCancel}
label={headerLabel} showHeaderButtonLoader={showHeaderButtonLoader}
modifiedData={modifiedData} />
onCancel={handleCancel} <BaselineAlignment top size="3px" />
showHeaderButtonLoader={showHeaderButtonLoader} {/* Experience block */}
/> <FormBloc
</ContainerFluid> isLoading={isLoading}
title={formatMessage({ id: 'Settings.profile.form.section.profile.title' })}
<BaselineAlignment top size="5px" /> >
{Object.keys(form).map(key => (
{/* Experience block */}
<Padded size="md" left right bottom>
<Bloc isLoading={isLoading}>
<Padded size="sm" top left right bottom>
<Col>
<Padded size="sm" top bottom>
<Title>
{formatMessage({ id: 'Settings.profile.form.section.profile.title' })}
</Title>
</Padded>
</Col>
<BaselineAlignment top size="9px" />
<Row>
{Object.keys(form).map(key => (
<SizedInput
{...form[key]}
key={key}
error={formErrors[key]}
name={key}
onChange={handleChange}
value={get(modifiedData, key, '')}
/>
))}
</Row>
</Padded>
</Bloc>
</Padded>
<BaselineAlignment top size="13px" />
{/* Password block */}
<Padded size="md" left right bottom>
<Bloc>
<Padded size="sm" top left right bottom>
<Col>
<Padded size="sm" top bottom>
<Title>
{formatMessage({ id: 'Settings.profile.form.section.password.title' })}
</Title>
</Padded>
</Col>
<BaselineAlignment top size="9px" />
<Row>
<SizedInput <SizedInput
label="Auth.form.password.label" {...form[key]}
type="password" key={key}
autoComplete="new-password" error={formErrors[key]}
validations={{}} name={key}
error={formErrors.password}
name="password"
onChange={handleChange} onChange={handleChange}
value={get(modifiedData, 'password', '')} value={get(modifiedData, key, '')}
/> />
))}
</FormBloc>
<BaselineAlignment top size="2px" />
<SizedInput {/* Password block */}
label="Auth.form.confirmPassword.label" {!isLoading && (
type="password" <>
validations={{}} <Padded top size="md">
error={formErrors.confirmPassword} <FormBloc
name="confirmPassword" title={formatMessage({ id: 'Settings.profile.form.section.password.title' })}
onChange={handleChange} >
value={get(modifiedData, 'confirmPassword', '')} <SizedInput
/> label="Auth.form.password.label"
</Row> type="password"
</Padded> autoComplete="new-password"
</Bloc> validations={{}}
</Padded> error={formErrors.password}
name="password"
onChange={handleChange}
value={get(modifiedData, 'password', '')}
/>
<BaselineAlignment top size="13px" /> <SizedInput
label="Auth.form.confirmPassword.label"
{/* Interface block */} type="password"
<Padded size="md" left right bottom> validations={{}}
<Bloc> error={formErrors.confirmPassword}
<Padded size="sm" top left right bottom> name="confirmPassword"
<Col> onChange={handleChange}
<Padded size="sm" top bottom> value={get(modifiedData, 'confirmPassword', '')}
<Title> />
{formatMessage({ id: 'Settings.profile.form.section.experience.title' })} </FormBloc>
</Title>
</Padded> </Padded>
</Col>
<BaselineAlignment top size="7px" /> <BaselineAlignment top size="13px" />
<div className="col-6"> {/* Interface block */}
<ProfilePageLabel htmlFor=""> <Padded top size="smd">
{formatMessage({ <FormBloc
id: 'Settings.profile.form.section.experience.interfaceLanguage', title={formatMessage({ id: 'Settings.profile.form.section.experience.title' })}
})} >
</ProfilePageLabel> <ProfilePageLabel htmlFor="">
{formatMessage({
id: 'Settings.profile.form.section.experience.interfaceLanguage',
})}
</ProfilePageLabel>
<Col xs="6">
<Select
aria-labelledby="interface-language"
selectedValue={get(modifiedData, 'preferedLanguage')}
onChange={nextLocaleCode => setField('preferedLanguage', nextLocaleCode)}
>
{languages.map(language => {
const langName = languageNativeNames[language];
<Select return (
aria-labelledby="interface-language" <Option value={language} key={language}>
selectedValue={get(modifiedData, 'preferedLanguage')} {langName}
onChange={nextLocaleCode => setField('preferedLanguage', nextLocaleCode)} </Option>
> );
{languages.map(language => { })}
const langName = languageNativeNames[language]; </Select>
return ( <Padded size="sm" top bottom>
<Option value={language} key={language}> <Text color="grey">
{langName} {formatMessage({
</Option> id: 'Settings.profile.form.section.experience.interfaceLanguage.hint',
); })}
})} </Text>
</Select> </Padded>
</Col>
<Padded size="sm" top bottom> </FormBloc>
<Text color="grey">
{formatMessage({
id: 'Settings.profile.form.section.experience.interfaceLanguage.hint',
})}
</Text>
</Padded> </Padded>
</div> </>
</Padded> )}
</Bloc> </ContainerFluid>
</Padded> </form>
</>
<BaselineAlignment top size="80px" />
</form>
); );
}; };

View File

@ -101,6 +101,7 @@ const getStyles = theme => {
...base, ...base,
padding: '2px 10px 4px 10px', // These value don't exist in the theme padding: '2px 10px 4px 10px', // These value don't exist in the theme
fontSize: sizes.fonts.md, fontSize: sizes.fonts.md,
lineHeight: '18px',
}), }),
indicatorsContainer: base => ({ indicatorsContainer: base => ({
...base, ...base,