Skip to content

Commit

Permalink
Past dates are disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
euphelity committed May 12, 2021
1 parent 095b7ed commit 4048783
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/screens/HospitalForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import complaint from "../assets/complaint.png";
import FooterIcon from "../components/footerIcons";
import Footer from "../components/footer";
import Typewriter from "typewriter-effect";
import moment from "moment";

const { Option } = Select;

Expand Down Expand Up @@ -99,6 +100,10 @@ export class HospitalForm extends Component {
{ width: 992, itemsToShow: 3, pagination: false, showArrows: false },
{ width: 1200, itemsToShow: 3, pagination: false, showArrows: false },
];
function disabledDate(current) {
// Can not select days before today and today
return current && current < moment().startOf('day');
}

return (
<>
Expand Down Expand Up @@ -192,6 +197,7 @@ export class HospitalForm extends Component {
<DatePicker
onChange={this.dateSelected}
style={{ width: "100%" }}
disabledDate={disabledDate}
/>
</Form.Item>
<Form.Item name="slot" label=" Select Preferred Time">
Expand Down
8 changes: 8 additions & 0 deletions src/screens/conferenceBookingForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { connect } from "react-redux";
import { withRouter } from "react-router-dom";
import BackNavbar from "../components/backNavbar";
import Success from "./success";
import moment from 'moment';


import CalanderImg from "../assets/calander.png";
import { roomBookingApi, getRoomBookingsApi } from "../api/roomBooking";
Expand Down Expand Up @@ -177,8 +179,13 @@ class ConferenceBookingForm extends Component {
title: await event.target.value,
});
};

render() {
const format = "HH:mm";
function disabledDate(current) {
// Can not select days before today and today
return current && current < moment().startOf('day');
}
return (
<>
<BackNavbar />
Expand Down Expand Up @@ -222,6 +229,7 @@ class ConferenceBookingForm extends Component {
<DatePicker
onChange={this.dateSelected}
style={{ width: "100%" }}
disabledDate={disabledDate}
/>
</Form.Item>
<Row>
Expand Down
6 changes: 6 additions & 0 deletions src/screens/eventUtility.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Footers from "../components/footer";
import FooterIcon from "../components/footerIcons";
import eventutility from "../assets/eventutility.png";
import "./styles/eventUtility.css";
import moment from "moment";

class EventUtility extends Component {
constructor() {
Expand Down Expand Up @@ -180,6 +181,10 @@ class EventUtility extends Component {
);
}
const format = "HH:mm";
function disabledDate(current) {
// Can not select days before today and today
return current && current < moment().startOf('day');
}
return (
<div>
<>
Expand Down Expand Up @@ -213,6 +218,7 @@ class EventUtility extends Component {
<DatePicker
onChange={this.dateSelected}
style={{ width: "100%" }}
disabledDate={disabledDate}
/>
</Form.Item>
<Row>
Expand Down

0 comments on commit 4048783

Please sign in to comment.