Skip to content
This repository has been archived by the owner on Aug 20, 2023. It is now read-only.

Commit

Permalink
Feature/data loader (#6)
Browse files Browse the repository at this point in the history
* remove unwanted css for App logo

* importation des données par fichier JSON

* rendu condition et affichage de 15 elements
  • Loading branch information
KenJoelTL authored Feb 7, 2023
1 parent b7c92dd commit b7dcfef
Show file tree
Hide file tree
Showing 14 changed files with 176 additions and 646 deletions.
38 changes: 0 additions & 38 deletions index.html

This file was deleted.

42 changes: 21 additions & 21 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--

<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Expand All @@ -24,12 +22,13 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
<title>Laboratoire GTI525 - Équipe 01-01</title>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand All @@ -39,5 +38,6 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
</body>

</html>
6 changes: 3 additions & 3 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"short_name": "GTI525 ÉQ01-01",
"name": "Laboratoire GTI525 - Équipe 01-01",
"icons": [
{
"src": "favicon.ico",
Expand All @@ -22,4 +22,4 @@
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
}
34 changes: 1 addition & 33 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,6 @@
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

/* .App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
} */

.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

}
27 changes: 15 additions & 12 deletions src/components/ButtonsSection.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import React, { useState } from 'react'

const ButtonsSection = ({ menuButtons }) => {
const [selectedId, setSelectedId] = useState(null);
const ButtonsSection = ({ menuButtons, selectedId, onClick }) => {
const handleOnClick = (buttonId) => {
onClick(buttonId)
}

return (
<div>
<ul align="left">
<>
<ul>
{menuButtons.map(mButton => (
<li><button type="button"
key={mButton.id}
className={mButton.id === selectedId ? 'selected' : ''}
onClick={() => setSelectedId(mButton.id)}
>{mButton.name}</button></li>
<li key={mButton.id}>
<button type="button"
className={mButton.id === selectedId ? 'selected' : ''}
onClick={() => handleOnClick(mButton.id)}
>{mButton.name}</button>
</li>
))}
</ul>
</div>
);
};
</>
)
}

export default ButtonsSection
22 changes: 7 additions & 15 deletions src/components/CompteurTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import StartEndDatePicker from './StartEndDatePicker'
function CompteurTable(props) {

const compteurList = props.compteurList
const handleSort = (column) => { props.onSort(column) }

const [showDetails, setShowDetails] = React.useState({ show: false, id: -1 })
const [showResults, setShowResults] = React.useState({ show: false, id: -1 })
Expand All @@ -13,20 +14,11 @@ function CompteurTable(props) {
const [startDate, setStartDate] = React.useState(null)
const [endDate, setEndDate] = React.useState(null)

const handleStartDateChange = (date) => {
setStartDate(date)
}

const handleEndDateChange = (date) => {
setEndDate(date)
}

const handleSort = (column) => {
props.onSort(column)
}
const handleStartDateChange = (date) => { setStartDate(date) }
const handleEndDateChange = (date) => { setEndDate(date) }

return (
<div>
<>
<table>
<thead>
<tr>
Expand Down Expand Up @@ -61,8 +53,8 @@ function CompteurTable(props) {
</table>
{showDetails.show && (
<div>
{props.compteurList.filter(compteur => compteur.ID === showDetails.id).map(selectedCompteur => (
<div>
{props.compteurList.filter(compteur => compteur.ID === showDetails.id).map((selectedCompteur, i) => (
<div key={selectedCompteur.ID + "-" + i}>
<h3>Statistiques du compteur: {selectedCompteur.ID}</h3>
<p>Plage de dates</p>
<div>
Expand All @@ -80,7 +72,7 @@ function CompteurTable(props) {
))}
</div>
)}
</div>
</>
)
}

Expand Down
64 changes: 64 additions & 0 deletions src/components/FontaineTable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import React from 'react'
import PropTypes from 'prop-types'

function FontaineTable(props) {

const fontaineList = props.fontaineList
const handleSort = (column) => { props.onSort(column) }

const [showDetails, setShowDetails] = React.useState({ show: false, id: -1 })

return (
<>
<table>
<thead>
<tr>
<th className='clickable left' onClick={() => handleSort('Arrondissement')}>Arrondissement</th>
<th className='clickable left'>Type</th>
<th className='clickable left' onClick={() => handleSort('Nom_parc_lieu')}>Nom du lieu</th>
<th className='clickable left' onClick={() => handleSort('Intersection')}>Adresse</th>
<th></th>
</tr>
</thead>

<tbody>
{
fontaineList.map(fontaine => {
return (
<tr key={fontaine.ID}>
<td className='left'> {fontaine.Arrondissement} </td>
<td className='left'> Fontaine à boire </td>
<td className='left'> {fontaine.Nom_parc_lieu} </td>
<td className='left'> {fontaine.Intersection} </td>
<td className='center'>
<button onClick={() => setShowDetails({ show: true, id: fontaine.ID })}>
IC
</button>
</td>
</tr>)
})
}
</tbody>
</table>
{showDetails.show && (
<div>
{props.fontaineList.filter(fontaine => fontaine.ID === showDetails.id).map((selectedFontaine, i) => (
<div key={selectedFontaine.ID + "-" + i}>
<h3>Point d'intérêt</h3>
<div>
<p>Proximité: {selectedFontaine.Proximité_jeux_repère}</p>
<p>Remarque: {selectedFontaine.Remarque}</p>
</div>
</div>
))}
</div>
)}
</>
)
}

FontaineTable.propTypes = {
fontaineList: PropTypes.array
}

export default FontaineTable
Loading

0 comments on commit b7dcfef

Please sign in to comment.