feat: SW-1583 Used constants for strings
This commit is contained in:
@@ -4,6 +4,8 @@ import { type FieldError, useFormContext } from "react-hook-form"
|
||||
import { useIntl } from "react-intl"
|
||||
import { useMediaQuery } from "usehooks-ts"
|
||||
|
||||
import { REDEMPTION } from "@/constants/booking"
|
||||
|
||||
import { ErrorCircleIcon, InfoCircleIcon } from "@/components/Icons"
|
||||
import Modal from "@/components/Modal"
|
||||
import Button from "@/components/TempDesignSystem/Button"
|
||||
@@ -52,9 +54,14 @@ export default function BookingCode() {
|
||||
})
|
||||
|
||||
function updateBookingCodeFormValue(value: string) {
|
||||
// Set value and show error if validation fails
|
||||
setValue("bookingCode.value", value, { shouldValidate: true })
|
||||
if (getValues("redemption")) {
|
||||
setValue("redemption", false)
|
||||
|
||||
if (getValues(REDEMPTION)) {
|
||||
// Remove the redemption as user types booking code and show notification for the same
|
||||
setValue(REDEMPTION, false)
|
||||
// Hide the above notification popup after 5 seconds by re-triggering validation
|
||||
// This is kept consistent with location search field error notification timeout
|
||||
setTimeout(function () {
|
||||
trigger("bookingCode.value")
|
||||
}, 5000)
|
||||
|
||||
Reference in New Issue
Block a user