Compare commits

..

No commits in common. "develop" and "master" have entirely different histories.

34 changed files with 1 additions and 12279 deletions

1
.env
View file

@ -1 +0,0 @@
SKIP_PREFLIGHT_CHECK=true

View file

@ -1,24 +0,0 @@
module.exports = {
env: {
browser: true,
es6: true,
},
extends: 'airbnb',
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: [
'react',
],
rules: {
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
},
};

23
.gitignore vendored
View file

@ -1,23 +0,0 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

View file

@ -1,44 +1,2 @@
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). # front
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br>
You will also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.<br>
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.<br>
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.<br>
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you cant go back!**
If you arent satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point youre on your own.
You dont have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldnt feel obligated to use this feature. However we understand that this tool wouldnt be useful if you couldnt customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).

View file

@ -1,41 +0,0 @@
{
"name": "front",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.0",
"bootstrap": "^4.1.3",
"history": "^4.9.0",
"prop-types": "^15.7.2",
"react": "^16.6.1",
"react-dom": "^16.6.1",
"react-ga": "^2.5.7",
"react-icons": "^3.2.2",
"react-notifications": "^1.4.3",
"react-router-dom": "^4.3.1",
"react-scripts": "2.1.1",
"reactstrap": "^6.5.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build && ssh guarda 'rm -r www/darkou.fr/cfa/front/static' && scp -r build/* guarda:www/darkou.fr/cfa/front",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.12.4"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 451 KiB

View file

@ -1,26 +0,0 @@
<!DOCTYPE html>
<html lang="fr" class="h-100">
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#ffffff">
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<title>RodiVert</title>
</head>
<body class="d-flex flex-column h-100">
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<footer class="footer mt-auto py-3">
<div class="container">
<span class="text-muted">Une idée originale de Charlotte Ley, Julie Bonjour, Clément Verdollin et Alois
Herbard.</span>
</div>
</footer>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

View file

@ -1,15 +0,0 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

View file

@ -1,15 +0,0 @@
import axios from 'axios';
axios.defaults.headers.common['Access-Control-Allow-Origin'] = '*';
export function setDefaults(params) {
axios.defaults.headers.common.Authorization = params.Authorization;
}
export function setAuthorization(Authorization) {
axios.defaults.headers.common.Authorization = Authorization;
}
export default axios.create({
baseURL: 'https://api.cfa.darkou.fr/api/',
});

View file

@ -1,62 +0,0 @@
import React, { Component, Fragment } from 'react';
import ReactGA from 'react-ga';
import {
BrowserRouter as Router, Route,
Switch,
} from 'react-router-dom';
import Header from './Header';
import Map from '../Routes/Map';
import Search from '../Routes/Search';
import Home from '../Routes/Home';
import Vegetables from '../Routes/Vegetables';
import Vegetable from '../Routes/Vegetable';
ReactGA.initialize('UA-138332682-1');
ReactGA.pageview(window.location.pathname + window.location.search);
class App extends Component {
static changeBackground(background) {
document.body.style.background = `url('/background/${background}.jpg') no-repeat fixed`;
document.body.style.backgroundSize = 'cover';
document.body.style.backgroundPosition = 'center center';
}
render() {
return (
<Fragment>
<Header />
<Router>
<Switch>
<Route
exact
path="/"
render={props => <Home {...props} changeBackground={App.changeBackground} />}
/>
<Route
exact
path="/carte"
render={props => <Map {...props} changeBackground={App.changeBackground} />}
/>
<Route
exact
path="/recherche/:query"
render={props => <Search {...props} changeBackground={App.changeBackground} />}
/>
<Route
exact
path="/vegetaux/:typeId-:typeSlug"
render={props => <Vegetables {...props} changeBackground={App.changeBackground} />}
/>
<Route
exact
path="/vegetaux/:typeId-:typeSlug/:vegetableId-:vegetableSlug"
render={props => <Vegetable {...props} changeBackground={App.changeBackground} />}
/>
</Switch>
</Router>
</Fragment>
);
}
}
export default App;

View file

@ -1,147 +0,0 @@
import React from 'react';
import {
Collapse,
Navbar,
NavbarToggler,
NavbarBrand,
Nav,
NavItem,
NavLink,
InputGroup,
InputGroupAddon,
Input,
Button,
UncontrolledDropdown,
DropdownToggle,
DropdownMenu,
DropdownItem,
Badge,
} from 'reactstrap';
import {
FaSearch,
} from 'react-icons/fa';
import {
NotificationContainer,
NotificationManager,
} from 'react-notifications';
import { createBrowserHistory } from 'history';
import Api from './Api';
import strToSlug from '../StrToSlug';
import '../css/Header.css';
const history = createBrowserHistory();
export default class Header extends React.Component {
constructor(props) {
super(props);
this.toggle = this.toggle.bind(this);
this.getVegetablesTypes = this.getVegetablesTypes.bind(this);
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.state = {
isOpen: false,
types: [],
search: '',
};
this.getVegetablesTypes();
}
getVegetablesTypes() {
Api.get('types')
.then((res) => {
this.setState({
types: res.data.rows,
});
})
.catch(() => {
NotificationManager.error('Erreur lors de la récupération des catégories');
});
}
toggle() {
const {
isOpen,
} = this.state;
this.setState({
isOpen: !isOpen,
});
}
handleChange(event) {
this.setState({ search: event.target.value });
}
handleSubmit() {
const {
search,
} = this.state;
history.push(`/recherche/${search}`);
}
render() {
const {
search,
isOpen,
types,
} = this.state;
return (
<div>
<NotificationContainer />
<Navbar color="light" light fixed="top" expand="md">
<NavbarBrand href="/"><img src="/logo.png" alt="RodiVert" /></NavbarBrand>
<NavbarToggler onClick={this.toggle} />
<Collapse isOpen={isOpen} navbar>
<Nav className="ml-auto" navbar>
<NavItem>
<NavLink href="/carte">Carte</NavLink>
</NavItem>
<UncontrolledDropdown nav inNavbar>
<DropdownToggle nav caret>
Les végétaux
</DropdownToggle>
<DropdownMenu right>
{
types.map(type => (
<DropdownItem as="div" key={type.id}>
<NavLink href={`/vegetaux/${type.id}-${strToSlug(type.name)}`}>
<span className="text">{type.name}</span>
{' '}
<Badge pill>{type.Vegetables.length}</Badge>
</NavLink>
</DropdownItem>
))
}
</DropdownMenu>
</UncontrolledDropdown>
<NavItem>
<form onSubmit={this.handleSubmit}>
<InputGroup>
<Input
placeholder="rechercher..."
type="text"
value={search}
onChange={this.handleChange}
/>
<InputGroupAddon addonType="append">
<Button color="primary">
<FaSearch />
</Button>
</InputGroupAddon>
</InputGroup>
</form>
</NavItem>
</Nav>
</Collapse>
</Navbar>
</div>
);
}
}

View file

@ -1,177 +0,0 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
Row,
Col,
Tooltip,
} from 'reactstrap';
import {
FaMapMarkerAlt,
} from 'react-icons/fa';
import {
Link,
} from 'react-router-dom';
import strToSlug from '../StrToSlug';
import '../css/Map.css';
const MapDimensions = {
width: 734,
height: 530,
};
class Map extends React.Component {
constructor(props) {
super(props);
const {
selectedType,
selectedVegetable,
} = this.props;
this.state = {
selectedType,
selectedVegetable,
map: {
width: '20px',
height: '20px',
},
tooltipOpen: false,
};
this.selectVegetable = this.selectVegetable.bind(this);
this.setMap = this.setMap.bind(this);
this.toggle = this.toggle.bind(this);
}
componentDidMount() {
window.addEventListener('resize', this.setMap);
this.setMap();
}
componentWillReceiveProps(newProps) {
const {
selectedType,
selectedVegetable,
} = this.state;
if (newProps.selectedType !== selectedType
|| newProps.selectedVegetable !== selectedVegetable
) {
this.setState(prevState => ({
...prevState,
selectedType: newProps.selectedType,
selectedVegetable: newProps.selectedVegetable,
}), this.setMap);
}
}
componentWillUnmount() {
window.removeEventListener('resize', this.setMap);
}
setMap() {
const {
setHeight,
} = this.props;
const width = document.getElementById('MapContainer').clientWidth;
let MapWidth = MapDimensions.width;
let MapHeight = MapDimensions.height;
MapWidth = width;
MapHeight = Math.round(MapDimensions.height * MapWidth / MapDimensions.width);
if (setHeight) {
setHeight(MapHeight);
}
this.setState({
map: {
width: MapWidth,
height: MapHeight,
},
});
}
selectVegetable(vegetable) {
this.setState({
selectedVegetable: vegetable,
});
const {
selectVegetable,
} = this.props;
selectVegetable(vegetable);
}
toggle(id) {
this.setState(prevState => ({
tooltipOpen: prevState.tooltipOpen === id ? false : id,
}));
}
createLink(vegetable) {
const {
selectedType,
} = this.state;
let url = '/vegetaux/';
if (vegetable.Type) {
url += `${vegetable.Type.id}-${strToSlug(vegetable.Type.name)}`;
} else {
url += `${selectedType.id}-${strToSlug(selectedType.name)}`;
}
url += `/${vegetable.id}-${strToSlug(vegetable.name)}`;
return url;
}
render() {
const {
map,
selectedType,
selectedVegetable,
tooltipOpen,
} = this.state;
return (
<Row className="with-margin">
<Col className="with-border with-background">
<div id="MapContainer">
<div className="map" style={{ width: map.width, height: map.height }}>
{
selectedType
&& selectedType.Vegetables
&& selectedType.Vegetables.map(vegetable => (
<Link
to={this.createLink(vegetable)}
key={vegetable.id}
className={`mapMarker ${selectedVegetable && selectedVegetable.id === vegetable.id ? 'selected' : ''}`}
style={{ left: `calc(${vegetable.lat}% - 16px)`, top: `calc(${vegetable.lng}% - 16px)` }}
onMouseOver={() => this.selectVegetable(vegetable)}
onFocus={() => { }}
>
<Tooltip placement="top" isOpen={tooltipOpen === vegetable.id} target={`Tooltip-${vegetable.id}`} toggle={() => this.toggle(vegetable.id)}>
{vegetable.name}
</Tooltip>
<FaMapMarkerAlt id={`Tooltip-${vegetable.id}`} />
</Link>
))
}
</div>
</div>
</Col>
</Row>
);
}
}
Map.propTypes = {
selectedType: PropTypes.shape().isRequired,
selectedVegetable: PropTypes.shape().isRequired,
setHeight: PropTypes.func.isRequired,
selectVegetable: PropTypes.func.isRequired,
};
export default Map;

