/** * Service Service - Reactive service data management * Handles loading and managing a single service's data, loading state, and errors. */ import { type Signal, type ReadOnlySignal } from '@wix/services-definitions/core-services/signals'; import { type Service, type Payment } from '@wix/auto_sdk_bookings_services'; import type { MoneyData } from '@wix/headless-components/react'; /** * Actions object for service selection */ export interface ServiceActions { /** Replace entire selection with this service (with current modifiers) */ select: () => void; /** Add this service to selection (with current modifiers) */ add: () => void; /** Remove this service from selection */ remove: () => void; } /** * Payment data derived from service payment information * * @interface ServicePaymentData */ export interface ServicePaymentData { /** The service payment information from the service */ servicePayment: Payment | undefined; /** The rate type of the service (FIXED, VARIED, CUSTOM, NO_FEE, etc.) */ rateType: Payment['rateType'] | undefined; /** Primary price (used for FIXED or VARIED default) */ money: MoneyData | null; /** Minimum price (used for VARIED) */ minPrice: MoneyData | null; /** Maximum price (used for VARIED) */ maxPrice: MoneyData | null; /** Price description text (used for CUSTOM) */ priceDescription: string | null; /** Whether the service has add-ons available */ hasAddOns: boolean; /** Whether the service has pricing plans available */ hasPricingPlans: boolean; } /** * API interface for the Service service, providing reactive service data management. * * @interface ServiceServiceAPI */ export interface ServiceServiceAPI { /** Reactive signal containing the current service data */ serviceSignal: Signal; /** Reactive signal indicating if a service is currently being loaded */ isLoadingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; /** Function to load a service by its id */ loadServiceById: (id: string) => Promise; /** Indicates if BookingService is available (false in showcase mode/lead nurturing) */ bookableSignal: ReadOnlySignal; /** Indicates if the current service is selected in BookingService */ selectedSignal: ReadOnlySignal; /** Indicates if the service requires availability selection (true for APPOINTMENT and CLASS, false for COURSE) */ requiresAvailabilitySignal: ReadOnlySignal; /** Reactive signal containing computed payment data derived from service */ paymentDataSignal: ReadOnlySignal; /** Actions object containing service selection actions (only work when bookable is true) */ actions: ServiceActions; } /** * Service definition for the Service service. * This defines the contract that the ServiceService must implement. * * @constant */ export declare const ServiceServiceDefinition: string & { __api: ServiceServiceAPI; __config: {}; isServiceDefinition?: boolean; } & ServiceServiceAPI; /** * Configuration interface required to initialize the ServiceService. * Contains the initial service data that will be loaded into the service. * * @interface ServiceServiceConfig */ export interface ServiceServiceConfig { /** The initial service data to configure the service with */ service?: Service; /** The service ID to load if no initial service is provided */ serviceId?: string; /** The service slug to load if no initial service is provided */ serviceSlug?: string; /** The app ID to filter services by app and determine bookable */ appId?: string; } /** * Implementation of the Service service that manages reactive service data. * This service provides signals for service data, loading state, and error handling, * along with methods to dynamically load services. * * @example * ```tsx * import { ServiceService, ServiceServiceDefinition } from '@wix/bookings/services'; * import { useService } from '@wix/services-manager-react'; * * function ServiceComponent({ serviceConfig }) { * return ( * * * * ); * } * * function ServiceDisplay() { * const serviceService = useService(ServiceServiceDefinition); * const service = serviceService.serviceSignal.get(); * const isLoading = serviceService.isLoadingSignal.get(); * const error = serviceService.errorSignal.get(); * * if (isLoading) return
Loading...
; * if (error) return
Error: {error}
; * * return

{service.name}

; * } * ``` */ export declare const ServiceService: import("@wix/services-definitions").ServiceFactory; /** * Result types for service loading operations */ export type SuccessServiceServiceConfigResult = { type: 'success'; config: ServiceServiceConfig; }; export type NotFoundServiceServiceConfigResult = { type: 'notFound'; }; /** * Load service configuration for Server-Side Rendering (SSR). * This function is designed to be called during the build or server-side rendering phase * to pre-fetch service data before the React components are hydrated on the client. * * @param params - Either `{ slug: string, appId?: string }` or `{ serviceId: string, appId?: string }` * @returns A promise that resolves to either a success result with the config or a notFound result * * @example * ```ts * // In an Astro page or API route * import { loadServiceServiceInitialData } from '@wix/headless-bookings/services'; * * // Load by slug * const serviceResult = await loadServiceServiceInitialData({ slug: 'group-trainings' }); * * // Load by serviceId * const serviceResult = await loadServiceServiceInitialData({ serviceId: 'service-id-123' }); * * if (serviceResult.type === 'notFound') { * return Astro.redirect('/404'); * } * * const serviceConfig = serviceResult.config; * ``` */ export declare function loadServiceServiceInitialData(params: { slug: string; appId?: string; } | { serviceId: string; appId?: string; }): Promise;