Skip to content
Snippets Groups Projects
Commit 7e751bf9 authored by Ruginosu, M.I. (Ioana, Student B-BIT)'s avatar Ruginosu, M.I. (Ioana, Student B-BIT) :ear_tone1:
Browse files

issue#7 improved

parent f371cd90
Branches update-trainer
No related tags found
No related merge requests found
......@@ -153,6 +153,24 @@ function updatePokemonType() {
let pokedexNumberUpdate = document.getElementById("pokedex").value;
let primaryTypeUpdate = document.getElementById("primary").value;
let secondaryTypeUpdate = document.getElementById("secondary").value;
let time = new Date();
const pt = pokemonTypes?.data?.find(item => item.id === idPokemon);
if(nameUpdate === "") {
nameUpdate = pt.name;
}
if(imgUrlUpdate === "") {
imgUrlUpdate = pt.imgUrl;
}
if(pokedexNumberUpdate === "") {
pokedexNumberUpdate = pt.pokedexNumber;
}
if(primaryTypeUpdate === "") {
primaryTypeUpdate = pt.primaryType;
}
if(secondaryTypeUpdate === "") {
secondaryTypeUpdate = pt.secondaryType;
}
const data = {
id: idPokemon,
......@@ -160,7 +178,9 @@ function updatePokemonType() {
imgUrl: imgUrlUpdate,
pokedexNumber: pokedexNumberUpdate,
primaryType: primaryTypeUpdate,
secondaryType: secondaryTypeUpdate
secondaryType: secondaryTypeUpdate,
lastUpDate: time,
created: pt.created
// Add other fields as needed
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment