Skip to content

Commit

Permalink
Update BookingService.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Feb 18, 2024
1 parent 4418ca1 commit cdfad67
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
4 changes: 1 addition & 3 deletions mobile/components/BookingList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ import {
} from 'react-native-paper'
import { enUS, fr } from 'date-fns/locale'
import * as movininTypes from '../miscellaneous/movininTypes'

import * as Env from '../config/env.config'
import i18n from '../lang/i18n'
import * as Helper from '../common/Helper'
import * as BookingService from '../services/BookingService'

import Booking from './Booking'

interface BookingListProps {
Expand Down Expand Up @@ -71,7 +69,7 @@ function BookingList({
}
setLoading(true)
setFetch(true)
const data = await BookingService.getBookings(payload, _page, Env.BOOKINGS_PAGE_SIZE)
const data = await BookingService.getBookings(payload, _page + 1, Env.BOOKINGS_PAGE_SIZE)
const _data = data && data.length > 0 ? data[0] : { pageInfo: { totalRecord: 0 }, resultData: [] }
if (!_data) {
Helper.error()
Expand Down
2 changes: 1 addition & 1 deletion mobile/miscellaneous/movininTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export interface Booking {
cancelRequest?: boolean
}

export interface BookPayload {
export interface CheckoutPayload {
renter?: User
booking: Booking
payLater?: boolean
Expand Down
4 changes: 2 additions & 2 deletions mobile/screens/Checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -599,13 +599,13 @@ function CheckoutScreen({ navigation, route }: NativeStackScreenProps<StackParam
price,
}

const payload: movininTypes.BookPayload = {
const payload: movininTypes.CheckoutPayload = {
renter,
booking,
payLater,
}

const status = await BookingService.book(payload)
const status = await BookingService.checkout(payload)

if (status === 200) {
setLoading(false)
Expand Down
6 changes: 3 additions & 3 deletions mobile/services/BookingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ AxiosHelper.init(axios)
/**
* Complete the checkout process and create the booking.
*
* @param {movininTypes.BookPayload} data
* @param {movininTypes.CheckoutPayload} data
* @returns {Promise<number>}
*/
export const book = (data: movininTypes.BookPayload): Promise<number> =>
export const checkout = (data: movininTypes.CheckoutPayload): Promise<number> =>
axios
.post(
`${Env.API_HOST}/api/book`,
`${Env.API_HOST}/api/checkout`,
data
)
.then((res) => res.status)
Expand Down

0 comments on commit cdfad67

Please sign in to comment.