Skip to content

Commit

Permalink
Fix #369: Fixed Javascript console warnings on Create Benchmark page (#…
Browse files Browse the repository at this point in the history
…385)

Fixed warnings related to handling null for textarea values, custom Stepper icons.
  • Loading branch information
mrabbitt authored Aug 22, 2024
1 parent c7c1bb1 commit da611c7
Showing 1 changed file with 20 additions and 35 deletions.
55 changes: 20 additions & 35 deletions src/pages/students/[student_id]/goals/[goal_id]/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Box,
Stack,
Step,
StepIconProps,
StepLabel,
Stepper,
TextField,
Expand All @@ -27,6 +28,16 @@ interface BenchmarkFormEntry {
[key: string]: string | number | "";
}

const BenchmarkStepperIcon = (stepIconProps: StepIconProps) => {
const { completed = false } = stepIconProps;

if (completed) {
return <CheckCircle />;
} else {
return <TripOriginRounded />;
}
};

const CreateBenchmarkPage = () => {
const router = useRouter();
const { data: goal } = trpc.iep.getGoal.useQuery(
Expand Down Expand Up @@ -176,11 +187,7 @@ const CreateBenchmarkPage = () => {
multiline
rows={4}
name={field.name}
value={
benchmarkFormState[field.name] !== ""
? benchmarkFormState[field.name]
: null
}
value={benchmarkFormState[field.name] || ""}
onChange={(e: ChangeEvent) =>
setBenchmarkFormState({
...benchmarkFormState,
Expand Down Expand Up @@ -218,17 +225,11 @@ const CreateBenchmarkPage = () => {
Create Benchmark
</Typography>
<Stepper activeStep={viewState} alternativeLabel connector={null}>
{steps.map((label, index) => (
{steps.map((label) => (
<Step key={label}>
{index !== steps.length && (
<StepLabel
StepIconComponent={
index < viewState ? CheckCircle : TripOriginRounded
}
>
{label}
</StepLabel>
)}
<StepLabel StepIconComponent={BenchmarkStepperIcon}>
{label}
</StepLabel>
</Step>
))}
</Stepper>
Expand Down Expand Up @@ -263,11 +264,7 @@ const CreateBenchmarkPage = () => {
required
type="number"
name="baseline_level"
value={
benchmarkFormState["baseline_level"] !== ""
? benchmarkFormState["baseline_level"]
: ""
}
value={benchmarkFormState["baseline_level"] || ""}
onChange={(e: ChangeEvent) =>
setBenchmarkFormState({
...benchmarkFormState,
Expand All @@ -283,11 +280,7 @@ const CreateBenchmarkPage = () => {
required
type="number"
name="target_level"
value={
benchmarkFormState["target_level"] !== ""
? benchmarkFormState["target_level"]
: ""
}
value={benchmarkFormState["target_level"] || ""}
onChange={(e: ChangeEvent) =>
setBenchmarkFormState({
...benchmarkFormState,
Expand All @@ -302,11 +295,7 @@ const CreateBenchmarkPage = () => {
type="number"
name="attempts_per_trial"
required
value={
benchmarkFormState["attempts_per_trial"] !== ""
? benchmarkFormState["attempts_per_trial"]
: ""
}
value={benchmarkFormState["attempts_per_trial"] || ""}
onChange={(e: ChangeEvent) =>
setBenchmarkFormState({
...benchmarkFormState,
Expand All @@ -319,11 +308,7 @@ const CreateBenchmarkPage = () => {
type="number"
name="number_of_trials"
required
value={
benchmarkFormState["number_of_trials"] !== ""
? benchmarkFormState["number_of_trials"]
: ""
}
value={benchmarkFormState["number_of_trials"] || ""}
onChange={(e: ChangeEvent) =>
setBenchmarkFormState({
...benchmarkFormState,
Expand Down

0 comments on commit da611c7

Please sign in to comment.