feat(SW-2879): Move BookingWidget to booking-flow package * Fix lockfile * Fix styling * a tiny little booking widget test * Tiny fixes * Merge branch 'master' into feat/sw-2879-booking-widget-to-booking-flow-package * Remove unused scripts * lint:fix * Merge branch 'master' into feat/sw-2879-booking-widget-to-booking-flow-package * Tiny lint fixes * update test * Update Input in booking-flow * Clean up comments etc * Merge branch 'master' into feat/sw-2879-booking-widget-to-booking-flow-package * Setup tracking context for booking-flow * Add missing use client * Fix temp tracking function * Pass booking to booking-widget * Remove comment * Add use client to booking widget tracking provider * Add use client to tracking functions * Merge branch 'master' into feat/sw-2879-booking-widget-to-booking-flow-package * Move debug page * Merge branch 'master' into feat/sw-2879-booking-widget-to-booking-flow-package * Merge branch 'master' into feat/sw-2879-booking-widget-to-booking-flow-package * Merge branch 'master' into feat/sw-2879-booking-widget-to-booking-flow-package Approved-by: Bianca Widstam
50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
import { useIntl } from "react-intl"
|
|
|
|
import { changeOrCancelDateFormat } from "@scandic-hotels/common/constants/dateFormats"
|
|
import { dt } from "@scandic-hotels/common/dt"
|
|
|
|
import { useMyStayStore } from "@/stores/my-stay"
|
|
|
|
import { hasModifiableRate } from "@/components/HotelReservation/MyStay/utils"
|
|
import useLang from "@/hooks/useLang"
|
|
|
|
import Row from "./Row"
|
|
|
|
export default function ModifyBy() {
|
|
const intl = useIntl()
|
|
const lang = useLang()
|
|
|
|
const { checkInDate, isModifyable } = useMyStayStore((state) => ({
|
|
checkInDate: state.bookedRoom.checkInDate,
|
|
isModifyable: hasModifiableRate(
|
|
state.bookedRoom.rateDefinition.cancellationRule
|
|
),
|
|
}))
|
|
|
|
if (!isModifyable) {
|
|
return null
|
|
}
|
|
|
|
const fromDate = dt(checkInDate).locale(lang)
|
|
|
|
const text = intl.formatMessage(
|
|
{
|
|
defaultMessage: "Until {time}, {date}",
|
|
},
|
|
{
|
|
time: "18:00",
|
|
date: fromDate.format(changeOrCancelDateFormat[lang]),
|
|
}
|
|
)
|
|
|
|
return (
|
|
<Row
|
|
icon="refresh"
|
|
text={text}
|
|
title={intl.formatMessage({
|
|
defaultMessage: "Change or cancel",
|
|
})}
|
|
/>
|
|
)
|
|
}
|