From da611c78e35d1b7376c0d271906dba94167b3ebf Mon Sep 17 00:00:00 2001
From: mrabbitt <284825+mrabbitt@users.noreply.github.com>
Date: Thu, 22 Aug 2024 14:58:14 -0700
Subject: [PATCH] Fix #369: Fixed Javascript console warnings on Create
Benchmark page (#385)
Fixed warnings related to handling null for textarea values, custom Stepper icons.
---
.../[student_id]/goals/[goal_id]/create.tsx | 55 +++++++------------
1 file changed, 20 insertions(+), 35 deletions(-)
diff --git a/src/pages/students/[student_id]/goals/[goal_id]/create.tsx b/src/pages/students/[student_id]/goals/[goal_id]/create.tsx
index b63f516f..b1d928af 100644
--- a/src/pages/students/[student_id]/goals/[goal_id]/create.tsx
+++ b/src/pages/students/[student_id]/goals/[goal_id]/create.tsx
@@ -7,6 +7,7 @@ import {
Box,
Stack,
Step,
+ StepIconProps,
StepLabel,
Stepper,
TextField,
@@ -27,6 +28,16 @@ interface BenchmarkFormEntry {
[key: string]: string | number | "";
}
+const BenchmarkStepperIcon = (stepIconProps: StepIconProps) => {
+ const { completed = false } = stepIconProps;
+
+ if (completed) {
+ return ;
+ } else {
+ return ;
+ }
+};
+
const CreateBenchmarkPage = () => {
const router = useRouter();
const { data: goal } = trpc.iep.getGoal.useQuery(
@@ -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,
@@ -218,17 +225,11 @@ const CreateBenchmarkPage = () => {
Create Benchmark
- {steps.map((label, index) => (
+ {steps.map((label) => (
- {index !== steps.length && (
-
- {label}
-
- )}
+
+ {label}
+
))}
@@ -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,
@@ -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,
@@ -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,
@@ -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,