Commit 65fcb765 authored by CodeDuSoir's avatar CodeDuSoir
Browse files

toobib-93, toobib-94

parent 508053f6
......@@ -10,12 +10,12 @@ import Pagination from './pagination';
export default function Body(props) {
const { searchValue, searchResult, lastSearchTitle, page,fetchData, handleChange, searchFunction, handleIndentation } = props;
const { searchValue, searchResult, lastSearchTitle, page,fetchData, toobibDataFunction, handleChange, searchFunction, handleIndentation } = props;
return (
<main>
<Header/>
<SearchBar fetchData={fetchData} handleChange={handleChange} searchValue={searchValue} searchFunction={searchFunction} />
<ResultCards lastSearchTitle={lastSearchTitle} searchResult={searchResult}/>
<ResultCards lastSearchTitle={lastSearchTitle} searchResult={searchResult} toobibDataFunction={toobibDataFunction}/>
<Pagination searchResult={searchResult} page={page} handleIndentation={handleIndentation} />
</main>
);
......
......@@ -4,7 +4,7 @@ import {BrowserRouter as Router, Route, Switch, Link, Redirect } from 'react-rou
export default class ResultCards extends Component {
render() {
const { searchResult, lastSearchTitle } = this.props;
const { searchResult, lastSearchTitle, toobibDataFunction } = this.props;
if(!searchResult)
{
return(
......@@ -37,7 +37,7 @@ export default class ResultCards extends Component {
{e.libelleProfession}
<br />
</div>
<Link to={"/toobibPage/" + e.id} className="button is-link is-light has-text-right" value={e.id}>Consulter</Link>
<Link to={"/toobibPage/" + e.id} className="button is-link is-light has-text-right" onClick={toobibDataFunction()} value={e.id}>Consulter</Link>
</div>
</div>
</div>
......
import React, { Component, Suspense } from 'react';
import React, { useEffect, useState } from 'react';
import axios from 'axios';
import Header from './header';
const urlAPI = 'http://www.omdbapi.com/?apikey=9515cda&t='
function ProfileDetails(data) {
const resources = data;
console.log(resources);
function ProfileDetails(resources) {
return (
<div>
<Header />
......@@ -14,17 +12,17 @@ const urlAPI = 'http://www.omdbapi.com/?apikey=9515cda&t='
<div className="IMG_container">
<img className="IMG_container__img--doctor"/>
</div>
<h3 className="toobib_resources__title">{resources.prenom} {resources.nom}</h3>
<h4 className="toobib_resources__position">{resources.libelleProfession}</h4>
<p className="toobib_resources__number">{resources.telephone}</p>
<p className="toobib_resources__email">{resources.email}</p>
<p className="toobib_resources__convention">Conventionnement: {resources.conventionnement}</p>
<h3 className="toobib_resources__title">{resources.data.prenom} {resources.data.nom}</h3>
<h4 className="toobib_resources__position">{resources.data.libelleProfession}</h4>
<p className="toobib_resources__number">{resources.data.telephone}</p>
<p className="toobib_resources__email">{resources.data.email}</p>
<p className="toobib_resources__convention">Conventionnement: {resources.data.conventionnement}</p>
</div>
<br/>
<div className="card location_data">
<h3 className="location_data__title">Adresse</h3>
<p className="location_data__address">Centre de consultations Courlancy</p>
<p className="location_data__address">XX rue TEST TEST, {resources.libelleCommune}</p>
<p className="location_data__address">XX rue TEST TEST, {resources.data.libelleCommune}</p>
<h3 className="location_data__title">Informations supplémentaires</h3>
<p className="location_data__info">TEST TEST INFO SUP</p>
<p className="location_data__info">TEST INFO HANDICAPE</p>
......@@ -39,26 +37,49 @@ const urlAPI = 'http://www.omdbapi.com/?apikey=9515cda&t='
}
export default class ToobibPage extends Component {
state = {
data: null,
id: 'batman' // this.props.match.params.Id
};
const ToobibPage = (props) => {
const [toobibData, setToobibData] = useState(null);
componentDidMount() {
fetch(urlAPI + this.state.id, { header: {'Access-Control-Allow-Origin': '*'}})
.then(data => data.json())
.then(async data => await this.setState({ data }));
const toobibDataFunction = async () => {
try {
const data = await axios
.get('https://annuaire.interhop.org/provider/' + props.match.params.Id)
.then(res => {
console.log(res);
setToobibData(JSON.stringify(res.data));
});
} catch(e) {
console.log(e);
}
}
function stringToJSON(data) {
let result = (data + '').split(',');
let json = {};
result.forEach((item) => {
let pair = item.split(':');
pair[0] = pair[0].split('\"')[1];
if(typeof(pair[1]) === "string")
if(pair[1].split('\"')[0] === '')
pair[1] = pair[1].split('\"')[1];
else
pair[1] = pair[1].split('\"')[0];
json[pair[0]] = pair[1];
});
result = json;
return (result);
}
useEffect(() => {
toobibDataFunction();
}, []);
render() {
return (
<Suspense fallback={<h1>Loading...</h1>}>
<ProfileDetails data={this.state.data} />
</Suspense>
<div>
{toobibData ? <ProfileDetails data={stringToJSON(toobibData)} /> : <progress class="progress is-small is-primary" max="100">15%</progress>}
</div>
);
}
};
export default ToobibPage;
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