View file

@ -1,122 +0,0 @@
import React from 'react';
import {
ListGroup,
ListGroupItem,
} from 'reactstrap';
import PropTypes from 'prop-types';
import {
Link,
} from 'react-router-dom';
import strToSlug from '../StrToSlug';
import '../css/Vegetables.css';
class Vegetables extends React.Component {
constructor(props) {
super(props);
const {
selectedType,
selectVegetable,
} = this.props;
this.state = {
selectedType,
selectedVegetable: selectVegetable,
};
this.goTo = this.goTo.bind(this);
}
componentWillReceiveProps(newProps) {
this.setState(newProps);
}
createLink(vegetable) {
const {
selectedType,
} = this.state;
let url = '/vegetaux/';
if (vegetable.Type) {
url += `${vegetable.Type.id}-${strToSlug(vegetable.Type.name)}`;
} else {
url += `${selectedType.id}-${strToSlug(selectedType.name)}`;
}
url += `/${vegetable.id}-${strToSlug(vegetable.name)}`;
return url;
}
goTo(vegetable) {
const {
history,
} = this.props;
const url = this.createLink(vegetable);
history.push(url);
}
render() {
const {
double,
simple,
selectVegetable,
} = this.props;
const {
selectedType,
selectedVegetable,
} = this.state;
let addClass = 'triple';
if (simple) {
addClass = '';
} else if (double) {
addClass = 'double';
}
return (
<div className="with-margin">
<div className=" with-border with-background">
<ListGroup className={`vegetables--types--group ${addClass}`}>
{
selectedType
&& selectedType.Vegetables
&& selectedType.Vegetables.map(vegetable => (
<ListGroupItem
key={vegetable.id}
className={selectedVegetable.id === vegetable.id ? 'selected' : 'null'}
onMouseOver={() => selectVegetable(vegetable)}
onClick={() => this.goTo(vegetable)}
onFocus={() => { }}
>
<Link to={this.createLink(vegetable)}>
{vegetable.name}
</Link>
</ListGroupItem>
))
}
</ListGroup>
</div>
</div>
);
}
}
Vegetables.defaultProps = {
double: false,
simple: false,
};
Vegetables.propTypes = {
double: PropTypes.bool,
simple: PropTypes.bool,
selectedType: PropTypes.shape().isRequired,
selectVegetable: PropTypes.shape().isRequired,
history: PropTypes.shape().isRequired,
};
export default Vegetables;

View file

@ -1,63 +0,0 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
Container,
Row,
Col,
} from 'reactstrap';
import '../css/Home.css';
function RouterHome(props) {
const {
changeBackground,
} = props;
changeBackground('home');
return (
<Container>
<Row className="with-margin">
{/* <Row className="mainContainer"> */}
<Col xs="12" className=" with-border with-background">
<img src="/logo.png" className="logo float-left" alt="RodiVert" />
<p>
En tant quétudiant, nous savons ce que cest que de chercher chaque caractéristique
dun végétal et de créer une fiche de technique. Cela demande un temps énorme, en plus
du travail que lon doit fournir pour réussir notre BTS. Cest pour cela que nous avons
pensé à créer un site rassemblant toutes les informations sur le végétal que nous avons
besoin au cours de notre scolarité.
</p>
<p>
RodiVert regroupe toutes les caractéristiques dune plante, sa nomenclature et une
photo de celle-ci pour pouvoir le reconnaitre. Cest maintenant facile et un plaisir
dapprendre !
</p>
<p>
Etant donné que nous finissons nos études cette année, le site sera utile pour la
génération future. Notre but est de faire découvrir aux futurs étudiants une nouvelle
méthode dapprentissage, qui évolue avec laire du temps, une méthode plus moderne.
Mais aussi de créer un lieu entre les formateurs et les élèves.
</p>
<p>
Il permet aussi dapporter une plus-value au CFA du Gard. Le lien sera inscrit sur le
site officiel de létablissement.
</p>
<p>
Nous laissons lévolution du site entre les mains de formateur compétent en
reconnaissance de végétaux et technique.
</p>
<Col lg={{ size: 8, offset: 2 }} xs="12" className="margin-botton">
<img src="/img/Home_01.jpg" className="img-fluid" alt="Sharlotte, Julie, Clément, Alois" />
</Col>
</Col>
</Row>
</Container>
);
}
RouterHome.propTypes = {
changeBackground: PropTypes.func.isRequired,
};
export default RouterHome;

