From 4bd88f1b4eaf3aa13be542d994d22ff9238d6fe9 Mon Sep 17 00:00:00 2001 From: Helena Date: Wed, 17 Sep 2025 18:23:25 +0300 Subject: [PATCH] clean up --- .../(dashboard)/booking/[handle]/page.tsx | 2 +- .../_components/booking/booking.context.ts | 8 +++---- .../_components/booking/booking.provider.tsx | 9 ++++--- app/home/(user)/_lib/server/actions.ts | 24 ++----------------- .../medusa-storefront/src/lib/data/cart.ts | 1 - 5 files changed, 13 insertions(+), 31 deletions(-) diff --git a/app/home/(user)/(dashboard)/booking/[handle]/page.tsx b/app/home/(user)/(dashboard)/booking/[handle]/page.tsx index 3d9c29e..395b590 100644 --- a/app/home/(user)/(dashboard)/booking/[handle]/page.tsx +++ b/app/home/(user)/(dashboard)/booking/[handle]/page.tsx @@ -7,7 +7,7 @@ import { Trans } from '@kit/ui/trans'; import { createI18nServerInstance } from '~/lib/i18n/i18n.server'; import { withI18n } from '~/lib/i18n/with-i18n'; -import BookingContainer from '../../../_components/booking/booking-container'; +import BookingContainer from '~/home/(user)/_components/booking/booking-container'; export const generateMetadata = async () => { const i18n = await createI18nServerInstance(); diff --git a/app/home/(user)/_components/booking/booking.context.ts b/app/home/(user)/_components/booking/booking.context.ts index a8b47a4..ebff73d 100644 --- a/app/home/(user)/_components/booking/booking.context.ts +++ b/app/home/(user)/_components/booking/booking.context.ts @@ -55,12 +55,12 @@ const BookingContext = createContext<{ selectedService: StoreProduct | null; locations: Location[] | null; selectedLocationId: number | null; - selectedDate?: Date; + selectedDate?: Date | null; isLoadingTimeSlots?: boolean; - setSelectedService: (selectedService?: StoreProduct) => void; + setSelectedService: (selectedService: StoreProduct | null) => void; setSelectedLocationId: (selectedLocationId: number | null) => void; - updateTimeSlots: (serviceId: number) => Promise; - setSelectedDate: (selectedDate?: Date) => void; + updateTimeSlots: (serviceIds: number[]) => Promise; + setSelectedDate: (selectedDate: Date | null) => void; }>({ timeSlots: null, selectedService: null, diff --git a/app/home/(user)/_components/booking/booking.provider.tsx b/app/home/(user)/_components/booking/booking.provider.tsx index bf6e1f7..0bf823b 100644 --- a/app/home/(user)/_components/booking/booking.provider.tsx +++ b/app/home/(user)/_components/booking/booking.provider.tsx @@ -27,7 +27,7 @@ export const BookingProvider: React.FC<{ const [selectedLocationId, setSelectedLocationId] = useState( null, ); - const [selectedDate, setSelectedDate] = useState(); + const [selectedDate, setSelectedDate] = useState(); const [timeSlots, setTimeSlots] = useState(null); const [locations, setLocations] = useState(null); const [isLoadingTimeSlots, setIsLoadingTimeSlots] = useState(false); @@ -49,9 +49,12 @@ export const BookingProvider: React.FC<{ const updateTimeSlots = async (serviceIds: number[]) => { setIsLoadingTimeSlots(true); try { - const response = await getAvailableTimeSlotsForDisplay(serviceIds, selectedLocationId); + const response = await getAvailableTimeSlotsForDisplay( + serviceIds, + selectedLocationId, + ); setTimeSlots(response.timeSlots); - setLocations(response.locations) + setLocations(response.locations); } catch (error) { setTimeSlots(null); } finally { diff --git a/app/home/(user)/_lib/server/actions.ts b/app/home/(user)/_lib/server/actions.ts index 7543d34..dfb6f88 100644 --- a/app/home/(user)/_lib/server/actions.ts +++ b/app/home/(user)/_lib/server/actions.ts @@ -2,32 +2,12 @@ import { StoreProductVariant } from '@medusajs/types'; +import { updateLineItem } from "@lib/data/cart"; import { - bookAppointment, - createInitialReservation, + createInitialReservation } from '~/lib/services/connected-online.service'; import { handleAddToCart } from '~/lib/services/medusaCart.service'; -import { updateLineItem } from '../../../../../packages/features/medusa-storefront/src/lib/data'; - -export async function bookTimeAction( - serviceId: number, - clinicId: number, - appointmentUserId: number, - syncUserId: number, - startTime: Date, - comments?: string, -) { - return bookAppointment( - serviceId, - clinicId, - appointmentUserId, - syncUserId, - startTime, - comments, - ); -} - export async function createInitialReservationAction( selectedVariant: Pick, countryCode: string, diff --git a/packages/features/medusa-storefront/src/lib/data/cart.ts b/packages/features/medusa-storefront/src/lib/data/cart.ts index 5a0cd84..b56ba48 100644 --- a/packages/features/medusa-storefront/src/lib/data/cart.ts +++ b/packages/features/medusa-storefront/src/lib/data/cart.ts @@ -15,7 +15,6 @@ import { import { getRegion } from "./regions"; import { sdk } from "@lib/config"; import { retrieveOrder } from "./orders"; -import { completeTtoCart } from "../../../../../../lib/services/connected-online.service"; /** * Retrieves a cart by its ID. If no ID is provided, it will use the cart ID from the cookies.