Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cchampou committed Aug 4, 2019
1 parent 97b6b8d commit b14a9d8
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 119 deletions.
16 changes: 8 additions & 8 deletions src/components/individual/Manage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import {
Redirect, Route, Switch,
} from 'react-router-dom';
import { faFolder } from '@fortawesome/free-solid-svg-icons';
import { faArchive, faTags, faAddressCard, faTools, faSignOutAlt } from '@fortawesome/free-solid-svg-icons';

import Sidebar from '@cda/sidebar';
import { Rows, Item } from '@cda/flex';
Expand All @@ -16,21 +16,21 @@ import Meta from '../utils/Meta';
import NotFound from '../utils/NotFound';

const menu = [
{ label: 'Mon parrainage', icon: faFolder, link: '/individual/manage' },
{ label: 'Mes pots de miel', icon: faFolder, link: '/individual/manage/customize' },
{ label: 'Mes informations', icon: faFolder, link: '/individual/manage/infos' },
{ label: 'Mon compte', icon: faFolder, link: '/individual/manage/account' },
{ label: 'Deconnexion', icon: faFolder, link: '/logout' },
{ label: 'Mon parrainage', icon: faArchive, link: '/individual/manage' },
{ label: 'Mes pots de miel', icon: faTags, link: '/individual/manage/customize' },
{ label: 'Mes informations', icon: faAddressCard, link: '/individual/manage/infos' },
{ label: 'Mon compte', icon: faTools, link: '/individual/manage/account' },
{ label: 'Deconnexion', icon: faSignOutAlt, link: '/logout' },
];

export default () => (
<Rows>
<Meta title="Mon espace personnel" />
{(!isLoggedIn) ? <Redirect to="/" /> : null}
<Item>
<Item flex="0 0 10rem">
<Sidebar items={menu} compact={false} />
</Item>
<Item>
<Item flex={1}>
<Switch>
<Route exact path="/individual/manage" component={Bundle} />
<Route exact path="/individual/manage/customize" component={Custom} />
Expand Down
33 changes: 16 additions & 17 deletions src/components/individual/manage/Bundle.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/* eslint-disable camelcase */

import React, { Component } from 'react';
import { Redirect, Link } from 'react-router-dom';
import moment from 'moment';
import FontAwesome from 'react-fontawesome';
import Input from '@cda/input';
import PropTypes from 'prop-types';

import Input from '@cda/input';
import { Rows, Item } from '@cda/flex';
import ButtonLink from '@cda/button-link';

import request from '../../../services/Net';
import Loading from '../../utils/Loading';
import { handleChange } from '../../../services/FormService';
import Meta from '../../utils/Meta';
import Details from './bundle/Details';
import Hive from './bundle/Hive';
import { withNotification } from '../../../services/withNotification';
import PropTypes from 'prop-types';

class Bundle extends Component {
state = {
Expand Down Expand Up @@ -129,18 +129,18 @@ pour le faire ou
return (
<div>
<Meta title="Mon parrainage" />
<div className="row">
<div className="col-lg-12">
<h2 className="my-2 text-center">Mon parrainage</h2>
{(user) ? this.checkInfos() : ''}
</div>
</div>
<h2 className="my-2 text-center">Mon parrainage</h2>
{(user) ? this.checkInfos() : ''}
{(user && user.bundles[0])
? (
<div className="row">
<Details data={user.bundles[0]} />
{user.bundles[0].contain && <Hive hive={user.bundles[0].contain[0]} />}
</div>
<Rows>
<Item>
<Details data={user.bundles[0]} />
</Item>
<Item>
{user.bundles[0].contain && <Hive hive={user.bundles[0].contain[0]} />}
</Item>
</Rows>
)
: <Loading />}
<div className="row mt-4">
Expand Down Expand Up @@ -172,7 +172,6 @@ pour le faire ou
) : null}
<br />
<button className="btn btn-secondary btn-sm pull-right" onClick={() => { this.setState({ edit_present: true }); }}>
<FontAwesome name="pencil" />
{' '}
Modifier ces informations
</button>
Expand Down Expand Up @@ -204,12 +203,12 @@ Modifier ces informations
</div>
);
}
};
}

Bundle.propTypes = {
notification: PropTypes.shape({
addNotification: PropTypes.func.isRequired,
}).isRequired,
}
};

export default withNotification(Bundle);
121 changes: 58 additions & 63 deletions src/components/individual/manage/Infos.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { Component } from 'react';
import { Redirect } from 'react-router-dom';
import FontAwesome from 'react-fontawesome';
import { Button } from '@cda/button';

import Button from '@cda/button';
import Input from '@cda/input';
import { Rows, Item } from '@cda/flex';

import request from '../../../services/Net';
import { handleChange } from '../../../services/FormService';
Expand Down Expand Up @@ -138,76 +139,70 @@ export default withNotification(class IndividualManageInfos extends Component {
}

render() {
const { logout, user, editInfos } = this.state;
return (
<div>
<Meta title="Mes informations" />
{this.state.logout && <Redirect to="/" />}
{logout && <Redirect to="/" />}
<h2 className="text-center my-2">
Mes informations

</h2>
{(this.state.user)
{user
? (
<div>
<div className="row">
<div className="col-lg-6 col-sm-12">
<div className="newcard">
{(!this.state.editInfos)
? (
<div>
<h3 className="mb-2"><small>Informations générales</small></h3>
<strong>Nom :</strong>
{' '}
{this.state.user.name}
<br />
<strong>Prénom :</strong>
{' '}
{this.state.user.firstname}
<br />
<strong>Numéro de téléphone :</strong>
{' '}
{this.state.phone}
<br />
<strong>Email :</strong>
{' '}
{this.state.email}
<div className="text-right mt-2">
<Button primary onClick={() => { this.setState({ editInfos: true }); }}>
<FontAwesome name="pencil" />
&nbsp;Editer ces informations
</Button>
</div>
</div>
)
: (
<form onSubmit={this.changeInfos.bind(this)}>
<div className="form-group">
<label>Numéro de téléphone</label>
<Input type="tel" name="phone" onChange={handleChange.bind(this)} value={this.state.phone} placeholder="Numéro de téléphone" />
</div>
<div className="form-group">
<label>Email</label>
<Input type="email" name="email" onChange={handleChange.bind(this)} value={this.state.email} placeholder="Email" />
</div>
<div className="form-group text-center">
<Button>Enregistrer</Button>
</div>
</form>
)}
</div>
<div className="newcard">
<h3 className="mb-2"><small>Adresse de facturation</small></h3>
<Address data={this.state.billing_address} />
</div>
</div>
<div className="col-lg-6 col-sm-12">
<div className="newcard">
<h3 className="mb-2"><small>Informations de livraison</small></h3>
<Address data={this.state.delivery_address} />
</div>
<Rows>
<Item>
{!editInfos
? (
<div>
<h3 className="mb-2"><small>Informations générales</small></h3>
<strong>Nom :</strong>
{' '}
{this.state.user.name}
<br />
<strong>Prénom :</strong>
{' '}
{this.state.user.firstname}
<br />
<strong>Numéro de téléphone :</strong>
{' '}
{this.state.phone}
<br />
<strong>Email :</strong>
{' '}
{this.state.email}
<div className="text-right mt-2">
<Button primary onClick={() => { this.setState({ editInfos: true }); }}>
&nbsp;Editer ces informations
</Button>
</div>
</div>
)
: (
<form onSubmit={this.changeInfos.bind(this)}>
<div className="form-group">
<label>Numéro de téléphone</label>
<Input type="tel" name="phone" onChange={handleChange.bind(this)} value={this.state.phone} placeholder="Numéro de téléphone" />
</div>
<div className="form-group">
<label>Email</label>
<Input type="email" name="email" onChange={handleChange.bind(this)} value={this.state.email} placeholder="Email" />
</div>
<div className="form-group text-center">
<Button>Enregistrer</Button>
</div>
</form>
)}
<h3 className="mb-2"><small>Adresse de facturation</small></h3>
<Address data={this.state.billing_address} />
</Item>
<Item>
<div>
<h3 className="mb-2"><small>Informations de livraison</small></h3>
<Address data={this.state.delivery_address} />
</div>
</div>
</div>
</Item>
</Rows>
)
: <Loading />}
</div>
Expand Down
51 changes: 32 additions & 19 deletions src/components/individual/manage/bundle/Details.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
import React from 'react'
import Loading from '../../../utils/Loading'
import moment from 'moment'
import React from 'react';
import moment from 'moment';
import Loading from '../../../utils/Loading';

const Details = props => (
(props.data)?
<div className="col-lg-6">
<h3><small>Détails</small></h3>
<hr />
Offre : Parrainage de {props.data.bees} abeilles<br />
{(props.data.start_date && props.data.state >= 2)?
<div>
Date de début : {moment(props.data.start_date).format("DD/MM/YYYY")}<br />
Date de fin: {moment(props.data.end_date).format("DD/MM/YYYY")}
</div>
:<p>Votre offre débutera dès la réception du paiement</p>}
</div>
:<Loading />
)
const Details = ({ data }) => (
(data)
? (
<div className="col-lg-6">
<h3><small>Détails</small></h3>
Offre : Parrainage de
{' '}
{data.bees}
{' '}
abeilles
<br />
{(data.start_date && data.state >= 2)
? (
<div>
Date de début :
{' '}
{moment(data.start_date).format('DD/MM/YYYY')}
<br />
Date de fin:
{' '}
{moment(data.end_date).format('DD/MM/YYYY')}
</div>
)
: <p>Votre offre débutera dès la réception du paiement</p>}
</div>
)
: <Loading />
);

export default Details;
export default Details;
23 changes: 11 additions & 12 deletions src/components/individual/manage/bundle/Hive.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React from 'react'
import { Link } from 'react-router-dom'
import React from 'react';
import { Link } from 'react-router-dom';

const Hive = props => (
<div className="col-lg-6">
<h3><small>Ma ruche</small></h3>
<hr />
{(props.hive)?
<Link to={'/hive/'+props.hive.id}>{props.hive.name}</Link>
:"Aucune ruche ne vous a été attribuée pour l'instant"}
</div>
)
const Hive = ({ hive }) => (
<div>
<h3><small>Ma ruche</small></h3>
{(hive)
? <Link to={`/hive/${hive.id}`}>{hive.name}</Link>
: "Aucune ruche ne vous a été attribuée pour l'instant"}
</div>
);

export default Hive;
export default Hive;

0 comments on commit b14a9d8

Please sign in to comment.