Commit 7c3e0d25 authored by CodeDuSoir's avatar CodeDuSoir
Browse files

tache 78, 83, 85

parent e654e7d4
......@@ -3577,6 +3577,8 @@
},
"@testing-library/jest-dom": {
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-4.2.4.tgz",
"integrity": "sha512-j31Bn0rQo12fhCWOUWy9fl7wtqkp7In/YP2p5ZFyRuiiB9Qs3g+hS4gAmDWONbAHcRmVooNJ5eOHQDCOmUFXHg==",
"requires": {
"@babel/runtime": "^7.5.1",
"chalk": "^2.4.1",
......@@ -3601,6 +3603,8 @@
},
"@testing-library/react": {
"version": "9.5.0",
"resolved": "https://registry.npmjs.org/@testing-library/react/-/react-9.5.0.tgz",
"integrity": "sha512-di1b+D0p+rfeboHO5W7gTVeZDIK5+maEgstrZbWZSSvxDyfDRkkyBE1AJR5Psd6doNldluXlCWqXriUfqu/9Qg==",
"requires": {
"@babel/runtime": "^7.8.4",
"@testing-library/dom": "^6.15.0",
......@@ -3608,7 +3612,9 @@
}
},
"@testing-library/user-event": {
"version": "7.2.1"
"version": "7.2.1",
"resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-7.2.1.tgz",
"integrity": "sha512-oZ0Ib5I4Z2pUEcoo95cT1cr6slco9WY7yiPpG+RGNkj8YcYgJnM7pXmYmorNOReh8MIGcKSqXyeGjxnr8YiZbA=="
},
"@types/babel__core": {
"version": "7.1.9",
......@@ -8089,6 +8095,19 @@
"resolved": "https://registry.npmjs.org/hex-color-regex/-/hex-color-regex-1.1.0.tgz",
"integrity": "sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ=="
},
"history": {
"version": "4.10.1",
"resolved": "https://registry.npmjs.org/history/-/history-4.10.1.tgz",
"integrity": "sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==",
"requires": {
"@babel/runtime": "^7.1.2",
"loose-envify": "^1.2.0",
"resolve-pathname": "^3.0.0",
"tiny-invariant": "^1.0.2",
"tiny-warning": "^1.0.0",
"value-equal": "^1.0.1"
}
},
"hmac-drbg": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz",
......@@ -8099,6 +8118,14 @@
"minimalistic-crypto-utils": "^1.0.1"
}
},
"hoist-non-react-statics": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz",
"integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==",
"requires": {
"react-is": "^16.7.0"
}
},
"hosted-git-info": {
"version": "2.8.8",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz",
......@@ -10080,6 +10107,15 @@
"resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz",
"integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg=="
},
"mini-create-react-context": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/mini-create-react-context/-/mini-create-react-context-0.4.0.tgz",
"integrity": "sha512-b0TytUgFSbgFJGzJqXPKCFCBWigAjpjo+Fl7Vf7ZbKRDptszpppKxXH6DRXEABZ/gcEQczeb0iZ7JvL8e8jjCA==",
"requires": {
"@babel/runtime": "^7.5.5",
"tiny-warning": "^1.0.3"
}
},
"mini-css-extract-plugin": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-0.9.0.tgz",
......@@ -12350,6 +12386,8 @@
},
"react": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react/-/react-16.13.1.tgz",
"integrity": "sha512-YMZQQq32xHLX0bz5Mnibv1/LHb3Sqzngu7xstSM+vrkE5Kzr9xE0yMByK5kMoTK30YVJE61WfbxIFFvfeDKT1w==",
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
......@@ -12569,6 +12607,8 @@
},
"react-dom": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.13.1.tgz",
"integrity": "sha512-81PIMmVLnCNLO/fFOQxdQkvEq/+Hfpv24XNJfpyZhTRfO0QcmQIF/PgCa1zCOj2w1hrn12MFLyaJ/G0+Mxtfag==",
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
......@@ -12586,8 +12626,56 @@
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
},
"react-router": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-5.2.0.tgz",
"integrity": "sha512-smz1DUuFHRKdcJC0jobGo8cVbhO3x50tCL4icacOlcwDOEQPq4TMqwx3sY1TP+DvtTgz4nm3thuo7A+BK2U0Dw==",
"requires": {
"@babel/runtime": "^7.1.2",
"history": "^4.9.0",
"hoist-non-react-statics": "^3.1.0",
"loose-envify": "^1.3.1",
"mini-create-react-context": "^0.4.0",
"path-to-regexp": "^1.7.0",
"prop-types": "^15.6.2",
"react-is": "^16.6.0",
"tiny-invariant": "^1.0.2",
"tiny-warning": "^1.0.0"
},
"dependencies": {
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
},
"path-to-regexp": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz",
"integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==",
"requires": {
"isarray": "0.0.1"
}
}
}
},
"react-router-dom": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-5.2.0.tgz",
"integrity": "sha512-gxAmfylo2QUjcwxI63RhQ5G85Qqt4voZpUXSEqCwykV0baaOTQDR1f0PmY8AELqIyVc0NEZUj0Gov5lNGcXgsA==",
"requires": {
"@babel/runtime": "^7.1.2",
"history": "^4.9.0",
"loose-envify": "^1.3.1",
"prop-types": "^15.6.2",
"react-router": "5.2.0",
"tiny-invariant": "^1.0.2",
"tiny-warning": "^1.0.0"
}
},
"react-scripts": {
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-3.4.3.tgz",
"integrity": "sha512-oSnoWmii/iKdeQiwaO6map1lUaZLmG0xIUyb/HwCVFLT7gNbj8JZ9RmpvMCZ4fB98ZUMRfNmp/ft8uy/xD1RLA==",
"requires": {
"@babel/core": "7.9.0",
"@svgr/webpack": "4.3.3",
......@@ -13063,6 +13151,11 @@
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz",
"integrity": "sha1-six699nWiBvItuZTM17rywoYh0g="
},
"resolve-pathname": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/resolve-pathname/-/resolve-pathname-3.0.0.tgz",
"integrity": "sha512-C7rARubxI8bXFNB/hqcp/4iUeIXJhJZvFPFPiSPRnhU5UPxzMFIl+2E6yY6c4k9giDJAhtV+enfA+G89N6Csng=="
},
"resolve-url": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz",
......@@ -14606,6 +14699,16 @@
"resolved": "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz",
"integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q="
},
"tiny-invariant": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.1.0.tgz",
"integrity": "sha512-ytxQvrb1cPc9WBEI/HSeYYoGD0kWnGEOR8RY6KomWLBVhqz0RgTwVO9dLrGz7dC+nN9llyI7OKAgRq8Vq4ZBSw=="
},
"tiny-warning": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/tiny-warning/-/tiny-warning-1.0.3.tgz",
"integrity": "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA=="
},
"tmp": {
"version": "0.0.33",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
......@@ -14990,6 +15093,11 @@
"spdx-expression-parse": "^3.0.0"
}
},
"value-equal": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/value-equal/-/value-equal-1.0.1.tgz",
"integrity": "sha512-NOJ6JZCAWr0zlxZt+xqCHNTEKOsrks2HQd4MqhP1qy4z1SkbEP467eNx6TgDKXMvUOb+OENfJCZwM+16n7fRfw=="
},
"vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
......
......@@ -10,6 +10,7 @@
"node-sass": "^4.14.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3"
},
"scripts": {
......
import React from 'react';
import Body from './components/body';
import { BrowserRouter as Router, Route, Switch, Redirect } from 'react-router-dom';
import Body from './components/body';
import ToobibPage from './components/toobibPage';
import error from './components/error';
function App() {
return (
<Body/>
<Router>
<Switch>
<Route exact path="/" component={Body} />
<Route path="/toobibPage" component={ToobibPage} />
<Route exact path="/404" component={error} />
<Redirect to="/404" />
</Switch>
</Router>
);
}
......
......@@ -11,18 +11,24 @@ import Pagination from './pagination';
export default class Body extends Component {
state = {
'searchValue': 'Paris',
'lastSearchTitle': '',
'searchResult': '',
'page': 1
'page': '1'
}
fetchData() {
fetch(urlAPI + this.state.searchValue + '&page=' + this.state.page + '&origin=*', { header: {'Access-Control-Allow-Origin': '*'}})
.then(res => res.json())
.then(data => {
this.setState({ 'searchResult': data });
})
async fetchData() {
const response = await fetch(urlAPI + this.state.lastSearchTitle + '&page=' + this.state.page + '&origin=*', { header: {'Access-Control-Allow-Origin': '*'}})
const json = await response.json();
this.setState({ 'searchResult': json });
}
resetSearch() {
this.setState({'page': '1'});
this.setState({'lastSearchTitle': this.state.searchValue});
}
searchFunction = () => e => {
this.resetSearch();
e.preventDefault();
this.fetchData();
}
......@@ -31,20 +37,21 @@ export default class Body extends Component {
this.setState({[input]: e.target.value});
}
handleIndentation = input => e => {
this.setState({[input]: parseInt(e.target.value) + this.state.page});
handleIndentation = input => async e => {
let newNumber = parseInt(e.target.value) + parseInt(this.state.page);
await this.setState({[input]: newNumber.toString()});
this.fetchData();
}
render() {
const { searchValue, searchResult, page } = this.state;
const { searchValue, searchResult, lastSearchTitle, page } = this.state;
return (
<main>
<Header/>
<SearchBar handleChange={this.handleChange} searchValue={searchValue} searchFunction={this.searchFunction} />
<ResultCards searchValue={searchValue} searchResult={searchResult}/>
<Pagination searchResult={searchResult} page={page} handleIndentation={this.handleIndentation} searchFunction={this.searchFunction} />
<SearchBar fetchData={this.fetchData} handleChange={this.handleChange} searchValue={searchValue} searchFunction={this.searchFunction} />
<ResultCards lastSearchTitle={lastSearchTitle} searchResult={searchResult}/>
<Pagination searchResult={searchResult} page={page} handleIndentation={this.handleIndentation} />
</main>
);
}
......
import React, { Component } from 'react';
const error = () => {
return (
<div>
<h3>404 not found</h3>
</div>
);
};
export default error;
......@@ -2,28 +2,69 @@ import React, { Component } from 'react';
export default class Pagination extends Component {
render() {
render() {
const { handleIndentation, searchFunction } = this.props;
const { handleIndentation, page, searchResult } = this.props;
if(page === '1') {
return(
<nav aria-label="Pagination" className="columns is-centered">
<button value="-1" onClick={handleIndentation("page")} className="pagination-previous" disabled>
<span className="screen-reader-text">Page précédente</span>
<svg className="icon icon-arrow-left-mini" width="14" height="14" viewBox="-100.9 99.1 61.9 105.9">
<path d="M-98.2 158.8l43.5 43.5c1.7 1.7 4 2.7 6.5 2.7s4.8-1 6.5-2.7c1.7-1.7 2.7-4 2.7-6.5s-1-4.8-2.7-6.5l-37.2-37.2 37.2-37.2c1.7-1.7 2.7-4 2.7-6.5s-1-4.8-2.6-6.5c-1.8-1.9-4.2-2.8-6.6-2.8-2.3 0-4.6.9-6.5 2.6-11.5 11.4-41.2 41-43.3 43l-.2.2c-3.6 3.6-3.6 10.3 0 13.9z"></path>
</svg>
Précédente
</button>
<button value="1" onClick={handleIndentation("page")} className="pagination-next">
return(
<nav className aria-label="Pagination" class="columns is-centered">
<button value="-1" onClick={handleIndentation("page")} className="pagination-previous">
<span className="screen-reader-text">Page suivante</span>
Suivante
<svg width="14" height="14" viewBox="-100.9 99.1 61.9 105.9" className=" icon icon-arrow-right-mini">
<path d="M-41.7 145.3l-43.5-43.5c-1.7-1.7-4-2.7-6.5-2.7s-4.8 1-6.5 2.7c-1.7 1.7-2.7 4-2.7 6.5s1 4.8 2.7 6.5L-61 152l-37.2 37.2c-1.7 1.7-2.7 4-2.7 6.5s1 4.8 2.6 6.5c1.8 1.9 4.2 2.8 6.6 2.8 2.3 0 4.6-.9 6.5-2.6 11.5-11.4 41.2-41 43.3-43l.2-.2c3.6-3.6 3.6-10.4 0-13.9z"></path>
</svg>
</button>
</nav>
)
} else if(searchResult.providers.length < 9) {
return(
<nav aria-label="Pagination" className="columns is-centered">
<button value="-1" onClick={handleIndentation("page")} className="pagination-previous">
<span className="screen-reader-text">Page précédente</span>
<svg className="icon icon-arrow-left-mini" width="14" height="14" viewBox="-100.9 99.1 61.9 105.9">
<path d="M-98.2 158.8l43.5 43.5c1.7 1.7 4 2.7 6.5 2.7s4.8-1 6.5-2.7c1.7-1.7 2.7-4 2.7-6.5s-1-4.8-2.7-6.5l-37.2-37.2 37.2-37.2c1.7-1.7 2.7-4 2.7-6.5s-1-4.8-2.6-6.5c-1.8-1.9-4.2-2.8-6.6-2.8-2.3 0-4.6.9-6.5 2.6-11.5 11.4-41.2 41-43.3 43l-.2.2c-3.6 3.6-3.6 10.3 0 13.9z"></path>
<path d="M-98.2 158.8l43.5 43.5c1.7 1.7 4 2.7 6.5 2.7s4.8-1 6.5-2.7c1.7-1.7 2.7-4 2.7-6.5s-1-4.8-2.7-6.5l-37.2-37.2 37.2-37.2c1.7-1.7 2.7-4 2.7-6.5s-1-4.8-2.6-6.5c-1.8-1.9-4.2-2.8-6.6-2.8-2.3 0-4.6.9-6.5 2.6-11.5 11.4-41.2 41-43.3 43l-.2.2c-3.6 3.6-3.6 10.3 0 13.9z"></path>
</svg>
Précédente
</button>
<button value="1" onClick={handleIndentation("page")} className="pagination-next">
</button>
<button value="1" onClick={handleIndentation("page")} className="pagination-next" disabled>
<span className="screen-reader-text">Page suivante</span>
Suivante
<svg width="14" height="14" viewBox="-100.9 99.1 61.9 105.9" class=" icon icon-arrow-right-mini">
<path d="M-41.7 145.3l-43.5-43.5c-1.7-1.7-4-2.7-6.5-2.7s-4.8 1-6.5 2.7c-1.7 1.7-2.7 4-2.7 6.5s1 4.8 2.7 6.5L-61 152l-37.2 37.2c-1.7 1.7-2.7 4-2.7 6.5s1 4.8 2.6 6.5c1.8 1.9 4.2 2.8 6.6 2.8 2.3 0 4.6-.9 6.5-2.6 11.5-11.4 41.2-41 43.3-43l.2-.2c3.6-3.6 3.6-10.4 0-13.9z"></path>
<svg width="14" height="14" viewBox="-100.9 99.1 61.9 105.9" className=" icon icon-arrow-right-mini">
<path d="M-41.7 145.3l-43.5-43.5c-1.7-1.7-4-2.7-6.5-2.7s-4.8 1-6.5 2.7c-1.7 1.7-2.7 4-2.7 6.5s1 4.8 2.7 6.5L-61 152l-37.2 37.2c-1.7 1.7-2.7 4-2.7 6.5s1 4.8 2.6 6.5c1.8 1.9 4.2 2.8 6.6 2.8 2.3 0 4.6-.9 6.5-2.6 11.5-11.4 41.2-41 43.3-43l.2-.2c3.6-3.6 3.6-10.4 0-13.9z"></path>
</svg>
</button>
</nav>
)
}
</button>
</nav>
)
} else {
return(
<nav aria-label="Pagination" className="columns is-centered">
<button value="-1" onClick={handleIndentation("page")} className="pagination-previous">
<span className="screen-reader-text">Page précédente</span>
<svg className="icon icon-arrow-left-mini" width="14" height="14" viewBox="-100.9 99.1 61.9 105.9">
<path d="M-98.2 158.8l43.5 43.5c1.7 1.7 4 2.7 6.5 2.7s4.8-1 6.5-2.7c1.7-1.7 2.7-4 2.7-6.5s-1-4.8-2.7-6.5l-37.2-37.2 37.2-37.2c1.7-1.7 2.7-4 2.7-6.5s-1-4.8-2.6-6.5c-1.8-1.9-4.2-2.8-6.6-2.8-2.3 0-4.6.9-6.5 2.6-11.5 11.4-41.2 41-43.3 43l-.2.2c-3.6 3.6-3.6 10.3 0 13.9z"></path>
</svg>
Précédente
</button>
<button value="1" onClick={handleIndentation("page")} className="pagination-next">
<span className="screen-reader-text">Page suivante</span>
Suivante
<svg width="14" height="14" viewBox="-100.9 99.1 61.9 105.9" className=" icon icon-arrow-right-mini">
<path d="M-41.7 145.3l-43.5-43.5c-1.7-1.7-4-2.7-6.5-2.7s-4.8 1-6.5 2.7c-1.7 1.7-2.7 4-2.7 6.5s1 4.8 2.7 6.5L-61 152l-37.2 37.2c-1.7 1.7-2.7 4-2.7 6.5s1 4.8 2.6 6.5c1.8 1.9 4.2 2.8 6.6 2.8 2.3 0 4.6-.9 6.5-2.6 11.5-11.4 41.2-41 43.3-43l.2-.2c3.6-3.6 3.6-10.4 0-13.9z"></path>
</svg>
</button>
</nav>
)
}
}
}
import React, { Component } from 'react';
import {BrowserRouter as Router, Route, Switch, Link, Redirect } from 'react-router-dom';
export default class ResultCards extends Component {
render() {
const { searchResult, searchValue } = this.props;
const { searchResult, lastSearchTitle } = this.props;
if(!searchResult)
{
return(
......@@ -16,7 +17,7 @@ export default class ResultCards extends Component {
{
return(
<React.Fragment>
<h2>Voici les resultats pour: "{searchValue}"</h2>
<h2>Voici les resultats pour: "{lastSearchTitle}"</h2>
<nav className="columns is-multiline is-centered">
{
searchResult.providers.map((e) => {
......@@ -36,7 +37,7 @@ export default class ResultCards extends Component {
{e.libelleProfession}
<br />
</div>
<a className="button is-link is-light has-text-right">Consulter</a>
<Link to="/toobibPage" className="button is-link is-light has-text-right">Consulter</Link>
</div>
</div>
</div>
......
......@@ -3,7 +3,7 @@ import React, { Component } from 'react';
export default class SearchBar extends Component {
render() {
const { searchValue, handleChange, searchFunction } = this.props;
const { searchValue, handleChange, searchFunction, fetchData } = this.props;
return(
<React.Fragment>
<div className="level">
......@@ -14,7 +14,7 @@ export default class SearchBar extends Component {
<input className="input" value={searchValue} onChange={handleChange('searchValue')} placeholder="search" name="q" type="text"/>
</div>
<div className="control">
<input type="submit" className="button is-link" onClick={searchFunction(searchValue)} value="Rechercher"></input>
<input type="submit" className="button is-link" onClick={searchFunction(fetchData)} value="Rechercher"></input>
</div>
</div>
</form>
......
import React, { Component } from 'react';
const ToobibPage = () => {
return (
<div>
<h3>docteur numero 3</h3>
</div>
);
};
export default ToobibPage;
......@@ -11,3 +11,9 @@
text-overflow: ellipsis;
white-space: nowrap;
}
.screen-reader-text {
position: absolute;
top: -9999px;
left: -999px;
}
Markdown is supported
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