Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 6753 Rev 6861
Línea 1... Línea 1...
1
import React, { useState } from 'react'
1
import React, { useState } from 'react'
2
import { axios } from '../../utils'
2
import { axios } from '../../utils'
3
import { Modal } from 'react-bootstrap'
3
import { Modal } from 'react-bootstrap'
4
import { useForm } from 'react-hook-form'
4
import { useForm } from 'react-hook-form'
5
import { useDispatch } from 'react-redux'
5
import { useDispatch, useSelector } from 'react-redux'
6
import { addNotification } from '../../redux/notification/notification.actions'
6
import { addNotification } from '../../redux/notification/notification.actions'
Línea 7... Línea 7...
7
 
7
 
8
import Spinner from '../UI/Spinner'
8
import Spinner from '../UI/Spinner'
-
 
9
import FormErrorFeedback from '../UI/FormErrorFeedback'
Línea 9... Línea 10...
9
import FormErrorFeedback from '../UI/FormErrorFeedback'
10
import useFetchHelper from '../../hooks/useFetchHelper'
10
 
11
 
11
const AddCompanyModal = ({
12
const AddCompanyModal = ({
12
  show = false,
13
  show = false,
13
  onHide = () => null,
-
 
14
  fetchCompanies = () => [],
14
  onHide = () => null,
15
  companySizes = {},
15
  fetchCompanies = () => [],
16
  industries = {},
16
  industries = {},
-
 
17
}) => {
-
 
18
  const [loading, setLoading] = useState(false)
17
}) => {
19
  const { data: companySizes } = useFetchHelper('company-sizes')
Línea 18... Línea 20...
18
  const [loading, setLoading] = useState(false)
20
  const labels = useSelector(({ intl }) => intl.labels)
Línea 19... Línea 21...
19
  const dispatch = useDispatch()
21
  const dispatch = useDispatch()
Línea 52... Línea 54...
52
  }
54
  }
Línea 53... Línea 55...
53
 
55
 
54
  return (
56
  return (
55
    <Modal show={show} onHide={onHide}>
57
    <Modal show={show} onHide={onHide}>
56
      <Modal.Header closeButton>
58
      <Modal.Header closeButton>
57
        <Modal.Title>Nueva Empresa</Modal.Title>
59
        <Modal.Title>{labels.new_company}</Modal.Title>
58
      </Modal.Header>
60
      </Modal.Header>
59
      <form onSubmit={handleSubmit(onSubmitHandler)}>
61
      <form onSubmit={handleSubmit(onSubmitHandler)}>
60
        <Modal.Body className="position-relative">
62
        <Modal.Body className="position-relative">
61
          <div className="form-group">
63
          <div className="form-group">
62
            <input
64
            <input
63
              type="text"
65
              type="text"
64
              name="name"
66
              name="name"
65
              placeholder="Nombre de la empresa"
67
              placeholder={labels.name_of_company}
66
              ref={register({
68
              ref={register({
67
                required: 'Por favor ingrese el nombre de la Empresa',
69
                required: 'Por favor ingrese el nombre de la Empresa',
68
              })}
70
              })}
69
            />
71
            />
Línea 74... Línea 76...
74
 
76
 
75
          <div className="form-group">
77
          <div className="form-group">
76
            <select
78
            <select
77
              name="industry_id"
79
              name="industry_id"
78
              ref={register({
80
              ref={register({
79
                required: 'Por favor eliga una industria',
81
                required: labels.select_industry,
80
              })}
82
              })}
81
            >
83
            >
82
              <option value="" hidden>
84
              <option value="" hidden>
83
                Industria
85
                {labels.industry}
84
              </option>
86
              </option>
85
              {Object.entries(industries).map(([key, value]) => (
87
              {Object.entries(industries).map(([key, value]) => (
86
                <option value={key} key={key}>
88
                <option value={key} key={key}>
87
                  {value}
89
                  {value}
Línea 97... Línea 99...
97
 
99
 
98
          <div className="form-group">
100
          <div className="form-group">
99
            <select
101
            <select
100
              name="company_size_id"
102
              name="company_size_id"
101
              ref={register({
103
              ref={register({
102
                required: 'Por favor eliga el tamaño de la empresa',
104
                required: labels.select_company_size,
103
              })}
105
              })}
104
            >
106
            >
105
              <option value="" hidden>
107
              <option value="" hidden>
106
                Tamaño de la empresa
108
                {labels.company_size}
107
              </option>
109
              </option>
108
              {Object.entries(companySizes).map(([key, value]) => (
110
              {companySizes.map(({ name, value }) => (
109
                <option value={key} key={key}>
111
                <option value={value} key={value}>
110
                  {value}
112
                  {name}
111
                </option>
113
                </option>
112
              ))}
114
              ))}
113
            </select>
115
            </select>
114
            {errors.company_size_id && (
116
            {errors.company_size_id && (
Línea 120... Línea 122...
120
 
122
 
121
          {loading && <Spinner />}
123
          {loading && <Spinner />}
122
        </Modal.Body>
124
        </Modal.Body>
123
        <Modal.Footer>
125
        <Modal.Footer>
124
          <button type="submit" className="btn btn-primary">
126
          <button type="submit" className="btn btn-primary">
125
            Crear
127
            {labels.accept}
126
          </button>
128
          </button>
127
          <button type="button" className="btn btn-secondary" onClick={onHide}>
129
          <button type="button" className="btn btn-secondary" onClick={onHide}>
128
            Cancelar
130
            {labels.cancel}
129
          </button>
131
          </button>
130
        </Modal.Footer>
132
        </Modal.Footer>
131
      </form>
133
      </form>
132
    </Modal>
134
    </Modal>