import React from "react"; import Form from "react-bootstrap/Form"; import InputGroup from "react-bootstrap/InputGroup"; export default class Questionnaire extends React.Component { constructor(props) { super(props); this.state = { hoursPerWeek: 10, hostingDollarsPerMonthFixed: 100, hostingDollarsPerMonthVariable: 100, conversionRate: 0.1, opportunityCostDollarsPerYear: 100000, margin: 0.2, numUsers: 1000, }; this.handleChange = this.handleChange.bind(this); this.handleChange({ target: "" }); } async handleChange(event) { let val; switch (event.target.name) { case "margin": val = Number(event.target.value) / 100; break; case "conversionRate": val = Number(event.target.value) / 100; break; default: val = Number(event.target.value); } await this.setState({ [event.target.name]: val, }); const monthlyRate = (this.state.opportunityCostDollarsPerYear / 12) * (this.state.hoursPerWeek / 40); const monthlyCosts = this.state.hostingDollarsPerMonthFixed + (this.state.hostingDollarsPerMonthVariable / 1000) * this.state.numUsers; const costPerUser = (monthlyRate + monthlyCosts) / this.state.numUsers; const pricePerUser = costPerUser * (1 / this.state.conversionRate) * (1 + this.state.margin); this.props.onFormChange({ monthlyRate: Math.floor(monthlyRate), monthlyCosts: Math.floor(monthlyCosts), costPerUser: Math.floor(costPerUser), pricePerUser: Math.floor(pricePerUser), }); } render() { return (