From d51e29b462a0e4ffe6870302c69f4480ef254ae3 Mon Sep 17 00:00:00 2001 From: 00magikarp <94652654+00magikarp@users.noreply.github.com> Date: Tue, 4 Mar 2025 20:05:44 -0500 Subject: [PATCH] make image look better --- scoutingapp/src/components/img/RobotImage.tsx | 42 +++++++++++++------ .../src/components/texts/QRCodeModal.tsx | 5 +-- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/scoutingapp/src/components/img/RobotImage.tsx b/scoutingapp/src/components/img/RobotImage.tsx index 2a51051..94b7498 100644 --- a/scoutingapp/src/components/img/RobotImage.tsx +++ b/scoutingapp/src/components/img/RobotImage.tsx @@ -2,9 +2,8 @@ import React, {useEffect, useState} from "react" import { ComponentSetup } from "../interface" export const emptyImage = {`Picture export function RobotImage(props: ComponentSetup) { @@ -14,19 +13,29 @@ export function RobotImage(props: ComponentSetup) { useEffect(() => { const interval = setInterval(() => { if (robotNumber) { - setComponentInside( - {`Image - ) + fileExists(`./src/components/img/${robotNumber}.jpeg`).then((exists) => { + console.log("Exists => ", exists) + if (exists) { + setComponentInside( + + ) + } else { + setComponentInside( + + ) + } + }); } else { setComponentInside( {'Insert ) } @@ -37,4 +46,13 @@ export function RobotImage(props: ComponentSetup) { return (<> {componentInside} ) +} + +async function fileExists(imagePath: string): Promise { + try { + const response = await fetch(imagePath, { method: "HEAD" }); + return response.ok; + } catch { + return false; + } } \ No newline at end of file diff --git a/scoutingapp/src/components/texts/QRCodeModal.tsx b/scoutingapp/src/components/texts/QRCodeModal.tsx index 002394d..81c1c74 100644 --- a/scoutingapp/src/components/texts/QRCodeModal.tsx +++ b/scoutingapp/src/components/texts/QRCodeModal.tsx @@ -9,7 +9,6 @@ export function QRCodeModal(props: ComponentSetup){ */ const addToLocalStorage = function () { - console.log(localStorage.getItem("codes") as string) var currentData = JSON.parse(localStorage.getItem("codes") as string) currentData[props.getValue["MatchKey"].join("")] = props.getValue["export"].text localStorage.setItem("codes", JSON.stringify(currentData)) @@ -19,10 +18,8 @@ export function QRCodeModal(props: ComponentSetup){ const interval = setInterval(() => { var requiredFinished = true - console.log(props.required) for (const id of props.required){ - console.log(props.getValue[id]) - if (["", [], ","].includes(props.getValue[id]) || + if (["", [], ","].includes(props.getValue[id]) || (props.getValue[id][0].length == 2 && (props.getValue[id][0] == "" || props.getValue[id][1] == "") )