View file

@ -1,131 +0,0 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
Container,
Row,
Col,
ListGroup,
ListGroupItem,
Badge,
} from 'reactstrap';
import {
NotificationContainer,
NotificationManager,
} from 'react-notifications';
import Api from '../Components/Api';
import MapItem from '../Components/Map';
import Vegetables from '../Components/Vegetables';
class RouterMap extends React.Component {
constructor(props) {
super(props);
const {
changeBackground,
} = this.props;
this.state = {
types: [],
selectedType: {},
selectedVegetable: {},
};
this.getVegetablesTypes = this.getVegetablesTypes.bind(this);
this.selectType = this.selectType.bind(this);
this.selectVegetable = this.selectVegetable.bind(this);
this.getVegetablesTypes();
changeBackground('map');
}
getVegetablesTypes() {
Api.get('types')
.then((res) => {
this.setState({
types: res.data.rows,
});
})
.catch(() => {
NotificationManager.error('Erreur lors de la récupération des catégories');
});
}
selectType(type) {
this.setState({
selectedType: type,
});
}
selectVegetable(vegetable) {
this.setState({
selectedVegetable: vegetable,
});
}
render() {
const {
selectedType,
selectedVegetable,
types,
} = this.state;
const {
history,
} = this.props;
return (
<Container>
<NotificationContainer />
<Row>
<Col xs="12" sm="8">
<MapItem
selectedType={selectedType}
selectedVegetable={selectedVegetable}
selectVegetable={this.selectVegetable}
/>
</Col>
<Col xs="12" sm="4">
<Row>
<Col xs="6" sm="12">
<div className="with-margin">
<div className=" with-border with-background">
<ListGroup className="vegetables--types--group">
{
types.map(type => (
<ListGroupItem
key={type.id}
className={selectedType.id === type.id ? 'selected' : 'null'}
onClick={() => this.selectType(type)}
>
{type.name}
<Badge pill>{type.Vegetables.length}</Badge>
</ListGroupItem>
))
}
</ListGroup>
</div>
</div>
</Col>
</Row>
</Col>
<Col xs="12" sm="12">
<Vegetables
selectedType={selectedType}
selectedVegetable={selectedVegetable}
selectVegetable={this.selectVegetable}
history={history}
/>
</Col>
</Row>
</Container>
);
}
}
RouterMap.propTypes = {
changeBackground: PropTypes.func.isRequired,
history: PropTypes.shape().isRequired,
};
export default RouterMap;

