Show list of current workouts when adding set
This commit is contained in:
parent
24a44056f9
commit
bc3a39c4b6
|
@ -78,7 +78,7 @@ export default function EditSet() {
|
|||
|
||||
return (
|
||||
<View style={{padding: 10}}>
|
||||
<SetForm save={save} set={params.set} next={params.next} />
|
||||
<SetForm save={save} set={params.set} workouts={params.workouts} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ export type HomePageParams = {
|
|||
Sets: {};
|
||||
EditSet: {
|
||||
set: Set;
|
||||
next?: string;
|
||||
workouts?: string[];
|
||||
};
|
||||
};
|
||||
|
||||
|
|
17
SetForm.tsx
17
SetForm.tsx
|
@ -6,11 +6,11 @@ import Set from './set';
|
|||
export default function SetForm({
|
||||
save,
|
||||
set,
|
||||
next,
|
||||
workouts,
|
||||
}: {
|
||||
set: Set;
|
||||
save: (set: Set) => void;
|
||||
next?: string;
|
||||
workouts?: string[];
|
||||
}) {
|
||||
const [name, setName] = useState(set.name);
|
||||
const [reps, setReps] = useState(set.reps.toString());
|
||||
|
@ -81,10 +81,19 @@ export default function SetForm({
|
|||
/>
|
||||
{set.created && (
|
||||
<Text style={{marginBottom: 10}}>
|
||||
Created: {set.created?.replace('T', ' ')}
|
||||
{set.created.replace('T', ' ')}
|
||||
</Text>
|
||||
)}
|
||||
{next && <Text>Next: {next}</Text>}
|
||||
<Text>
|
||||
{workouts?.map((workout, index) => (
|
||||
<Text
|
||||
key={workout}
|
||||
style={{fontWeight: workout === name ? 'bold' : 'normal'}}>
|
||||
{workout}
|
||||
{index === workouts.length - 1 ? '.' : ', '}
|
||||
</Text>
|
||||
))}
|
||||
</Text>
|
||||
</ScrollView>
|
||||
<Button
|
||||
disabled={!name}
|
||||
|
|
|
@ -27,7 +27,7 @@ const defaultSet = {
|
|||
export default function SetList() {
|
||||
const [sets, setSets] = useState<Set[]>();
|
||||
const [set, setSet] = useState<Set>();
|
||||
const [nextWorkout, setNextWorkout] = useState<string>();
|
||||
const [workouts, setWorkouts] = useState<string[]>([]);
|
||||
const [offset, setOffset] = useState(0);
|
||||
const [search, setSearch] = useState('');
|
||||
const [refreshing, setRefreshing] = useState(false);
|
||||
|
@ -125,7 +125,7 @@ export default function SetList() {
|
|||
}
|
||||
const best = await getBest(workout);
|
||||
setSet({...best});
|
||||
setNextWorkout(todaysWorkouts[todaysWorkouts.indexOf(workout) + 1]);
|
||||
setWorkouts(todaysWorkouts);
|
||||
}, [getTodaysSets, getTodaysPlan, getBest, db]);
|
||||
|
||||
useFocusEffect(
|
||||
|
@ -171,9 +171,9 @@ export default function SetList() {
|
|||
const onAdd = useCallback(async () => {
|
||||
navigation.navigate('EditSet', {
|
||||
set: set || {...defaultSet},
|
||||
next: nextWorkout,
|
||||
workouts,
|
||||
});
|
||||
}, [navigation, set, nextWorkout]);
|
||||
}, [navigation, set, workouts]);
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
|
|
Loading…
Reference in New Issue
Block a user