Unilateral exercises logging
This commit is contained in:
@@ -17,6 +17,7 @@ const ExerciseModal: React.FC<ExerciseModalProps> = ({ isOpen, onClose, onSave,
|
|||||||
const [newName, setNewName] = useState('');
|
const [newName, setNewName] = useState('');
|
||||||
const [newType, setNewType] = useState<ExerciseType>(ExerciseType.STRENGTH);
|
const [newType, setNewType] = useState<ExerciseType>(ExerciseType.STRENGTH);
|
||||||
const [newBwPercentage, setNewBwPercentage] = useState<string>('100');
|
const [newBwPercentage, setNewBwPercentage] = useState<string>('100');
|
||||||
|
const [isUnilateral, setIsUnilateral] = useState(false);
|
||||||
const [error, setError] = useState<string>('');
|
const [error, setError] = useState<string>('');
|
||||||
|
|
||||||
const exerciseTypeLabels: Record<ExerciseType, string> = {
|
const exerciseTypeLabels: Record<ExerciseType, string> = {
|
||||||
@@ -47,12 +48,14 @@ const ExerciseModal: React.FC<ExerciseModalProps> = ({ isOpen, onClose, onSave,
|
|||||||
id: generateId(),
|
id: generateId(),
|
||||||
name: trimmedName,
|
name: trimmedName,
|
||||||
type: newType,
|
type: newType,
|
||||||
|
isUnilateral,
|
||||||
...(newType === ExerciseType.BODYWEIGHT && { bodyWeightPercentage: parseFloat(newBwPercentage) || 100 })
|
...(newType === ExerciseType.BODYWEIGHT && { bodyWeightPercentage: parseFloat(newBwPercentage) || 100 })
|
||||||
};
|
};
|
||||||
await onSave(newEx);
|
await onSave(newEx);
|
||||||
setNewName('');
|
setNewName('');
|
||||||
setNewType(ExerciseType.STRENGTH);
|
setNewType(ExerciseType.STRENGTH);
|
||||||
setNewBwPercentage('100');
|
setNewBwPercentage('100');
|
||||||
|
setIsUnilateral(false);
|
||||||
setError('');
|
setError('');
|
||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
@@ -120,6 +123,19 @@ const ExerciseModal: React.FC<ExerciseModalProps> = ({ isOpen, onClose, onSave,
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<div className="flex items-center gap-3 px-1">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="isUnilateral"
|
||||||
|
checked={isUnilateral}
|
||||||
|
onChange={(e) => setIsUnilateral(e.target.checked)}
|
||||||
|
className="w-5 h-5 rounded border-2 border-outline bg-surface-container-high checked:bg-primary checked:border-primary cursor-pointer"
|
||||||
|
/>
|
||||||
|
<label htmlFor="isUnilateral" className="text-sm text-on-surface cursor-pointer">
|
||||||
|
{t('unilateral_exercise', lang) || 'Unilateral exercise (separate left/right tracking)'}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-end mt-4">
|
<div className="flex justify-end mt-4">
|
||||||
<button
|
<button
|
||||||
onClick={handleCreateExercise}
|
onClick={handleCreateExercise}
|
||||||
|
|||||||
@@ -405,7 +405,10 @@ const Profile: React.FC<ProfileProps> = ({ user, onLogout, lang, onLanguageChang
|
|||||||
<div key={ex.id} className={`p-3 rounded-lg flex justify-between items-center border border-outline-variant/20 ${ex.isArchived ? 'bg-surface-container-low opacity-60' : 'bg-surface-container-high'}`}>
|
<div key={ex.id} className={`p-3 rounded-lg flex justify-between items-center border border-outline-variant/20 ${ex.isArchived ? 'bg-surface-container-low opacity-60' : 'bg-surface-container-high'}`}>
|
||||||
<div className="overflow-hidden mr-2">
|
<div className="overflow-hidden mr-2">
|
||||||
<div className="font-medium text-sm text-on-surface truncate">{ex.name}</div>
|
<div className="font-medium text-sm text-on-surface truncate">{ex.name}</div>
|
||||||
<div className="text-xs text-on-surface-variant">{exerciseTypeLabels[ex.type]}</div>
|
<div className="text-xs text-on-surface-variant">
|
||||||
|
{exerciseTypeLabels[ex.type]}
|
||||||
|
{ex.isUnilateral && `, ${t('unilateral', lang)}`}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-1 shrink-0">
|
<div className="flex items-center gap-1 shrink-0">
|
||||||
<button onClick={() => setEditingExercise(ex)} className="p-2 text-on-surface-variant hover:text-primary hover:bg-white/5 rounded-full">
|
<button onClick={() => setEditingExercise(ex)} className="p-2 text-on-surface-variant hover:text-primary hover:bg-white/5 rounded-full">
|
||||||
|
|||||||
@@ -227,6 +227,132 @@ const ActiveSessionView: React.FC<ActiveSessionViewProps> = ({ tracker, activeSe
|
|||||||
|
|
||||||
{selectedExercise && (
|
{selectedExercise && (
|
||||||
<div className="animate-in fade-in slide-in-from-bottom-4 duration-300 space-y-6">
|
<div className="animate-in fade-in slide-in-from-bottom-4 duration-300 space-y-6">
|
||||||
|
{/* Unilateral Exercise Toggle */}
|
||||||
|
{selectedExercise.isUnilateral && (
|
||||||
|
<div className="flex items-center gap-3 px-2 py-3 bg-surface-container rounded-xl">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="sameValuesBothSides"
|
||||||
|
checked={tracker.sameValuesBothSides}
|
||||||
|
onChange={(e) => tracker.handleToggleSameValues(e.target.checked)}
|
||||||
|
className="w-5 h-5 rounded border-2 border-outline bg-surface-container-high checked:bg-primary checked:border-primary cursor-pointer"
|
||||||
|
/>
|
||||||
|
<label htmlFor="sameValuesBothSides" className="text-sm text-on-surface cursor-pointer flex-1">
|
||||||
|
{t('same_values_both_sides', lang)}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Input Forms */}
|
||||||
|
{selectedExercise.isUnilateral && !tracker.sameValuesBothSides ? (
|
||||||
|
/* Separate Left/Right Inputs */
|
||||||
|
<div className="space-y-4">
|
||||||
|
{/* Left Side */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="text-sm font-medium text-primary flex items-center gap-2 px-2">
|
||||||
|
<span className="w-6 h-6 rounded-full bg-primary-container text-on-primary-container flex items-center justify-center text-xs font-bold">L</span>
|
||||||
|
{t('left', lang)}
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-2 gap-4">
|
||||||
|
{(selectedExercise.type === ExerciseType.STRENGTH || selectedExercise.type === ExerciseType.BODYWEIGHT || selectedExercise.type === ExerciseType.STATIC) && (
|
||||||
|
<FilledInput
|
||||||
|
label={selectedExercise.type === ExerciseType.BODYWEIGHT ? t('add_weight', lang) : t('weight_kg', lang)}
|
||||||
|
value={tracker.weightLeft}
|
||||||
|
step="0.1"
|
||||||
|
onChange={(e: any) => tracker.setWeightLeft(e.target.value)}
|
||||||
|
icon={<Scale size={10} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{(selectedExercise.type === ExerciseType.STRENGTH || selectedExercise.type === ExerciseType.BODYWEIGHT || selectedExercise.type === ExerciseType.PLYOMETRIC) && (
|
||||||
|
<FilledInput
|
||||||
|
label={t('reps', lang)}
|
||||||
|
value={tracker.repsLeft}
|
||||||
|
onChange={(e: any) => tracker.setRepsLeft(e.target.value)}
|
||||||
|
icon={<Activity size={10} />}
|
||||||
|
type="number"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{(selectedExercise.type === ExerciseType.CARDIO || selectedExercise.type === ExerciseType.STATIC) && (
|
||||||
|
<FilledInput
|
||||||
|
label={t('time_sec', lang)}
|
||||||
|
value={tracker.durationLeft}
|
||||||
|
onChange={(e: any) => tracker.setDurationLeft(e.target.value)}
|
||||||
|
icon={<TimerIcon size={10} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{(selectedExercise.type === ExerciseType.CARDIO || selectedExercise.type === ExerciseType.LONG_JUMP) && (
|
||||||
|
<FilledInput
|
||||||
|
label={t('dist_m', lang)}
|
||||||
|
value={tracker.distanceLeft}
|
||||||
|
onChange={(e: any) => tracker.setDistanceLeft(e.target.value)}
|
||||||
|
icon={<ArrowRight size={10} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{(selectedExercise.type === ExerciseType.HIGH_JUMP) && (
|
||||||
|
<FilledInput
|
||||||
|
label={t('height_cm', lang)}
|
||||||
|
value={tracker.heightLeft}
|
||||||
|
onChange={(e: any) => tracker.setHeightLeft(e.target.value)}
|
||||||
|
icon={<ArrowUp size={10} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Right Side */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="text-sm font-medium text-secondary flex items-center gap-2 px-2">
|
||||||
|
<span className="w-6 h-6 rounded-full bg-secondary-container text-on-secondary-container flex items-center justify-center text-xs font-bold">R</span>
|
||||||
|
{t('right', lang)}
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-2 gap-4">
|
||||||
|
{(selectedExercise.type === ExerciseType.STRENGTH || selectedExercise.type === ExerciseType.BODYWEIGHT || selectedExercise.type === ExerciseType.STATIC) && (
|
||||||
|
<FilledInput
|
||||||
|
label={selectedExercise.type === ExerciseType.BODYWEIGHT ? t('add_weight', lang) : t('weight_kg', lang)}
|
||||||
|
value={tracker.weightRight}
|
||||||
|
step="0.1"
|
||||||
|
onChange={(e: any) => tracker.setWeightRight(e.target.value)}
|
||||||
|
icon={<Scale size={10} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{(selectedExercise.type === ExerciseType.STRENGTH || selectedExercise.type === ExerciseType.BODYWEIGHT || selectedExercise.type === ExerciseType.PLYOMETRIC) && (
|
||||||
|
<FilledInput
|
||||||
|
label={t('reps', lang)}
|
||||||
|
value={tracker.repsRight}
|
||||||
|
onChange={(e: any) => tracker.setRepsRight(e.target.value)}
|
||||||
|
icon={<Activity size={10} />}
|
||||||
|
type="number"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{(selectedExercise.type === ExerciseType.CARDIO || selectedExercise.type === ExerciseType.STATIC) && (
|
||||||
|
<FilledInput
|
||||||
|
label={t('time_sec', lang)}
|
||||||
|
value={tracker.durationRight}
|
||||||
|
onChange={(e: any) => tracker.setDurationRight(e.target.value)}
|
||||||
|
icon={<TimerIcon size={10} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{(selectedExercise.type === ExerciseType.CARDIO || selectedExercise.type === ExerciseType.LONG_JUMP) && (
|
||||||
|
<FilledInput
|
||||||
|
label={t('dist_m', lang)}
|
||||||
|
value={tracker.distanceRight}
|
||||||
|
onChange={(e: any) => tracker.setDistanceRight(e.target.value)}
|
||||||
|
icon={<ArrowRight size={10} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{(selectedExercise.type === ExerciseType.HIGH_JUMP) && (
|
||||||
|
<FilledInput
|
||||||
|
label={t('height_cm', lang)}
|
||||||
|
value={tracker.heightRight}
|
||||||
|
onChange={(e: any) => tracker.setHeightRight(e.target.value)}
|
||||||
|
icon={<ArrowUp size={10} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
/* Single Input Form (for bilateral or unilateral with same values) */
|
||||||
<div className="grid grid-cols-2 gap-4">
|
<div className="grid grid-cols-2 gap-4">
|
||||||
{(selectedExercise.type === ExerciseType.STRENGTH || selectedExercise.type === ExerciseType.BODYWEIGHT || selectedExercise.type === ExerciseType.STATIC) && (
|
{(selectedExercise.type === ExerciseType.STRENGTH || selectedExercise.type === ExerciseType.BODYWEIGHT || selectedExercise.type === ExerciseType.STATIC) && (
|
||||||
<FilledInput
|
<FilledInput
|
||||||
@@ -272,6 +398,7 @@ const ActiveSessionView: React.FC<ActiveSessionViewProps> = ({ tracker, activeSe
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={handleAddSet}
|
onClick={handleAddSet}
|
||||||
|
|||||||
@@ -143,6 +143,132 @@ const SporadicView: React.FC<SporadicViewProps> = ({ tracker, lang, sporadicSets
|
|||||||
|
|
||||||
{selectedExercise && (
|
{selectedExercise && (
|
||||||
<div className="animate-in fade-in slide-in-from-bottom-4 duration-300 space-y-6">
|
<div className="animate-in fade-in slide-in-from-bottom-4 duration-300 space-y-6">
|
||||||
|
{/* Unilateral Exercise Toggle */}
|
||||||
|
{selectedExercise.isUnilateral && (
|
||||||
|
<div className="flex items-center gap-3 px-2 py-3 bg-surface-container rounded-xl">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="sameValuesBothSidesSporadic"
|
||||||
|
checked={tracker.sameValuesBothSides}
|
||||||
|
onChange={(e) => tracker.handleToggleSameValues(e.target.checked)}
|
||||||
|
className="w-5 h-5 rounded border-2 border-outline bg-surface-container-high checked:bg-primary checked:border-primary cursor-pointer"
|
||||||
|
/>
|
||||||
|
<label htmlFor="sameValuesBothSidesSporadic" className="text-sm text-on-surface cursor-pointer flex-1">
|
||||||
|
{t('same_values_both_sides', lang)}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Input Forms */}
|
||||||
|
{selectedExercise.isUnilateral && !tracker.sameValuesBothSides ? (
|
||||||
|
/* Separate Left/Right Inputs */
|
||||||
|
<div className="space-y-4">
|
||||||
|
{/* Left Side */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="text-sm font-medium text-primary flex items-center gap-2 px-2">
|
||||||
|
<span className="w-6 h-6 rounded-full bg-primary-container text-on-primary-container flex items-center justify-center text-xs font-bold">L</span>
|
||||||
|
{t('left', lang)}
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-2 gap-4">
|
||||||
|
{(selectedExercise.type === ExerciseType.STRENGTH || selectedExercise.type === ExerciseType.BODYWEIGHT || selectedExercise.type === ExerciseType.STATIC) && (
|
||||||
|
<FilledInput
|
||||||
|
label={selectedExercise.type === ExerciseType.BODYWEIGHT ? t('add_weight', lang) : t('weight_kg', lang)}
|
||||||
|
value={tracker.weightLeft}
|
||||||
|
step="0.1"
|
||||||
|
onChange={(e: any) => tracker.setWeightLeft(e.target.value)}
|
||||||
|
icon={<Scale size={10} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{(selectedExercise.type === ExerciseType.STRENGTH || selectedExercise.type === ExerciseType.BODYWEIGHT || selectedExercise.type === ExerciseType.PLYOMETRIC) && (
|
||||||
|
<FilledInput
|
||||||
|
label={t('reps', lang)}
|
||||||
|
value={tracker.repsLeft}
|
||||||
|
onChange={(e: any) => tracker.setRepsLeft(e.target.value)}
|
||||||
|
icon={<Activity size={10} />}
|
||||||
|
type="number"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{(selectedExercise.type === ExerciseType.CARDIO || selectedExercise.type === ExerciseType.STATIC) && (
|
||||||
|
<FilledInput
|
||||||
|
label={t('time_sec', lang)}
|
||||||
|
value={tracker.durationLeft}
|
||||||
|
onChange={(e: any) => tracker.setDurationLeft(e.target.value)}
|
||||||
|
icon={<TimerIcon size={10} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{(selectedExercise.type === ExerciseType.CARDIO || selectedExercise.type === ExerciseType.LONG_JUMP) && (
|
||||||
|
<FilledInput
|
||||||
|
label={t('dist_m', lang)}
|
||||||
|
value={tracker.distanceLeft}
|
||||||
|
onChange={(e: any) => tracker.setDistanceLeft(e.target.value)}
|
||||||
|
icon={<ArrowRight size={10} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{(selectedExercise.type === ExerciseType.HIGH_JUMP) && (
|
||||||
|
<FilledInput
|
||||||
|
label={t('height_cm', lang)}
|
||||||
|
value={tracker.heightLeft}
|
||||||
|
onChange={(e: any) => tracker.setHeightLeft(e.target.value)}
|
||||||
|
icon={<ArrowUp size={10} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Right Side */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<div className="text-sm font-medium text-secondary flex items-center gap-2 px-2">
|
||||||
|
<span className="w-6 h-6 rounded-full bg-secondary-container text-on-secondary-container flex items-center justify-center text-xs font-bold">R</span>
|
||||||
|
{t('right', lang)}
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-2 gap-4">
|
||||||
|
{(selectedExercise.type === ExerciseType.STRENGTH || selectedExercise.type === ExerciseType.BODYWEIGHT || selectedExercise.type === ExerciseType.STATIC) && (
|
||||||
|
<FilledInput
|
||||||
|
label={selectedExercise.type === ExerciseType.BODYWEIGHT ? t('add_weight', lang) : t('weight_kg', lang)}
|
||||||
|
value={tracker.weightRight}
|
||||||
|
step="0.1"
|
||||||
|
onChange={(e: any) => tracker.setWeightRight(e.target.value)}
|
||||||
|
icon={<Scale size={10} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{(selectedExercise.type === ExerciseType.STRENGTH || selectedExercise.type === ExerciseType.BODYWEIGHT || selectedExercise.type === ExerciseType.PLYOMETRIC) && (
|
||||||
|
<FilledInput
|
||||||
|
label={t('reps', lang)}
|
||||||
|
value={tracker.repsRight}
|
||||||
|
onChange={(e: any) => tracker.setRepsRight(e.target.value)}
|
||||||
|
icon={<Activity size={10} />}
|
||||||
|
type="number"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{(selectedExercise.type === ExerciseType.CARDIO || selectedExercise.type === ExerciseType.STATIC) && (
|
||||||
|
<FilledInput
|
||||||
|
label={t('time_sec', lang)}
|
||||||
|
value={tracker.durationRight}
|
||||||
|
onChange={(e: any) => tracker.setDurationRight(e.target.value)}
|
||||||
|
icon={<TimerIcon size={10} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{(selectedExercise.type === ExerciseType.CARDIO || selectedExercise.type === ExerciseType.LONG_JUMP) && (
|
||||||
|
<FilledInput
|
||||||
|
label={t('dist_m', lang)}
|
||||||
|
value={tracker.distanceRight}
|
||||||
|
onChange={(e: any) => tracker.setDistanceRight(e.target.value)}
|
||||||
|
icon={<ArrowRight size={10} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{(selectedExercise.type === ExerciseType.HIGH_JUMP) && (
|
||||||
|
<FilledInput
|
||||||
|
label={t('height_cm', lang)}
|
||||||
|
value={tracker.heightRight}
|
||||||
|
onChange={(e: any) => tracker.setHeightRight(e.target.value)}
|
||||||
|
icon={<ArrowUp size={10} />}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
/* Single Input Form (for bilateral or unilateral with same values) */
|
||||||
<div className="grid grid-cols-2 gap-4">
|
<div className="grid grid-cols-2 gap-4">
|
||||||
{(selectedExercise.type === ExerciseType.STRENGTH || selectedExercise.type === ExerciseType.BODYWEIGHT || selectedExercise.type === ExerciseType.STATIC) && (
|
{(selectedExercise.type === ExerciseType.STRENGTH || selectedExercise.type === ExerciseType.BODYWEIGHT || selectedExercise.type === ExerciseType.STATIC) && (
|
||||||
<FilledInput
|
<FilledInput
|
||||||
@@ -187,6 +313,7 @@ const SporadicView: React.FC<SporadicViewProps> = ({ tracker, lang, sporadicSets
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={handleLogSporadicSet}
|
onClick={handleLogSporadicSet}
|
||||||
|
|||||||
@@ -77,6 +77,36 @@ export const useTracker = ({
|
|||||||
const [isSporadicMode, setIsSporadicMode] = useState(false);
|
const [isSporadicMode, setIsSporadicMode] = useState(false);
|
||||||
const [sporadicSuccess, setSporadicSuccess] = useState(false);
|
const [sporadicSuccess, setSporadicSuccess] = useState(false);
|
||||||
|
|
||||||
|
// Unilateral Exercise State
|
||||||
|
const [sameValuesBothSides, setSameValuesBothSides] = useState(true);
|
||||||
|
const [weightLeft, setWeightLeft] = useState<string>('');
|
||||||
|
const [weightRight, setWeightRight] = useState<string>('');
|
||||||
|
const [repsLeft, setRepsLeft] = useState<string>('');
|
||||||
|
const [repsRight, setRepsRight] = useState<string>('');
|
||||||
|
const [durationLeft, setDurationLeft] = useState<string>('');
|
||||||
|
const [durationRight, setDurationRight] = useState<string>('');
|
||||||
|
const [distanceLeft, setDistanceLeft] = useState<string>('');
|
||||||
|
const [distanceRight, setDistanceRight] = useState<string>('');
|
||||||
|
const [heightLeft, setHeightLeft] = useState<string>('');
|
||||||
|
const [heightRight, setHeightRight] = useState<string>('');
|
||||||
|
|
||||||
|
const handleToggleSameValues = (checked: boolean) => {
|
||||||
|
setSameValuesBothSides(checked);
|
||||||
|
if (!checked) {
|
||||||
|
// Propagate values from single fields to left/right fields
|
||||||
|
setWeightLeft(weight);
|
||||||
|
setWeightRight(weight);
|
||||||
|
setRepsLeft(reps);
|
||||||
|
setRepsRight(reps);
|
||||||
|
setDurationLeft(duration);
|
||||||
|
setDurationRight(duration);
|
||||||
|
setDistanceLeft(distance);
|
||||||
|
setDistanceRight(distance);
|
||||||
|
setHeightLeft(height);
|
||||||
|
setHeightRight(height);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const exList = await getExercises(userId);
|
const exList = await getExercises(userId);
|
||||||
@@ -216,6 +246,128 @@ export const useTracker = ({
|
|||||||
const handleAddSet = async () => {
|
const handleAddSet = async () => {
|
||||||
if (!activeSession || !selectedExercise) return;
|
if (!activeSession || !selectedExercise) return;
|
||||||
|
|
||||||
|
// For unilateral exercises, create two sets (LEFT and RIGHT)
|
||||||
|
if (selectedExercise.isUnilateral) {
|
||||||
|
const setsToCreate: Array<Partial<WorkoutSet> & { side: 'LEFT' | 'RIGHT' }> = [];
|
||||||
|
|
||||||
|
if (sameValuesBothSides) {
|
||||||
|
// Create two identical sets with LEFT and RIGHT sides
|
||||||
|
const setData: Partial<WorkoutSet> = {
|
||||||
|
exerciseId: selectedExercise.id,
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (selectedExercise.type) {
|
||||||
|
case ExerciseType.STRENGTH:
|
||||||
|
if (weight) setData.weight = parseFloat(weight);
|
||||||
|
if (reps) setData.reps = parseInt(reps);
|
||||||
|
break;
|
||||||
|
case ExerciseType.BODYWEIGHT:
|
||||||
|
if (weight) setData.weight = parseFloat(weight);
|
||||||
|
if (reps) setData.reps = parseInt(reps);
|
||||||
|
setData.bodyWeightPercentage = parseFloat(bwPercentage) || 100;
|
||||||
|
break;
|
||||||
|
case ExerciseType.CARDIO:
|
||||||
|
if (duration) setData.durationSeconds = parseInt(duration);
|
||||||
|
if (distance) setData.distanceMeters = parseFloat(distance);
|
||||||
|
break;
|
||||||
|
case ExerciseType.STATIC:
|
||||||
|
if (duration) setData.durationSeconds = parseInt(duration);
|
||||||
|
setData.bodyWeightPercentage = parseFloat(bwPercentage) || 100;
|
||||||
|
break;
|
||||||
|
case ExerciseType.HIGH_JUMP:
|
||||||
|
if (height) setData.height = parseFloat(height);
|
||||||
|
break;
|
||||||
|
case ExerciseType.LONG_JUMP:
|
||||||
|
if (distance) setData.distanceMeters = parseFloat(distance);
|
||||||
|
break;
|
||||||
|
case ExerciseType.PLYOMETRIC:
|
||||||
|
if (reps) setData.reps = parseInt(reps);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
setsToCreate.push({ ...setData, side: 'LEFT' });
|
||||||
|
setsToCreate.push({ ...setData, side: 'RIGHT' });
|
||||||
|
} else {
|
||||||
|
// Create separate sets for LEFT and RIGHT with different values
|
||||||
|
const leftSetData: Partial<WorkoutSet> = {
|
||||||
|
exerciseId: selectedExercise.id,
|
||||||
|
};
|
||||||
|
const rightSetData: Partial<WorkoutSet> = {
|
||||||
|
exerciseId: selectedExercise.id,
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (selectedExercise.type) {
|
||||||
|
case ExerciseType.STRENGTH:
|
||||||
|
if (weightLeft) leftSetData.weight = parseFloat(weightLeft);
|
||||||
|
if (repsLeft) leftSetData.reps = parseInt(repsLeft);
|
||||||
|
if (weightRight) rightSetData.weight = parseFloat(weightRight);
|
||||||
|
if (repsRight) rightSetData.reps = parseInt(repsRight);
|
||||||
|
break;
|
||||||
|
case ExerciseType.BODYWEIGHT:
|
||||||
|
if (weightLeft) leftSetData.weight = parseFloat(weightLeft);
|
||||||
|
if (repsLeft) leftSetData.reps = parseInt(repsLeft);
|
||||||
|
leftSetData.bodyWeightPercentage = parseFloat(bwPercentage) || 100;
|
||||||
|
if (weightRight) rightSetData.weight = parseFloat(weightRight);
|
||||||
|
if (repsRight) rightSetData.reps = parseInt(repsRight);
|
||||||
|
rightSetData.bodyWeightPercentage = parseFloat(bwPercentage) || 100;
|
||||||
|
break;
|
||||||
|
case ExerciseType.CARDIO:
|
||||||
|
if (durationLeft) leftSetData.durationSeconds = parseInt(durationLeft);
|
||||||
|
if (distanceLeft) leftSetData.distanceMeters = parseFloat(distanceLeft);
|
||||||
|
if (durationRight) rightSetData.durationSeconds = parseInt(durationRight);
|
||||||
|
if (distanceRight) rightSetData.distanceMeters = parseFloat(distanceRight);
|
||||||
|
break;
|
||||||
|
case ExerciseType.STATIC:
|
||||||
|
if (durationLeft) leftSetData.durationSeconds = parseInt(durationLeft);
|
||||||
|
leftSetData.bodyWeightPercentage = parseFloat(bwPercentage) || 100;
|
||||||
|
if (durationRight) rightSetData.durationSeconds = parseInt(durationRight);
|
||||||
|
rightSetData.bodyWeightPercentage = parseFloat(bwPercentage) || 100;
|
||||||
|
break;
|
||||||
|
case ExerciseType.HIGH_JUMP:
|
||||||
|
if (heightLeft) leftSetData.height = parseFloat(heightLeft);
|
||||||
|
if (heightRight) rightSetData.height = parseFloat(heightRight);
|
||||||
|
break;
|
||||||
|
case ExerciseType.LONG_JUMP:
|
||||||
|
if (distanceLeft) leftSetData.distanceMeters = parseFloat(distanceLeft);
|
||||||
|
if (distanceRight) rightSetData.distanceMeters = parseFloat(distanceRight);
|
||||||
|
break;
|
||||||
|
case ExerciseType.PLYOMETRIC:
|
||||||
|
if (repsLeft) leftSetData.reps = parseInt(repsLeft);
|
||||||
|
if (repsRight) rightSetData.reps = parseInt(repsRight);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
setsToCreate.push({ ...leftSetData, side: 'LEFT' });
|
||||||
|
setsToCreate.push({ ...rightSetData, side: 'RIGHT' });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log both sets
|
||||||
|
try {
|
||||||
|
for (const setData of setsToCreate) {
|
||||||
|
const response = await api.post('/sessions/active/log-set', setData);
|
||||||
|
if (response.success) {
|
||||||
|
const { newSet } = response;
|
||||||
|
onSetAdded(newSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update plan progress after logging both sets
|
||||||
|
if (activePlan) {
|
||||||
|
const response = await api.post('/sessions/active/log-set', { exerciseId: selectedExercise.id });
|
||||||
|
if (response.success && response.activeExerciseId) {
|
||||||
|
const nextStepIndex = activePlan.steps.findIndex(step => step.exerciseId === response.activeExerciseId);
|
||||||
|
if (nextStepIndex !== -1) {
|
||||||
|
setCurrentStepIndex(nextStepIndex);
|
||||||
|
}
|
||||||
|
} else if (response.success && !response.activeExerciseId) {
|
||||||
|
setCurrentStepIndex(activePlan.steps.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to log unilateral sets:", error);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Regular bilateral exercise - single set
|
||||||
const setData: Partial<WorkoutSet> = {
|
const setData: Partial<WorkoutSet> = {
|
||||||
exerciseId: selectedExercise.id,
|
exerciseId: selectedExercise.id,
|
||||||
};
|
};
|
||||||
@@ -268,11 +420,139 @@ export const useTracker = ({
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to log set:", error);
|
console.error("Failed to log set:", error);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleLogSporadicSet = async () => {
|
const handleLogSporadicSet = async () => {
|
||||||
if (!selectedExercise) return;
|
if (!selectedExercise) return;
|
||||||
|
|
||||||
|
// For unilateral exercises, create two sets (LEFT and RIGHT)
|
||||||
|
if (selectedExercise.isUnilateral) {
|
||||||
|
const setsToCreate: any[] = [];
|
||||||
|
|
||||||
|
if (sameValuesBothSides) {
|
||||||
|
// Create two identical sets with LEFT and RIGHT sides
|
||||||
|
const set: any = {
|
||||||
|
exerciseId: selectedExercise.id,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (selectedExercise.type) {
|
||||||
|
case ExerciseType.STRENGTH:
|
||||||
|
if (weight) set.weight = parseFloat(weight);
|
||||||
|
if (reps) set.reps = parseInt(reps);
|
||||||
|
break;
|
||||||
|
case ExerciseType.BODYWEIGHT:
|
||||||
|
if (weight) set.weight = parseFloat(weight);
|
||||||
|
if (reps) set.reps = parseInt(reps);
|
||||||
|
set.bodyWeightPercentage = parseFloat(bwPercentage) || 100;
|
||||||
|
break;
|
||||||
|
case ExerciseType.CARDIO:
|
||||||
|
if (duration) set.durationSeconds = parseInt(duration);
|
||||||
|
if (distance) set.distanceMeters = parseFloat(distance);
|
||||||
|
break;
|
||||||
|
case ExerciseType.STATIC:
|
||||||
|
if (duration) set.durationSeconds = parseInt(duration);
|
||||||
|
set.bodyWeightPercentage = parseFloat(bwPercentage) || 100;
|
||||||
|
break;
|
||||||
|
case ExerciseType.HIGH_JUMP:
|
||||||
|
if (height) set.height = parseFloat(height);
|
||||||
|
break;
|
||||||
|
case ExerciseType.LONG_JUMP:
|
||||||
|
if (distance) set.distanceMeters = parseFloat(distance);
|
||||||
|
break;
|
||||||
|
case ExerciseType.PLYOMETRIC:
|
||||||
|
if (reps) set.reps = parseInt(reps);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
setsToCreate.push({ ...set, side: 'LEFT' });
|
||||||
|
setsToCreate.push({ ...set, side: 'RIGHT' });
|
||||||
|
} else {
|
||||||
|
// Create separate sets for LEFT and RIGHT with different values
|
||||||
|
const leftSet: any = {
|
||||||
|
exerciseId: selectedExercise.id,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
};
|
||||||
|
const rightSet: any = {
|
||||||
|
exerciseId: selectedExercise.id,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (selectedExercise.type) {
|
||||||
|
case ExerciseType.STRENGTH:
|
||||||
|
if (weightLeft) leftSet.weight = parseFloat(weightLeft);
|
||||||
|
if (repsLeft) leftSet.reps = parseInt(repsLeft);
|
||||||
|
if (weightRight) rightSet.weight = parseFloat(weightRight);
|
||||||
|
if (repsRight) rightSet.reps = parseInt(repsRight);
|
||||||
|
break;
|
||||||
|
case ExerciseType.BODYWEIGHT:
|
||||||
|
if (weightLeft) leftSet.weight = parseFloat(weightLeft);
|
||||||
|
if (repsLeft) leftSet.reps = parseInt(repsLeft);
|
||||||
|
leftSet.bodyWeightPercentage = parseFloat(bwPercentage) || 100;
|
||||||
|
if (weightRight) rightSet.weight = parseFloat(weightRight);
|
||||||
|
if (repsRight) rightSet.reps = parseInt(repsRight);
|
||||||
|
rightSet.bodyWeightPercentage = parseFloat(bwPercentage) || 100;
|
||||||
|
break;
|
||||||
|
case ExerciseType.CARDIO:
|
||||||
|
if (durationLeft) leftSet.durationSeconds = parseInt(durationLeft);
|
||||||
|
if (distanceLeft) leftSet.distanceMeters = parseFloat(distanceLeft);
|
||||||
|
if (durationRight) rightSet.durationSeconds = parseInt(durationRight);
|
||||||
|
if (distanceRight) rightSet.distanceMeters = parseFloat(distanceRight);
|
||||||
|
break;
|
||||||
|
case ExerciseType.STATIC:
|
||||||
|
if (durationLeft) leftSet.durationSeconds = parseInt(durationLeft);
|
||||||
|
leftSet.bodyWeightPercentage = parseFloat(bwPercentage) || 100;
|
||||||
|
if (durationRight) rightSet.durationSeconds = parseInt(durationRight);
|
||||||
|
rightSet.bodyWeightPercentage = parseFloat(bwPercentage) || 100;
|
||||||
|
break;
|
||||||
|
case ExerciseType.HIGH_JUMP:
|
||||||
|
if (heightLeft) leftSet.height = parseFloat(heightLeft);
|
||||||
|
if (heightRight) rightSet.height = parseFloat(heightRight);
|
||||||
|
break;
|
||||||
|
case ExerciseType.LONG_JUMP:
|
||||||
|
if (distanceLeft) leftSet.distanceMeters = parseFloat(distanceLeft);
|
||||||
|
if (distanceRight) rightSet.distanceMeters = parseFloat(distanceRight);
|
||||||
|
break;
|
||||||
|
case ExerciseType.PLYOMETRIC:
|
||||||
|
if (repsLeft) leftSet.reps = parseInt(repsLeft);
|
||||||
|
if (repsRight) rightSet.reps = parseInt(repsRight);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
setsToCreate.push({ ...leftSet, side: 'LEFT' });
|
||||||
|
setsToCreate.push({ ...rightSet, side: 'RIGHT' });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log both sets
|
||||||
|
try {
|
||||||
|
for (const set of setsToCreate) {
|
||||||
|
await logSporadicSet(set);
|
||||||
|
}
|
||||||
|
setSporadicSuccess(true);
|
||||||
|
setTimeout(() => setSporadicSuccess(false), 2000);
|
||||||
|
// Reset form
|
||||||
|
setWeight('');
|
||||||
|
setReps('');
|
||||||
|
setDuration('');
|
||||||
|
setDistance('');
|
||||||
|
setHeight('');
|
||||||
|
setWeightLeft('');
|
||||||
|
setWeightRight('');
|
||||||
|
setRepsLeft('');
|
||||||
|
setRepsRight('');
|
||||||
|
setDurationLeft('');
|
||||||
|
setDurationRight('');
|
||||||
|
setDistanceLeft('');
|
||||||
|
setDistanceRight('');
|
||||||
|
setHeightLeft('');
|
||||||
|
setHeightRight('');
|
||||||
|
if (onSporadicSetAdded) onSporadicSetAdded();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to log unilateral sporadic sets:", error);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Regular bilateral exercise - single set
|
||||||
const set: any = {
|
const set: any = {
|
||||||
exerciseId: selectedExercise.id,
|
exerciseId: selectedExercise.id,
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
@@ -323,6 +603,7 @@ export const useTracker = ({
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to log sporadic set:", error);
|
console.error("Failed to log sporadic set:", error);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCreateExercise = async (newEx: ExerciseDef) => {
|
const handleCreateExercise = async (newEx: ExerciseDef) => {
|
||||||
@@ -440,5 +721,29 @@ export const useTracker = ({
|
|||||||
handleCancelEdit,
|
handleCancelEdit,
|
||||||
jumpToStep,
|
jumpToStep,
|
||||||
resetForm,
|
resetForm,
|
||||||
|
// Unilateral exercise state
|
||||||
|
sameValuesBothSides,
|
||||||
|
setSameValuesBothSides,
|
||||||
|
weightLeft,
|
||||||
|
setWeightLeft,
|
||||||
|
weightRight,
|
||||||
|
setWeightRight,
|
||||||
|
repsLeft,
|
||||||
|
setRepsLeft,
|
||||||
|
repsRight,
|
||||||
|
setRepsRight,
|
||||||
|
durationLeft,
|
||||||
|
setDurationLeft,
|
||||||
|
durationRight,
|
||||||
|
setDurationRight,
|
||||||
|
distanceLeft,
|
||||||
|
setDistanceLeft,
|
||||||
|
distanceRight,
|
||||||
|
setDistanceRight,
|
||||||
|
heightLeft,
|
||||||
|
setHeightLeft,
|
||||||
|
heightRight,
|
||||||
|
setHeightRight,
|
||||||
|
handleToggleSameValues,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
PORT=3002
|
PORT=3002
|
||||||
DATABASE_URL="file:./dev.db"
|
DATABASE_URL="file:D:/Coding/gymflow/server/prisma/dev.db"
|
||||||
JWT_SECRET="supersecretkey_change_in_production"
|
JWT_SECRET="supersecretkey_change_in_production"
|
||||||
API_KEY="AIzaSyCiu9gD-BcsbyIT1qpPIJrKvz_2sVyZE9A"
|
API_KEY="AIzaSyCiu9gD-BcsbyIT1qpPIJrKvz_2sVyZE9A"
|
||||||
ADMIN_EMAIL=admin@gymflow.ai
|
ADMIN_EMAIL=admin@gymflow.ai
|
||||||
|
|||||||
0
server/dev.db
Normal file
0
server/dev.db
Normal file
721
server/package-lock.json
generated
721
server/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -5,17 +5,21 @@
|
|||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node dist/index.js",
|
"start": "node dist/index.js",
|
||||||
"dev": "nodemon src/index.ts",
|
"dev": "ts-node-dev -r dotenv/config --respawn --transpile-only src/index.ts",
|
||||||
"build": "tsc"
|
"build": "tsc"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@google/generative-ai": "^0.24.1",
|
"@google/generative-ai": "^0.24.1",
|
||||||
|
"@prisma/adapter-better-sqlite3": "^7.1.0",
|
||||||
"@prisma/client": "*",
|
"@prisma/client": "*",
|
||||||
|
"@types/better-sqlite3": "^7.6.13",
|
||||||
"bcryptjs": "*",
|
"bcryptjs": "*",
|
||||||
|
"better-sqlite3": "^12.5.0",
|
||||||
"cors": "*",
|
"cors": "*",
|
||||||
"dotenv": "*",
|
"dotenv": "*",
|
||||||
"express": "*",
|
"express": "*",
|
||||||
"jsonwebtoken": "*"
|
"jsonwebtoken": "*",
|
||||||
|
"ts-node-dev": "^2.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bcryptjs": "*",
|
"@types/bcryptjs": "*",
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,116 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "User" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"email" TEXT NOT NULL,
|
||||||
|
"password" TEXT NOT NULL,
|
||||||
|
"role" TEXT NOT NULL DEFAULT 'USER',
|
||||||
|
"isFirstLogin" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"isBlocked" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "BodyWeightRecord" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"userId" TEXT NOT NULL,
|
||||||
|
"weight" REAL NOT NULL,
|
||||||
|
"date" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"dateStr" TEXT NOT NULL,
|
||||||
|
CONSTRAINT "BodyWeightRecord_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "UserProfile" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"userId" TEXT NOT NULL,
|
||||||
|
"weight" REAL,
|
||||||
|
"height" REAL,
|
||||||
|
"gender" TEXT,
|
||||||
|
"birthDate" DATETIME,
|
||||||
|
"language" TEXT DEFAULT 'en',
|
||||||
|
CONSTRAINT "UserProfile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Exercise" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"userId" TEXT,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"type" TEXT NOT NULL,
|
||||||
|
"bodyWeightPercentage" REAL DEFAULT 0,
|
||||||
|
"isArchived" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"isUnilateral" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
CONSTRAINT "Exercise_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "WorkoutSession" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"userId" TEXT NOT NULL,
|
||||||
|
"startTime" DATETIME NOT NULL,
|
||||||
|
"endTime" DATETIME,
|
||||||
|
"userBodyWeight" REAL,
|
||||||
|
"note" TEXT,
|
||||||
|
"planId" TEXT,
|
||||||
|
"planName" TEXT,
|
||||||
|
CONSTRAINT "WorkoutSession_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "WorkoutSet" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"sessionId" TEXT NOT NULL,
|
||||||
|
"exerciseId" TEXT NOT NULL,
|
||||||
|
"order" INTEGER NOT NULL,
|
||||||
|
"weight" REAL,
|
||||||
|
"reps" INTEGER,
|
||||||
|
"distanceMeters" REAL,
|
||||||
|
"durationSeconds" INTEGER,
|
||||||
|
"completed" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"side" TEXT,
|
||||||
|
CONSTRAINT "WorkoutSet_sessionId_fkey" FOREIGN KEY ("sessionId") REFERENCES "WorkoutSession" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "WorkoutSet_exerciseId_fkey" FOREIGN KEY ("exerciseId") REFERENCES "Exercise" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "WorkoutPlan" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"userId" TEXT NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"description" TEXT,
|
||||||
|
"exercises" TEXT NOT NULL,
|
||||||
|
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" DATETIME NOT NULL,
|
||||||
|
CONSTRAINT "WorkoutPlan_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "SporadicSet" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"userId" TEXT NOT NULL,
|
||||||
|
"exerciseId" TEXT NOT NULL,
|
||||||
|
"weight" REAL,
|
||||||
|
"reps" INTEGER,
|
||||||
|
"distanceMeters" REAL,
|
||||||
|
"durationSeconds" INTEGER,
|
||||||
|
"height" REAL,
|
||||||
|
"bodyWeightPercentage" REAL,
|
||||||
|
"side" TEXT,
|
||||||
|
"timestamp" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"note" TEXT,
|
||||||
|
CONSTRAINT "SporadicSet_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "SporadicSet_exerciseId_fkey" FOREIGN KEY ("exerciseId") REFERENCES "Exercise" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "BodyWeightRecord_userId_dateStr_key" ON "BodyWeightRecord"("userId", "dateStr");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "UserProfile_userId_key" ON "UserProfile"("userId");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "SporadicSet_userId_timestamp_idx" ON "SporadicSet"("userId", "timestamp");
|
||||||
3
server/prisma/migrations/migration_lock.toml
Normal file
3
server/prisma/migrations/migration_lock.toml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Please do not edit this file manually
|
||||||
|
# It should be added in your version-control system (e.g., Git)
|
||||||
|
provider = "sqlite"
|
||||||
@@ -58,6 +58,7 @@ model Exercise {
|
|||||||
type String // STRENGTH, CARDIO, BODYWEIGHT, STATIC
|
type String // STRENGTH, CARDIO, BODYWEIGHT, STATIC
|
||||||
bodyWeightPercentage Float? @default(0)
|
bodyWeightPercentage Float? @default(0)
|
||||||
isArchived Boolean @default(false)
|
isArchived Boolean @default(false)
|
||||||
|
isUnilateral Boolean @default(false)
|
||||||
|
|
||||||
sets WorkoutSet[]
|
sets WorkoutSet[]
|
||||||
sporadicSets SporadicSet[]
|
sporadicSets SporadicSet[]
|
||||||
@@ -90,6 +91,7 @@ model WorkoutSet {
|
|||||||
distanceMeters Float?
|
distanceMeters Float?
|
||||||
durationSeconds Int?
|
durationSeconds Int?
|
||||||
completed Boolean @default(true)
|
completed Boolean @default(true)
|
||||||
|
side String? // LEFT, RIGHT, or null for bilateral
|
||||||
}
|
}
|
||||||
|
|
||||||
model WorkoutPlan {
|
model WorkoutPlan {
|
||||||
@@ -116,6 +118,7 @@ model SporadicSet {
|
|||||||
durationSeconds Int?
|
durationSeconds Int?
|
||||||
height Float?
|
height Float?
|
||||||
bodyWeightPercentage Float?
|
bodyWeightPercentage Float?
|
||||||
|
side String? // LEFT, RIGHT, or null for bilateral
|
||||||
|
|
||||||
timestamp DateTime @default(now())
|
timestamp DateTime @default(now())
|
||||||
note String?
|
note String?
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import cors from 'cors';
|
import cors from 'cors';
|
||||||
import dotenv from 'dotenv';
|
|
||||||
import authRoutes from './routes/auth';
|
import authRoutes from './routes/auth';
|
||||||
import exerciseRoutes from './routes/exercises';
|
import exerciseRoutes from './routes/exercises';
|
||||||
import sessionRoutes from './routes/sessions';
|
import sessionRoutes from './routes/sessions';
|
||||||
@@ -10,8 +9,9 @@ import weightRoutes from './routes/weight';
|
|||||||
import sporadicSetsRoutes from './routes/sporadic-sets';
|
import sporadicSetsRoutes from './routes/sporadic-sets';
|
||||||
import bcrypt from 'bcryptjs';
|
import bcrypt from 'bcryptjs';
|
||||||
import { PrismaClient } from '@prisma/client';
|
import { PrismaClient } from '@prisma/client';
|
||||||
|
import { PrismaBetterSqlite3 } from '@prisma/adapter-better-sqlite3';
|
||||||
dotenv.config();
|
import BetterSqlite3 from 'better-sqlite3';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
@@ -22,7 +22,8 @@ async function ensureAdminUser() {
|
|||||||
const adminEmail = process.env.ADMIN_EMAIL || 'admin@gymflow.ai';
|
const adminEmail = process.env.ADMIN_EMAIL || 'admin@gymflow.ai';
|
||||||
const adminPassword = process.env.ADMIN_PASSWORD || 'admin1234';
|
const adminPassword = process.env.ADMIN_PASSWORD || 'admin1234';
|
||||||
|
|
||||||
const prisma = new PrismaClient();
|
// Use the singleton prisma client
|
||||||
|
const prisma = (await import('./lib/prisma')).default;
|
||||||
|
|
||||||
// Check for existing admin
|
// Check for existing admin
|
||||||
const existingAdmin = await prisma.user.findFirst({
|
const existingAdmin = await prisma.user.findFirst({
|
||||||
|
|||||||
33
server/src/lib/prisma.ts
Normal file
33
server/src/lib/prisma.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import { PrismaClient } from '@prisma/client';
|
||||||
|
import { PrismaBetterSqlite3 } from '@prisma/adapter-better-sqlite3';
|
||||||
|
import BetterSqlite3 from 'better-sqlite3';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
// Ensure env vars are loaded
|
||||||
|
import 'dotenv/config';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
// allow global `var` declarations
|
||||||
|
// eslint-disable-next-line no-var
|
||||||
|
var prisma: PrismaClient | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dbUrl = process.env.DATABASE_URL;
|
||||||
|
|
||||||
|
if (!dbUrl) {
|
||||||
|
throw new Error("DATABASE_URL environment variable is not set. Please check your .env file.");
|
||||||
|
}
|
||||||
|
|
||||||
|
const adapter = new PrismaBetterSqlite3({ url: dbUrl });
|
||||||
|
|
||||||
|
const prisma =
|
||||||
|
global.prisma ||
|
||||||
|
new PrismaClient({
|
||||||
|
adapter,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
global.prisma = prisma;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default prisma;
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { PrismaClient } from '@prisma/client';
|
|
||||||
import jwt from 'jsonwebtoken';
|
import jwt from 'jsonwebtoken';
|
||||||
import bcrypt from 'bcryptjs';
|
import bcrypt from 'bcryptjs';
|
||||||
|
import prisma from '../lib/prisma';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const prisma = new PrismaClient();
|
|
||||||
const JWT_SECRET = process.env.JWT_SECRET || 'secret';
|
const JWT_SECRET = process.env.JWT_SECRET || 'secret';
|
||||||
|
|
||||||
// Get Current User
|
// Get Current User
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { PrismaClient } from '@prisma/client';
|
|
||||||
import jwt from 'jsonwebtoken';
|
import jwt from 'jsonwebtoken';
|
||||||
|
import prisma from '../lib/prisma';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const prisma = new PrismaClient();
|
|
||||||
const JWT_SECRET = process.env.JWT_SECRET || 'secret';
|
const JWT_SECRET = process.env.JWT_SECRET || 'secret';
|
||||||
|
|
||||||
// Middleware to check auth
|
// Middleware to check auth
|
||||||
@@ -46,9 +45,15 @@ router.get('/', async (req: any, res) => {
|
|||||||
router.post('/', async (req: any, res) => {
|
router.post('/', async (req: any, res) => {
|
||||||
try {
|
try {
|
||||||
const userId = req.user.userId;
|
const userId = req.user.userId;
|
||||||
const { id, name, type, bodyWeightPercentage, isArchived } = req.body;
|
const { id, name, type, bodyWeightPercentage, isArchived, isUnilateral } = req.body;
|
||||||
|
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
name,
|
||||||
|
type,
|
||||||
|
bodyWeightPercentage: bodyWeightPercentage ? parseFloat(bodyWeightPercentage) : undefined,
|
||||||
|
isArchived: !!isArchived,
|
||||||
|
isUnilateral: !!isUnilateral
|
||||||
|
};
|
||||||
|
|
||||||
// If id exists and belongs to user, update. Else create.
|
// If id exists and belongs to user, update. Else create.
|
||||||
// Note: We can't update system exercises directly. If user edits a system exercise,
|
// Note: We can't update system exercises directly. If user edits a system exercise,
|
||||||
@@ -62,7 +67,7 @@ router.post('/', async (req: any, res) => {
|
|||||||
|
|
||||||
const updated = await prisma.exercise.update({
|
const updated = await prisma.exercise.update({
|
||||||
where: { id },
|
where: { id },
|
||||||
data: { name, type, bodyWeightPercentage, isArchived }
|
data: data
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.json(updated);
|
return res.json(updated);
|
||||||
@@ -74,10 +79,11 @@ router.post('/', async (req: any, res) => {
|
|||||||
data: {
|
data: {
|
||||||
id: id || undefined, // Use provided ID if available
|
id: id || undefined, // Use provided ID if available
|
||||||
userId,
|
userId,
|
||||||
name,
|
name: data.name,
|
||||||
type,
|
type: data.type,
|
||||||
bodyWeightPercentage,
|
bodyWeightPercentage: data.bodyWeightPercentage,
|
||||||
isArchived: isArchived || false
|
isArchived: data.isArchived,
|
||||||
|
isUnilateral: data.isUnilateral,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
res.json(newExercise);
|
res.json(newExercise);
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { PrismaClient } from '@prisma/client';
|
|
||||||
import jwt from 'jsonwebtoken';
|
import jwt from 'jsonwebtoken';
|
||||||
|
import prisma from '../lib/prisma';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const prisma = new PrismaClient();
|
|
||||||
const JWT_SECRET = process.env.JWT_SECRET || 'secret';
|
const JWT_SECRET = process.env.JWT_SECRET || 'secret';
|
||||||
|
|
||||||
const authenticate = (req: any, res: any, next: any) => {
|
const authenticate = (req: any, res: any, next: any) => {
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { PrismaClient } from '@prisma/client';
|
|
||||||
import jwt from 'jsonwebtoken';
|
import jwt from 'jsonwebtoken';
|
||||||
|
import prisma from '../lib/prisma';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const prisma = new PrismaClient();
|
|
||||||
const JWT_SECRET = process.env.JWT_SECRET || 'secret';
|
const JWT_SECRET = process.env.JWT_SECRET || 'secret';
|
||||||
|
|
||||||
const authenticate = (req: any, res: any, next: any) => {
|
const authenticate = (req: any, res: any, next: any) => {
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { PrismaClient } from '@prisma/client';
|
|
||||||
import jwt from 'jsonwebtoken';
|
import jwt from 'jsonwebtoken';
|
||||||
|
import prisma from '../lib/prisma';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const prisma = new PrismaClient();
|
|
||||||
const JWT_SECRET = process.env.JWT_SECRET || 'secret';
|
const JWT_SECRET = process.env.JWT_SECRET || 'secret';
|
||||||
|
|
||||||
const authenticate = (req: any, res: any, next: any) => {
|
const authenticate = (req: any, res: any, next: any) => {
|
||||||
@@ -58,12 +57,22 @@ router.get('/', async (req: any, res) => {
|
|||||||
router.post('/', async (req: any, res) => {
|
router.post('/', async (req: any, res) => {
|
||||||
try {
|
try {
|
||||||
const userId = req.user.userId;
|
const userId = req.user.userId;
|
||||||
const { exerciseId, weight, reps, distanceMeters, durationSeconds, height, bodyWeightPercentage, note } = req.body;
|
const { exerciseId, weight, reps, distanceMeters, durationSeconds, height, bodyWeightPercentage, note, side } = req.body;
|
||||||
|
|
||||||
if (!exerciseId) {
|
if (!exerciseId) {
|
||||||
return res.status(400).json({ error: 'Exercise ID is required' });
|
return res.status(400).json({ error: 'Exercise ID is required' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verify that the exercise exists
|
||||||
|
const exercise = await prisma.exercise.findUnique({
|
||||||
|
where: { id: exerciseId }
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!exercise) {
|
||||||
|
return res.status(400).json({ error: `Exercise with ID ${exerciseId} not found` });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const sporadicSet = await prisma.sporadicSet.create({
|
const sporadicSet = await prisma.sporadicSet.create({
|
||||||
data: {
|
data: {
|
||||||
userId,
|
userId,
|
||||||
@@ -74,7 +83,8 @@ router.post('/', async (req: any, res) => {
|
|||||||
durationSeconds: durationSeconds ? parseInt(durationSeconds) : null,
|
durationSeconds: durationSeconds ? parseInt(durationSeconds) : null,
|
||||||
height: height ? parseFloat(height) : null,
|
height: height ? parseFloat(height) : null,
|
||||||
bodyWeightPercentage: bodyWeightPercentage ? parseFloat(bodyWeightPercentage) : null,
|
bodyWeightPercentage: bodyWeightPercentage ? parseFloat(bodyWeightPercentage) : null,
|
||||||
note: note || null
|
note: note || null,
|
||||||
|
side: side || null
|
||||||
},
|
},
|
||||||
include: { exercise: true }
|
include: { exercise: true }
|
||||||
});
|
});
|
||||||
@@ -91,7 +101,8 @@ router.post('/', async (req: any, res) => {
|
|||||||
height: sporadicSet.height,
|
height: sporadicSet.height,
|
||||||
bodyWeightPercentage: sporadicSet.bodyWeightPercentage,
|
bodyWeightPercentage: sporadicSet.bodyWeightPercentage,
|
||||||
timestamp: sporadicSet.timestamp.getTime(),
|
timestamp: sporadicSet.timestamp.getTime(),
|
||||||
note: sporadicSet.note
|
note: sporadicSet.note,
|
||||||
|
side: sporadicSet.side
|
||||||
};
|
};
|
||||||
|
|
||||||
res.json({ success: true, sporadicSet: mappedSet });
|
res.json({ success: true, sporadicSet: mappedSet });
|
||||||
@@ -106,7 +117,7 @@ router.put('/:id', async (req: any, res) => {
|
|||||||
try {
|
try {
|
||||||
const userId = req.user.userId;
|
const userId = req.user.userId;
|
||||||
const { id } = req.params;
|
const { id } = req.params;
|
||||||
const { weight, reps, distanceMeters, durationSeconds, height, bodyWeightPercentage, note } = req.body;
|
const { weight, reps, distanceMeters, durationSeconds, height, bodyWeightPercentage, note, side } = req.body;
|
||||||
|
|
||||||
// Verify ownership
|
// Verify ownership
|
||||||
const existing = await prisma.sporadicSet.findFirst({
|
const existing = await prisma.sporadicSet.findFirst({
|
||||||
@@ -126,7 +137,8 @@ router.put('/:id', async (req: any, res) => {
|
|||||||
durationSeconds: durationSeconds !== undefined ? (durationSeconds ? parseInt(durationSeconds) : null) : undefined,
|
durationSeconds: durationSeconds !== undefined ? (durationSeconds ? parseInt(durationSeconds) : null) : undefined,
|
||||||
height: height !== undefined ? (height ? parseFloat(height) : null) : undefined,
|
height: height !== undefined ? (height ? parseFloat(height) : null) : undefined,
|
||||||
bodyWeightPercentage: bodyWeightPercentage !== undefined ? (bodyWeightPercentage ? parseFloat(bodyWeightPercentage) : null) : undefined,
|
bodyWeightPercentage: bodyWeightPercentage !== undefined ? (bodyWeightPercentage ? parseFloat(bodyWeightPercentage) : null) : undefined,
|
||||||
note: note !== undefined ? note : undefined
|
note: note !== undefined ? note : undefined,
|
||||||
|
side: side !== undefined ? side : undefined
|
||||||
},
|
},
|
||||||
include: { exercise: true }
|
include: { exercise: true }
|
||||||
});
|
});
|
||||||
@@ -143,7 +155,8 @@ router.put('/:id', async (req: any, res) => {
|
|||||||
height: updated.height,
|
height: updated.height,
|
||||||
bodyWeightPercentage: updated.bodyWeightPercentage,
|
bodyWeightPercentage: updated.bodyWeightPercentage,
|
||||||
timestamp: updated.timestamp.getTime(),
|
timestamp: updated.timestamp.getTime(),
|
||||||
note: updated.note
|
note: updated.note,
|
||||||
|
side: updated.side
|
||||||
};
|
};
|
||||||
|
|
||||||
res.json({ success: true, sporadicSet: mappedSet });
|
res.json({ success: true, sporadicSet: mappedSet });
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { PrismaClient } from '@prisma/client';
|
|
||||||
import { authenticateToken } from '../middleware/auth';
|
import { authenticateToken } from '../middleware/auth';
|
||||||
|
import prisma from '../lib/prisma';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const prisma = new PrismaClient();
|
|
||||||
|
|
||||||
// Get weight history
|
// Get weight history
|
||||||
router.get('/', authenticateToken, async (req, res) => {
|
router.get('/', authenticateToken, async (req, res) => {
|
||||||
|
|||||||
@@ -167,6 +167,13 @@ const translations = {
|
|||||||
sporadic_set_note: 'Note (optional)',
|
sporadic_set_note: 'Note (optional)',
|
||||||
done: 'Done',
|
done: 'Done',
|
||||||
saved: 'Saved',
|
saved: 'Saved',
|
||||||
|
|
||||||
|
// Unilateral exercises
|
||||||
|
unilateral_exercise: 'Unilateral exercise (separate left/right tracking)',
|
||||||
|
unilateral: 'Unilateral',
|
||||||
|
same_values_both_sides: 'Same values for both sides',
|
||||||
|
left: 'Left',
|
||||||
|
right: 'Right',
|
||||||
},
|
},
|
||||||
ru: {
|
ru: {
|
||||||
// Tabs
|
// Tabs
|
||||||
@@ -326,6 +333,13 @@ const translations = {
|
|||||||
sporadic_set_note: 'Заметка (опц.)',
|
sporadic_set_note: 'Заметка (опц.)',
|
||||||
done: 'Готово',
|
done: 'Готово',
|
||||||
saved: 'Сохранено',
|
saved: 'Сохранено',
|
||||||
|
|
||||||
|
// Unilateral exercises
|
||||||
|
unilateral_exercise: 'Односторонее упражнение (отдельно левая/правая)',
|
||||||
|
unilateral: 'Одностороннее',
|
||||||
|
same_values_both_sides: 'Одинаковые значения для обеих сторон',
|
||||||
|
left: 'Левая',
|
||||||
|
right: 'Правая',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export async function logSporadicSet(setData: {
|
|||||||
height?: number;
|
height?: number;
|
||||||
bodyWeightPercentage?: number;
|
bodyWeightPercentage?: number;
|
||||||
note?: string;
|
note?: string;
|
||||||
|
side?: 'LEFT' | 'RIGHT';
|
||||||
}): Promise<SporadicSet | null> {
|
}): Promise<SporadicSet | null> {
|
||||||
try {
|
try {
|
||||||
const response = await api.post('/sporadic-sets', setData);
|
const response = await api.post('/sporadic-sets', setData);
|
||||||
|
|||||||
3
types.ts
3
types.ts
@@ -21,6 +21,7 @@ export interface WorkoutSet {
|
|||||||
height?: number;
|
height?: number;
|
||||||
bodyWeightPercentage?: number; // Percentage of bodyweight used (e.g. 65 for pushups)
|
bodyWeightPercentage?: number; // Percentage of bodyweight used (e.g. 65 for pushups)
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
|
side?: 'LEFT' | 'RIGHT'; // For unilateral exercises
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WorkoutSession {
|
export interface WorkoutSession {
|
||||||
@@ -41,6 +42,7 @@ export interface ExerciseDef {
|
|||||||
defaultRestSeconds?: number;
|
defaultRestSeconds?: number;
|
||||||
bodyWeightPercentage?: number; // Default percentage
|
bodyWeightPercentage?: number; // Default percentage
|
||||||
isArchived?: boolean;
|
isArchived?: boolean;
|
||||||
|
isUnilateral?: boolean; // For exercises requiring separate left/right tracking
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PlannedSet {
|
export interface PlannedSet {
|
||||||
@@ -92,6 +94,7 @@ export interface SporadicSet {
|
|||||||
bodyWeightPercentage?: number;
|
bodyWeightPercentage?: number;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
note?: string;
|
note?: string;
|
||||||
|
side?: 'LEFT' | 'RIGHT'; // For unilateral exercises
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface User {
|
export interface User {
|
||||||
|
|||||||
Reference in New Issue
Block a user