Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { Editor } from '@tinymce/tinymce-react'
import React, { ChangeEvent } from 'react'
import { ContentItems } from '../Editing/Editing'
import './poll.scss'
interface PollProps {
question: string
link: string
handleChange: (
value: string,
type: 'header' | 'quote' | '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">
<h2>Ajouter un sondage</h2>
<p className="title">Lien</p>
<input
type="text"
className="input-dark"
value={link}
onChange={handleChangeLink}
/>
<div>
<p className="title">Question</p>
<Editor
init={{
menubar: false,
toolbar:
'undo redo | bold italic underline | alignleft aligncenter alignright | code | ecolyoLink',
}}
value={question}
onEditorChange={(newQuestion: string) =>
handleChange(newQuestion, 'question')
}
/>
<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