fixed network selection (hex string) and icons

This commit is contained in:
hueso
2025-10-11 21:31:53 -03:00
parent a906fa136d
commit 358ae7410f
5 changed files with 12 additions and 10 deletions

View File

@@ -7,17 +7,16 @@ export const imagesPath = import.meta.glob<string>("@/assets/*.{png,svg}", {
});
export const getNetworkImage = (networkName: string): string => {
const imageName = networkName
.toLowerCase()
.replace(/[^a-z0-9]/g, '-');
try {
const path = Object.keys(imagesPath).find((key) =>
key.endsWith(`${networkName.toLowerCase()}.svg`)
key.endsWith(`${imageName}.svg`)
);
return path ? imagesPath[path] : "";
} catch (error) {
console.error("Error fetching network image");
const path = Object.keys(imagesPath).find((key) =>
key.endsWith(`invalidIcon.svg`)
);
return path ? imagesPath[path] : "";
return "";
}
};