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

@@ -1,22 +1,46 @@
'use client';
import { ServiceCategory } from '../service-categories';
import { StoreProduct } from '@medusajs/types';
import { Trans } from '@kit/ui/trans';
import { EnrichedCartItem } from '../cart/types';
import BookingCalendar from './booking-calendar';
import { BookingProvider } from './booking.provider';
import LocationSelector from './location-selector';
import ServiceSelector from './service-selector';
import TimeSlots from './time-slots';
const BookingContainer = ({ category }: { category: ServiceCategory }) => {
const BookingContainer = ({
category,
cartItem,
onComplete,
}: {
category: { products: StoreProduct[]; countryCode: string };
cartItem?: EnrichedCartItem;
onComplete?: () => void;
}) => {
const products = cartItem?.product ? [cartItem.product] : category.products;
if (!cartItem || !products?.length) {
<p>
<Trans i18nKey="booking:noProducts" />
</p>;
}
return (
<BookingProvider category={category}>
<BookingProvider category={{ products }} service={cartItem?.product}>
<div className="xs:flex-row flex max-h-full flex-col gap-6">
<div className="flex flex-col">
<ServiceSelector products={category.products} />
<ServiceSelector products={products} />
<BookingCalendar />
<LocationSelector />
</div>
<TimeSlots countryCode={category.countryCode} />
<TimeSlots
countryCode={category.countryCode}
cartItem={cartItem}
onComplete={onComplete}
/>
</div>
</BookingProvider>
);