import { useEffect, useState } from 'react'; import { IconButton } from '@chakra-ui/button'; import { Editable, EditableInput, EditablePreview } from '@chakra-ui/editable'; import { Tooltip } from '@chakra-ui/tooltip'; import { IoSunny } from '@react-icons/all-files/io5/IoSunny'; import { tooltipDelayMid } from '../../../ontimeConfig'; import style from './MessageControl.module.scss'; interface InputRowProps { label: string; placeholder: string; text: string; visible: boolean; actionHandler: (action: string, payload: object) => void; changeHandler: (newValue: string) => void; } export default function InputRow(props: InputRowProps) { const { label, placeholder, text, visible, actionHandler, changeHandler } = props; const [inputText, setInputText] = useState(text || ''); const handleInputChange = (newValue: string) => { setInputText(newValue); changeHandler(newValue); }; useEffect(() => { if (text) { setInputText(text); } }, [text]); return (
{label}
handleInputChange(newValue)} value={inputText} placeholder={placeholder} className={style.inline} color={text === '' ? '#666' : 'inherit'} > } colorScheme='blue' variant={visible ? 'solid' : 'outline'} onClick={() => actionHandler('update', { field: 'isPublic', value: !visible })} />
); }