clean up
This commit is contained in:
@@ -7,7 +7,7 @@ import { Trans } from '@kit/ui/trans';
|
|||||||
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
|
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
|
||||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
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 () => {
|
export const generateMetadata = async () => {
|
||||||
const i18n = await createI18nServerInstance();
|
const i18n = await createI18nServerInstance();
|
||||||
|
|||||||
@@ -55,12 +55,12 @@ const BookingContext = createContext<{
|
|||||||
selectedService: StoreProduct | null;
|
selectedService: StoreProduct | null;
|
||||||
locations: Location[] | null;
|
locations: Location[] | null;
|
||||||
selectedLocationId: number | null;
|
selectedLocationId: number | null;
|
||||||
selectedDate?: Date;
|
selectedDate?: Date | null;
|
||||||
isLoadingTimeSlots?: boolean;
|
isLoadingTimeSlots?: boolean;
|
||||||
setSelectedService: (selectedService?: StoreProduct) => void;
|
setSelectedService: (selectedService: StoreProduct | null) => void;
|
||||||
setSelectedLocationId: (selectedLocationId: number | null) => void;
|
setSelectedLocationId: (selectedLocationId: number | null) => void;
|
||||||
updateTimeSlots: (serviceId: number) => Promise<void>;
|
updateTimeSlots: (serviceIds: number[]) => Promise<void>;
|
||||||
setSelectedDate: (selectedDate?: Date) => void;
|
setSelectedDate: (selectedDate: Date | null) => void;
|
||||||
}>({
|
}>({
|
||||||
timeSlots: null,
|
timeSlots: null,
|
||||||
selectedService: null,
|
selectedService: null,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export const BookingProvider: React.FC<{
|
|||||||
const [selectedLocationId, setSelectedLocationId] = useState<number | null>(
|
const [selectedLocationId, setSelectedLocationId] = useState<number | null>(
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
const [selectedDate, setSelectedDate] = useState<Date>();
|
const [selectedDate, setSelectedDate] = useState<Date | null>();
|
||||||
const [timeSlots, setTimeSlots] = useState<TimeSlot[] | null>(null);
|
const [timeSlots, setTimeSlots] = useState<TimeSlot[] | null>(null);
|
||||||
const [locations, setLocations] = useState<Location[] | null>(null);
|
const [locations, setLocations] = useState<Location[] | null>(null);
|
||||||
const [isLoadingTimeSlots, setIsLoadingTimeSlots] = useState<boolean>(false);
|
const [isLoadingTimeSlots, setIsLoadingTimeSlots] = useState<boolean>(false);
|
||||||
@@ -49,9 +49,12 @@ export const BookingProvider: React.FC<{
|
|||||||
const updateTimeSlots = async (serviceIds: number[]) => {
|
const updateTimeSlots = async (serviceIds: number[]) => {
|
||||||
setIsLoadingTimeSlots(true);
|
setIsLoadingTimeSlots(true);
|
||||||
try {
|
try {
|
||||||
const response = await getAvailableTimeSlotsForDisplay(serviceIds, selectedLocationId);
|
const response = await getAvailableTimeSlotsForDisplay(
|
||||||
|
serviceIds,
|
||||||
|
selectedLocationId,
|
||||||
|
);
|
||||||
setTimeSlots(response.timeSlots);
|
setTimeSlots(response.timeSlots);
|
||||||
setLocations(response.locations)
|
setLocations(response.locations);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setTimeSlots(null);
|
setTimeSlots(null);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -2,32 +2,12 @@
|
|||||||
|
|
||||||
import { StoreProductVariant } from '@medusajs/types';
|
import { StoreProductVariant } from '@medusajs/types';
|
||||||
|
|
||||||
|
import { updateLineItem } from "@lib/data/cart";
|
||||||
import {
|
import {
|
||||||
bookAppointment,
|
createInitialReservation
|
||||||
createInitialReservation,
|
|
||||||
} from '~/lib/services/connected-online.service';
|
} from '~/lib/services/connected-online.service';
|
||||||
import { handleAddToCart } from '~/lib/services/medusaCart.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(
|
export async function createInitialReservationAction(
|
||||||
selectedVariant: Pick<StoreProductVariant, 'id'>,
|
selectedVariant: Pick<StoreProductVariant, 'id'>,
|
||||||
countryCode: string,
|
countryCode: string,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import {
|
|||||||
import { getRegion } from "./regions";
|
import { getRegion } from "./regions";
|
||||||
import { sdk } from "@lib/config";
|
import { sdk } from "@lib/config";
|
||||||
import { retrieveOrder } from "./orders";
|
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.
|
* Retrieves a cart by its ID. If no ID is provided, it will use the cart ID from the cookies.
|
||||||
|
|||||||
Reference in New Issue
Block a user