Skip to content
Snippets Groups Projects
MonthlyInfo.tsx 1.64 KiB
Newer Older
  • Learn to ignore specific revisions
  • import React from 'react'
    import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css'
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    import { convertStringToEditorState } from '../../utils/editorStateManagment'
    
    import ImagePicker from '../ImagePicker/ImagePicker'
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    import CustomEditor from '../Newsletter/CustomEditor'
    import { ContentItems } from '../Newsletter/Newsletter'
    import './monthlyInfo.scss'
    
    interface MonthlyInfoProps {
      onSave: () => Promise<void>
      onCancel: () => void
      info: string
      handleChange: (
        value: string,
    
        type:
          | 'info'
          | 'title'
          | 'content'
          | 'question'
          | 'link'
          | 'image'
          | 'subject'
    
      ) => void
      onDelete: (target: ContentItems) => void
    
    }
    const MonthlyInfo: React.FC<MonthlyInfoProps> = ({
      onSave,
      onCancel,
      info,
      handleChange,
      onDelete,
    
    }: MonthlyInfoProps) => {
      return (
        <div className="monthlyInfo">
    
          <h2>Informations du mois (Optionnel)</h2>
    
            <p className="title">Image</p>
            <ImagePicker imageURL={imageURL} handleChange={handleChange} />
            <p className="title">Info</p>
    
            <CustomEditor
              baseState={convertStringToEditorState(info)}
              handleChange={handleChange}
              editorType="info"
            />
            <div className="buttons">
              <button className="btnCancel" onClick={onCancel}>
                Annuler
              </button>
              <button className="btnValid" onClick={onSave}>
                Sauvegarder
              </button>
              <button className="btnDelete" onClick={() => onDelete('monthlyInfo')}>
                Supprimer
              </button>
            </div>
          </div>
        </div>
      )
    }
    
    export default MonthlyInfo