Renaming Issue
This commit is contained in:
parent
6dbbf05106
commit
9bfc097051
|
@ -1,87 +1,88 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from "react";
|
||||||
import Navbar from './nav'
|
import Navbar from "./nav";
|
||||||
import "../components/css/bookAppointment.css";
|
import "../components/css/bookedAppointment.css";
|
||||||
import { API } from "../helper/apicall";
|
import { API } from "../helper/apicall";
|
||||||
import Axios from 'axios';
|
import Axios from "axios";
|
||||||
import { Redirect } from 'react-router';
|
import { Redirect } from "react-router";
|
||||||
|
|
||||||
function BookedAppointment(props) {
|
function BookedAppointment(props) {
|
||||||
const [data, setData] = useState([]);
|
const [data, setData] = useState([]);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [routeRedirect, setRedirect] = useState("");
|
const [routeRedirect, setRedirect] = useState("");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const result = await Axios(
|
const result = await Axios(API + "/apointments");
|
||||||
API +'/apointments',
|
|
||||||
);
|
|
||||||
setData(result.data.rows);
|
setData(result.data.rows);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
console.log(result.data.rows);
|
console.log(result.data.rows);
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchData();
|
fetchData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const removeData = (id) => {
|
const removeData = (id) => {
|
||||||
|
Axios.delete(API + `/apointments/${id}`).then((res) => {
|
||||||
|
const del = data.filter((item) => id !== item.id);
|
||||||
|
setData(del);
|
||||||
|
setRedirect(true);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
Axios.delete(API + `/apointments/${id}`).then(res => {
|
const redirect = routeRedirect;
|
||||||
const del = data.filter(item => id !== item.id)
|
if (redirect) {
|
||||||
setData(del)
|
return <Redirect to="/" />;
|
||||||
setRedirect(true);
|
}
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const redirect = routeRedirect;
|
return (
|
||||||
if(redirect){
|
<div>
|
||||||
return <Redirect to="/" />
|
<Navbar></Navbar>
|
||||||
}
|
<div className="container-fluid m-2 mb-10">
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Navbar></Navbar>
|
|
||||||
<div className="container-fluid m-2 mb-10">
|
|
||||||
<table className="table table-responsive">
|
<table className="table table-responsive">
|
||||||
<thead className="text-dark">
|
<thead className="text-dark">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">PatientName</th>
|
<th scope="col">PatientName</th>
|
||||||
{/* <th scope="col">DocterName</th> */}
|
{/* <th scope="col">DocterName</th> */}
|
||||||
<th scope="col">Email</th>
|
<th scope="col">Email</th>
|
||||||
<th scope="col">PhoneNo</th>
|
<th scope="col">PhoneNo</th>
|
||||||
<th scope="col">Date</th>
|
<th scope="col">Date</th>
|
||||||
<th scope="col">Time</th>
|
<th scope="col">Time</th>
|
||||||
<th scope="col">Age</th>
|
<th scope="col">Age</th>
|
||||||
<th scope="col">Description</th>
|
<th scope="col">Description</th>
|
||||||
<th scope="col">Action</th>
|
<th scope="col">Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div>Loading ...</div>
|
<div>Loading ...</div>
|
||||||
) : (
|
) : (
|
||||||
<tbody>
|
<tbody>
|
||||||
{data.map(item => (
|
{data.map((item) => (
|
||||||
<tr key={item.id}>
|
<tr key={item.id}>
|
||||||
<td className="text-center"> {item.PatientName}</td>
|
<td className="text-center"> {item.PatientName}</td>
|
||||||
{/* <td className="text-center">{item.DocterName}</td> */}
|
{/* <td className="text-center">{item.DocterName}</td> */}
|
||||||
<td className="text-center">{item.Email}</td>
|
<td className="text-center">{item.Email}</td>
|
||||||
<td className="text-center">{item.PhoneNo}</td>
|
<td className="text-center">{item.PhoneNo}</td>
|
||||||
<td className="text-center">{item.Date}</td>
|
<td className="text-center">{item.Date}</td>
|
||||||
<td className="text-center">{item.Time}</td>
|
<td className="text-center">{item.Time}</td>
|
||||||
<td className="text-center">{item.Age}</td>
|
<td className="text-center">{item.Age}</td>
|
||||||
<td className="text-center">{item.Description}</td>
|
<td className="text-center">{item.Description}</td>
|
||||||
<td className="text-center">
|
<td className="text-center">
|
||||||
<button onClick={() => removeData(item.id)} className="btn btn-danger">Delete</button>
|
<button
|
||||||
</td>
|
onClick={() => removeData(item.id)}
|
||||||
</tr>
|
className="btn btn-danger"
|
||||||
))}
|
>
|
||||||
</tbody>
|
Delete
|
||||||
)}
|
</button>
|
||||||
</table>
|
</td>
|
||||||
</div>
|
</tr>
|
||||||
</div>
|
))}
|
||||||
);
|
</tbody>
|
||||||
|
)}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default BookedAppointment;
|
export default BookedAppointment;
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue