Compare commits

..

1 Commits

Author SHA1 Message Date
GotPPay
591d7be308 round time to the nearest 5 min 2018-05-11 17:24:40 +02:00
2 changed files with 28 additions and 45 deletions

View File

@@ -34,7 +34,7 @@ import Checkbox from 'material-ui/Checkbox';
import Popover from 'material-ui/Popover'; import Popover from 'material-ui/Popover';
let DateTimeFormat; let DateTimeFormat;
const roundingTime = 1000 * 60 * 5; //5 minutes
DateTimeFormat = global.Intl.DateTimeFormat; DateTimeFormat = global.Intl.DateTimeFormat;
@@ -416,16 +416,18 @@ class VerticalNonLinear extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
let dateNow = new Date();
this.state = { this.state = {
stepIndex: 0, stepIndex: 0,
rideTypeValue: 0, rideTypeValue: 0,
providerID: 0, providerID: 0,
providerName: '', providerName: '',
visitDate: new Date(), visitDate: new Date(),
visitTime: new Date(), visitTime: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
pickupLocation: null, pickupLocation: null,
pickupTime: new Date(), pickupTime: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
pickupTimeReturn: new Date(), pickupTimeReturn: new Date(Math.round(dateNow.getTime() / roundingTime) * roundingTime),
pickupTimeReturnDisplayMode: 'none', pickupTimeReturnDisplayMode: 'none',
open: false, open: false,
message: 'Booking Ride', message: 'Booking Ride',
@@ -489,10 +491,10 @@ class VerticalNonLinear extends React.Component {
} }
}); });
let visitTime = new Date(new Date().getTime() + (1 * 60 * 60 * 1000)); let visitTime = new Date(Math.round((date.getTime() + (1 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
let visitDate = visitTime; let visitDate = date;
let pickupTime = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000)); let pickupTime = new Date(Math.round((visitTime.getTime() - (0.5 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
let pickupTimeReturn = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000)); let pickupTimeReturn = new Date(Math.round((visitTime.getTime() - (0.5 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
this.setState(Object.assign(this.state, { this.setState(Object.assign(this.state, {
visitDate: visitDate, visitDate: visitDate,
@@ -600,10 +602,10 @@ class VerticalNonLinear extends React.Component {
handleDate(event, date, state) { handleDate(event, date, state) {
let self = state let self = state
let visitTime = new Date(date.getTime() + (1 * 60 * 60 * 1000)); let visitTime = new Date(Math.round((date.getTime() + (1 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
let visitDate = date; let visitDate = date;
let pickupTime = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000)); let pickupTime = new Date(Math.round((visitTime.getTime() - (0.5 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
let pickupTimeReturn = new Date(visitTime.getTime() - (0.5 * 60 * 60 * 1000)); let pickupTimeReturn = new Date(Math.round((visitTime.getTime() - (0.5 * 60 * 60 * 1000)) / roundingTime) * roundingTime);
self.setState(Object.assign(self.state, { self.setState(Object.assign(self.state, {
visitDate: visitDate, visitDate: visitDate,

View File

@@ -143,7 +143,7 @@ const Address = (props) => {
) )
}; };
const Main = ({ user, onAddressAdded, onAddressRemoved, onContactAdded, readOnly }) => { const Main = ({ user, onAddressAdded, onAddressRemoved, readOnly }) => {
return ( return (
<div className="row"> <div className="row">
<div className="col-xl-12"> <div className="col-xl-12">
@@ -158,7 +158,7 @@ const Main = ({ user, onAddressAdded, onAddressRemoved, onContactAdded, readOnly
/> />
</div> </div>
<div className="col-xl-6"> <div className="col-xl-6">
<ContactInfo user={user} readOnly={readOnly} onContactAdded={onContactAdded} /> <ContactInfo user={user} readOnly={readOnly} />
</div> </div>
</div> </div>
); );
@@ -685,7 +685,6 @@ const ContactInfo = (props) => {
title={"Member Contact"} title={"Member Contact"}
buttonValue={"Add Contact"} buttonValue={"Add Contact"}
showDescription={false} showDescription={false}
onNewContact={props.onContactAdded}
/> />
} }
</div> </div>
@@ -824,7 +823,6 @@ class User extends React.Component {
this.getUser = this.getUser.bind(this); this.getUser = this.getUser.bind(this);
this.handleAddressAdded = this.handleAddressAdded.bind(this); this.handleAddressAdded = this.handleAddressAdded.bind(this);
this.handleAddressRemoved = this.handleAddressRemoved.bind(this); this.handleAddressRemoved = this.handleAddressRemoved.bind(this);
this.handleContactAdded = this.handleContactAdded.bind(this);
} }
componentDidMount() { componentDidMount() {
@@ -842,22 +840,6 @@ class User extends React.Component {
.catch(console.error); .catch(console.error);
} }
handleContactAdded(contact) {
const user_uuid = this.props.params.user_uuid;
const self = this;
var contactObj = {
"type": contact.type,
"contact": contact.contact,
}
Instance.getRawConn().post(`/v1/nemt/users/portal/${user_uuid}/contact`, contactObj)
.then(res => {
this.getUser(user_uuid);
})
.catch(console.error);
}
handleAddressAdded(address) { handleAddressAdded(address) {
const user_uuid = this.props.params.user_uuid; const user_uuid = this.props.params.user_uuid;
const self = this; const self = this;
@@ -908,7 +890,6 @@ class User extends React.Component {
user={user} user={user}
onAddressAdded={this.handleAddressAdded} onAddressAdded={this.handleAddressAdded}
onAddressRemoved={this.handleAddressRemoved} onAddressRemoved={this.handleAddressRemoved}
onContactAdded={this.handleContactAdded}
readOnly={readOnly} readOnly={readOnly}
/> />
</QueueAnim> </QueueAnim>