Minor Fixes

This commit is contained in:
Jyotirmoy Bandyopadhayaya 2020-10-29 08:54:47 +05:30
parent 641f96c380
commit bf4e471d27
18 changed files with 665 additions and 471 deletions

View File

@ -6,7 +6,17 @@ import { schema } from "./model";
export Apointment, { schema } from "./model";
const router = new Router();
const { No, PatientName, Email, PhoneNo, Date, Time, Msg, Age } = schema.tree;
const {
No,
PatientName,
DocterName,
Email,
PhoneNo,
Date,
Time,
Age,
Description,
} = schema.tree;
/**
* @api {post} /apointments Create apointment
@ -29,12 +39,13 @@ router.post(
body({
No,
PatientName,
DocterName,
Email,
PhoneNo,
Date,
Time,
Msg,
Age,
Description,
}),
create
);
@ -81,12 +92,13 @@ router.put(
body({
No,
PatientName,
DocterName,
Email,
PhoneNo,
Date,
Time,
Msg,
Age,
Description,
}),
update
);

View File

@ -8,8 +8,8 @@ const apointmentSchema = new Schema(
PatientName: {
type: String,
},
docID: {
type: Number,
DocterName: {
type: String,
},
Email: {
type: String,
@ -23,14 +23,11 @@ const apointmentSchema = new Schema(
Time: {
type: String,
},
depID: {
type: Number,
},
Msg: {
Age: {
type: String,
},
Age: {
type: Number,
Description: {
type: String,
},
},
{
@ -51,12 +48,13 @@ apointmentSchema.methods = {
id: this.id,
No: this.No,
PatientName: this.PatientName,
DocterName: this.DocterName,
Email: this.Email,
PhoneNo: this.PhoneNo,
Date: this.Date,
Time: this.Time,
Msg: this.Msg,
Age: this.Age,
Description: this.Description,
createdAt: this.createdAt,
updatedAt: this.updatedAt,
};

View File

@ -1,13 +1,13 @@
import { Router } from "express";
import { middleware as query } from "querymen";
import { middleware as body } from "bodymen";
import { token } from "../../services/passport";
import { create, index, show, update, destroy } from "./controller";
import { schema } from "./model";
export Department, { schema } from "./model";
import { Router } from 'express'
import { middleware as query } from 'querymen'
import { middleware as body } from 'bodymen'
import { token } from '../../services/passport'
import { create, index, show, update, destroy } from './controller'
import { schema } from './model'
export Department, { schema } from './model'
const router = new Router();
const { depID, Name, Nos } = schema.tree;
const router = new Router()
const { ID, Name, Nos } = schema.tree
/**
* @api {post} /Departments Create department
@ -23,12 +23,10 @@ const { depID, Name, Nos } = schema.tree;
* @apiError 404 Department not found.
* @apiError 401 admin access only.
*/
router.post(
"/",
token({ required: true, roles: ["admin"] }),
body({ depID, Name, Nos }),
create
);
router.post('/',
token({ required: true, roles: ['admin'] }),
body({ ID, Name, Nos }),
create)
/**
* @api {get} /Departments Retrieve departments
@ -39,7 +37,9 @@ router.post(
* @apiSuccess {Object[]} rows List of departments.
* @apiError {Object} 400 Some parameters may contain invalid values.
*/
router.get("/", query(), index);
router.get('/',
query(),
index)
/**
* @api {get} /Departments/:id Retrieve department
@ -49,7 +49,8 @@ router.get("/", query(), index);
* @apiError {Object} 400 Some parameters may contain invalid values.
* @apiError 404 Department not found.
*/
router.get("/:id", show);
router.get('/:id',
show)
/**
* @api {put} /Departments/:id Update department
@ -62,7 +63,9 @@ router.get("/:id", show);
* @apiError {Object} 400 Some parameters may contain invalid values.
* @apiError 404 Department not found.
*/
router.put("/:id", body({ depID, Name, Nos }), update);
router.put('/:id',
body({ ID, Name, Nos }),
update)
/**
* @api {delete} /Departments/:id Delete department
@ -71,6 +74,7 @@ router.put("/:id", body({ depID, Name, Nos }), update);
* @apiSuccess (Success 204) 204 No Content.
* @apiError 404 Department not found.
*/
router.delete("/:id", destroy);
router.delete('/:id',
destroy)
export default router;
export default router

View File

@ -1,50 +1,43 @@
import mongoose, { Schema } from "mongoose";
import mongoose, { Schema } from 'mongoose'
const departmentSchema = new Schema(
{
depID: {
type: String,
},
Name: {
type: String,
},
Nos: {
type: String,
},
const departmentSchema = new Schema({
ID: {
type: String
},
{
timestamps: true,
toJSON: {
virtuals: true,
transform: (obj, ret) => {
delete ret._id;
},
},
Name: {
type: String
},
Nos: {
type: String
}
);
}, {
timestamps: true,
toJSON: {
virtuals: true,
transform: (obj, ret) => { delete ret._id }
}
})
departmentSchema.methods = {
view(full) {
view (full) {
const view = {
// simple view
id: this.id,
depID: this.depID,
ID: this.ID,
Name: this.Name,
Nos: this.Nos,
createdAt: this.createdAt,
updatedAt: this.updatedAt,
};
updatedAt: this.updatedAt
}
return full
? {
...view,
// add properties for a full view
}
: view;
},
};
return full ? {
...view
// add properties for a full view
} : view
}
}
const model = mongoose.model("Department", departmentSchema);
const model = mongoose.model('Department', departmentSchema)
export const schema = model.schema;
export default model;
export const schema = model.schema
export default model

View File

@ -1,13 +1,13 @@
import { Router } from "express";
import { middleware as query } from "querymen";
import { middleware as body } from "bodymen";
import { token } from "../../services/passport";
import { create, index, show, update, destroy } from "./controller";
import { schema } from "./model";
export Doctor, { schema } from "./model";
import { Router } from 'express'
import { middleware as query } from 'querymen'
import { middleware as body } from 'bodymen'
import { token } from '../../services/passport'
import { create, index, show, update, destroy } from './controller'
import { schema } from './model'
export Doctor, { schema } from './model'
const router = new Router();
const { docID, Name, Dapartment } = schema.tree;
const router = new Router()
const { ID, Name, Dapartment } = schema.tree
/**
* @api {post} /Doctors Create doctor
@ -23,7 +23,10 @@ const { docID, Name, Dapartment } = schema.tree;
* @apiError 404 Doctor not found.
* @apiError 401 admin access only.
*/
router.post("/", create);
router.post('/',
token({ required: true, roles: ['admin'] }),
body({ ID, Name, Dapartment }),
create)
/**
* @api {get} /Doctors Retrieve doctors
@ -37,7 +40,10 @@ router.post("/", create);
* @apiError {Object} 400 Some parameters may contain invalid values.
* @apiError 401 admin access only.
*/
router.get("/", query(), index);
router.get('/',
token({ required: true, roles: ['admin'] }),
query(),
index)
/**
* @api {get} /Doctors/:id Retrieve doctor
@ -50,7 +56,9 @@ router.get("/", query(), index);
* @apiError 404 Doctor not found.
* @apiError 401 admin access only.
*/
router.get("/:id", show);
router.get('/:id',
token({ required: true, roles: ['admin'] }),
show)
/**
* @api {put} /Doctors/:id Update doctor
@ -66,12 +74,10 @@ router.get("/:id", show);
* @apiError 404 Doctor not found.
* @apiError 401 admin access only.
*/
router.put(
"/:id",
token({ required: true, roles: ["admin"] }),
body({ docID, Name, Dapartment }),
update
);
router.put('/:id',
token({ required: true, roles: ['admin'] }),
body({ ID, Name, Dapartment }),
update)
/**
* @api {delete} /Doctors/:id Delete doctor
@ -83,6 +89,8 @@ router.put(
* @apiError 404 Doctor not found.
* @apiError 401 admin access only.
*/
router.delete("/:id", token({ required: true, roles: ["admin"] }), destroy);
router.delete('/:id',
token({ required: true, roles: ['admin'] }),
destroy)
export default router;
export default router

View File

@ -1,50 +1,43 @@
import mongoose, { Schema } from "mongoose";
import mongoose, { Schema } from 'mongoose'
const doctorSchema = new Schema(
{
docID: {
type: String,
},
Name: {
type: String,
},
Dapartment: {
type: String,
},
const doctorSchema = new Schema({
ID: {
type: String
},
{
timestamps: true,
toJSON: {
virtuals: true,
transform: (obj, ret) => {
delete ret._id;
},
},
Name: {
type: String
},
Dapartment: {
type: String
}
);
}, {
timestamps: true,
toJSON: {
virtuals: true,
transform: (obj, ret) => { delete ret._id }
}
})
doctorSchema.methods = {
view(full) {
view (full) {
const view = {
// simple view
id: this.id,
docID: this.docID,
ID: this.ID,
Name: this.Name,
Dapartment: this.Dapartment,
createdAt: this.createdAt,
updatedAt: this.updatedAt,
};
updatedAt: this.updatedAt
}
return full
? {
...view,
// add properties for a full view
}
: view;
},
};
return full ? {
...view
// add properties for a full view
} : view
}
}
const model = mongoose.model("Doctor", doctorSchema);
const model = mongoose.model('Doctor', doctorSchema)
export const schema = model.schema;
export default model;
export const schema = model.schema
export default model

View File

