import { Link } from "@remix-run/react"; import { useAtomValue } from "jotai"; import React, { useRef } from "react"; import SubmitButton from "../../components/SubmitButton"; import { gamingLeftTimeSecondsAtom, scoreAtom, submitResultAtom, } from "../../states/play"; import type { PlayerProfile } from "../../types/PlayerProfile"; import BorderedContainer from "../BorderedContainer"; import SubmitResult from "../Gaming/SubmitResult"; import UserIcon from "../UserIcon"; type Props = { gameDisplayName: string; playerProfile: PlayerProfile; problemTitle: string; problemDescription: string; initialCode: string; onCodeChange: (code: string) => void; onCodeSubmit: (code: string) => void; }; export default function GolfPlayAppGaming({ gameDisplayName, playerProfile, problemTitle, problemDescription, initialCode, onCodeChange, onCodeSubmit, }: Props) { const leftTimeSeconds = useAtomValue(gamingLeftTimeSecondsAtom)!; const score = useAtomValue(scoreAtom); const submitResult = useAtomValue(submitResultAtom); const textareaRef = useRef(null); const handleTextChange = (e: React.ChangeEvent) => { onCodeChange(e.target.value); }; const handleSubmitButtonClick = () => { if (textareaRef.current) { onCodeSubmit(textareaRef.current.value); } }; const leftTime = (() => { const m = Math.floor(leftTimeSeconds / 60); const s = leftTimeSeconds % 60; return `${m.toString().padStart(2, "0")}:${s.toString().padStart(2, "0")}`; })(); return (
{gameDisplayName}
{leftTime}
{score}
Player 1
{playerProfile.displayName}
{playerProfile.iconPath && ( )}
{problemTitle}
{problemDescription}