Little fix

This commit is contained in:
Sébastien GLATZ
2019-07-05 15:33:10 +02:00
parent 0706fda67c
commit 72d98e057c
6 changed files with 45 additions and 46 deletions
+8 -2
View File
@@ -10,11 +10,16 @@ const theme = createMuiTheme({
},
secondary: {
main: '#FFFFFF',
dark: '#BBBCBD',
},
error: {
main: red.A400,
},
offerlistitem: {
title: '#1E2327',
icon: '#BBBCBD',
text: '#787B7D',
},
background: {
default: '#ffffff',
@@ -29,6 +34,7 @@ const theme = createMuiTheme({
lightText: '#E1E6EA',
darkDivider: '#32383C',
lightDivider: '#E2E2E2',
backArrow: 'rgba(30, 35, 39, 0.5)',
},
input: {
main: '#F0F0F0',
@@ -54,7 +60,7 @@ const theme = createMuiTheme({
MuiPaper: {
elevation1: {
transition: 'box-shadow .25s',
boxShadow: '0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12), 0 3px 5px -1px rgba(0, 0, 0, 0.2)',
boxShadow: '0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12), 0 3px 5px -1px rgba(0, 0, 0, 0.14)',
},
},
MuiButton: {
-1
View File
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import IconButton from '@material-ui/core/IconButton';
import Typography from '@material-ui/core/Typography';
import { withStyles, getMuiTheme } from '@material-ui/core/styles';
import MenuIcon from '@material-ui/icons/Menu';
import Link from 'next/link'
@@ -21,7 +21,7 @@ const styles = theme => ({
}
},
button: {
padding: theme.spacing(2,0),
padding: theme.spacing(2, 0),
boxShadown: '0px',
backgroundColor: theme.palette.input.main,
},
@@ -30,7 +30,7 @@ const styles = theme => ({
alignItems: 'center',
justifyContent: 'center',
backgroundColor: theme.palette.input.main,
margin: theme.spacing(0,4),
margin: theme.spacing(0, 4),
},
})
@@ -39,9 +39,9 @@ class NewsLetterRegistration extends Component {
data: {
email: "",
},
success: false,
errors: { message: "" },
loading: false,
emailIsValid: false,
tabIndex: 0,
openSnack: false
};
@@ -51,8 +51,9 @@ class NewsLetterRegistration extends Component {
console.log("componentWillReceiveProps")
console.log(nextProps)
this.setState({
errors: !!!nextProps.errors?{errors: { message: "" }}:nextProps.errors,
errors: !!!nextProps.errors ? { errors: { message: "" } } : nextProps.errors,
loading: nextProps.loading,
success: nextProps.success,
openSnack: !_.isEmpty(nextProps.errors)
})
}
@@ -79,16 +80,19 @@ class NewsLetterRegistration extends Component {
return errors;
};
handleClose = (event, reason) => {
this.setState({ openSnack: false });
}
handleClose = e =>
this.setState({
openSnack: { ...this.state.openSnack, [e.target.name]: e.target.value }
});
render() {
const { classes } = this.props;
const { data, errors, loading, openSnack } = this.state;
const { data, success, errors, loading, openSnack } = this.state;
console.log("render")
console.log(errors);
console.log(errors);
return (
<Fragment>
<Typography
@@ -123,18 +127,18 @@ class NewsLetterRegistration extends Component {
Ok
</Button >
</form>
<Snack variant="warning" message={errors.message} openSnack={openSnack} onClose={this.handleClose}/>
<Snack name={success?'snackSuccess':'snackWarning'} variant={success?'success':'warning'} message={success?'Inscription validée.':errors.message} openSnack={openSnack} onClose={this.handleClose} />
</Fragment>
)
}
}
function mapStateToProps(state, ownProps) {
return {
openSnack: !_.isEmpty(ownProps.errors),
loading: !!state.user.loading,
emailIsValid: state.user.emailIsValid,
success: state.user.NewsLetterRegistrationSuccess,
errors: state.user.errors || ownProps.errors
};
}
+18 -25
View File
@@ -3,21 +3,24 @@ import PropTypes from "prop-types";
import Router from 'next/router'
import getConfig from 'next/config'
import { withStyles } from '@material-ui/core/styles';
import Chip from '@material-ui/core/Chip';
import Typography from '@material-ui/core/Typography';
import Chip from '@material-ui/core/Chip';
import IconText from './../atoms/IconText';
const styles = theme => ({
details_container: {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
padding: '8vh 0 0 0',
justifyContent: 'space-between',
position: 'absolute',
top: '60%',
minHeight: '35%',
},
company_title: {
fontSize: '1em',
fontWeight: 'normal',
textTransform: 'uppercase',
paddingLeft: theme.spacing(1),
paddingRight: theme.spacing(1),
},
chip: {
margin: '0 1vh 0 1vh',
@@ -25,7 +28,7 @@ const styles = theme => ({
});
class TileCompany extends React.Component {
class CompanyOffre extends React.Component {
render() {
@@ -33,39 +36,29 @@ class TileCompany extends React.Component {
return (
<Fragment>
<div className={classes.details_container}>
<Typography
gutterBottom
variant="headline"
variant="h6"
component="h4"
align="center"
className={classes.company_title}>
{tile.company.business_name}
</Typography>
<section className={classes.details_container}>
<Typography
gutterBottom
variant="headline"
variant="h6"
component="h3"
align="center"
className={classes.job_title}>
{tile.title}
className={classes.company_title}>
{tile.company.business_name}
</Typography>
</div>
<div>
<Chip label={tile.extra.contract_type} className={classes.chip} />
<Chip label={tile.location.gmap_address.address_components[0].long_name} className={classes.chip} />
</div>
<IconText variant="location_on" text={tile.location.gmap_address.address_components[0].long_name} />
<IconText variant="business_center" text={tile.title} />
<Chip color="primary" size="small" label="Basic Chip" className={classes.chip} />
</section>
</Fragment>
);
}
}
TileCompany.propTypes = {
CompanyOffre.propTypes = {
classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired,
tile: PropTypes.object.isRequired
};
export default withStyles(styles, { withTheme: true })(TileCompany);
export default withStyles(styles, { withTheme: true })(CompanyOffre);
+2 -2
View File
@@ -113,8 +113,8 @@ const styles = theme => ({
textAlign: 'center',
marginTop: theme.spacing(4),
marginBottom: theme.spacing(3),
},
white: {
color: theme.palette.common.white
},
@@ -189,7 +189,7 @@ class Index extends React.Component {
data={this.state.promotedAds}
className={classes.HorizontalScroller}
>
<TileOffre />
<TileCompany />
</HorizontalScroller>
</div>
-3
View File
@@ -81,15 +81,12 @@ export function* requestNewsletterSubscribitionSaga(action) {
const res = yield call(api.user.subscribeToNewsletter, action.payload);
console.log(res);
if (res.data.success === true) {
yield put(subscribeToNewsletterSuccess(res));
} else
console.log(res.data.message);
if (_.startsWith(res.data.message, 'Unsuccessful: 400 MJ18')) {
throw new Error("Existe déjà.")
}
} catch (err) {
console.log(err.message)
yield put(subscribeToNewsletterFailure({err:err, message:err.message}));