aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/components/GolfPlayApps
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/app/components/GolfPlayApps')
-rw-r--r--frontend/app/components/GolfPlayApps/GolfPlayAppGaming.tsx27
1 files changed, 24 insertions, 3 deletions
diff --git a/frontend/app/components/GolfPlayApps/GolfPlayAppGaming.tsx b/frontend/app/components/GolfPlayApps/GolfPlayAppGaming.tsx
index 75ab18e..9fddb01 100644
--- a/frontend/app/components/GolfPlayApps/GolfPlayAppGaming.tsx
+++ b/frontend/app/components/GolfPlayApps/GolfPlayAppGaming.tsx
@@ -1,18 +1,30 @@
+import React, { useRef } from "react";
+
type Props = {
problem: string;
onCodeChange: (code: string) => void;
+ onCodeSubmit: (code: string) => void;
currentScore: number | null;
};
export default function GolfPlayAppGaming({
problem,
onCodeChange,
+ onCodeSubmit,
currentScore,
}: Props) {
+ const textareaRef = useRef<HTMLTextAreaElement>(null);
+
const handleTextChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
onCodeChange(e.target.value);
};
+ const handleSubmitButtonClick = () => {
+ if (textareaRef.current) {
+ onCodeSubmit(textareaRef.current.value);
+ }
+ };
+
return (
<div className="min-h-screen flex">
<div className="mx-auto flex min-h-full flex-grow">
@@ -22,16 +34,25 @@ export default function GolfPlayAppGaming({
<div className="text-gray-700">{problem}</div>
</div>
<div className="mb-4 mt-auto">
- <div className="font-semibold text-green-500">
- Score: {currentScore == null ? "-" : `${currentScore}`}
+ <div className="mb-2">
+ <div className="font-semibold text-green-500">
+ Score: {currentScore == null ? "-" : `${currentScore}`}
+ </div>
</div>
+ <button
+ onClick={handleSubmitButtonClick}
+ className="focus:shadow-outline rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700 focus:outline-none"
+ >
+ Submit
+ </button>
</div>
</div>
<div className="w-1/2 p-4 flex">
<div className="flex-grow">
<textarea
- className="h-full w-full rounded-lg border border-gray-300 p-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
+ ref={textareaRef}
onChange={handleTextChange}
+ className="h-full w-full rounded-lg border border-gray-300 p-2 focus:outline-none focus:ring-2 focus:ring-blue-500"
></textarea>
</div>
</div>