Validate and fix numbers in StartPlan
This commit is contained in:
parent
f778426aba
commit
f51284e4ea
|
@ -14,6 +14,7 @@ import { PADDING } from "./constants";
|
||||||
import CountMany from "./count-many";
|
import CountMany from "./count-many";
|
||||||
import { AppDataSource } from "./data-source";
|
import { AppDataSource } from "./data-source";
|
||||||
import { getNow, setRepo, settingsRepo } from "./db";
|
import { getNow, setRepo, settingsRepo } from "./db";
|
||||||
|
import { fixNumeric } from "./fix-numeric";
|
||||||
import GymSet from "./gym-set";
|
import GymSet from "./gym-set";
|
||||||
import { PlanPageParams } from "./plan-page-params";
|
import { PlanPageParams } from "./plan-page-params";
|
||||||
import Settings from "./settings";
|
import Settings from "./settings";
|
||||||
|
@ -129,7 +130,12 @@ export default function StartPlan() {
|
||||||
label="Reps"
|
label="Reps"
|
||||||
keyboardType="numeric"
|
keyboardType="numeric"
|
||||||
value={reps}
|
value={reps}
|
||||||
onChangeText={setReps}
|
onChangeText={(newReps) => {
|
||||||
|
const fixed = fixNumeric(newReps);
|
||||||
|
setReps(fixed);
|
||||||
|
if (fixed.length !== newReps.length)
|
||||||
|
toast("Reps must be a number");
|
||||||
|
}}
|
||||||
onSubmitEditing={() => weightRef.current?.focus()}
|
onSubmitEditing={() => weightRef.current?.focus()}
|
||||||
selection={selection}
|
selection={selection}
|
||||||
onSelectionChange={(e) => setSelection(e.nativeEvent.selection)}
|
onSelectionChange={(e) => setSelection(e.nativeEvent.selection)}
|
||||||
|
@ -139,7 +145,12 @@ export default function StartPlan() {
|
||||||
label="Weight"
|
label="Weight"
|
||||||
keyboardType="numeric"
|
keyboardType="numeric"
|
||||||
value={weight}
|
value={weight}
|
||||||
onChangeText={setWeight}
|
onChangeText={(newWeight) => {
|
||||||
|
const fixed = fixNumeric(newWeight);
|
||||||
|
setWeight(fixed);
|
||||||
|
if (fixed.length !== newWeight.length)
|
||||||
|
toast("Weight must be a number");
|
||||||
|
}}
|
||||||
onSubmitEditing={handleSubmit}
|
onSubmitEditing={handleSubmit}
|
||||||
innerRef={weightRef}
|
innerRef={weightRef}
|
||||||
blurOnSubmit
|
blurOnSubmit
|
||||||
|
|
Loading…
Reference in New Issue
Block a user