/* eslint-disable react-hooks/exhaustive-deps */ import { PhoneIcon } from "@heroicons/react/24/outline"; import { default as React } from "react"; import { type PhoneQuestionData } from "./PhoneQuestion"; const DEFAULT_INITIAL_DATA = () => { return { label: "", placeholder: "", help: "", required: false, }; }; type Props = { data: PhoneQuestionData; onDataChange: (newData: PhoneQuestionData) => void; }; const PhoneQuestionComponent = (props: Props) => { const [data, setData] = React.useState(props.data ? props.data : DEFAULT_INITIAL_DATA); const updateData = (newData: PhoneQuestionData) => { setData(newData); if (props.onDataChange) { props.onDataChange(newData); } }; const onInputChange = (fieldName: string) => { return (e: React.FormEvent) => { const newData = { ...data, }; newData[fieldName] = e.currentTarget.value; updateData(newData); }; }; return (
{data.required && (
*
)}
); }; export default PhoneQuestionComponent;