Follow review comments

This commit is contained in:
keisuke-umezawa committed 2023-01-24 10:58:18 +09:00
1 parent 798a433029
commit cf16cd8507
3 files changed
+28 -21

No files matched your search

+1 -1
View File
@@ -289,7 +289,7 @@ export const actionCreator = () => {
studyId: number,
trialId: number,
state: TrialStateFinished,
values?: string[]
values?: number[]
): Promise<void> => {
const message =
values === undefined
+2 -2
View File
@@ -221,9 +221,9 @@ export const tellTrialAPI = (
studyId: number,
trialId: number,
state: TrialStateFinished,
values?: string[]
values?: number[]
): Promise<void> => {
const req: { state: TrialState; values?: string[] } = {
const req: { state: TrialState; values?: number[] } = {
state: state,
values: values,
}
+25 -18
View File
@@ -1,4 +1,11 @@
import React, {ChangeEvent, createRef, FC, FormEvent, MouseEvent, useState} from "react"
import React, {
ChangeEvent,
createRef,
FC,
FormEvent,
MouseEvent,
useState,
} from "react"
import {
Typography,
Grid,
@@ -274,7 +281,9 @@ export const TrialTable: FC<{
]
const collapseBody = (index: number) => {
const objectiveFormRefs = studyDetail?.directions.map(d => createRef<HTMLInputElement>())
const objectiveFormRefs = studyDetail?.directions.map((d) =>
createRef<HTMLInputElement>()
)
const handleSubmit = (e: FormEvent<HTMLFormElement>): void => {
if (objectiveFormRefs === undefined) {
return
@@ -283,14 +292,11 @@ export const TrialTable: FC<{
e.preventDefault()
const studyId = (studyDetail as StudyDetail).id
const trialId = trials[index].number
const objectiveValues = objectiveFormRefs.map(ref => ref.current ? ref.current.value : "")
console.dir(objectiveValues)
action.tellTrial(
studyId,
trialId,
"Complete",
objectiveValues
const objectiveValues = objectiveFormRefs.map((ref) =>
ref.current ? ref.current.value : ""
)
console.dir(objectiveValues)
action.tellTrial(studyId, trialId, "Complete", objectiveValues)
}
const handleFailTrial = (e: MouseEvent<HTMLButtonElement>): void => {
const studyId = (studyDetail as StudyDetail).id
@@ -337,15 +343,16 @@ export const TrialTable: FC<{
<form onSubmit={handleSubmit}>
<Box margin={1}>
<Stack direction="row" spacing={1}>
{objectiveFormRefs !== undefined && objectiveFormRefs.map((ref, i) => (
<TextField
id={`objective-${i}`}
key={`objective-${i}`}
label={`Objective ${i}`}
type="number"
inputRef={ref}
/>
))}
{objectiveFormRefs !== undefined &&
objectiveFormRefs.map((ref, i) => (
<TextField
id={`objective-${i}`}
key={`objective-${i}`}
label={`Objective ${i}`}
type="number"
inputRef={ref}
/>
))}
</Stack>
</Box>
<Box margin={1}>