Skip to content
Snippets Groups Projects
Poll.tsx 1.4 KiB
Newer Older
  • Learn to ignore specific revisions
  • Guilhem CARRON's avatar
    Guilhem CARRON committed
    import { Editor } from '@tinymce/tinymce-react'
    import React, { ChangeEvent } from 'react'
    import './poll.scss'
    
    interface PollProps {
      question: string
      link: string
      handleChange: (
        value: string,
        type: 'header' | 'quote' | 'question' | 'link'
      ) => void
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
      onSave: () => void
      onCancel: () => void
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    }
    const Poll: React.FC<PollProps> = ({
      question,
      link,
      handleChange,
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
      onSave,
      onCancel,
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    }: PollProps) => {
      const handleChangeLink = (e: ChangeEvent<HTMLInputElement>) => {
        handleChange(e.target.value, 'link')
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
    
    
      return (
        <div className="poll">
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
          <h2>Ajouter un sondage</h2>
    
          <p className="title">Lien</p>
    
          <input
            type="text"
            className="input-dark"
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
            value={link}
            onChange={handleChangeLink}
    
    Guilhem CARRON's avatar
    Guilhem CARRON committed
          <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, editor) =>
                handleChange(newQuestion, 'question')
              }
            />
            <button className="btnCancel" onClick={onCancel}>
              Annuler
            </button>
            <button className="btnValid" onClick={onSave}>
              Sauvegarder
            </button>
          </div>
    
        </div>
      )
    }
    
    export default Poll