import React, { useEffect, useState } from "react";
import "./css/newAppointment.css";
import Navbar from "./nav";
import { Redirect } from "react-router";
import { API } from "../helper/apicall";
const NewAppointment = () => {
const [PatientName, setPatientName] = useState("");
const [Email, setEmail] = useState("");
const [PhoneNo, setPhoneNo] = useState("");
const [Date, setDate] = useState("");
const [Time, setTime] = useState("");
const [Age, setAge] = useState("");
const [Description, setDescription] = useState("");
const [error, setError] = useState(false);
const [success, setSuccess] = useState(false);
const [routeRedirect, setRedirect] = useState("");
const createItem = (e) => {
e.preventDefault();
const item = {
PatientName: PatientName,
// DocterName: DocterName,
Email: Email,
PhoneNo: PhoneNo,
Date: Date,
Time: Time,
Age: Age,
Description: Description,
// Department: Department,
};
const options = {
method: "post",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(item),
};
if (
PatientName &&
// DocterName &&
Email &&
PhoneNo &&
Date &&
Time &&
Age &&
Description
// Department
) {
fetch(API + "/apointments", options).then((res) => {
console.log(res);
setRedirect(true);
});
} else {
console.log("The form is not valid to be sent");
}
};
const redirect = routeRedirect;
if (redirect) {
return