feat: SW-963 Optimized code

This commit is contained in:
Hrishikesh Vaipurkar
2025-03-05 17:13:13 +01:00
parent 561b121b54
commit 0e55c6ac6d

View File

@@ -44,6 +44,7 @@ export default function BookingCode() {
const codeVoucher = intl.formatMessage({ id: "Code / Voucher" }) const codeVoucher = intl.formatMessage({ id: "Code / Voucher" })
const addCode = intl.formatMessage({ id: "Add code" }) const addCode = intl.formatMessage({ id: "Add code" })
const ref = useRef<HTMLDivElement | null>(null) const ref = useRef<HTMLDivElement | null>(null)
const removeExtraRoomsText = intl.formatMessage({ id: "Remove extra rooms" })
function updateBookingCodeFormValue(value: string) { function updateBookingCodeFormValue(value: string) {
setValue("bookingCode.value", value, { shouldValidate: true }) setValue("bookingCode.value", value, { shouldValidate: true })
@@ -56,8 +57,7 @@ export default function BookingCode() {
target && target &&
!ref.current.contains(target) && !ref.current.contains(target) &&
// This is for mobile layout having "Remove extra rooms" button outside the container // This is for mobile layout having "Remove extra rooms" button outside the container
target.getAttribute("value") !== target.innerText !== removeExtraRoomsText
intl.formatMessage({ id: "Remove extra rooms" })
) { ) {
setShowRemember(false) setShowRemember(false)
if (codeError) { if (codeError) {
@@ -65,7 +65,7 @@ export default function BookingCode() {
} }
} }
}, },
[setShowRemember, setValue, intl, ref, codeError] [setShowRemember, setValue, removeExtraRoomsText, ref, codeError]
) )
function showRememberCheck() { function showRememberCheck() {
@@ -262,7 +262,6 @@ export function RemoveExtraRooms({ ...props }: ButtonProps) {
return ( return (
<Button <Button
value={intl.formatMessage({ id: "Remove extra rooms" })}
type="button" type="button"
onClick={removeExtraRooms} onClick={removeExtraRooms}
size="small" size="small"