Merged in feat/SW-1880-pool-depth (pull request #2233)

feat/SW-1880-pool-depth

* feat(SW-1880): update pool depth

* fix(SW-1880): handle non existing values


Approved-by: Erik Tiekstra
This commit is contained in:
Matilda Landström
2025-06-02 07:31:30 +00:00
parent 7e97b74c18
commit 50a6f4e28c

View File

@@ -41,40 +41,24 @@ export async function translateWellnessDetails({
case HealthFacilitiesEnum.OutdoorPool: case HealthFacilitiesEnum.OutdoorPool:
case HealthFacilitiesEnum.IndoorPool: case HealthFacilitiesEnum.IndoorPool:
return details const poolDepth = await getPoolDepthTranslation(details)
.map(({ name, value }) => { const poolTranslations = details.map(({ name, value }) => {
switch (name) { switch (name) {
case IndoorPoolDetails.DepthFrom: case IndoorPoolDetails.Length:
return intl.formatMessage( return intl.formatMessage(
{ {
defaultMessage: "Pool depth from: {value} m", defaultMessage: "Pool length: {value} m",
}, },
{ value: value } { value: value }
) )
case IndoorPoolDetails.Width:
case IndoorPoolDetails.DepthTo: return intl.formatMessage(
return intl.formatMessage( {
{ defaultMessage: "Pool width: {value} m",
defaultMessage: "Pool depth to: {value} m", },
}, { value: value }
{ value: value } )
) /* TODO: Awaiting clarification from Content on how to handle these parts
case IndoorPoolDetails.Length:
return intl.formatMessage(
{
defaultMessage: "Pool length: {value} m",
},
{ value: value }
)
case IndoorPoolDetails.Width:
return intl.formatMessage(
{
defaultMessage: "Pool width: {value} m",
},
{ value: value }
)
/* TODO: Awaiting clarification from Content on how to handle these parts
case OutdoorPoolDetails.OpenMonthFrom: case OutdoorPoolDetails.OpenMonthFrom:
if (type === HealthFacilitiesEnum.OutdoorPool) if (type === HealthFacilitiesEnum.OutdoorPool)
return intl.formatMessage( return intl.formatMessage(
@@ -91,9 +75,13 @@ export async function translateWellnessDetails({
}, },
{ value: value } { value: value }
)*/ )*/
} }
}) })
return poolTranslations
.concat(poolDepth)
.filter((d): d is string => !!d) .filter((d): d is string => !!d)
.sort()
case HealthFacilitiesEnum.Gym: case HealthFacilitiesEnum.Gym:
if ( if (
@@ -121,8 +109,40 @@ export async function translateWellnessDetails({
} }
}) })
.filter((d): d is string => !!d) .filter((d): d is string => !!d)
.sort()
default: default:
console.warn(`Unsupported type given: ${type}`) console.warn(`Unsupported type given: ${type}`)
} }
} }
async function getPoolDepthTranslation(details: WellnessDetails["details"]) {
const intl = await getIntl()
const depthTo = details.find(
(d) => d.name === IndoorPoolDetails.DepthTo
)?.value
const depthFrom = details.find(
(d) => d.name === IndoorPoolDetails.DepthFrom
)?.value
if (depthFrom && depthTo) {
return depthFrom !== depthTo
? intl.formatMessage(
{ defaultMessage: "Pool depth: {from}{to} m" },
{ from: depthFrom, to: depthTo }
)
: intl.formatMessage(
{ defaultMessage: "Pool depth: {value} m" },
{ value: depthFrom }
)
}
if (depthFrom || depthTo) {
const value = depthFrom || depthTo
return intl.formatMessage(
{ defaultMessage: "Pool depth: {value} m" },
{ value }
)
}
}