11import React , { Fragment } from 'react'
2- import { Link , withRouter } from 'react-router-dom'
2+ import { Link , useNavigate , useLocation , useParams } from 'react-router-dom'
33import clientAxios from '../config/axios'
44import Swal from 'sweetalert2' ;
5+ let navigate ;
6+ function withRouter ( Component ) {
7+ function ComponentWithRouterProp ( props ) {
8+ let location = useLocation ( ) ;
9+ navigate = useNavigate ( ) ;
10+ let params = useParams ( ) ;
11+ return (
12+ < Component
13+ { ...props }
14+ router = { { location, navigate, params } }
15+ />
16+ ) ;
17+ }
18+
19+ return ComponentWithRouterProp ;
20+ }
21+
522
623const Meeting = ( props ) => {
724
25+
826 if ( ! props . meeting ) {
9- props . history . push ( '/' )
27+ //props.history.push('/')
28+ //para las nuevas versiones de react
29+ navigate ( '/' )
1030 return null ;
1131 }
12-
32+ console . log ( props )
33+
1334 //extraemos props
1435 const { meeting :{ _id, name, owner, date, time, signals, phone} } = props
15-
16- const deleteMeeting = id => {
17-
36+
37+ const deleteMeeting = id => {
38+
1839 Swal . fire ( {
1940 title : 'Estas seguro?' ,
2041 text : "Una cita eliminada no se puede recuperar!" ,
@@ -31,12 +52,13 @@ const Meeting = (props) => {
3152 'success'
3253 )
3354 //Eliminando de la base de datos
34- clientAxios . delete ( `/patients/${ id } ` )
35- . then (
55+ //clientAxios.delete(`/patients/${id}`)
56+ clientAxios . delete ( "/patients/" + id )
57+ . then (
3658 response => {
3759 props . saveConsult ( true )
3860 console . log ( response ) ;
39- props . history . push ( '/' )
61+ navigate ( '/' )
4062 }
4163 )
4264
@@ -78,16 +100,14 @@ const Meeting = (props) => {
78100 </ div >
79101 < div className = "d-flex" >
80102 < button type = "button"
81- className = "text-uppercase py-2 px-5 font-weight-bold btn btn-dange col"
103+ className = "text-uppercase py-2 px-5 font-weight-bold btn btn-danger col"
82104 onClick = { ( ) => deleteMeeting ( _id ) }
83105 >
84106 Eliminar ×
85107 </ button >
86108
87109 </ div >
88110
89-
90-
91111 </ div >
92112
93113 </ div >
0 commit comments