Merged in fix/SW-2501-validation-trigger (pull request #1924)
fix(SW-2501): validation trigger * fix(SW-2501): validation trigger On enter details, when submitting we want to trigger the validation for the details forms for each room. This will display error messages for the form fields with errors if they are not already displayed, so the user knows which fields has errors. Approved-by: Tobias Johansson
This commit is contained in:
@@ -76,11 +76,13 @@ export default function PaymentClient({
|
||||
|
||||
const [showBookingAlert, setShowBookingAlert] = useState(false)
|
||||
|
||||
const { booking, rooms, totalPrice } = useEnterDetailsStore((state) => ({
|
||||
booking: state.booking,
|
||||
rooms: state.rooms,
|
||||
totalPrice: state.totalPrice,
|
||||
}))
|
||||
const { booking, rooms, totalPrice, preSubmitCallbacks } =
|
||||
useEnterDetailsStore((state) => ({
|
||||
booking: state.booking,
|
||||
rooms: state.rooms,
|
||||
totalPrice: state.totalPrice,
|
||||
preSubmitCallbacks: state.preSubmitCallbacks,
|
||||
}))
|
||||
|
||||
const bookingMustBeGuaranteed = rooms.some(({ room }, idx) => {
|
||||
if (idx === 0 && isUserLoggedIn && room.memberMustBeGuaranteed) {
|
||||
@@ -282,6 +284,9 @@ export default function PaymentClient({
|
||||
|
||||
const handleSubmit = useCallback(
|
||||
(data: PaymentFormData) => {
|
||||
Object.values(preSubmitCallbacks).forEach((callback) => {
|
||||
callback()
|
||||
})
|
||||
const firstIncompleteRoomIndex = rooms.findIndex(
|
||||
(room) => !room.isComplete
|
||||
)
|
||||
@@ -445,10 +450,11 @@ export default function PaymentClient({
|
||||
fromDate,
|
||||
toDate,
|
||||
rooms,
|
||||
booking,
|
||||
booking.rooms,
|
||||
getPaymentMethod,
|
||||
hasOnlyFlexRates,
|
||||
bookingMustBeGuaranteed,
|
||||
preSubmitCallbacks,
|
||||
isUserLoggedIn,
|
||||
getTopOffset,
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user