Merged in chore/cleanup-after-trpc-migration (pull request #2457)
Chore/cleanup after trpc migration * Clean up TODOs * Rename REDEMPTION constant to SEARCH_TYPE_REDEMPTION * Update dependencies Remove unused deps from scandic-web Add missing deps to trpc package * Update self-referencing imports * Remove unused variables from scandic-web env * Fix missing graphql-tag package * Actually fix * Remove unused env var Approved-by: Christian Andolf Approved-by: Linus Flood
This commit is contained in:
@@ -7,7 +7,7 @@ import { FormProvider, useForm } from "react-hook-form"
|
||||
|
||||
import { dt } from "@scandic-hotels/common/dt"
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
import { REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
|
||||
import { trpc } from "@/lib/trpc/client"
|
||||
import { StickyElementNameEnum } from "@/stores/sticky-position"
|
||||
@@ -123,7 +123,7 @@ export default function BookingWidgetClient({
|
||||
value: selectedBookingCode,
|
||||
remember: false,
|
||||
},
|
||||
redemption: data.searchType === REDEMPTION,
|
||||
redemption: data.searchType === SEARCH_TYPE_REDEMPTION,
|
||||
rooms: defaultRoomsData,
|
||||
city: data.city || undefined,
|
||||
hotel: hotelId,
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useMediaQuery } from "usehooks-ts"
|
||||
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
import { REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
|
||||
import Modal from "@/components/Modal"
|
||||
import Button from "@/components/TempDesignSystem/Button"
|
||||
@@ -65,11 +65,11 @@ export default function BookingCode() {
|
||||
shouldDirty: true,
|
||||
})
|
||||
|
||||
if (getValues(REDEMPTION)) {
|
||||
if (getValues(SEARCH_TYPE_REDEMPTION)) {
|
||||
// Remove the redemption as user types booking code and show notification for the same
|
||||
// Add delay to handle table mode rendering
|
||||
setTimeout(function () {
|
||||
setValue(REDEMPTION, false, {
|
||||
setValue(SEARCH_TYPE_REDEMPTION, false, {
|
||||
shouldValidate: true,
|
||||
shouldDirty: true,
|
||||
})
|
||||
@@ -321,7 +321,7 @@ export function RemoveExtraRooms({ ...props }: ButtonProps) {
|
||||
const rooms = getValues("rooms")[0]
|
||||
setValue("rooms", [rooms], { shouldValidate: true, shouldDirty: true })
|
||||
trigger("bookingCode.value")
|
||||
trigger(REDEMPTION)
|
||||
trigger(SEARCH_TYPE_REDEMPTION)
|
||||
}, 300)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useMediaQuery } from "usehooks-ts"
|
||||
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
import { REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
|
||||
import Modal from "@/components/Modal"
|
||||
import Button from "@/components/TempDesignSystem/Button"
|
||||
@@ -38,26 +38,26 @@ export default function RewardNight() {
|
||||
defaultMessage:
|
||||
"To book a reward night, make sure you're logged in to your Scandic Friends account.",
|
||||
})
|
||||
const redemptionErr = errors[REDEMPTION]
|
||||
const redemptionErr = errors[SEARCH_TYPE_REDEMPTION]
|
||||
const isDesktop = useMediaQuery("(min-width: 767px)")
|
||||
|
||||
function validateRedemption(value: boolean) {
|
||||
// Validate redemption as per the rules defined in the schema
|
||||
trigger(REDEMPTION)
|
||||
trigger(SEARCH_TYPE_REDEMPTION)
|
||||
if (value && getValues("bookingCode.value")) {
|
||||
setValue("bookingCode.flag", false)
|
||||
setValue("bookingCode.value", "", { shouldValidate: true })
|
||||
// Hide the notification popup after 5 seconds by re-triggering validation
|
||||
// This is kept consistent with location search field error notification timeout
|
||||
setTimeout(() => {
|
||||
trigger(REDEMPTION)
|
||||
trigger(SEARCH_TYPE_REDEMPTION)
|
||||
}, 5000)
|
||||
}
|
||||
}
|
||||
|
||||
const resetOnMultiroomError = useCallback(() => {
|
||||
if (isMultiRoomError(redemptionErr?.message) && isDesktop) {
|
||||
setValue(REDEMPTION, false, { shouldValidate: true })
|
||||
setValue(SEARCH_TYPE_REDEMPTION, false, { shouldValidate: true })
|
||||
}
|
||||
}, [redemptionErr?.message, setValue, isDesktop])
|
||||
|
||||
@@ -85,7 +85,7 @@ export default function RewardNight() {
|
||||
<div ref={ref} onBlur={(e) => closeOnBlur(e.nativeEvent)}>
|
||||
<Checkbox
|
||||
hideError
|
||||
name={REDEMPTION}
|
||||
name={SEARCH_TYPE_REDEMPTION}
|
||||
registerOptions={{
|
||||
onChange: (e) => {
|
||||
validateRedemption(e.target.value)
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useIntl } from "react-intl"
|
||||
import { dt } from "@scandic-hotels/common/dt"
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
import { REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
|
||||
import { hotelreservation } from "@/constants/routes/hotelReservation"
|
||||
|
||||
@@ -111,7 +111,7 @@ export default function FormContent({
|
||||
</div>
|
||||
<div className={`${styles.buttonContainer} ${styles.hideOnTablet}`}>
|
||||
{isMultiRoomError(errors.bookingCode?.value?.message) ||
|
||||
isMultiRoomError(errors[REDEMPTION]?.message) ? (
|
||||
isMultiRoomError(errors[SEARCH_TYPE_REDEMPTION]?.message) ? (
|
||||
<div className={styles.showOnMobile}>
|
||||
<RemoveExtraRooms size="medium" fullWidth />
|
||||
</div>
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Form as FormRAC } from "react-aria-components"
|
||||
import { useFormContext } from "react-hook-form"
|
||||
|
||||
import { selectRate } from "@scandic-hotels/common/constants/routes/hotelReservation"
|
||||
import { REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
|
||||
import {
|
||||
selectHotel,
|
||||
@@ -60,7 +60,7 @@ export default function Form({ type, onClose }: BookingWidgetFormProps) {
|
||||
? { bookingCode: data.bookingCode.value }
|
||||
: {}),
|
||||
// Followed current url structure to keep searchtype=redemption param incase of reward night
|
||||
...(data.redemption ? { searchType: REDEMPTION } : {}),
|
||||
...(data.redemption ? { searchType: SEARCH_TYPE_REDEMPTION } : {}),
|
||||
})
|
||||
|
||||
onClose()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { z } from "zod"
|
||||
|
||||
import { REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
import { ChildBedMapEnum } from "@scandic-hotels/trpc/enums/childBedMapEnum"
|
||||
|
||||
export const bookingWidgetErrors = {
|
||||
@@ -104,7 +104,7 @@ export const bookingWidgetSchema = z
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: bookingWidgetErrors.MULTIROOM_REWARD_NIGHT_UNAVAILABLE,
|
||||
path: [REDEMPTION],
|
||||
path: [SEARCH_TYPE_REDEMPTION],
|
||||
})
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
@@ -116,7 +116,7 @@ export const bookingWidgetSchema = z
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: bookingWidgetErrors.CODE_VOUCHER_REWARD_NIGHT_UNAVAILABLE,
|
||||
path: [REDEMPTION],
|
||||
path: [SEARCH_TYPE_REDEMPTION],
|
||||
})
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useIntl } from "react-intl"
|
||||
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
import { REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
|
||||
import Button from "../TempDesignSystem/Button"
|
||||
import { Tooltip } from "../TempDesignSystem/Tooltip"
|
||||
@@ -39,7 +39,7 @@ export default function GuestsRoomsPickerDialog({
|
||||
defaultMessage: "Done",
|
||||
})
|
||||
// Disable add room if booking code is either voucher or corporate cheque, or reward night is enabled
|
||||
const addRoomDisabledTextForSpecialRate = getValues(REDEMPTION)
|
||||
const addRoomDisabledTextForSpecialRate = getValues(SEARCH_TYPE_REDEMPTION)
|
||||
? intl.formatMessage({
|
||||
defaultMessage:
|
||||
"Multi-room booking is not available with reward night.",
|
||||
@@ -73,7 +73,7 @@ export default function GuestsRoomsPickerDialog({
|
||||
|
||||
if (updatedRooms.length === 1) {
|
||||
trigger("bookingCode.value")
|
||||
trigger(REDEMPTION)
|
||||
trigger(SEARCH_TYPE_REDEMPTION)
|
||||
}
|
||||
},
|
||||
[roomsValue, trigger, setValue]
|
||||
|
||||
@@ -13,7 +13,7 @@ import { selectRate } from "@scandic-hotels/common/constants/routes/hotelReserva
|
||||
import { Button } from "@scandic-hotels/design-system/Button"
|
||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
import { bedTypeMap } from "@scandic-hotels/trpc/constants/bedTypeMap"
|
||||
import { REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
import { BookingStatusEnum } from "@scandic-hotels/trpc/enums/bookingStatus"
|
||||
import { RoomPackageCodeEnum } from "@scandic-hotels/trpc/enums/roomFilter"
|
||||
|
||||
@@ -517,7 +517,7 @@ export default function PaymentClient({
|
||||
onSubmit={methods.handleSubmit(handleSubmit)}
|
||||
id={formId}
|
||||
>
|
||||
{booking.searchType === REDEMPTION ? (
|
||||
{booking.searchType === SEARCH_TYPE_REDEMPTION ? (
|
||||
<ConfirmBookingRedemption />
|
||||
) : hasOnlyFlexRates && !bookingMustBeGuaranteed ? (
|
||||
<ConfirmBooking savedCreditCards={savedCreditCards} />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { differenceInCalendarDays, format, isWeekend } from "date-fns"
|
||||
|
||||
import { CurrencyEnum } from "@scandic-hotels/common/constants/currency"
|
||||
import { REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
import { ChildBedMapEnum } from "@scandic-hotels/trpc/enums/childBedMapEnum"
|
||||
import { PackageTypeEnum } from "@scandic-hotels/trpc/enums/packages"
|
||||
import { RoomPackageCodeEnum } from "@scandic-hotels/trpc/enums/roomFilter"
|
||||
@@ -192,9 +192,9 @@ export function getTracking(
|
||||
})
|
||||
),
|
||||
].join(","),
|
||||
rewardNight: booking.searchType === REDEMPTION ? "yes" : "no",
|
||||
rewardNight: booking.searchType === SEARCH_TYPE_REDEMPTION ? "yes" : "no",
|
||||
rewardNightAvailability:
|
||||
booking.searchType === REDEMPTION ? "true" : "false",
|
||||
booking.searchType === SEARCH_TYPE_REDEMPTION ? "true" : "false",
|
||||
roomPrice: calcTotalRoomPrice(storedRooms, isMember),
|
||||
roomTypeCode: rooms.map((room) => room.roomTypeCode).join("|"),
|
||||
roomTypeName: rooms.map((room) => room.roomType).join("|"),
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { useSearchParams } from "next/navigation"
|
||||
import React from "react"
|
||||
|
||||
import { REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
|
||||
import TrackingSDK from "@/components/TrackingSDK"
|
||||
import useLang from "@/hooks/useLang"
|
||||
@@ -57,7 +57,7 @@ export default function Tracking({
|
||||
city,
|
||||
paramCity,
|
||||
bookingCode,
|
||||
searchType === REDEMPTION,
|
||||
searchType === SEARCH_TYPE_REDEMPTION,
|
||||
rooms
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user