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 ; } const createApppointmentForm = () => (

Fill The below form for New Appointment

* refers to mandatory

setPatientName(e.target.value)} placeholder="Your Name*" className="formInput" required /> {/* setDocterName(e.target.value)} value={DocterName} required /> */} setEmail(e.target.value)} className="formInput" name="Email" /> setPhoneNo(e.target.value)} value={PhoneNo} required /> setDate(e.target.value)} name="Date" required /> setTime(e.target.value)} name="Time" required /> setAge(e.target.value)} name="Age" required />