Newer
Older
import React, { ChangeEvent } from 'react'
import { ContentItems } from '../Editing/Editing'
import CustomEditor from '../Editing/CustomEditor'
import { convertStringToEditorState } from '../../utils/editorStateManagment'
import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css'
import './poll.scss'
interface PollProps {
question: string
link: string
handleChange: (
value: string,
type: 'info' | 'title' | 'content' | 'question' | 'link'
) => void
onSave: () => Promise<void>
onCancel: () => void
onDelete: (target: ContentItems) => void
}
const Poll: React.FC<PollProps> = ({
question,
link,
handleChange,
onSave,
onCancel,
onDelete,
}: PollProps) => {
const handleChangeLink = (e: ChangeEvent<HTMLInputElement>) => {
handleChange(e.target.value, 'link')
}
return (
<div className="poll">
<p className="title">Lien</p>
<input
type="text"
className="input-dark"
value={link}
onChange={handleChangeLink}
/>
<div>
<p className="title">Question</p>
<div>
<CustomEditor
baseState={convertStringToEditorState(question)}
handleChange={handleChange}
editorType="question"
/>
</div>
<div className="buttons">
<button className="btnCancel" onClick={onCancel}>
Annuler
</button>
<button className="btnValid" onClick={onSave}>
Sauvegarder
</button>
<button className="btnDelete" onClick={() => onDelete('poll')}>
Supprimer
</button>
</div>
</div>
</div>
)
}
export default Poll