Spaces:
Sleeping
Sleeping
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>
);
}
|