🐛 FIX: Bug et améliorations globale

This commit is contained in:
Divlo 2020-04-23 01:08:54 +02:00
parent 032ef566c7
commit 4454f2e089
4 changed files with 15 additions and 4 deletions

View File

@ -23,7 +23,7 @@ function armstrongNumber(number) {
const isArmstrongNumber = (result === number);
return {
isArmstrongNumber,
resultHTML: `<p>${formattedNumber} ${isArmstrongNumber ? "" : "n'"}est pas un nombre d'Armstrong, car ${resultString.slice(2)} = ${formatNumberResult(result)}.</p>`
resultHTML: `<p>${formattedNumber} ${isArmstrongNumber ? "est" : "n'est pas"} un nombre d'Armstrong, car ${resultString.slice(2)} = ${formatNumberResult(result)}.</p>`
}
}

View File

@ -30,7 +30,7 @@ module.exports = convertCurrencyOutput = ({ res, next }, argsObject) => {
const day = ('0'+(dateObject.getDate())).slice(-2);
const month = ('0'+(dateObject.getMonth()+1)).slice(-2);
const date = `${day}/${month}/${year}`;
const resultHTML = `<p>${formatNumberResult(number)} ${response.data.base} = ${formatNumberResult(result).toFixed(2)} ${finalCurrency}</p><p>Dernier rafraîchissement du taux d'échange : ${data}</p>`;
const resultHTML = `<p>${formatNumberResult(number)} ${response.data.base} = ${formatNumberResult(result.toFixed(2))} ${finalCurrency}</p><p>Dernier rafraîchissement du taux d'échange : ${date}</p>`;
return res.status(200).json({ date, result, resultHTML });
})
.catch(() => errorHandling(next, { message: "La devise n'existe pas.", statusCode: 404 }));

View File

@ -124,7 +124,7 @@ function numberUnicodeToText(string) {
const array = string.split(" ");
let resultat = "";
for (let index in array) {
resultat = resultat + String.fromCodePoint(parseInt(array[index]).toString());
resultat += String.fromCodePoint(parseInt(array[index]).toString());
}
return resultat;
}

View File

@ -1,4 +1,4 @@
import { Fragment, useState } from 'react';
import { Fragment, useState, useEffect } from 'react';
import Loader from './Loader';
import htmlParser from 'html-react-parser';
import dynamic from 'next/dynamic';
@ -16,6 +16,17 @@ const FunctionForm = (props) => {
const [message, setMessage] = useState("");
const [isLoading, setIsLoading] = useState(false);
// inputState par défaut
useEffect(() => {
const inputStateNew = { ...inputState };
props.inputsArray.forEach((input) => {
if (input.type === "select" && input.options.length > 0) {
inputStateNew[input.name] = input.options[0].value;
}
});
setInputState(inputStateNew);
}, []);
const handleSubmit = (event) => {
setIsLoading(true);
event.preventDefault();