Fixed ISO-8859 bug
This commit is contained in:
parent
b481f4c4d7
commit
f73a9e8e36
5 changed files with 27 additions and 5 deletions
|
@ -2,6 +2,8 @@ import React from 'react';
|
|||
import { Modal, Button, ListGroup } from "react-bootstrap";
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import { capitalizeFirstLetter} from "../helpers";
|
||||
|
||||
class GasStation extends React.Component {
|
||||
renderPrices = () => {
|
||||
const {
|
||||
|
@ -38,7 +40,7 @@ class GasStation extends React.Component {
|
|||
>
|
||||
<Modal.Header closeButton>
|
||||
<Modal.Title>
|
||||
{`${selectedGasStation.address} - ${selectedGasStation.city}`}
|
||||
{`${selectedGasStation.address} - ${capitalizeFirstLetter(selectedGasStation.city)}`}
|
||||
</Modal.Title>
|
||||
</Modal.Header>
|
||||
<Modal.Body>
|
||||
|
|
|
@ -4,6 +4,7 @@ import { Button } from "react-bootstrap";
|
|||
import XmlReader from 'xml-reader';
|
||||
import { withToastManager } from 'react-toast-notifications';
|
||||
import PropTypes from 'prop-types';
|
||||
import iconv from "iconv-lite";
|
||||
import { haveSelectedGas, extractGasStationFromXml } from '../helpers';
|
||||
|
||||
import 'mapbox-gl/dist/mapbox-gl.css';
|
||||
|
@ -89,8 +90,11 @@ class Map extends React.Component {
|
|||
toastManager,
|
||||
} = this.props;
|
||||
|
||||
toastManager.add('Chargement de la liste des stations...', { appearance: 'info', autoDismiss: true });
|
||||
|
||||
fetch('/gasStations.xml')
|
||||
.then((response) => response.text())
|
||||
.then(res => res.arrayBuffer())
|
||||
.then(arrayBuffer => iconv.decode(Buffer.from(arrayBuffer), 'iso-8859-1').toString())
|
||||
.then((response) => {
|
||||
const reader = XmlReader.create();
|
||||
|
||||
|
@ -110,6 +114,8 @@ class Map extends React.Component {
|
|||
}));
|
||||
});
|
||||
reader.parse(response);
|
||||
|
||||
toastManager.add('Liste des stations correctement chargée', { appearance: 'success', autoDismiss: true });
|
||||
}).catch(() => {
|
||||
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.children && currentChildren.children.length > 0 ) {
|
||||
return currentChildren.children[0].value;
|
||||
return currentChildren.children[0].value.toLowerCase();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -60,4 +60,10 @@ export const extractGasStationFromXml = (currentPdv ) => {
|
|||
city: getPlvInformation(currentPdv, 'ville')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const capitalizeFirstLetter = (string) => {
|
||||
if ( !string){
|
||||
return '';
|
||||
}
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue