feat: SW-276 Optimized code
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"use client"
|
||||
import { useFormContext } from "react-hook-form"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { useGuestsRoomsStore } from "@/stores/guests-rooms"
|
||||
@@ -13,6 +14,7 @@ import ChildSelector from "./ChildSelector"
|
||||
|
||||
import styles from "./guests-rooms-picker.module.css"
|
||||
|
||||
import { BookingWidgetSchema } from "@/types/components/bookingWidget"
|
||||
import { GuestsRoomsPickerProps } from "@/types/components/bookingWidget/guestsRoomsPicker"
|
||||
|
||||
export default function GuestsRoomsPicker({
|
||||
@@ -20,11 +22,11 @@ export default function GuestsRoomsPicker({
|
||||
}: GuestsRoomsPickerProps) {
|
||||
const intl = useIntl()
|
||||
const doneLabel = intl.formatMessage({ id: "Done" })
|
||||
const roomLabel = intl.formatMessage({ id: "Room" })
|
||||
|
||||
const { getFieldState } = useFormContext<BookingWidgetSchema>()
|
||||
|
||||
const rooms = useGuestsRoomsStore((state) => state.rooms)
|
||||
const guestRoomsValidData = guestRoomsSchema.safeParse(rooms)
|
||||
const isInValid = !guestRoomsValidData.success
|
||||
const roomLabel = intl.formatMessage({ id: "Room" })
|
||||
|
||||
// Not in MVP
|
||||
// const { increaseRoom, decreaseRoom } = guestsRoomsStore()
|
||||
@@ -63,7 +65,7 @@ export default function GuestsRoomsPicker({
|
||||
) : null} */}
|
||||
<Button
|
||||
onClick={closePicker}
|
||||
disabled={isInValid}
|
||||
disabled={getFieldState("rooms").invalid}
|
||||
className={styles.hideOnMobile}
|
||||
intent="tertiary"
|
||||
theme="base"
|
||||
@@ -73,7 +75,7 @@ export default function GuestsRoomsPicker({
|
||||
</Button>
|
||||
<Button
|
||||
onClick={closePicker}
|
||||
disabled={isInValid}
|
||||
disabled={getFieldState("rooms").invalid}
|
||||
className={styles.hideOnDesktop}
|
||||
intent="tertiary"
|
||||
theme="base"
|
||||
|
||||
Reference in New Issue
Block a user