1. Exercise lists sorted. 2. Session finishing confirmation. 3. Quit without saving option added.
This commit is contained in:
@@ -275,7 +275,10 @@ const Plans: React.FC<PlansProps> = ({ userId, onStartPlan, lang }) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1 overflow-y-auto p-2">
|
<div className="flex-1 overflow-y-auto p-2">
|
||||||
{availableExercises.map(ex => (
|
{availableExercises
|
||||||
|
.slice()
|
||||||
|
.sort((a, b) => a.name.localeCompare(b.name))
|
||||||
|
.map(ex => (
|
||||||
<button
|
<button
|
||||||
key={ex.id}
|
key={ex.id}
|
||||||
onClick={() => addStep(ex)}
|
onClick={() => addStep(ex)}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { Plus, Activity, ChevronDown, ChevronUp, Dumbbell, PlayCircle, CheckCircle, User, Scale, X, Flame, Timer as TimerIcon, ArrowUp, ArrowRight, Footprints, Ruler, CheckSquare, Trash2, Percent } from 'lucide-react';
|
import { Plus, Activity, ChevronDown, ChevronUp, Dumbbell, PlayCircle, CheckCircle, User, Scale, X, Flame, Timer as TimerIcon, ArrowUp, ArrowRight, Footprints, Ruler, CheckSquare, Trash2, Percent, MoreVertical } from 'lucide-react';
|
||||||
import { WorkoutSession, WorkoutSet, ExerciseDef, ExerciseType, WorkoutPlan, Language } from '../types';
|
import { WorkoutSession, WorkoutSet, ExerciseDef, ExerciseType, WorkoutPlan, Language } from '../types';
|
||||||
import { getExercises, getLastSetForExercise, saveExercise, getPlans } from '../services/storage';
|
import { getExercises, getLastSetForExercise, saveExercise, getPlans } from '../services/storage';
|
||||||
import { getCurrentUserProfile } from '../services/auth';
|
import { getCurrentUserProfile } from '../services/auth';
|
||||||
@@ -49,6 +49,11 @@ const Tracker: React.FC<TrackerProps> = ({ userId, userWeight, activeSession, ac
|
|||||||
const [showPlanPrep, setShowPlanPrep] = useState<WorkoutPlan | null>(null);
|
const [showPlanPrep, setShowPlanPrep] = useState<WorkoutPlan | null>(null);
|
||||||
const [showPlanList, setShowPlanList] = useState(false);
|
const [showPlanList, setShowPlanList] = useState(false);
|
||||||
|
|
||||||
|
// Confirmation State
|
||||||
|
const [showFinishConfirm, setShowFinishConfirm] = useState(false);
|
||||||
|
const [showQuitConfirm, setShowQuitConfirm] = useState(false);
|
||||||
|
const [showMenu, setShowMenu] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const exList = await getExercises(userId);
|
const exList = await getExercises(userId);
|
||||||
@@ -284,12 +289,40 @@ const Tracker: React.FC<TrackerProps> = ({ userId, userWeight, activeSession, ac
|
|||||||
{activeSession.userBodyWeight ? ` • ${activeSession.userBodyWeight}kg` : ''}
|
{activeSession.userBodyWeight ? ` • ${activeSession.userBodyWeight}kg` : ''}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex items-center gap-2 relative">
|
||||||
<button
|
<button
|
||||||
onClick={onSessionEnd}
|
onClick={() => setShowFinishConfirm(true)}
|
||||||
className="px-5 py-2 rounded-full bg-error-container text-on-error-container text-sm font-medium hover:opacity-90 transition-opacity"
|
className="px-5 py-2 rounded-full bg-error-container text-on-error-container text-sm font-medium hover:opacity-90 transition-opacity"
|
||||||
>
|
>
|
||||||
{t('finish', lang)}
|
{t('finish', lang)}
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => setShowMenu(!showMenu)}
|
||||||
|
className="p-2 rounded-full bg-surface-container-high text-on-surface hover:bg-surface-container-highest transition-colors"
|
||||||
|
>
|
||||||
|
<MoreVertical size={20} />
|
||||||
|
</button>
|
||||||
|
{showMenu && (
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
className="fixed inset-0 z-30"
|
||||||
|
onClick={() => setShowMenu(false)}
|
||||||
|
/>
|
||||||
|
<div className="absolute right-0 top-full mt-2 bg-surface-container rounded-xl shadow-elevation-3 overflow-hidden z-40 min-w-[200px]">
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
setShowMenu(false);
|
||||||
|
setShowQuitConfirm(true);
|
||||||
|
}}
|
||||||
|
className="w-full px-4 py-3 text-left text-error hover:bg-error-container/20 transition-colors flex items-center gap-2"
|
||||||
|
>
|
||||||
|
<X size={18} />
|
||||||
|
{t('quit_no_save', lang)}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{activePlan && (
|
{activePlan && (
|
||||||
@@ -348,7 +381,10 @@ const Tracker: React.FC<TrackerProps> = ({ userId, userWeight, activeSession, ac
|
|||||||
onChange={(e) => setSelectedExercise(exercises.find(ex => ex.id === e.target.value) || null)}
|
onChange={(e) => setSelectedExercise(exercises.find(ex => ex.id === e.target.value) || null)}
|
||||||
>
|
>
|
||||||
<option value="" disabled>{t('select_exercise', lang)}</option>
|
<option value="" disabled>{t('select_exercise', lang)}</option>
|
||||||
{exercises.map(ex => (
|
{exercises
|
||||||
|
.slice()
|
||||||
|
.sort((a, b) => a.name.localeCompare(b.name))
|
||||||
|
.map(ex => (
|
||||||
<option key={ex.id} value={ex.id} className="bg-surface-container text-on-surface">{ex.name}</option>
|
<option key={ex.id} value={ex.id} className="bg-surface-container text-on-surface">{ex.name}</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
@@ -497,6 +533,61 @@ const Tracker: React.FC<TrackerProps> = ({ userId, userWeight, activeSession, ac
|
|||||||
lang={lang}
|
lang={lang}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Finish Confirmation Dialog */}
|
||||||
|
{showFinishConfirm && (
|
||||||
|
<div className="absolute inset-0 bg-black/60 z-50 flex items-center justify-center p-6 backdrop-blur-sm">
|
||||||
|
<div className="w-full max-w-sm bg-surface-container rounded-[28px] p-6 shadow-elevation-3">
|
||||||
|
<h3 className="text-2xl font-normal text-on-surface mb-2">{t('finish_confirm_title', lang)}</h3>
|
||||||
|
<p className="text-on-surface-variant text-sm mb-8">{t('finish_confirm_msg', lang)}</p>
|
||||||
|
<div className="flex justify-end gap-2">
|
||||||
|
<button
|
||||||
|
onClick={() => setShowFinishConfirm(false)}
|
||||||
|
className="px-6 py-2.5 rounded-full text-primary font-medium hover:bg-white/5"
|
||||||
|
>
|
||||||
|
{t('cancel', lang)}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
setShowFinishConfirm(false);
|
||||||
|
onSessionEnd();
|
||||||
|
}}
|
||||||
|
className="px-6 py-2.5 rounded-full bg-primary text-on-primary font-medium"
|
||||||
|
>
|
||||||
|
{t('confirm', lang)}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Quit Without Saving Confirmation Dialog */}
|
||||||
|
{showQuitConfirm && (
|
||||||
|
<div className="absolute inset-0 bg-black/60 z-50 flex items-center justify-center p-6 backdrop-blur-sm">
|
||||||
|
<div className="w-full max-w-sm bg-surface-container rounded-[28px] p-6 shadow-elevation-3">
|
||||||
|
<h3 className="text-2xl font-normal text-error mb-2">{t('quit_confirm_title', lang)}</h3>
|
||||||
|
<p className="text-on-surface-variant text-sm mb-8">{t('quit_confirm_msg', lang)}</p>
|
||||||
|
<div className="flex justify-end gap-2">
|
||||||
|
<button
|
||||||
|
onClick={() => setShowQuitConfirm(false)}
|
||||||
|
className="px-6 py-2.5 rounded-full text-primary font-medium hover:bg-white/5"
|
||||||
|
>
|
||||||
|
{t('cancel', lang)}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
setShowQuitConfirm(false);
|
||||||
|
// Quit without saving - just navigate away or reset
|
||||||
|
window.location.reload();
|
||||||
|
}}
|
||||||
|
className="px-6 py-2.5 rounded-full bg-error text-on-error font-medium"
|
||||||
|
>
|
||||||
|
{t('confirm', lang)}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Binary file not shown.
@@ -50,6 +50,12 @@ const translations = {
|
|||||||
cancel: 'Cancel',
|
cancel: 'Cancel',
|
||||||
start: 'Start',
|
start: 'Start',
|
||||||
finish: 'Finish',
|
finish: 'Finish',
|
||||||
|
finish_confirm_title: 'Finish Workout?',
|
||||||
|
finish_confirm_msg: 'Are you sure you want to finish this workout? Your progress will be saved.',
|
||||||
|
quit_no_save: 'Quit without saving',
|
||||||
|
quit_confirm_title: 'Quit without saving?',
|
||||||
|
quit_confirm_msg: 'All progress from this session will be lost. This action cannot be undone.',
|
||||||
|
confirm: 'Confirm',
|
||||||
plan_completed: 'Plan Completed!',
|
plan_completed: 'Plan Completed!',
|
||||||
step: 'Step',
|
step: 'Step',
|
||||||
of: 'of',
|
of: 'of',
|
||||||
@@ -71,7 +77,7 @@ const translations = {
|
|||||||
add_weight: 'Add. Weight',
|
add_weight: 'Add. Weight',
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
type_strength: 'Strength',
|
type_strength: 'Free Weights & Machines',
|
||||||
type_bodyweight: 'Bodyweight',
|
type_bodyweight: 'Bodyweight',
|
||||||
type_cardio: 'Cardio',
|
type_cardio: 'Cardio',
|
||||||
type_static: 'Static',
|
type_static: 'Static',
|
||||||
@@ -191,6 +197,12 @@ const translations = {
|
|||||||
cancel: 'Отмена',
|
cancel: 'Отмена',
|
||||||
start: 'Начать',
|
start: 'Начать',
|
||||||
finish: 'Завершить',
|
finish: 'Завершить',
|
||||||
|
finish_confirm_title: 'Завершить тренировку?',
|
||||||
|
finish_confirm_msg: 'Вы уверены, что хотите завершить эту тренировку? Ваш прогресс будет сохранен.',
|
||||||
|
quit_no_save: 'Выйти без сохранения',
|
||||||
|
quit_confirm_title: 'Выйти без сохранения?',
|
||||||
|
quit_confirm_msg: 'Весь прогресс этой сессии будет потерян. Это действие нельзя отменить.',
|
||||||
|
confirm: 'Подтвердить',
|
||||||
plan_completed: 'План выполнен!',
|
plan_completed: 'План выполнен!',
|
||||||
step: 'Шаг',
|
step: 'Шаг',
|
||||||
of: 'из',
|
of: 'из',
|
||||||
@@ -212,7 +224,7 @@ const translations = {
|
|||||||
add_weight: 'Доп. вес',
|
add_weight: 'Доп. вес',
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
type_strength: 'Силовое',
|
type_strength: 'Свободные веса и тренажеры',
|
||||||
type_bodyweight: 'Свой вес',
|
type_bodyweight: 'Свой вес',
|
||||||
type_cardio: 'Кардио',
|
type_cardio: 'Кардио',
|
||||||
type_static: 'Статика',
|
type_static: 'Статика',
|
||||||
|
|||||||
Reference in New Issue
Block a user