toobibPage.jsx 2.58 KB
Newer Older
CodeDuSoir's avatar
CodeDuSoir committed
1
2
import React, { useEffect, useState } from 'react';
import axios from 'axios';
CodeDuSoir's avatar
CodeDuSoir committed
3
import Header from './header';
CodeDuSoir's avatar
CodeDuSoir committed
4

5

CodeDuSoir's avatar
CodeDuSoir committed
6
	function ProfileDetails(resources) {
7
8
9
10
11
12
13
14
		return (
			<div>
				<Header />
				<div className="container column is-10">
					<div className="card toobib_data">
						<div className="IMG_container">
							<img className="IMG_container__img--doctor"/>
						</div>
CodeDuSoir's avatar
CodeDuSoir committed
15
						<h3 className="subtitle toobib_resources__title">{resources.data.prenom}  {resources.data.nom}</h3>
CodeDuSoir's avatar
CodeDuSoir committed
16
						<h4 className="toobib_resources__position">{resources.data.libelleProfession}</h4>
CodeDuSoir's avatar
CodeDuSoir committed
17
18
19
						<p className="toobib_resources__number">téléphone: {resources.data.telephone}</p>
						<p className="toobib_resources__email">e-mail: {resources.data.email}</p>
						<p className="toobib_resources__convention">Conventionnement: null {resources.data.conventionnement}</p>
20
21
22
					</div>
					<br/>
					<div className="card location_data">
CodeDuSoir's avatar
CodeDuSoir committed
23
24
						<h3 className="subtitle location_data__title">Adresse</h3>
						<p className="location_data__address">NOM DU LIEU</p>
CodeDuSoir's avatar
CodeDuSoir committed
25
						<p className="location_data__address">XX rue TEST TEST, {resources.data.libelleCommune}</p>
CodeDuSoir's avatar
CodeDuSoir committed
26
27
						<br/>
						<h3 className="subtitle location_data__title">Informations supplémentaires</h3>
28
29
						<p className="location_data__info">TEST TEST INFO SUP</p>
						<p className="location_data__info">TEST INFO HANDICAPE</p>
CodeDuSoir's avatar
CodeDuSoir committed
30
						<p className="location_data__info">TEST INFO PARKING </p>
31
32
33
34
35
36
37
38
39
						<div className="MAP_container">
							<img className="MAP_container__map--doctor"/>
						</div>
					</div>
				</div>
			</div>
		)
	}

CodeDuSoir's avatar
CodeDuSoir committed
40

CodeDuSoir's avatar
CodeDuSoir committed
41
42
const ToobibPage = (props) =>  {
	const [toobibData, setToobibData] = useState(null);
CodeDuSoir's avatar
CodeDuSoir committed
43

CodeDuSoir's avatar
CodeDuSoir committed
44
45
46
47
48
49
50
51
52
53
54
	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);
		}
CodeDuSoir's avatar
CodeDuSoir committed
55
	}
CodeDuSoir's avatar
CodeDuSoir committed
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
	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();
	}, []);
77
	
CodeDuSoir's avatar
CodeDuSoir committed
78
		return (
CodeDuSoir's avatar
CodeDuSoir committed
79
80
81
			<div>
				{toobibData ? <ProfileDetails data={stringToJSON(toobibData)} /> : <progress class="progress is-small is-primary" max="100">15%</progress>}
			</div>
82
		);
CodeDuSoir's avatar
CodeDuSoir committed
83
	}
CodeDuSoir's avatar
CodeDuSoir committed
84

CodeDuSoir's avatar
CodeDuSoir committed
85
export default ToobibPage;
CodeDuSoir's avatar
CodeDuSoir committed
86