Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 1437 | Rev 1929 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1437 Rev 1460
Línea 1... Línea 1...
1
import React, { useEffect, useState } from 'react'
1
import React, { useEffect, useState } from 'react'
-
 
2
import { useDispatch, useSelector } from 'react-redux'
2
import { useForm } from 'react-hook-form'
3
import { useForm } from 'react-hook-form'
3
import { CKEditor } from 'ckeditor4-react'
4
import { CKEditor } from 'ckeditor4-react'
4
import { useDispatch, useSelector } from 'react-redux'
-
 
5
import { Button, Form, Modal } from 'react-bootstrap'
-
 
-
 
5
 
6
import { CKEDITOR_OPTIONS, axios } from '../../utils'
6
import { CKEDITOR_OPTIONS, axios } from 'utils/index'
7
import { addNotification } from '../../redux/notification/notification.actions'
7
import { addNotification } from '../../redux/notification/notification.actions'
Línea -... Línea 8...
-
 
8
 
8
 
9
import Modal from 'components/UI/modal/Modal'
9
import Spinner from '../UI/Spinner'
10
import Spinner from 'components/UI/Spinner'
Línea 10... Línea 11...
10
import FormErrorFeedback from '../UI/form/FormErrorFeedback'
11
import FormErrorFeedback from 'components/UI/form/FormErrorFeedback'
11
 
12
 
12
const AnswerModal = ({
13
const AnswerModal = ({
13
  show = false,
14
  show = false,
Línea 55... Línea 56...
55
  useEffect(() => {
56
  useEffect(() => {
56
    setValue('description', currentAnswer)
57
    setValue('description', currentAnswer)
57
  }, [currentAnswer])
58
  }, [currentAnswer])
Línea 58... Línea 59...
58
 
59
 
59
  return (
60
  return (
60
    <Modal show={show}>
-
 
61
      <Modal.Header className='pb-0'>
61
    <Modal
62
        <Modal.Title>
-
 
63
          {currentAnswer
62
      title={
64
            ? labels.my_coach_answer_edit
-
 
65
            : labels.my_coach_answer_add}
-
 
66
        </Modal.Title>
63
        currentAnswer ? labels.my_coach_answer_edit : labels.my_coach_answer_add
67
      </Modal.Header>
64
      }
68
      <Modal.Body>
65
      show={show}
69
        {loading ? (
66
      onClose={onClose}
70
          <Spinner />
67
      onAccept={onSubmit}
71
        ) : (
-
 
72
          <Form onSubmit={onSubmit}>
68
    >
73
            <CKEditor
69
      <CKEditor
74
              onChange={(e) => setValue('description', e.editor.getData())}
70
        onChange={(e) => setValue('description', e.editor.getData())}
75
              onInstanceReady={(e) => e.editor.setData(currentAnswer)}
71
        onInstanceReady={(e) => e.editor.setData(currentAnswer)}
76
              config={CKEDITOR_OPTIONS}
72
        config={CKEDITOR_OPTIONS}
77
            />
73
      />
78
            {errors.description && (
74
      {errors.description && (
79
              <FormErrorFeedback>{labels.error_field_empty}</FormErrorFeedback>
75
        <FormErrorFeedback>{labels.error_field_empty}</FormErrorFeedback>
80
            )}
76
      )}
81
 
-
 
82
            <Button className='mt-3 mr-2' variant='primary' type='submit'>
-
 
83
              {labels.accept}
-
 
84
            </Button>
-
 
85
            <Button className='btn-secondary mt-3' onClick={onClose}>
77
 
86
              {labels.cancel}
-
 
87
            </Button>
-
 
88
          </Form>
-
 
89
        )}
-
 
90
      </Modal.Body>
78
      {loading && <Spinner />}
91
    </Modal>
79
    </Modal>
92
  )
80
  )
Línea 93... Línea 81...
93
}
81
}