Merged in fix/SW-449-booking-widget-url-date (pull request #847)
fix(SW-449): Updated Date format to match current web Approved-by: Niclas Edenvin
This commit is contained in:
@@ -86,11 +86,11 @@ export default function BookingWidgetClient({
|
||||
// UTC is required to handle requests from far away timezones https://scandichotels.atlassian.net/browse/SWAP-6375 & PET-507
|
||||
// This is specifically to handle timezones falling in different dates.
|
||||
fromDate: isDateParamValid
|
||||
? bookingWidgetSearchData?.fromDate?.toString()
|
||||
: dt().utc().format("YYYY-MM-DD"),
|
||||
? dt(bookingWidgetSearchData?.fromDate).format("YYYY-M-D")
|
||||
: dt().utc().format("YYYY-M-D"),
|
||||
toDate: isDateParamValid
|
||||
? bookingWidgetSearchData?.toDate?.toString()
|
||||
: dt().utc().add(1, "day").format("YYYY-MM-DD"),
|
||||
? dt(bookingWidgetSearchData?.toDate).format("YYYY-M-D")
|
||||
: dt().utc().add(1, "day").format("YYYY-M-D"),
|
||||
},
|
||||
bookingCode: "",
|
||||
redemption: false,
|
||||
|
||||
@@ -47,7 +47,7 @@ export default function DatePickerForm({ name = "date" }: DatePickerFormProps) {
|
||||
if (!dt(selected).isBefore(dt(), "day")) {
|
||||
if (isSelectingFrom) {
|
||||
setValue(name, {
|
||||
fromDate: dt(selected).format("YYYY-MM-DD"),
|
||||
fromDate: dt(selected).format("YYYY-MM-D"),
|
||||
toDate: undefined,
|
||||
})
|
||||
setIsSelectingFrom(false)
|
||||
@@ -57,11 +57,11 @@ export default function DatePickerForm({ name = "date" }: DatePickerFormProps) {
|
||||
if (toDate.isAfter(fromDate)) {
|
||||
setValue(name, {
|
||||
fromDate: selectedDate.fromDate,
|
||||
toDate: toDate.format("YYYY-MM-DD"),
|
||||
toDate: toDate.format("YYYY-MM-D"),
|
||||
})
|
||||
} else {
|
||||
setValue(name, {
|
||||
fromDate: toDate.format("YYYY-MM-DD"),
|
||||
fromDate: toDate.format("YYYY-MM-D"),
|
||||
toDate: selectedDate.fromDate,
|
||||
})
|
||||
}
|
||||
@@ -75,9 +75,7 @@ export default function DatePickerForm({ name = "date" }: DatePickerFormProps) {
|
||||
if (!selectedDate.toDate) {
|
||||
setValue(name, {
|
||||
fromDate: selectedDate.fromDate,
|
||||
toDate: dt(selectedDate.fromDate)
|
||||
.add(1, "day")
|
||||
.format("YYYY-MM-DD"),
|
||||
toDate: dt(selectedDate.fromDate).add(1, "day").format("YYYY-MM-D"),
|
||||
})
|
||||
setIsSelectingFrom(true)
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ export default function Form({ locations, type }: BookingWidgetFormProps) {
|
||||
type,
|
||||
})
|
||||
|
||||
const { formState, handleSubmit, register } =
|
||||
useFormContext<BookingWidgetSchema>()
|
||||
const { handleSubmit, register } = useFormContext<BookingWidgetSchema>()
|
||||
|
||||
function onSubmit(data: BookingWidgetSchema) {
|
||||
const locationData: Location = JSON.parse(decodeURIComponent(data.location))
|
||||
|
||||
@@ -83,7 +83,7 @@ export default function DateSelect({ name, registerOptions = {} }: DateProps) {
|
||||
.date(Number(day))
|
||||
|
||||
if (newDate.isValid()) {
|
||||
setValue(name, newDate.format("YYYY-MM-DD"), {
|
||||
setValue(name, newDate.format("YYYY-MM-D"), {
|
||||
shouldDirty: true,
|
||||
shouldTouch: true,
|
||||
shouldValidate: true,
|
||||
|
||||
Reference in New Issue
Block a user