/** * ServiceList Service - Reactive service list data management * Handles querying and pagination of services list (NO selection management) */ import { type Signal, type ReadOnlySignal } from '@wix/services-definitions/core-services/signals'; import type { Service } from '@wix/auto_sdk_bookings_services'; import type { QueryServicesRequest, PagingMetadata } from '../../api/query-services/index.js'; import { type Category } from '../../api/query-categories/index.js'; import type { FilterOption, FilterValue as Filter } from '@wix/headless-components/react'; /** * Query options without paging metadata (user-controlled request params) * Effect subscribes to changes in this signal to trigger re-fetches */ export type QueryOptions = Omit; /** * Configuration for the ServiceList service */ export interface ServiceListServiceConfig { services?: Service[]; categories?: Category[]; options?: QueryServicesRequest; } /** * Actions object for service list operations */ export interface ServiceListActions { loadMore: (count?: number) => Promise; setQueryOptions: (options: QueryOptions) => void; setFilter: (filter: Filter) => void; resetFilter: () => void; resetFilterField: (fieldName: string) => void; } /** * API interface for the ServiceList service */ export interface ServiceListServiceAPI { /** Reactive signal containing the list of services */ servicesSignal: Signal; /** Reactive signal containing current query options (appId, filter, sort) - changes trigger re-fetch */ queryOptionsSignal: Signal; /** Reactive signal containing pagination metadata (limit, offset, count, hasNext) - updated after fetches */ pagingMetadataSignal: Signal; /** Reactive signal indicating if services are currently being loaded */ isLoadingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; /** Reactive signal containing available categories for filtering */ categoriesSignal: Signal; /** Computed signal containing filter options derived from categories */ filterOptionsSignal: ReadOnlySignal; /** Computed signal indicating if any filters are active (from queryOptionsSignal.filter) */ isFilteredSignal: ReadOnlySignal; /** Computed signal containing effective filter (queryOptions.filter + location from BookingService) */ effectiveFilterSignal: ReadOnlySignal; /** Actions object containing query actions */ actions: ServiceListActions; /** Reactive signal indicating if there are more services to load */ hasMoreServicesSignal: ReadOnlySignal; } /** * Service definition for the ServiceList service */ export declare const ServiceListServiceDefinition: string & { __api: ServiceListServiceAPI; __config: ServiceListServiceConfig; isServiceDefinition?: boolean; } & ServiceListServiceAPI; /** * Implementation of the ServiceList service that manages reactive services list data. * This service provides signals for services data, query options, pagination metadata * (including hasNext flag), loading state, and error handling. * It automatically re-fetches services when query options change. * * @example * ```tsx * import { ServiceListService, ServiceListServiceDefinition } from '@wix/bookings/services'; * import { useService } from '@wix/services-manager-react'; * * function ServicesComponent({ serviceListConfig }) { * return ( * * * * ); * } * * function ServicesDisplay() { * const serviceListService = useService(ServiceListServiceDefinition); * const services = serviceListService.servicesSignal.get(); * const isLoading = serviceListService.isLoadingSignal.get(); * const error = serviceListService.errorSignal.get(); * const pagingMetadata = serviceListService.pagingMetadataSignal.get(); * const hasMore = serviceListService.hasMoreServicesSignal.get(); * * if (isLoading) return
Loading services...
; * if (error) return
Error: {error}
; * * return ( *
* {services.map(service => ( *
*

{service.name}

*

{service.description}

*
* ))} * {hasMore && ( * * )} * {pagingMetadata.hasNext && ( * More services available * )} *
* ); * } * ``` */ export declare const ServiceListService: import("@wix/services-definitions").ServiceFactory; /** * Result types for service list loading operations */ export type SuccessServiceListServiceConfigResult = { type: 'success'; config: ServiceListServiceConfig; }; export type ErrorServiceListServiceConfigResult = { type: 'error'; error: Error; }; /** * Load service list configuration for Server-Side Rendering (SSR). * This function is designed to be called during the build or server-side rendering phase * to pre-fetch services data before the React components are hydrated on the client. * The returned config includes paging metadata with hasNext flag indicating if more services are available. * * @param options - Query options following QueryServicesRequest type, or a URL string (to be implemented) * @returns A promise that resolves to either a success result with the config or an error result * * @example * ```ts * // In an Astro page or API route * import { loadServiceListServiceInitialData } from '@wix/bookings/services'; * * // Load with query options * const serviceListResult = await loadServiceListServiceInitialData({ * appId: '13d21c63-b5ec-5912-8397-c3a5ddb27a97', * pagingMetadata: { limit: 20, offset: 0 }, * }); * * if (serviceListResult.type === 'error') { * console.error('Failed to load services:', serviceListResult.error); * return Astro.redirect('/500'); * } * * const serviceListConfig = serviceListResult.config; * * // Check if more services are available * if (serviceListConfig.options?.pagingMetadata?.hasNext) { * // More services can be loaded * } * ``` */ export declare function loadServiceListServiceInitialData(options: QueryServicesRequest): Promise;