Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#Issue 8 _ date / time can't be in the past for ride creation #109

Open
wanhoyinjoshua opened this issue Dec 21, 2022 · 0 comments
Open

Comments

@wanhoyinjoshua
Copy link
Collaborator

wanhoyinjoshua commented Dec 21, 2022

When Creating a ride details, the date and/or time of the ride can not be in the past.

Proposed solution:

Backend validation: here

import isRideInPast from "../../../src/common/util"

if(isRideInPast(req.body)){
    res.status(500).json({ status: 'Error please make sure date is valid' });

  }

Frontend validation:

if(moment(rideFromState.pickupTimeAndDate).isBefore(moment.now())){
      this.setState({
        
        updatingError: new Error('Invalid Date and time'),
      });
      return window.alert("You can't create ride in the past")
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant