import React, { Component } from 'react'; import { Button } from '../ui/button'; import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell, } from '../ui/table'; import { isString } from 'lodash'; import { SCREENS } from '../../constants/constants'; import { ExperimentParameters } from '../../constants/interfaces'; import { DesignProps } from './index'; import SecondaryNavComponent from '../SecondaryNavComponent'; import PreviewExperimentComponent from '../PreviewExperimentComponent'; import { ParamSlider } from './ParamSlider'; import PreviewButton from '../PreviewButtonComponent'; import researchQuestionImage from '../../assets/common/ResearchQuestion2.png'; import methodsImage from '../../assets/common/Methods2.png'; import hypothesisImage from '../../assets/common/Hypothesis2.png'; const CUSTOM_STEPS = { OVERVIEW: 'OVERVIEW', CONDITIONS: 'CONDITIONS', TRIALS: 'TRIALS', PARAMETERS: 'PARAMETERS', INSTRUCTIONS: 'INSTRUCTIONS', PREVIEW: 'PREVIEW', }; const FIELDS = { QUESTION: 'Research Question', HYPOTHESIS: 'Hypothesis', METHODS: 'Methods', INTRO: 'Experiment Instructions', HELP: 'Instructions for the task screen', }; interface State { activeStep: string; isPreviewing: boolean; params: ExperimentParameters; saved: boolean; } export default class CustomDesign extends Component { constructor(props: DesignProps) { super(props); this.state = { activeStep: CUSTOM_STEPS.OVERVIEW, isPreviewing: true, params: props.params, saved: false, }; this.handleStepClick = this.handleStepClick.bind(this); this.handleStartExperiment = this.handleStartExperiment.bind(this); this.handlePreview = this.handlePreview.bind(this); this.handleSaveParams = this.handleSaveParams.bind(this); this.handleProgressBar = this.handleProgressBar.bind(this); this.handleEEGEnabled = this.handleEEGEnabled.bind(this); this.endPreview = this.endPreview.bind(this); } endPreview() { this.setState({ isPreviewing: false }); } handleStepClick(step: string) { this.handleSaveParams(); this.setState({ activeStep: step }); } handleProgressBar(e: React.ChangeEvent) { const { checked } = e.target; this.setState((prevState) => ({ params: { ...prevState.params, showProgessBar: checked }, })); } handleEEGEnabled(e: React.ChangeEvent) { this.props.ExperimentActions.SetEEGEnabled(e.target.checked); } handleStartExperiment() { this.props.navigate(SCREENS.COLLECT.route); } handlePreview(e) { e.target.blur(); this.setState({ isPreviewing: !this.state.isPreviewing }); } handleSaveParams() { this.props.ExperimentActions.SetParams(this.state.params); this.props.ExperimentActions.SaveWorkspace(); this.setState({ saved: true }); } handleSetText(text: string, section: 'hypothesis' | 'methods' | 'question') { // @ts-expect-error this.setState((prevState) => ({ params: { ...prevState.params, description: { ...prevState.params.description, [section]: text }, }, saved: false, })); } renderSectionContent() { const stimi = [ { name: 'stimulus1', number: 1 }, { name: 'stimulus2', number: 2 }, { name: 'stimulus3', number: 3 }, { name: 'stimulus4', number: 4 }, ]; switch (this.state.activeStep) { case CUSTOM_STEPS.OVERVIEW: default: return (
Research Question