import React from 'react'; import { Field, reduxForm, formValueSelector } from 'redux-form'; import formInput from '../../common/formInput'; import { connect } from 'react-redux'; import validate from '../../../configs/validate' class CreateTopic extends React.Component { state = { click: false, arrayAnswers: [], array: [], simple: false, click_2: false, click_3: false } submit = () => { const { actions: { createTopicsRequest }, categoryId, formValues: { name, description } } = this.props; console.log(name, description) createTopicsRequest({ name, description, categoryId, }) } qestionAnswerSubmit = () => { const { simple, array } = this.state const { topic: { _id } , actions: { createTestRequest }, formValues: { questions } } = this.props; console.log(questions) createTestRequest({ questions, simple, _id, array }) this.setState({ arrayAnswers:[] }) this.setState({ array:[] }) } handelChange = () => { this.setState((prevState) => ({ simple: !prevState.simple })) } handelClick = () => { this.setState((prevState) => ({ click: !prevState.click })) } handleClick_3 = () => { this.setState((prevState) => ({ click_2: !prevState.click_2 })) this.setState({ click_3:true }) this.setState((prevState) => ({ arrayAnswers: prevState.arrayAnswers.concat(prevState.arrayAnswers.length + 1) })) } handelClick_2 =()=>{ this.setState((prevState) => ({ click_3: !prevState.click_3 })) } formSubmitinput = (event) => { const currentId = this.state.arrayAnswers.length; const values = { answer: event[`answers${currentId}`], price: Number(event[`price${currentId}`]), correct: event[`correct${currentId}`] || false } console.log(values) this.setState((prevState) => ({ array: prevState.array.push(values) }, console.log(prevState.array))) this.setState((prevState) => ({ click_2: !prevState.click_2 })) } render() { const { handleSubmit} = this.props; const { simple, price, correct, click, array, arrayAnswers, click_2, click_3 } = this.state; const { handelChange, submit, handelClick, formSubmitinput, qestionAnswerSubmit, handelClick_2, handleClick_3 } = this; console.log(this.state) return (