chore: Cleanup booking widget with types and other minor issues
This commit is contained in:
@@ -27,21 +27,23 @@ export default function MobileToggleButton({
|
||||
}: BookingWidgetToggleButtonProps) {
|
||||
const intl = useIntl()
|
||||
const lang = useLang()
|
||||
const d = useWatch({ name: "date" })
|
||||
const location = useWatch({ name: "location" })
|
||||
const rooms: BookingWidgetSchema["rooms"] = useWatch({ name: "rooms" })
|
||||
const date = useWatch<BookingWidgetSchema, "date">({ name: "date" })
|
||||
const location = useWatch<BookingWidgetSchema, "location">({
|
||||
name: "location",
|
||||
})
|
||||
const rooms = useWatch<BookingWidgetSchema, "rooms">({ name: "rooms" })
|
||||
|
||||
const parsedLocation: Location | null =
|
||||
location && isValidJson(location)
|
||||
? JSON.parse(decodeURIComponent(location))
|
||||
: null
|
||||
|
||||
const selectedFromDate = dt(d.fromDate).locale(lang).format("D MMM")
|
||||
const selectedToDate = dt(d.toDate).locale(lang).format("D MMM")
|
||||
const selectedFromDate = dt(date.fromDate).locale(lang).format("D MMM")
|
||||
const selectedToDate = dt(date.toDate).locale(lang).format("D MMM")
|
||||
|
||||
const locationAndDateIsSet = parsedLocation && d
|
||||
const locationAndDateIsSet = parsedLocation && date
|
||||
|
||||
const totalNights = dt(d.toDate).diff(dt(d.fromDate), "days")
|
||||
const totalNights = dt(date.toDate).diff(dt(date.fromDate), "days")
|
||||
const totalRooms = rooms.length
|
||||
const totalAdults = rooms.reduce((acc, room) => {
|
||||
if (room.adults) {
|
||||
|
||||
Reference in New Issue
Block a user