Fixed ISO-8859 bug
This commit is contained in:
parent
b481f4c4d7
commit
f73a9e8e36
5 changed files with 27 additions and 5 deletions
|
@ -9,6 +9,7 @@
|
||||||
"bootstrap": "^4.4.1",
|
"bootstrap": "^4.4.1",
|
||||||
"eslint-config-prettier": "^6.10.0",
|
"eslint-config-prettier": "^6.10.0",
|
||||||
"eslint-plugin-prettier": "^3.1.2",
|
"eslint-plugin-prettier": "^3.1.2",
|
||||||
|
"iconv-lite": "^0.5.1",
|
||||||
"mapbox-gl": "^1.8.1",
|
"mapbox-gl": "^1.8.1",
|
||||||
"moment": "^2.24.0",
|
"moment": "^2.24.0",
|
||||||
"prop-types": "^15.7.2",
|
"prop-types": "^15.7.2",
|
||||||
|
@ -64,4 +65,4 @@
|
||||||
"husky": "^4.2.3",
|
"husky": "^4.2.3",
|
||||||
"lint-staged": "^10.0.8"
|
"lint-staged": "^10.0.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,6 +2,8 @@ import React from 'react';
|
||||||
import { Modal, Button, ListGroup } from "react-bootstrap";
|
import { Modal, Button, ListGroup } from "react-bootstrap";
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
import { capitalizeFirstLetter} from "../helpers";
|
||||||
|
|
||||||
class GasStation extends React.Component {
|
class GasStation extends React.Component {
|
||||||
renderPrices = () => {
|
renderPrices = () => {
|
||||||
const {
|
const {
|
||||||
|
@ -38,7 +40,7 @@ class GasStation extends React.Component {
|
||||||
>
|
>
|
||||||
<Modal.Header closeButton>
|
<Modal.Header closeButton>
|
||||||
<Modal.Title>
|
<Modal.Title>
|
||||||
{`${selectedGasStation.address} - ${selectedGasStation.city}`}
|
{`${selectedGasStation.address} - ${capitalizeFirstLetter(selectedGasStation.city)}`}
|
||||||
</Modal.Title>
|
</Modal.Title>
|
||||||
</Modal.Header>
|
</Modal.Header>
|
||||||
<Modal.Body>
|
<Modal.Body>
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { Button } from "react-bootstrap";
|
||||||
import XmlReader from 'xml-reader';
|
import XmlReader from 'xml-reader';
|
||||||
import { withToastManager } from 'react-toast-notifications';
|
import { withToastManager } from 'react-toast-notifications';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import iconv from "iconv-lite";
|
||||||
import { haveSelectedGas, extractGasStationFromXml } from '../helpers';
|
import { haveSelectedGas, extractGasStationFromXml } from '../helpers';
|
||||||
|
|
||||||
import 'mapbox-gl/dist/mapbox-gl.css';
|
import 'mapbox-gl/dist/mapbox-gl.css';
|
||||||
|
@ -89,8 +90,11 @@ class Map extends React.Component {
|
||||||
toastManager,
|
toastManager,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
toastManager.add('Chargement de la liste des stations...', { appearance: 'info', autoDismiss: true });
|
||||||
|
|
||||||
fetch('/gasStations.xml')
|
fetch('/gasStations.xml')
|
||||||
.then((response) => response.text())
|
.then(res => res.arrayBuffer())
|
||||||
|
.then(arrayBuffer => iconv.decode(Buffer.from(arrayBuffer), 'iso-8859-1').toString())
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const reader = XmlReader.create();
|
const reader = XmlReader.create();
|
||||||
|
|
||||||
|
@ -110,6 +114,8 @@ class Map extends React.Component {
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
reader.parse(response);
|
reader.parse(response);
|
||||||
|
|
||||||
|
toastManager.add('Liste des stations correctement chargée', { appearance: 'success', autoDismiss: true });
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
toastManager.add('Erreur lors du chargement de la liste des stations', { appearance: 'error', autoDismiss: true });
|
toastManager.add('Erreur lors du chargement de la liste des stations', { appearance: 'error', autoDismiss: true });
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,7 +25,7 @@ export const getPlvInformation = (pdv, name) => {
|
||||||
if (currentChildren.type === 'element' && currentChildren.name === name) {
|
if (currentChildren.type === 'element' && currentChildren.name === name) {
|
||||||
|
|
||||||
if ( currentChildren.children && currentChildren.children.length > 0 ) {
|
if ( currentChildren.children && currentChildren.children.length > 0 ) {
|
||||||
return currentChildren.children[0].value;
|
return currentChildren.children[0].value.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -60,4 +60,10 @@ export const extractGasStationFromXml = (currentPdv ) => {
|
||||||
city: getPlvInformation(currentPdv, 'ville')
|
city: getPlvInformation(currentPdv, 'ville')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const capitalizeFirstLetter = (string) => {
|
||||||
|
if ( !string){
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||||
|
}
|
|
@ -5428,6 +5428,13 @@ iconv-lite@0.4.24, iconv-lite@^0.4.24:
|
||||||
dependencies:
|
dependencies:
|
||||||
safer-buffer ">= 2.1.2 < 3"
|
safer-buffer ">= 2.1.2 < 3"
|
||||||
|
|
||||||
|
iconv-lite@^0.5.1:
|
||||||
|
version "0.5.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.5.1.tgz#b2425d3c7b18f7219f2ca663d103bddb91718d64"
|
||||||
|
integrity sha512-ONHr16SQvKZNSqjQT9gy5z24Jw+uqfO02/ngBSBoqChZ+W8qXX7GPRa1RoUnzGADw8K63R1BXUMzarCVQBpY8Q==
|
||||||
|
dependencies:
|
||||||
|
safer-buffer ">= 2.1.2 < 3"
|
||||||
|
|
||||||
icss-utils@^4.0.0, icss-utils@^4.1.1:
|
icss-utils@^4.0.0, icss-utils@^4.1.1:
|
||||||
version "4.1.1"
|
version "4.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/icss-utils/-/icss-utils-4.1.1.tgz#21170b53789ee27447c2f47dd683081403f9a467"
|
resolved "https://registry.yarnpkg.com/icss-utils/-/icss-utils-4.1.1.tgz#21170b53789ee27447c2f47dd683081403f9a467"
|
||||||
|
|
Loading…
Reference in a new issue