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:
@@ -41,40 +41,24 @@ export async function translateWellnessDetails({
|
||||
|
||||
case HealthFacilitiesEnum.OutdoorPool:
|
||||
case HealthFacilitiesEnum.IndoorPool:
|
||||
return details
|
||||
.map(({ name, value }) => {
|
||||
switch (name) {
|
||||
case IndoorPoolDetails.DepthFrom:
|
||||
return intl.formatMessage(
|
||||
{
|
||||
defaultMessage: "Pool depth from: {value} m",
|
||||
},
|
||||
{ value: value }
|
||||
)
|
||||
|
||||
case IndoorPoolDetails.DepthTo:
|
||||
return intl.formatMessage(
|
||||
{
|
||||
defaultMessage: "Pool depth to: {value} m",
|
||||
},
|
||||
{ value: value }
|
||||
)
|
||||
|
||||
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
|
||||
const poolDepth = await getPoolDepthTranslation(details)
|
||||
const poolTranslations = details.map(({ name, value }) => {
|
||||
switch (name) {
|
||||
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:
|
||||
if (type === HealthFacilitiesEnum.OutdoorPool)
|
||||
return intl.formatMessage(
|
||||
@@ -91,9 +75,13 @@ export async function translateWellnessDetails({
|
||||
},
|
||||
{ value: value }
|
||||
)*/
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return poolTranslations
|
||||
.concat(poolDepth)
|
||||
.filter((d): d is string => !!d)
|
||||
.sort()
|
||||
|
||||
case HealthFacilitiesEnum.Gym:
|
||||
if (
|
||||
@@ -121,8 +109,40 @@ export async function translateWellnessDetails({
|
||||
}
|
||||
})
|
||||
.filter((d): d is string => !!d)
|
||||
.sort()
|
||||
|
||||
default:
|
||||
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 }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user