hacer editable el campo asociado al valor
This commit is contained in:
		
							parent
							
								
									1c6fa54f3a
								
							
						
					
					
						commit
						197d1d5e47
					
				| 
						 | 
					@ -16,7 +16,7 @@ import classNames from 'classnames';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const RegistroComunicado = () => {
 | 
					const RegistroComunicado = () => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let emptyComunicado = {
 | 
					  const emptyComunicado = {
 | 
				
			||||||
    _id: null,
 | 
					    _id: null,
 | 
				
			||||||
    post: '',
 | 
					    post: '',
 | 
				
			||||||
    user_id: '',
 | 
					    user_id: '',
 | 
				
			||||||
| 
						 | 
					@ -51,7 +51,7 @@ const RegistroComunicado = () => {
 | 
				
			||||||
  const saveComunicado = () => {
 | 
					  const saveComunicado = () => {
 | 
				
			||||||
    if (comunicado._id === null) {
 | 
					    if (comunicado._id === null) {
 | 
				
			||||||
      var data = {
 | 
					      var data = {
 | 
				
			||||||
        post: document.getElementById('txt_comunicado').value,
 | 
					        post: comunicado.post,
 | 
				
			||||||
        user_id: cookies.id,
 | 
					        user_id: cookies.id,
 | 
				
			||||||
        community_id: cookies.community_id
 | 
					        community_id: cookies.community_id
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
| 
						 | 
					@ -69,16 +69,16 @@ const RegistroComunicado = () => {
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
          return response.json();
 | 
					          return response.json();
 | 
				
			||||||
      }).then((_response) => {
 | 
					      }).then((_response) => {
 | 
				
			||||||
 | 
					        setComunicado(emptyComunicado);
 | 
				
			||||||
      }).catch(
 | 
					      }).catch(
 | 
				
			||||||
        err => console.log('Ocurrió un error con el fetch', err)
 | 
					        err => console.log('Ocurrió un error con el fetch', err)
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      const data = {
 | 
					      const data = {
 | 
				
			||||||
        _id: comunicado._id,
 | 
					        _id: comunicado._id,
 | 
				
			||||||
        post: document.getElementById('txt_comunicado').value,
 | 
					        post: comunicado.post,
 | 
				
			||||||
        user_id: cookies.id,
 | 
					        user_id: comunicado.user_id,
 | 
				
			||||||
        community_id: cookies.community_id
 | 
					        community_id: comunicado.community_id
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      fetch(`http://localhost:4000/post/updatePost/${comunicado._id}`, {
 | 
					      fetch(`http://localhost:4000/post/updatePost/${comunicado._id}`, {
 | 
				
			||||||
| 
						 | 
					@ -95,6 +95,8 @@ const RegistroComunicado = () => {
 | 
				
			||||||
          return response.json();
 | 
					          return response.json();
 | 
				
			||||||
      }).then((_response) => {
 | 
					      }).then((_response) => {
 | 
				
			||||||
        setComunicado(emptyComunicado);
 | 
					        setComunicado(emptyComunicado);
 | 
				
			||||||
 | 
					        setSaveButtonLabel('Registrar');
 | 
				
			||||||
 | 
					        listaComunis();
 | 
				
			||||||
      }).catch(
 | 
					      }).catch(
 | 
				
			||||||
        err => console.log('Ocurrió un error con el fetch', err)
 | 
					        err => console.log('Ocurrió un error con el fetch', err)
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
| 
						 | 
					@ -245,7 +247,16 @@ const RegistroComunicado = () => {
 | 
				
			||||||
                  <span className="p-inputgroup-addon p-button p-icon-input-khaki">
 | 
					                  <span className="p-inputgroup-addon p-button p-icon-input-khaki">
 | 
				
			||||||
                    <i className="pi pi-pencil"></i>
 | 
					                    <i className="pi pi-pencil"></i>
 | 
				
			||||||
                  </span>
 | 
					                  </span>
 | 
				
			||||||
                  <InputTextarea value={comunicado.post} id="txt_comunicado" />
 | 
					                  <InputTextarea
 | 
				
			||||||
 | 
					                    value={comunicado.post}
 | 
				
			||||||
 | 
					                    placeholder="Ingrese el contenido del comunicado"
 | 
				
			||||||
 | 
					                    onChange={(e) => setComunicado({ ...comunicado, post: e.target.value })}
 | 
				
			||||||
 | 
					                    id="txt_comunicado"
 | 
				
			||||||
 | 
					                    type="text"
 | 
				
			||||||
 | 
					                    autoResize
 | 
				
			||||||
 | 
					                    rows={5}
 | 
				
			||||||
 | 
					                    cols={50}
 | 
				
			||||||
 | 
					                  />
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
              </div>
 | 
					              </div>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
| 
						 | 
					@ -257,7 +268,7 @@ const RegistroComunicado = () => {
 | 
				
			||||||
            }}>
 | 
					            }}>
 | 
				
			||||||
              <Button
 | 
					              <Button
 | 
				
			||||||
                label={`${saveButtonLabel}`}
 | 
					                label={`${saveButtonLabel}`}
 | 
				
			||||||
                onClick={() => saveComunicado()}
 | 
					                onClick={saveComunicado}
 | 
				
			||||||
              />
 | 
					              />
 | 
				
			||||||
              {saveButtonLabel === 'Actualizar' && (
 | 
					              {saveButtonLabel === 'Actualizar' && (
 | 
				
			||||||
                <Button
 | 
					                <Button
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue