Skip to content

Commit

Permalink
Fix some issues related to cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Sep 25, 2023
1 parent 5372c03 commit be64958
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 429 deletions.
8 changes: 7 additions & 1 deletion frontend/src/components/BookingList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,12 @@ const BookingList = (
setOpenCancelDialog(true)
}

const today = new Date()
today.setHours(0)
today.setMinutes(0)
today.setSeconds(0)
today.setMilliseconds(0)

return (
<>
<Tooltip title={strings.VIEW}>
Expand All @@ -307,7 +313,7 @@ const BookingList = (
{params.row.cancellation &&
!params.row.cancelRequest &&
params.row.status !== bookcarsTypes.BookingStatus.Cancelled &&
new Date(params.row.from) > new Date() && (
new Date(params.row.from) >= today && (
<Tooltip title={strings.CANCEL}>
<IconButton onClick={cancelBooking}>
<CancelIcon />
Expand Down
10 changes: 8 additions & 2 deletions mobile/components/Booking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { memo } from 'react'
import { StyleSheet, Text, View, Image } from 'react-native'
import { MaterialIcons } from '@expo/vector-icons'
import { format } from 'date-fns'
import * as bookcarsTypes from '../miscellaneous/bookcarsTypes'
import * as bookcarsTypes from '../miscellaneous/bookcarsTypes'
import * as bookcarsHelper from '../miscellaneous/bookcarsHelper'

import BookingStatus from './BookingStatus'
Expand Down Expand Up @@ -36,6 +36,12 @@ const Booking = (
const car = booking.car as bookcarsTypes.Car
const supplier = booking.company as bookcarsTypes.User

const today = new Date()
today.setHours(0)
today.setMinutes(0)
today.setSeconds(0)
today.setMilliseconds(0)

return (
<View key={booking._id} style={styles.bookingContainer}>
<View style={styles.booking}>
Expand Down Expand Up @@ -132,7 +138,7 @@ const Booking = (
{booking.cancellation
&& !booking.cancelRequest
&& booking.status !== bookcarsTypes.BookingStatus.Cancelled
&& new Date(booking.from) > new Date()
&& new Date(booking.from) >= today
&& (
<Button
size="small"
Expand Down
Loading

0 comments on commit be64958

Please sign in to comment.