import { createContext, useContext, useState } from 'react'
import { Flex, Button, Image, Divider, Typography, Empty, Skeleton, Row, Col, InputNumber, Form, DatePicker, Input } from 'antd'
const HotelContext = createContext()
export function SearchForm({ onSearch, onInit }) {
const [searchForm] = Form.useForm()
onInit(searchForm)
const handelFormFinish = () => {
const formValue = searchForm.getFieldValue()
// setSearchParams({
// hotel: formValue.hotelName,
// checkin: formValue.dataRange[0].format('YYYY-MM-DD'),
// checkout: formValue.dataRange[1].format('YYYY-MM-DD')
// })
onSearch(formValue)
// setLoading(true)
// searchByCriteria(formValue)
// .finally(() => setLoading(false))
}
return (
)
}
export function HotelList({ dataSource, loading, onChange }) {
if (dataSource && dataSource.length > 0) {
const itemList = dataSource.map((data, index) => {
return (
<>
{data.hotel_name}
{data.address}
{data.base_price.Price??0} 起
>
)
})
return (
{itemList}
)
} else {
return
}
}
export function RoomList({ dataSource, loading, onChange }) {
const triggerChange = (changedValue) => {
onChange?.(
changedValue
)
}
if (dataSource && dataSource.length > 0) {
const itemList = dataSource.map((room, index) => {
let roomImage =
if (room?.Images && room?.Images.length > 0) {
roomImage =
}
return (
{room.RoomName}, {room.BedTypeDesc}
{roomImage}
大小: {room.Area??0}m²
{
room.RatePlans.map((plan, index) => {
return (
)
})
}
)
})
return (
{itemList}
)
} else {
return
}
}
const getMealDesc = (plan) => {
const type = plan.MealType
let desc = '未知'
if (type === 1) desc = '早' + plan.Breakfast + '中' + plan.Lunch + '晚' + plan.Dinner
else if (type === 2) desc = '半包'
else if (type === 3) desc = '全包'
else if (type === 4) desc = '午/晚二选一'
else if (type === 5) desc = '早+午/晚二选一'
return desc
}
const PlanItem = ({room, plan}) => {
const { triggerChange } = useContext(HotelContext)
return (
<>
餐: {getMealDesc(plan)}
{plan.Cancelable ? plan.CancelRulesText.join(';') : plan.CancelableText}
{plan.PriceUnit}
{plan.Currency}
>
)
}