diff --git a/app/[lang]/(live)/(public)/hotelreservation/(standard)/step/@hotelHeader/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/(standard)/step/@hotelHeader/page.tsx
index 0543c5416..2fafe2dbc 100644
--- a/app/[lang]/(live)/(public)/hotelreservation/(standard)/step/@hotelHeader/page.tsx
+++ b/app/[lang]/(live)/(public)/hotelreservation/(standard)/step/@hotelHeader/page.tsx
@@ -7,6 +7,7 @@ import Body from "@/components/TempDesignSystem/Text/Body"
import Caption from "@/components/TempDesignSystem/Text/Caption"
import Title from "@/components/TempDesignSystem/Text/Title"
import { getIntl } from "@/i18n"
+import getSingleDecimal from "@/utils/numberFormatting"
import styles from "./page.module.css"
@@ -47,7 +48,11 @@ export default async function HotelHeader({
{intl.formatMessage(
{ id: "Distance in km to city centre" },
- { number: hotel.location.distanceToCentre / 1000 }
+ {
+ number: getSingleDecimal(
+ hotel.location.distanceToCentre / 1000
+ ),
+ }
)}
diff --git a/components/ContentType/ContentPage/HotelListingItem/index.tsx b/components/ContentType/ContentPage/HotelListingItem/index.tsx
index d1e592f90..18f8f6f7f 100644
--- a/components/ContentType/ContentPage/HotelListingItem/index.tsx
+++ b/components/ContentType/ContentPage/HotelListingItem/index.tsx
@@ -8,6 +8,7 @@ import Caption from "@/components/TempDesignSystem/Text/Caption"
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
import Title from "@/components/TempDesignSystem/Text/Title"
import { getIntl } from "@/i18n"
+import getSingleDecimal from "@/utils/numberFormatting"
import styles from "./hotelListingItem.module.css"
@@ -47,7 +48,7 @@ export default async function HotelListingItem({
{intl.formatMessage(
{ id: "Distance in km to city centre" },
- { number: distanceToCentre / 1000 }
+ { number: getSingleDecimal(distanceToCentre / 1000) }
)}
diff --git a/components/ContentType/HotelPage/IntroSection/index.tsx b/components/ContentType/HotelPage/IntroSection/index.tsx
index 394566fea..7a5349ff0 100644
--- a/components/ContentType/HotelPage/IntroSection/index.tsx
+++ b/components/ContentType/HotelPage/IntroSection/index.tsx
@@ -8,6 +8,7 @@ import Preamble from "@/components/TempDesignSystem/Text/Preamble"
import Title from "@/components/TempDesignSystem/Text/Title"
import { getIntl } from "@/i18n"
import { getLang } from "@/i18n/serverContext"
+import getSingleDecimal from "@/utils/numberFormatting"
import styles from "./introSection.module.css"
@@ -25,7 +26,7 @@ export default async function IntroSection({
const { distanceToCentre } = location
const formattedDistanceText = intl.formatMessage(
{ id: "Distance in km to city centre" },
- { number: distanceToCentre / 1000 }
+ { number: getSingleDecimal(distanceToCentre / 1000) }
)
const lang = getLang()
const formattedLocationText = `${streetAddress}, ${city} (${formattedDistanceText})`
diff --git a/components/HotelReservation/HotelCard/index.tsx b/components/HotelReservation/HotelCard/index.tsx
index 734035c05..616ca03cf 100644
--- a/components/HotelReservation/HotelCard/index.tsx
+++ b/components/HotelReservation/HotelCard/index.tsx
@@ -12,6 +12,7 @@ import Link from "@/components/TempDesignSystem/Link"
import Body from "@/components/TempDesignSystem/Text/Body"
import Caption from "@/components/TempDesignSystem/Text/Caption"
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
+import getSingleDecimal from "@/utils/numberFormatting"
import ReadMore from "../ReadMore"
import TripAdvisorChip from "../TripAdvisorChip"
@@ -104,7 +105,11 @@ export default function HotelCard({
{intl.formatMessage(
{ id: "Distance in km to city centre" },
- { number: hotelData.location.distanceToCentre / 1000 }
+ {
+ number: getSingleDecimal(
+ hotelData.location.distanceToCentre / 1000
+ ),
+ }
)}
diff --git a/components/HotelReservation/SelectRate/HotelInfoCard/index.tsx b/components/HotelReservation/SelectRate/HotelInfoCard/index.tsx
index 72abaffc0..e7951c490 100644
--- a/components/HotelReservation/SelectRate/HotelInfoCard/index.tsx
+++ b/components/HotelReservation/SelectRate/HotelInfoCard/index.tsx
@@ -11,6 +11,7 @@ import Body from "@/components/TempDesignSystem/Text/Body"
import Caption from "@/components/TempDesignSystem/Text/Caption"
import Title from "@/components/TempDesignSystem/Text/Title"
import { getIntl } from "@/i18n"
+import getSingleDecimal from "@/utils/numberFormatting"
import ReadMore from "../../ReadMore"
import TripAdvisorChip from "../../TripAdvisorChip"
@@ -69,7 +70,7 @@ export default async function HotelInfoCard({
- {`${hotelAttributes.address.streetAddress}, ${hotelAttributes.address.city} ∙ ${hotelAttributes.location.distanceToCentre / 1000} ${intl.formatMessage({ id: "km to city center" })}`}
+ {`${hotelAttributes.address.streetAddress}, ${hotelAttributes.address.city} ∙ ${getSingleDecimal(hotelAttributes.location.distanceToCentre / 1000)} ${intl.formatMessage({ id: "km to city center" })}`}
{hotelAttributes.hotelContent.texts.descriptions.medium}
diff --git a/utils/numberFormatting.ts b/utils/numberFormatting.ts
new file mode 100644
index 000000000..cd3cd1fa4
--- /dev/null
+++ b/utils/numberFormatting.ts
@@ -0,0 +1,8 @@
+/**
+ * Function to parse number with single decimal if any
+ * @param n
+ * @returns number in float type with single digit decimal if any
+ */
+export default function getSingleDecimal(n: Number | string) {
+ return parseFloat(Number(n).toFixed(1))
+}