import React from 'react'; import type { SalesSdkResourceError } from '../types'; /** * SalesSdkBookingContext:把 OS BookingContext 子模块以薄壳形式暴露给 React 消费方。 * * 设计目标: * - **写**(setBookingConfig / setResources / setBookingDate):透传到 OS BookingContext。 * - **读**(getResourcesForProduct / getProductExtend / getResourceErrors):透传到 OS BookingTicket * 的同名方法(OS 那边已经基于 BookingContext.utils 包了一层)。 * - 数据加载(`/core/board/management/config`、`/form/schedule`)**不在 SDK 内触发**: * 消费方在已经拉到数据的地方一次 `setBookingConfig` / `setResources` 即可。 * * 与 ticketBooking 现有 Info2 / mini-redux **完全解耦**,只服务 saleDetail 等新组件。 * * 该 Provider 为可选:消费方在不需要 booking 上下文的纯 sale 场景里可以不挂载,节省渲染。 * 挂载时应放在 SalesSdkProvider 内部、Cart/Customer 等其它子 Provider 同级。 */ export interface SalesSdkBookingContextValue { setBookingConfig: (config: Record | null) => void; getBookingConfig: () => Record | null; setResources: (resources: any[] | null | undefined) => void; getResourcesOrigin: () => any[]; getResourcesOriginMap: () => Record; setDate: (date: any) => void; getDate: () => string | null; /** * 取某商品当前可用的资源列表(含 unbound / display_scope='all' 等三特性,与 info2 等价)。 * 透传到 OS `bookingTicket.getResourcesForProduct`。 */ getResourcesForProduct: (product: any, options?: { extraResources?: Array<{ form_id: number | string; id: number; }>; }) => any[]; /** * 算 cacheItem 的 _extend / _data(资源、容量、timeObj 等),与 info2 `getProductExtend` 等价。 * 用于新 saleDetail 组件在弹窗内做调价 / 选资源等交互。 */ getProductExtend: (cacheItem: any, extra?: Record) => any; /** * 给资源跑一遍可用性检查,输出结构化错误(与 OS `getResourceErrors` 一一对应)。 * UI 拿到 reason + params 后自行渲染 i18n 文案,对照表见 docs.md。 */ getResourceErrors: (resource: any, cacheItem: any) => SalesSdkResourceError[]; } export declare const SalesSdkBookingContext: React.Context; /** * BookingContext Provider —— 极薄壳:所有写都透传到 OS,所有读都调 OS 上的同名方法。 * * 不持有 React state(避免与 OS 数据不一致);如果消费方需要订阅 booking config 变更, * 通过 `useSalesSdk().bookingTicket?.effectsOn('bookingContext:onBookingConfigChange', cb)` 自订阅。 */ export declare const SalesSdkBookingContextProvider: React.FC<{ children: React.ReactNode; }>; export declare function useSalesSdkBookingContext(): SalesSdkBookingContextValue;