Skip to content

Commit

Permalink
Add multiple currencies to booking pages
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Dec 12, 2024
1 parent 9b78f41 commit c28c1b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions frontend/src/components/BookingList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { fr as dfnsFR, enUS as dfnsENUS } from 'date-fns/locale'
import * as bookcarsTypes from ':bookcars-types'
import * as bookcarsHelper from ':bookcars-helper'
import * as BookingService from '@/services/BookingService'
import * as StripeService from '@/services/StripeService'
import * as helper from '@/common/helper'
import { strings } from '@/lang/booking-list'
import { strings as csStrings } from '@/lang/cars'
Expand Down Expand Up @@ -124,6 +125,10 @@ const BookingList = ({
}
const totalRecords = Array.isArray(_data.pageInfo) && _data.pageInfo.length > 0 ? _data.pageInfo[0].totalRecords : 0

for (const booking of _data.resultData) {
booking.price = await StripeService.convertPrice(booking.price!)
}

if (env.isMobile) {
const _rows = _page === 0 ? _data.resultData : [...rows, ..._data.resultData]
setRows(_rows)
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/pages/Booking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Layout from '@/components/Layout'
import * as UserService from '@/services/UserService'
import * as BookingService from '@/services/BookingService'
import * as CarService from '@/services/CarService'
import * as StripeService from '@/services/StripeService'
import Backdrop from '@/components/SimpleBackdrop'
import NoMatch from './NoMatch'
import Error from './Error'
Expand Down Expand Up @@ -249,7 +250,7 @@ const Booking = () => {
const _booking = await BookingService.getBooking(id)
if (_booking) {
setBooking(_booking)
setPrice(_booking.price)
setPrice(await StripeService.convertPrice(_booking.price!))
setLoading(false)
setVisible(true)
const cmp = _booking.supplier as bookcarsTypes.User
Expand Down Expand Up @@ -476,7 +477,7 @@ const Booking = () => {
<div>
{edit && (
<div className="booking-buttons">
<Button variant="contained" className="btn-primary btn-margin-bottom" size="small" type="submit">
<Button variant="contained" className="btn-primary btn-margin-bottom" type="submit">
{commonStrings.SAVE}
</Button>
</div>
Expand All @@ -489,7 +490,7 @@ const Booking = () => {
<div className="price">
<span className="price-days">{helper.getDays(days)}</span>
<span className="price-main">{bookcarsHelper.formatPrice(price as number, commonStrings.CURRENCY, language)}</span>
<span className="price-day">{`${csStrings.PRICE_PER_DAY} ${bookcarsHelper.formatPrice(Math.floor((price as number) / days), commonStrings.CURRENCY, language)}`}</span>
<span className="price-day">{`${csStrings.PRICE_PER_DAY} ${bookcarsHelper.formatPrice((price as number) / days, commonStrings.CURRENCY, language)}`}</span>
</div>
</div>
<CarList
Expand Down

0 comments on commit c28c1b5

Please sign in to comment.