File size: 6,068 Bytes
89b8989
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import React from 'react';
import { useState } from 'react';
import { PlusIcon } from '@heroicons/react/24/outline';

const exerciseTypes = [
  { id: 'walking', name: 'ζ­₯葌', caloriesPerMinute: 4 },
  { id: 'running', name: 'θ·‘ζ­₯', caloriesPerMinute: 10 },
  { id: 'cycling', name: '騎θ‡ͺ葌車', caloriesPerMinute: 7 },
  { id: 'swimming', name: 'ζΈΈζ³³', caloriesPerMinute: 8 },
  { id: 'yoga', name: 'η‘œδΌ½', caloriesPerMinute: 3 },
  { id: 'weightlifting', name: '重訓', caloriesPerMinute: 6 },
];

export default function ExerciseTracker() {
  const [selectedExercise, setSelectedExercise] = useState('');
  const [duration, setDuration] = useState('');

  const calculateCalories = () => {
    const exercise = exerciseTypes.find(e => e.id === selectedExercise);
    if (exercise && duration) {
      return exercise.caloriesPerMinute * parseInt(duration);
    }
    return 0;
  };

  return (
    <div className="space-y-6">
      <div className="bg-white p-6 rounded-lg shadow">
        <h2 className="text-2xl font-semibold text-gray-800 mb-6">θ¨˜ιŒ„ι‹ε‹•</h2>

        <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
          <div className="space-y-4">
            <div>
              <label htmlFor="exercise-type" className="block text-sm font-medium text-gray-700">
                ι‹ε‹•ι‘žεž‹
              </label>
              <select
                id="exercise-type"
                value={selectedExercise}
                onChange={(e) => setSelectedExercise(e.target.value)}
                className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500"
              >
                <option value="">ιΈζ“‡ι‹ε‹•ι‘žεž‹</option>
                {exerciseTypes.map(type => (
                  <option key={type.id} value={type.id}>{type.name}</option>
                ))}
              </select>
            </div>

            <div>
              <label htmlFor="duration" className="block text-sm font-medium text-gray-700">
                運動時間 (εˆ†ι˜)
              </label>
              <input
                type="number"
                id="duration"
                value={duration}
                onChange={(e) => setDuration(e.target.value)}
                className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500"
                placeholder="0"
                min="0"
              />
            </div>

            {selectedExercise && duration && (
              <div className="p-4 bg-green-50 rounded-md">
                <p className="text-green-700">ι θ¨ˆζΆˆθ€—ε‘θ·―ι‡Œ: {calculateCalories()} kcal</p>
              </div>
            )}

            <button
              type="button"
              className="w-full flex justify-center items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700"
            >
              <PlusIcon className="h-5 w-5 mr-2" />
              ζ–°ε’žθ¨˜ιŒ„
            </button>
          </div>

          <div className="bg-gray-50 p-4 rounded-lg">
            <h3 className="text-lg font-medium text-gray-900 mb-4">ζœ¬ι€±ι‹ε‹•η΅±θ¨ˆ</h3>
            <div className="space-y-4">
              <div>
                <div className="flex justify-between text-sm text-gray-600">
                  <span>總運動時間</span>
                  <span>180 εˆ†ι˜</span>
                </div>
                <div className="w-full bg-gray-200 rounded-full h-2.5 mt-2">
                  <div className="bg-indigo-600 h-2.5 rounded-full" style={{ width: '60%' }}></div>
                </div>
              </div>
              <div>
                <div className="flex justify-between text-sm text-gray-600">
                  <span>ζΆˆθ€—ε‘θ·―ι‡Œ</span>
                  <span>1,200 kcal</span>
                </div>
                <div className="w-full bg-gray-200 rounded-full h-2.5 mt-2">
                  <div className="bg-green-600 h-2.5 rounded-full" style={{ width: '40%' }}></div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      {/* ι‹ε‹•θ¨˜ιŒ„ */}
      <div className="bg-white p-6 rounded-lg shadow">
        <h3 className="text-xl font-semibold text-gray-800 mb-4">ζœ€θΏ‘ηš„ι‹ε‹•θ¨˜ιŒ„</h3>
        <div className="overflow-x-auto">
          <table className="min-w-full divide-y divide-gray-200">
            <thead className="bg-gray-50">
              <tr>
                <th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ζ—₯期</th>
                <th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ι‹ε‹•ι‘žεž‹</th>
                <th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ζ™‚ι–“ (εˆ†ι˜)</th>
                <th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ζΆˆθ€—ε‘θ·―ι‡Œ</th>
              </tr>
            </thead>
            <tbody className="bg-white divide-y divide-gray-200">
              <tr>
                <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">2025-04-21</td>
                <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900">θ·‘ζ­₯</td>
                <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">30</td>
                <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">300</td>
              </tr>
              <tr>
                <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">2025-04-20</td>
                <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900">重訓</td>
                <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">45</td>
                <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">270</td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>
  );
}