Scope of addType function is global

This commit is contained in:
Alexis
2021-03-05 16:05:45 +01:00
parent b6cb9157ed
commit f5af25e0f0
4 changed files with 37 additions and 30 deletions

View File

@@ -0,0 +1,26 @@
export const addCelestialType = (celestial: any) => {
if (celestial.isPlanet) {
if (celestial.moons) {
celestial.type = "planète à lunes";
} else {
celestial.type = "planète";
}
// Check if element is moon
} else if (celestial.aroundPlanet != null) {
celestial.type = "lune";
// Check if element is star
} else if (celestial.id === "soleil") {
celestial.type = "étoile";
// ...else, body is "other"
} else {
celestial.type = "autre";
}
return celestial;
};
export default {
addCelestialType
};