View file

@ -1,120 +0,0 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
Container,
Row,
Col,
} from 'reactstrap';
import {
NotificationContainer,
NotificationManager,
} from 'react-notifications';
import Api from '../Components/Api';
import MapItem from '../Components/Map';
import Vegetables from '../Components/Vegetables';
class Search extends React.Component {
constructor(props) {
super(props);
const {
match,
changeBackground,
} = props;
this.state = {
query: match.params.query || null,
selectedType: {},
selectedVegetable: {},
};
this.getVegetables = this.getVegetables.bind(this);
this.selectVegetable = this.selectVegetable.bind(this);
this.getVegetables();
changeBackground('map');
}
getVegetables() {
const {
query,
} = this.state;
Api.get(`search/vegetables/?q=${query}`)
.then((res) => {
this.setState({
selectedType: {
Vegetables: res.data.rows,
id: res.data.rows.length > 0 ? res.data.rows[0].Type.id : null,
name: res.data.rows.length > 0 ? res.data.rows[0].Type.name : null,
},
});
})
.catch(() => {
NotificationManager.error('Erreur lors de la récupération des catégories');
});
}
selectVegetable(vegetable) {
this.setState({
selectedVegetable: vegetable,
});
}
render() {
const {
history,
} = this.props;
const {
selectedType,
selectedVegetable,
} = this.state;
return (
<Container>
<NotificationContainer />
<Row>
<Col xs="12" sm="8">
<MapItem
selectedType={selectedType}
selectedVegetable={selectedVegetable}
selectVegetable={this.selectVegetable}
/>
</Col>
<Col xs="12" sm="4">
<Row>
<Col xs="12">
<Vegetables
selectedType={selectedType}
selectedVegetable={selectedVegetable}
selectVegetable={this.selectVegetable}
simple
history={history}
/>
</Col>
</Row>
</Col>
</Row>
</Container>
);
}
}
Search.defaultProps = {
match: {
params: {
query: null,
},
},
};
Search.propTypes = {
changeBackground: PropTypes.func.isRequired,
match: PropTypes.shape({
params: PropTypes.shape({
query: PropTypes.string,
}),
}),
history: PropTypes.shape().isRequired,
};
export default Search;

View file

@ -1,293 +0,0 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
Container,
Row,
Col,
ListGroup,
ListGroupItem,
Carousel,
CarouselItem,
CarouselControl,
CarouselIndicators,
Breadcrumb,
BreadcrumbItem,
} from 'reactstrap';
import {
NotificationContainer,
NotificationManager,
} from 'react-notifications';
import Api from '../Components/Api';
import MapItem from '../Components/Map';
import strToSlug from '../StrToSlug';
class RouterVegetable extends React.Component {
static formatValue(value) {
if (!value) {
return (null);
}
if (value[0] === '*') {
return (<div className="tabbed" dangerouslySetInnerHTML={{ __html: value.replace('*', '- ').replace(/\*/g, '<br />- ') }} />);
}
return value;
}
constructor(props) {
super(props);
const {
match,
changeBackground,
} = props;
this.state = {
typeId: match.params.typeId,
vegetableId: match.params.vegetableId,
selectedType: {
name: '',
Vegetables: [],
},
item: {
name: null,
Type: {
id: null,
name: null,
},
},
activeIndex: 0,
carouselHeight: 0,
};
this.getItem = this.getItem.bind(this);
this.next = this.next.bind(this);
this.previous = this.previous.bind(this);
this.goToIndex = this.goToIndex.bind(this);
this.onExiting = this.onExiting.bind(this);
this.onExited = this.onExited.bind(this);
this.setHeight = this.setHeight.bind(this);
this.getItem();
changeBackground('vegetables');
}
onExiting() {
this.animating = true;
}
onExited() {
this.animating = false;
}
getItem() {
const {
typeId,
vegetableId,
} = this.state;
Api.get(`/types/${typeId}/vegetables/${vegetableId}`)
.then((res) => {
this.setState({
selectedType: {
id: res.data.Type.id,
name: res.data.Type.name,
Vegetables: [
res.data,
],
},
item: res.data,
});
})
.catch(() => {
NotificationManager.error('Erreur lors de la récupération du végétal');
});
}
setHeight(height) {
this.setState({
carouselHeight: height,
});
}
goToIndex(newIndex) {
if (this.animating) return;
this.setState({ activeIndex: newIndex });
}
next() {
const {
activeIndex,
item,
} = this.state;
if (this.animating) return;
const nextIndex = activeIndex === item.Pictures.length - 1 ? 0 : activeIndex + 1;
this.setState({ activeIndex: nextIndex });
}
previous() {
const {
activeIndex,
item,
} = this.state;
if (this.animating) return;
const nextIndex = activeIndex === 0 ? item.Pictures.length - 1 : activeIndex - 1;
this.setState({ activeIndex: nextIndex });
}
renderCarousel() {
const {
activeIndex,
item,
carouselHeight,
} = this.state;
if (!item || !item.Pictures || item.Pictures.length === 0) {
return (null);
}
return (
<Col xs="12" lg="6">
<Row className="with-margin">
<Col className="with-border with-background">
<Carousel
activeIndex={activeIndex}
next={this.next}
previous={this.previous}
>
<CarouselIndicators
items={item.Pictures}
activeIndex={activeIndex}
onClickHandler={this.goToIndex}
/>
{item
&& item.Pictures
&& item.Pictures.map(picture => (
<CarouselItem
onExiting={this.onExiting}
onExited={this.onExited}
key={picture.url}
>
<img src={picture.url} alt={picture.url} style={{ maxHeight: `${carouselHeight}px` }} />
</CarouselItem>
))}
<CarouselControl direction="prev" directionText="Previous" onClickHandler={this.previous} />
<CarouselControl direction="next" directionText="Next" onClickHandler={this.next} />
</Carousel>
</Col>
</Row>
</Col>
);
}
renderMap() {
const {
item,
selectedType,
} = this.state;
const sm = (!item || !item.Pictures || item.Pictures.length === 0) ? 12 : 6;
return (
<Col xs="12" lg={sm}>
<MapItem
selectedType={selectedType}
selectedVegetable={item}
selectVegetable={() => { }}
setHeight={this.setHeight}
/>
</Col>
);
}
static renderProperty(item, key) {
if (item.Property === null || item.Property === undefined || !item.value) {
return (null);
}
return (
<ListGroupItem key={key}>
<strong>{item.Property.name}</strong>
{' '}
:
{' '}
{RouterVegetable.formatValue(item.value)}
</ListGroupItem>
);
}
renderProperties() {
const {
item,
} = this.state;
if (!item.Properties
|| !item.Properties.length === 0
) {
return (null);
}
return (
<ListGroup className="double">
{item.Properties.map(RouterVegetable.renderProperty)}
</ListGroup>
);
}
render() {
const {
item,
} = this.state;
return (
<Container>
<NotificationContainer />
<Row>
<Col xs="12">
<Row className="with-margin">
<Col className="no-padding">
<Breadcrumb>
<BreadcrumbItem><a href={`/vegetaux/${item.Type.id}-${strToSlug(item.Type.name)}`}>{item.Type.name}</a></BreadcrumbItem>
<BreadcrumbItem active>{item.name}</BreadcrumbItem>
</Breadcrumb>
</Col>
</Row>
</Col>
{this.renderMap()}
{this.renderCarousel()}
<Col xs="12">
<Row className="with-margin">
<Col className=" with-border with-background">
{this.renderProperties()}
</Col>
</Row>
</Col>
</Row>
</Container>
);
}
}
RouterVegetable.defaultProps = {
match: {
params: {
typeId: null,
vegetableId: null,
},
},
};
RouterVegetable.propTypes = {
changeBackground: PropTypes.func.isRequired,
match: PropTypes.shape({
params: PropTypes.shape({
typeId: PropTypes.string,
vegetableId: PropTypes.string,
}),
}),
};
export default RouterVegetable;

