add cart functionality for tto services

This commit is contained in:
Helena
2025-09-19 16:23:19 +03:00
parent 3c272505d6
commit b59148630a
26 changed files with 921 additions and 221 deletions

View File

@@ -4,7 +4,6 @@ import { StoreProduct } from '@medusajs/types';
import { getAvailableTimeSlotsForDisplay } from '~/lib/services/connected-online.service';
import { ServiceCategory } from '../service-categories';
import { BookingContext, Location, TimeSlot } from './booking.context';
export function useBooking() {
@@ -19,10 +18,11 @@ export function useBooking() {
export const BookingProvider: React.FC<{
children: React.ReactElement;
category: ServiceCategory;
}> = ({ children, category }) => {
category: { products: StoreProduct[] };
service?: StoreProduct;
}> = ({ children, category, service }) => {
const [selectedService, setSelectedService] = useState<StoreProduct | null>(
category.products[0] || null,
(service ?? category?.products?.[0]) || null,
);
const [selectedLocationId, setSelectedLocationId] = useState<number | null>(
null,
@@ -32,6 +32,7 @@ export const BookingProvider: React.FC<{
const [locations, setLocations] = useState<Location[] | null>(null);
const [isLoadingTimeSlots, setIsLoadingTimeSlots] = useState(false);
useEffect(() => {
let metadataServiceIds = [];
try {