aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/src/routes/golf/play/apps/Gaming.tsx
blob: 27488e371d64b6fb3716a7a916b940f8916912d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import React from 'react';

type Props = {
  gameId: number;
  playerId: number;
  problem: string | null;
  onCodeChange: (data: { code: string }) => void;
  score: number | null;
};

export default ({ problem, onCodeChange, score }: Props) => {
  const handleTextChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
    onCodeChange({ code: e.target.value });
  };

  return (
    <div style={{ display: 'flex' }}>
      <div style={{ flex: 1, padding: '10px', borderRight: '1px solid #ccc' }}>
        <div>
          {problem}
        </div>
        <div>
          {score == null ? 'Score: -' : `Score: ${score} byte`}
        </div>
      </div>
      <div style={{ flex: 1, padding: '10px' }}>
        <textarea
          style={{ width: '100%', height: '100%' }}
          onChange={handleTextChange}
        />
      </div>
    </div>
  );
};