@ -1,15 +1,16 @@
import React from "react";
import {BrowserRouter as Router ,Route ,Switch} from 'react-router-dom'
import Home from './components/home';
import Header from './components/header'
import Department from './components/department'
import NewAppointment from './components/newAppointment'
import Doctors from './components/doctors'
import Contact from './components/contact'
import AdminLogin from './components/adminLogin'
import AdminAfterLogin from './components/adminafterlogin'
import Logout from './components/logout'
import Footer from './components/footer'
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import Home from "./components/home";
import Header from "./components/header";
import Department from "./components/department";
import NewAppointment from "./components/newAppointment";
import Doctors from "./components/doctors";
import Contact from "./components/contact";
import AdminLogin from "./components/adminLogin";
import AdminAfterLogin from "./components/adminafterlogin";
import Logout from "./components/logout";
import Footer from "./components/footer";
import BookedAppointment from "./components/BookedAppointment";
function App() {
return (
@ -17,14 +18,13 @@ function App() {
<Router>
<Header></Header>
<Switch>
<Route exact path = "/" component = {Home} />
<Route exact path = "/department" component = {Department} />
<Route path = "/newappointment" component = {NewAppointment} />
<Route path = "/doctors" component = {Doctors} />
<Route path = "/contact" component = {Contact} />
<Route path = "/adminLogin" component = {AdminLogin} />
<Route path = "/adminafterlogin" component = {AdminAfterLogin} />
<Route path = "/logout" component = {Logout} />
<Route exact path="/" component={Home} />
<Route path="/newappointment" component={NewAppointment} />
<Route path="/contact" component={Contact} />
<Route path="/adminLogin" component={AdminLogin} />
<Route path="/adminafterlogin" component={AdminAfterLogin} />
<Route path="/booked-appointments" component={BookedAppointment} />
<Route path="/logout" component={Logout} />
</Switch>
<Footer></Footer>
</Router>

View File

@ -0,0 +1,88 @@
import React, { useEffect, useState } from 'react';
import Navbar from './nav'
import "../components/css/boostrap.css";
import '../components/css/adminNav.css'
import { API } from "../helper/apicall";
import Axios from 'axios';
import { Redirect } from 'react-router';
function BookedAppointment(props) {
const [data, setData] = useState([]);
const [isLoading, setIsLoading] = useState(false);
const [routeRedirect, setRedirect] = useState("");
useEffect(() => {
const fetchData = async () => {
setIsLoading(true);
const result = await Axios(
API +'/apointments',
);
setData(result.data.rows);
setIsLoading(false);
console.log(result.data.rows);
};
fetchData();
}, []);
const removeData = (id) => {
Axios.delete(API + `/apointments/${id}`).then(res => {
const del = data.filter(item => id !== item.id)
setData(del)
setRedirect(true);
})
}
const redirect = routeRedirect;
if(redirect){
return <Redirect to="/" />
}
return (
<div>
<Navbar></Navbar>
<div className="container-fluid m-2 mb-10">
<table className="table table-responsive">
<thead className="text-dark">
<tr>
<th scope="col">PatientName</th>
{/* <th scope="col">DocterName</th> */}
<th scope="col">Email</th>
<th scope="col">PhoneNo</th>
<th scope="col">Date</th>
<th scope="col">Time</th>
<th scope="col">Age</th>
<th scope="col">Description</th>
<th scope="col">Action</th>
</tr>
</thead>
{isLoading ? (
<div>Loading ...</div>
) : (
<tbody>
{data.map(item => (
<tr key={item.id}>
<td className="text-center"> {item.PatientName}</td>
{/* <td className="text-center">{item.DocterName}</td> */}
<td className="text-center">{item.Email}</td>
<td className="text-center">{item.PhoneNo}</td>
<td className="text-center">{item.Date}</td>
<td className="text-center">{item.Time}</td>
<td className="text-center">{item.Age}</td>
<td className="text-center">{item.Description}</td>
<td className="text-center">
<button onClick={() => removeData(item.id)} className="btn btn-danger">Delete</button>
</td>
</tr>
))}
</tbody>
)}
</table>
</div>
</div>
);
}
export default BookedAppointment;

View File

@ -1,16 +1,15 @@
import React from 'react';
import Navbar from './nav'
import './css/basic.css'
import React from "react";
import Navbar from "./nav";
import "./css/basic.css";
class Contact extends React.Component {
render(){
return(
<div>
<Navbar></Navbar>
<h1 className= "message">This is Contact us Page</h1>
</div>
);
}
render() {
return (
<div>
<Navbar></Navbar>
<h1 className="message">This is Contact us Page</h1>
</div>
);
}
}
export default Contact
export default Contact;

View File

@ -46,3 +46,10 @@
background-size: cover;
background-blend-mode: darken;
}
.mb-10{
margin-bottom: 80rem !important;
}
.table{
margin:10rem !important
}

File diff suppressed because one or more lines are too long

View File

@ -4,8 +4,8 @@ class Footer extends React.Component {
render() {
return (
<div>
<footer class="background">
<p class="text-footer">
<footer className="background">
<p className="text-footer">
CopyRight &copy; www.Medicare.com..All Right are Reserved.
</p>
</footer>

View File

@ -1,39 +1,44 @@
import React from 'react'
import './css/header.css'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faFacebook,faWhatsapp,faInstagram,faTwitter } from '@fortawesome/free-brands-svg-icons'
import { faClock } from '@fortawesome/free-regular-svg-icons'
import { faPhoneVolume } from '@fortawesome/free-solid-svg-icons'
import React from "react";
import "./css/header.css";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
faFacebook,
faWhatsapp,
faInstagram,
faTwitter,
} from "@fortawesome/free-brands-svg-icons";
import { faClock } from "@fortawesome/free-regular-svg-icons";
import { faPhoneVolume } from "@fortawesome/free-solid-svg-icons";
function Header(){
return(
<div>
<nav class="smallnav">
<div class="smallnav-info">
<FontAwesomeIcon icon={faClock} />
<p>MON-FRI 8AM - 7PM</p>
</div>
<div class="smallnav-info">
<FontAwesomeIcon icon={faPhoneVolume} />
<p>CALL +91 9557860483</p>
</div>
<div class="icon">
<div class= "icondesign">
<FontAwesomeIcon icon={faFacebook} />
</div>
<div class= "icondesign">
<FontAwesomeIcon icon={faWhatsapp} />
</div>
<div class= "icondesign">
<FontAwesomeIcon icon={faInstagram} />
</div>
<div class= "icondesign">
<FontAwesomeIcon icon={faTwitter} />
</div>
</div>
</nav>
function Header() {
return (
<div>
<nav className="smallnav">
<div className="smallnav-info">
<FontAwesomeIcon icon={faClock} />
<p>MON-FRI 8AM - 7PM</p>
</div>
);
<div className="smallnav-info">
<FontAwesomeIcon icon={faPhoneVolume} />
<p>CALL +91 9557860483</p>
</div>
<div className="icon">
<div className="icondesign">
<FontAwesomeIcon icon={faFacebook} />
</div>
<div className="icondesign">
<FontAwesomeIcon icon={faWhatsapp} />
</div>
<div className="icondesign">
<FontAwesomeIcon icon={faInstagram} />
</div>
<div className="icondesign">
<FontAwesomeIcon icon={faTwitter} />
</div>
</div>
</nav>
</div>
);
}
export default Header
export default Header;

View File

@ -1,90 +1,107 @@
import React from 'react';
import './css/home.css';
import logo from './img/logo.png'
import Navbar from './nav'
import React from "react";
import "./css/home.css";
import logo from "./img/logo.png";
import Navbar from "./nav";
class Home extends React.Component {
constructor(props) {
super();
this.onClick = this.onClick.bind(this);
}
class Home extends React.Component{
onClick(e) {
e.preventDefault();
this.props.history.push("/adminLogin");
}
constructor(props){
super();
this.onClick=this.onClick.bind(this);
}
onClick(e){
e.preventDefault();
this.props.history.push('/adminLogin')
}
render(){
return(
<div>
<Navbar></Navbar>
<div class="firstSection background">
<div class="main-box">
<div class="firstHalf">
<p class="text-big">Your doctor your treatment</p>
<div class="text-small">
Proactively envisioned multimedia based expertise and cross-media growth strategies. Seamlessly visualize quality intellectual capital without superior collaboration and idea-sharing.
<div class="buttons">
<button class="btn" onClick={this.onClick}>Admin Sign in</button>
</div>
</div>
</div>
<div class="secondHalf">
<img src={logo} alt="logoImage" />
</div>
</div>
render() {
return (
<div>
<Navbar></Navbar>
<div className="firstSection background">
<div className="main-box">
<div className="firstHalf">
<p className="text-big">Your doctor your treatment</p>
<div className="text-small">
Proactively envisioned multimedia based expertise and
cross-media growth strategies. Seamlessly visualize quality
intellectual capital without superior collaboration and
idea-sharing.
<div className="buttons">
<button className="btn" onClick={this.onClick}>
Admin Sign in
</button>
</div>
<section class="section">
<div class="para">
<p class="sectionTag text-big">Health care</p>
<p class="sectionSubTag text-small">
For all your family needs
</p>
<p class="sectionSubTag text-small">
Efficiently unleash cross-media information without cross-media value. Quickly maximize timely deliverables for real-time schemas. Dramatically maintain clicks-and-mortar solutions without functional solutions.
</p>
</div>
</div>
</div>
<div className="secondHalf">
<img src={logo} alt="logoImage" />
</div>
</div>
</div>
<section className="section">
<div className="para">
<p className="sectionTag text-big">Health care</p>
<p className="sectionSubTag text-small">
For all your family needs
</p>
<p className="sectionSubTag text-small">
Efficiently unleash cross-media information without cross-media
value. Quickly maximize timely deliverables for real-time schemas.
Dramatically maintain clicks-and-mortar solutions without
functional solutions.
</p>
</div>
<div class="thumbnail">
<img src="https://source.unsplash.com/900x900/?Health,doctor" alt="Laptop" />
</div>
</section>
<section class="section section-left">
<div class="para">
<p class="sectionTag text-big">Dentist</p>
<p class="sectionSubTag text-small">
For your child whitest teeths
</p>
<p class="sectionSubTag text-small">
Completely synergize resource taxing relationships via premier niche markets. Professionally cultivate one-to-one customer service with robust ideas. Dynamically innovate resource-leveling customer service for state of the art customer service.
</p>
</div>
<div class="thumbnail">
<img src="https://source.unsplash.com/900x900/?Dentist" alt="Laptop" />
</div>
</section>
<section class="section">
<div class="para">
<p class="sectionTag text-big">Pediatrician</p>
<p class="sectionSubTag text-small">
Children medical care
</p>
<p class="sectionSubTag text-small">
Objectively innovate empowered manufactured products whereas parallel platforms. Holisticly predominate extensible testing procedures for reliable supply chains. Dramatically engage top-line web services vis-a-vis cutting-edge deliverables.
</p>
</div>
<div className="thumbnail">
<img
src="https://source.unsplash.com/900x900/?Health,doctor"
alt="Laptop"
/>
</div>
</section>
<section className="section section-left">
<div className="para">
<p className="sectionTag text-big">Dentist</p>
<p className="sectionSubTag text-small">
For your child whitest teeths
</p>
<p className="sectionSubTag text-small">
Completely synergize resource taxing relationships via premier
niche markets. Professionally cultivate one-to-one customer
service with robust ideas. Dynamically innovate resource-leveling
customer service for state of the art customer service.
</p>
</div>
<div className="thumbnail">
<img
src="https://source.unsplash.com/900x900/?Dentist"
alt="Laptop"
/>
</div>
</section>
<section className="section">
<div className="para">
<p className="sectionTag text-big">Pediatrician</p>
<p className="sectionSubTag text-small">Children medical care</p>
<p className="sectionSubTag text-small">
Objectively innovate empowered manufactured products whereas
parallel platforms. Holisticly predominate extensible testing
procedures for reliable supply chains. Dramatically engage
top-line web services vis-a-vis cutting-edge deliverables.
</p>
</div>
<div class="thumbnail">
<img src="https://source.unsplash.com/900x900/?Pediatrician" alt="Laptop" />
</div>
</section>
</div>
);
}
<div className="thumbnail">
<img
src="https://source.unsplash.com/900x900/?Pediatrician"
alt="Laptop"
/>
</div>
</section>
</div>
);
}
}
export default Home
export default Home;

View File

@ -1,52 +1,108 @@
import React from 'react';
import './css/nav.css';
import {NavLink} from 'react-router-dom'
class Nav extends React.Component{
render(){
let authuser = sessionStorage.getItem('Key_Veriable');
if (authuser === "admin@gmail.com")
{
return(
<nav className="navbar background">
<ul className="nav-list ">
<div className="logo">
<img src="http://medicare.bold-themes.com/general-hospital/wp-content/uploads/sites/14/2018/03/general-hospital-logo-color.png" alt="logo" />
</div>
<li><NavLink to ="/adminafterlogin" exact activeclassNameName="active" className= "listdesign">Admin Home</NavLink></li>
<li><NavLink to ="/patientdetails" exact activeclassNameName="active" className= "listdesign">Patient Details</NavLink></li>
<li><NavLink to ="search" exact activeclassNameName="active" className= "listdesign">Search</NavLink></li>
<li><NavLink to ="/logout" exact activeclassNameName="active" className= "listdesign">Logout</NavLink></li>
</ul>
<div className="right-nav v-className-resp">
<input type="text" name="search" id="search" />
<button className="btn btn-small">Search</button>
import React from "react";
import "./css/nav.css";
import { NavLink } from "react-router-dom";
class Nav extends React.Component {
render() {
let authuser = sessionStorage.getItem("Key_Veriable");
if (authuser === "admin@gmail.com") {
return (
<nav className="navbar background">
<ul className="nav-list ">
<div className="logo">
<img
src="http://medicare.bold-themes.com/general-hospital/wp-content/uploads/sites/14/2018/03/general-hospital-logo-color.png"
alt="logo"
/>
</div>
<li>
<NavLink
to="/adminafterlogin"
exact
activeclassname="active"
className="listdesign"
>
Admin Home
</NavLink>
</li>
<li>
<NavLink
to="/booked-appointments"
exact
activeclassname="active"
className="listdesign"
>
All Booked Appointments
</NavLink>
</li>
<li>
<NavLink
to="/logout"
exact
activeclassname="active"
className="listdesign"
>
Logout
</NavLink>
</li>
</ul>
<div className="right-nav v-className-resp">
<input type="text" name="search" id="search" />
<button className="btn btn-small">Search</button>
</div>
</nav>
)
}
else
{
return(
<nav className="navbar h-nav-resp background">
<ul className="nav-list v-className-resp">
<div className="logo">
<img src="http://medicare.bold-themes.com/general-hospital/wp-content/uploads/sites/14/2018/03/general-hospital-logo-color.png" alt="logo" />
</div>
<li><NavLink to ="/" exact activeclassNameName="active" className= "listdesign">Home</NavLink></li>
<li><NavLink to ="/department" exact activeclassNameName="active" className= "listdesign">Department</NavLink></li>
<li><NavLink to ="/newappointment" exact activeclassNameName="active" className= "listdesign">New Appointment</NavLink></li>
<li><NavLink to ="/doctors" exact activeclassNameName="active" className= "listdesign">Doctors</NavLink></li>
<li><NavLink to ="/contact" exact activeclassNameName="active" className= "listdesign">Contact us</NavLink></li>
</ul>
<div className="right-nav v-className-resp">
<input type="text" name="search" id="search" />
<button className="btn btn-small">Search</button>
);
} else {
return (
<nav className="navbar h-nav-resp background">
<ul className="nav-list v-className-resp">
<div className="logo">
<img
src="http://medicare.bold-themes.com/general-hospital/wp-content/uploads/sites/14/2018/03/general-hospital-logo-color.png"
alt="logo"
/>
</div>
<li>
<NavLink
to="/"
exact
activeclassname="active"
className="listdesign"
>
Home
</NavLink>
</li>
<li>
<NavLink
to="/newappointment"
exact
activeclassname="active"
className="listdesign"
>
Book a Appointment
</NavLink>
</li>
<li>
<NavLink
to="/contact"
exact
activeclassname="active"
className="listdesign"
>
Contact us
</NavLink>
</li>
</ul>
<div className="right-nav v-className-resp">
<input type="text" name="search" id="search" />
<button className="btn btn-small">Search</button>
</div>
</nav>
)
}
);
}
}
}
export default Nav
export default Nav;

View File

@ -1,157 +1,161 @@
import React from 'react';
// import axios from 'axios'; BACKEND PART IMPORT IT
import './css/newAppointment.css';
import Navbar from './nav'
import React, { useEffect, useState } from "react";
import axios from "axios"; //BACKEND PART IMPORT IT
import "./css/newAppointment.css";
import Navbar from "./nav";
import { Redirect } from "react-router";
import { API } from "../helper/apicall";
class newAppointment extends React.Component {
const NewAppointment = () => {
const [PatientName, setPatientName] = useState("");
const [DocterName, setDocterName] = 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 [Department, setDepartment] = 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,
};
constructor(){
const options = {
method: "post",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(item),
};
super();
this.onChangeName=this.onChangeName.bind(this);
this.onChangePhone=this.onChangePhone.bind(this);
this.onChangeEmail=this.onChangeEmail.bind(this);
this.onChangeAge=this.onChangeAge.bind(this);
this.onChangeGender=this.onChangeGender.bind(this);
this.onChangeDepartment=this.onChangeDepartment.bind(this);
this.onChangeDate=this.onChangeDate.bind(this);
this.onChangeTime=this.onChangeTime.bind(this);
this.onChangeDescription=this.onChangeDescription.bind(this);
this.onSubmit= this.onSubmit.bind(this);
this.state ={
name: '',
phone: '',
email: '',
age: '',
gender: '',
department: '',
date: '',
time: '',
description: '',
msg: ''
}
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 <Redirect to="/" />;
}
onChangeName(e){
this.setState({name: e.target.value});
}
onChangePhone(e){
this.setState({phone: e.target.value});
}
onChangeEmail(e){
this.setState({email: e.target.value});
}
onChangeAge(e){
this.setState({age: e.target.value});
}
onChangeGender(e){
this.setState({gender: e.target.value});
}
onChangeDepartment(e){
this.setState({department: e.target.value});
}
onChangeDate(e){
this.setState({date: e.target.value});
}
onChangeTime(e){
this.setState({time: e.target.value});
}
onChangeDescription(e){
this.setState({description: e.target.value});
}
onSubmit(e){
e.preventDefault();
console.log('Form Submited');
console.log(`NAME: ${this.state.name}`);
console.log(`PHONE: ${this.state.phone}`);
console.log(`EMAIL: ${this.state.email}`);
console.log(`AGE: ${this.state.age}`);
console.log(`GENDER: ${this.state.gender}`);
console.log(`DEPARTMENT: ${this.state.department}`);
console.log(`DATE: ${this.state.date}`);
console.log(`TIME: ${this.state.time}`);
console.log(`DESCRIPTIOND: ${this.state.description}`);
// PASSING OBJECT TO BACKEND
const createApppointmentForm = () => (
<div>
<Navbar></Navbar>
<section className="appointment">
<h1 className="subHeading">Fill The below form for New Appointment</h1>
<h4 className="note"> * refers to mandatory</h4>
<form className="form" onSubmit={createItem}>
<input
type="text"
id="name"
name="PatientName"
onChange={(e) => setPatientName(e.target.value)}
placeholder="Your Name*"
className="formInput"
required
/>
// const patientinfo= {
// name : this.state.name,
// phone : this.state.phone,
// email : this.state.email,
// age : this.state.age,
// gender : this.state.gender,
// department : this.state.department,
// date : this.state.date,
// time : this.state.time,
// description : this.state.description,
// }
// BACKEND PART
// axios.post('http://localhost:3000/newappointment', patientinfo)
// .then(res => {
// console.log(res.data)
// this.setState({ msg: 'APPOINTMENT REGISTRATION SUCCESSFUL' })
// })
// .catch( err => console.log(err))
{/* <input
type="text"
id="name"
placeholder="Doctor Name*"
className="formInput"
name="DocterName"
onChange={(e) => setDocterName(e.target.value)}
value={DocterName}
required
/> */}
<input
type="email"
id="email"
placeholder="Your Email(optional)"
onChange={(e) => setEmail(e.target.value)}
className="formInput"
name="Email"
/>
<input
type="phone"
id="phone"
name="PhoneNo"
placeholder="Your Phone*"
className="formInput"
onChange={(e) => setPhoneNo(e.target.value)}
value={PhoneNo}
required
/>
this.setState({
name: '',
phone: '',
email: '',
age: '',
gender: '',
department: '',
date: '',
time: '',
description: '',
msg: ''
})
}
<input
type="date"
id="date"
className="formInput datetime"
onChange={(e) => setDate(e.target.value)}
name="Date"
required
/>
render() {
return (
<div>
<Navbar></Navbar>
<section class="appointment">
<h1 class="subHeading">Fill The below form for New Appointment</h1>
<h4 class="note"> * refers to mandatory</h4>
<h4>{this.state.msg}</h4>
<form action="noaction.php" method="post" class="form" onSubmit={this.onSubmit}>
<input type="text" name="id" id="patient_id" placeholder="patient_id*" class="formInput" required/>
<input
type="time"
id="time"
className="formInput datetime"
onChange={(e) => setTime(e.target.value)}
name="Time"
required
/>
<input
type="number"
className="formInput datetime"
placeholder="Age"
onChange={(e) => setAge(e.target.value)}
name="Age"
required
/>
<textarea
type="text"
className="formInput datetime"
placeholder="Elaborate your problem"
onChange={(e) => setDescription(e.target.value)}
name="Description"
required
/>
<input type="text" name="name" id="name" placeholder="Your Name*" class="formInput" required value={this.state.name} onChange={this.onChangeName}/>
<button className="btn-submit btn-dark">Submit</button>
</form>
</section>
</div>
);
<input type="phone" name="phone" id="phone" placeholder="Your Phone*" class="formInput" required value={this.state.phone} onChange={this.onChangePhone}/>
return (
<div className="row bg-dark text-white rounded">
<div className="col-md-8 offset-md-2">{createApppointmentForm()}</div>
</div>
);
};
<input type="email" name="email" id="email" placeholder="Your Email(optional)" class="formInput" value={this.state.email} onChange={this.onChangeEmail}/>
<input type="text" name="age" id="age" placeholder="Your Age*" class="formInput" required value={this.state.age} onChange={this.onChangeAge}/>
<select type="text" name="gender" id="gender" placeholder="Gender*" class="formInput widthfix" required value={this.state.gender} onChange={this.onChangeGender}>
<option value= "Male">Male</option>
<option value= "Female">Female</option>
<option value= "Other">Other</option>
</select>
<select type="text" name="department" id="department" placeholder="Department*" class="formInput widthfix" required value={this.state.department} onChange={this.onChangeDepartment}>
<option value= "ENT">ENT</option>
<option value= "Orthopedic">Orthopedic</option>
<option value= "General Medicine">General Medicine</option>
<option value= "Chemo">Chemo</option>
</select>
<input type="date" name="date" id="date" class="formInput datetime" required value={this.state.date} onChange={this.onChangeDate}/>
<input type="time" name="time" id="time" class="formInput datetime" required value={this.state.time} onChange={this.onChangeTime}/>
<textarea name="description" id="Description" cols="30" rows="10" placeholder="Ellaborate your concern*" class="formInput" required value={this.state.description} onChange={this.onChangeDescription}></textarea>
<button class="btn-submit btn-dark">Submit</button>
</form>
</section>
</div>
);
}
}
export default newAppointment
export default NewAppointment;

View File

@ -0,0 +1 @@
export const API = "http://doc-backend-api.herokuapp.com"; //backend API URL

View File

@ -1,14 +1,13 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
document.getElementById("root")
);
// If you want your app to work offline and load faster, you can change