View file

@ -1,118 +0,0 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
Container,
Row,
Col,
} from 'reactstrap';
import {
NotificationContainer,
NotificationManager,
} from 'react-notifications';
import Api from '../Components/Api';
import MapItem from '../Components/Map';
import VegetablesList from '../Components/Vegetables';
class RouterVegetables extends React.Component {
constructor(props) {
super(props);
const {
match,
changeBackground,
} = props;
this.state = {
typeId: match.params.typeId,
selectedType: {},
selectedVegetable: {},
};
this.getItem = this.getItem.bind(this);
this.selectVegetable = this.selectVegetable.bind(this);
this.getItem();
changeBackground('vegetables');
}
getItem() {
const {
typeId,
} = this.state;
Api.get(`/types/${typeId}`)
.then((res) => {
this.setState({
selectedType: res.data,
});
})
.catch(() => {
NotificationManager.error('Erreur lors de la récupération des végétaux');
});
}
selectVegetable(vegetable) {
this.setState({
selectedVegetable: vegetable,
});
}
render() {
const {
history,
} = this.props;
const {
selectedType,
selectedVegetable,
} = this.state;
return (
<Container>
<NotificationContainer />
<Row>
<Col xs="12" md="6">
<MapItem
selectedType={selectedType}
selectedVegetable={selectedVegetable}
selectVegetable={this.selectVegetable}
/>
</Col>
<Col xs="12" md="6">
<Row>
<Col xs="12">
<VegetablesList
selectedType={selectedType}
selectedVegetable={selectedVegetable}
selectVegetable={this.selectVegetable}
double
history={history}
/>
</Col>
</Row>
</Col>
</Row>
</Container>
);
}
}
RouterVegetables.defaultProps = {
match: {
params: {
typeId: null,
},
},
};
RouterVegetables.propTypes = {
changeBackground: PropTypes.func.isRequired,
match: PropTypes.shape({
params: PropTypes.shape({
typeId: PropTypes.string,
}),
}),
history: PropTypes.shape().isRequired,
};
export default RouterVegetables;

View file

@ -1,21 +0,0 @@
export default (string) => {
if (!string) {
return '';
}
let str = string;
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
const from = 'àáäâèéëêìíïîòóöôùúüûñç·/_,:;';
const to = 'aaaaeeeeiiiioooouuuunc------';
for (let i = 0, l = from.length; i < l; i += 1) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
str = str.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
.replace(/\s+/g, '-') // collapse whitespace and replace by -
.replace(/-+/g, '-'); // collapse dashes
return str;
};

View file

@ -1,25 +0,0 @@
.navbar-collapse {
flex-grow: unset !important;
}
.nav-item {
padding: 0 16px;
border-left: 1px solid #ccc;
}
.navbar.navbar-expand-md.navbar-light.bg-light {
box-shadow: 0 2px 2px #a7a7a7;
margin-bottom: 16px;
}
.nav-link .text {
padding-right: 32px;
}
.nav-link .badge {
position: absolute;
right: 24px;
}
.navbar-brand img {
max-height: 48px;
}

View file

@ -1,11 +0,0 @@
.logo {
margin: 0 16px 16px 0;
}
.mainContainer {
margin: 16px 8px !important;
}
.margin-botton {
margin-bottom: 32px;
}

View file

@ -1,49 +0,0 @@
.map {
width: 734px;
height: 530px;
background: url('/plan.jpg');
background-size: cover;
position: relative;
}
.mapMarker {
position: absolute;
left: 25%;
top: 33%;
}
.mapMarker svg {
color: #dc3545;
font-size: 2rem;
cursor: pointer;
}
.mapMarker.selected svg {
color: #007bff;
animation: bounce 0.7s ease 5;
}
@keyframes bounce{
from {margin-top: 0;}
50% {margin-top: 8px;}
to {margin-top: 0;}
}
.vegetables--types--group li {
cursor: pointer;
text-align: left;
}
.vegetables--types--group li:hover {
background: #fafafa;
opacity: 0.6;
}
.vegetables--types--group li.selected {
background: #f1f1f1;
font-weight: bold;
}
.vegetables--types--group .badge {
margin-left: 8px;
}

View file

@ -1,3 +0,0 @@
.vegetables--types--group.list-group a {
color: #212529;
}

View file

@ -1,120 +0,0 @@
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background: url('/background/1.jpg') no-repeat fixed;
background-size: cover;
background-position: center center;
}
.with-border {
box-shadow: 4px 4px 6px #a7a7a7;
border-radius: 8px;
border: 1px solid #ccc;
/* margin: 16px; */
padding: 8px;
}
.with-margin {
margin: 8px;
}
@media (max-width: 575.98px) {
.with-margin {
margin: 8px 0;
}
}
.with-background {
background-color: rgba(248,249,250, 0.7) !important;
}
.container {
margin-top: 116px;
margin-bottom: 32px;
}
.double {
display: inherit;
columns: 2;
-webkit-columns: 2;
-moz-columns: 2;
}
@media (min-width: 540px) {
.triple {
display: inherit;
columns: 2;
-webkit-columns: 2;
-moz-columns: 2;
}
}
@media (min-width: 720px) {
.triple {
display: inherit;
columns: 3;
-webkit-columns: 3;
-moz-columns: 3;
}
}
@media (min-width: 960px) {
.triple {
display: inherit;
columns: 4;
-webkit-columns: 4;
-moz-columns: 4;
}
}
.double li {
/* width:50%;
float:left;
display:inline; */
}
.no-padding {
padding: 0;
}
.center {
display: flex;
justify-content: center;
}
.footer .container {
/* width: auto; */
/* max-width: 680px; */
padding: 0 15px;
margin: 0 auto;
}
.footer {
z-index: 200;
background-color: rgba(248,249,250, 0.7) !important;
padding: 4px 0 !important;
box-shadow: 4px -4px 6px #a7a7a7;
font-size: 14px;
/* border-radius: 8px; */
border: 1px solid #ccc;
}
.carousel-item {
text-align: center;
}
.carousel-item img {
max-width: 100%;
}
.tabbed {
padding-left: 16px;
}

View file

@ -1,12 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './Components/App';
import * as serviceWorker from './serviceWorker';
import 'react-notifications/lib/notifications.css';
import 'bootstrap/dist/css/bootstrap.min.css';
import './css/index.css';
ReactDOM.render(<App />, document.getElementById('root'));
serviceWorker.unregister();

View file

@ -1,114 +0,0 @@
const isLocalhost = Boolean(
window.location.hostname === 'localhost'
|| window.location.hostname === '[::1]'
|| window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,
),
);
export function register(config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
return;
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {
checkValidServiceWorker(swUrl, config);
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service '
+ 'worker. To learn more, visit http://bit.ly/CRA-PWA',
);
});
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config);
}
});
}
}
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then((registration) => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all '
+ 'tabs for this page are closed. See http://bit.ly/CRA-PWA.',
);
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
}
}
}
};
};
})
.catch((error) => {
console.error('Error during service worker registration:', error);
});
}
function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
.then((response) => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
response.status === 404
|| (contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then((registration) => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config);
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.',
);
});
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then((registration) => {
registration.unregister();
});
}
}

10503
yarn.lock

File diff suppressed because it is too large Load diff