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 { 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)
|
||||
|
||||
Reference in New Issue
Block a user