import useGame from "@/hook/useGame"; import { RedButton } from "../util/button"; import { useEffect, useRef } from "react"; import Image from "next/image"; import { env } from 'next-runtime-env'; export function EnemyTeamModal({ visible, onClose }) { const { teamId, enemyName } = useGame(); const imageRef = useRef(null); useEffect(() => { if (visible) { refreshImage(); } }, [visible]); function refreshImage() { imageRef.current.src = SERVER_URL + "/photo/enemy?team=" + teamId.toString() + "&t=" + new Date().getTime(); } var protocol = "https://"; const NEXT_PUBLIC_SOCKET_HOST = env("NEXT_PUBLIC_SOCKET_HOST"); if (NEXT_PUBLIC_SOCKET_HOST == "localhost") { protocol = "http://"; } const SERVER_URL = protocol + NEXT_PUBLIC_SOCKET_HOST + "/back"; console.log(SERVER_URL); return (visible && <>