medos-sdk 1.1.10 → 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/MedosClient.d.ts +1 -0
- package/dist/client/MedosClient.js +8 -1
- package/dist/components/AppointmentCalender.js +19 -22
- package/dist/components/AppointmentConfirmationStep.d.ts +1 -0
- package/dist/components/AppointmentConfirmationStep.js +34 -42
- package/dist/components/AppointmentDateTimeModal.d.ts +1 -0
- package/dist/components/AppointmentDateTimeModal.js +201 -168
- package/dist/components/AppointmentSummaryStep.d.ts +12 -0
- package/dist/components/AppointmentSummaryStep.js +168 -0
- package/dist/components/BookingOptionStep.d.ts +14 -0
- package/dist/components/BookingOptionStep.js +346 -0
- package/dist/components/ContactInformationStep.js +10 -4
- package/dist/components/ContactPreferenceStep.js +10 -1
- package/dist/components/DoctorSelectModal.js +105 -59
- package/dist/components/EnquiryForm.js +81 -69
- package/dist/components/Icons/CloseIcon.d.ts +9 -0
- package/dist/components/Icons/CloseIcon.js +5 -0
- package/dist/components/InquiryDetailsStep.js +5 -1
- package/dist/components/PatientDetailsStep.js +17 -12
- package/dist/components/PatientSelectionStep.d.ts +12 -0
- package/dist/components/PatientSelectionStep.js +254 -0
- package/dist/components/PhoneVerificationStep.js +1 -1
- package/dist/components/SuccessStep.js +1 -1
- package/dist/components/appointment-booking/AppointmentCalender.js +145 -67
- package/dist/components/appointment-booking/appointment-modal-styles.d.ts +272 -0
- package/dist/components/appointment-booking/appointment-modal-styles.js +419 -0
- package/dist/components/appointment-booking/components/AppointmentConfirmationStep.d.ts +28 -0
- package/dist/components/appointment-booking/components/AppointmentConfirmationStep.js +107 -0
- package/dist/components/appointment-booking/components/AppointmentDateTimeModal.d.ts +18 -0
- package/dist/components/appointment-booking/components/AppointmentDateTimeModal.js +306 -0
- package/dist/components/appointment-booking/components/AppointmentSummaryStep.d.ts +12 -0
- package/dist/components/appointment-booking/components/AppointmentSummaryStep.js +194 -0
- package/dist/components/appointment-booking/components/BookingOptionStep.d.ts +14 -0
- package/dist/components/appointment-booking/components/BookingOptionStep.js +350 -0
- package/dist/components/appointment-booking/components/DoctorSelectModal.d.ts +14 -0
- package/dist/components/appointment-booking/components/DoctorSelectModal.js +213 -0
- package/dist/components/appointment-booking/components/PatientDetailsStep.d.ts +3 -0
- package/dist/components/appointment-booking/components/PatientDetailsStep.js +96 -0
- package/dist/components/appointment-booking/components/PatientSelectionStep.d.ts +12 -0
- package/dist/components/appointment-booking/components/PatientSelectionStep.js +254 -0
- package/dist/components/appointment-booking/components/PhoneVerificationStep.d.ts +3 -0
- package/dist/components/appointment-booking/components/PhoneVerificationStep.js +49 -0
- package/dist/components/appointment-booking/components/SuccessStep.d.ts +5 -0
- package/dist/components/appointment-booking/components/SuccessStep.js +9 -0
- package/dist/components/appointment-booking/components/index.d.ts +9 -0
- package/dist/components/appointment-booking/components/index.js +9 -0
- package/dist/components/appointment-booking/hooks/useAppointmentFlow.d.ts +0 -1
- package/dist/components/appointment-booking/hooks/useAppointmentFlow.js +111 -25
- package/dist/components/appointment-booking/hooks/useAppointmentState.js +32 -0
- package/dist/components/appointment-booking/hooks/useInitializeAddresses.js +0 -1
- package/dist/components/appointment-booking/index.d.ts +2 -4
- package/dist/components/appointment-booking/index.js +2 -2
- package/dist/components/appointment-booking/types.d.ts +167 -0
- package/dist/components/appointment-booking/types.js +16 -0
- package/dist/components/appointment-modal-styles.d.ts +259 -0
- package/dist/components/appointment-modal-styles.js +395 -0
- package/dist/components/constant.d.ts +2 -0
- package/dist/components/constant.js +15 -0
- package/dist/components/constants/constant.d.ts +2 -0
- package/dist/components/constants/constant.js +15 -0
- package/dist/components/constants/index.d.ts +3 -0
- package/dist/components/constants/index.js +24 -0
- package/dist/components/constants/options.d.ts +13 -0
- package/dist/components/constants/options.js +35 -0
- package/dist/components/constants/validation.d.ts +6 -0
- package/dist/components/constants/validation.js +16 -0
- package/dist/components/custom-calendar.js +20 -11
- package/dist/components/enquiry-form/EnquiryForm.d.ts +7 -0
- package/dist/components/enquiry-form/EnquiryForm.js +238 -0
- package/dist/components/enquiry-form/components/ContactInformationStep.d.ts +13 -0
- package/dist/components/enquiry-form/components/ContactInformationStep.js +21 -0
- package/dist/components/enquiry-form/components/ContactPreferenceStep.d.ts +9 -0
- package/dist/components/enquiry-form/components/ContactPreferenceStep.js +20 -0
- package/dist/components/enquiry-form/components/InquiryDetailsStep.d.ts +10 -0
- package/dist/components/enquiry-form/components/InquiryDetailsStep.js +20 -0
- package/dist/components/enquiry-form/components/index.d.ts +3 -0
- package/dist/components/enquiry-form/components/index.js +3 -0
- package/dist/components/enquiry-form/index.d.ts +2 -0
- package/dist/components/enquiry-form/index.js +2 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.js +7 -0
- package/dist/components/shared/icons/Check.d.ts +6 -0
- package/dist/components/shared/icons/Check.js +2 -0
- package/dist/components/shared/icons/ChevronDownIcon.d.ts +4 -0
- package/dist/components/shared/icons/ChevronDownIcon.js +2 -0
- package/dist/components/shared/icons/ChevronLeft.d.ts +3 -0
- package/dist/components/shared/icons/ChevronLeft.js +3 -0
- package/dist/components/shared/icons/ChevronRight.d.ts +3 -0
- package/dist/components/shared/icons/ChevronRight.js +3 -0
- package/dist/components/shared/icons/CloseIcon.d.ts +9 -0
- package/dist/components/shared/icons/CloseIcon.js +5 -0
- package/dist/components/shared/icons/ConfirmationCheck.d.ts +1 -0
- package/dist/components/shared/icons/ConfirmationCheck.js +9 -0
- package/dist/components/shared/icons/ConsultationType.d.ts +1 -0
- package/dist/components/shared/icons/ConsultationType.js +2 -0
- package/dist/components/shared/icons/Date&TimeIcon.d.ts +1 -0
- package/dist/components/shared/icons/Date&TimeIcon.js +2 -0
- package/dist/components/shared/icons/MapIcon.d.ts +1 -0
- package/dist/components/shared/icons/MapIcon.js +2 -0
- package/dist/components/shared/icons/MedosLogo.d.ts +3 -0
- package/dist/components/shared/icons/MedosLogo.js +3 -0
- package/dist/components/shared/icons/PaymentMethodIcon.d.ts +1 -0
- package/dist/components/shared/icons/PaymentMethodIcon.js +2 -0
- package/dist/components/shared/icons/SuccessIcon.d.ts +8 -0
- package/dist/components/shared/icons/SuccessIcon.js +14 -0
- package/dist/components/shared/icons/UserIcon.d.ts +1 -0
- package/dist/components/shared/icons/UserIcon.js +2 -0
- package/dist/components/shared/icons/index.d.ts +13 -0
- package/dist/components/shared/icons/index.js +13 -0
- package/dist/components/shared/index.d.ts +2 -0
- package/dist/components/shared/index.js +2 -0
- package/dist/components/shared/ui/Calendar.d.ts +5 -0
- package/dist/components/shared/ui/Calendar.js +167 -0
- package/dist/components/shared/ui/SelectDropdown.d.ts +41 -0
- package/dist/components/shared/ui/SelectDropdown.js +301 -0
- package/dist/components/shared/ui/index.d.ts +2 -0
- package/dist/components/shared/ui/index.js +2 -0
- package/dist/components/styles/appointment.d.ts +4 -0
- package/dist/components/styles/appointment.js +220 -0
- package/dist/components/styles/enquiry.d.ts +2 -0
- package/dist/components/styles/enquiry.js +3 -0
- package/dist/components/styles/index.d.ts +2 -0
- package/dist/components/styles/index.js +2 -0
- package/dist/components/styles/shared.d.ts +3 -0
- package/dist/components/styles/shared.js +78 -0
- package/dist/components/styles.d.ts +1 -6
- package/dist/components/styles.js +1 -257
- package/dist/components/theme-styles.d.ts +5 -4
- package/dist/components/theme-styles.js +239 -125
- package/dist/components/types/appointment.d.ts +42 -0
- package/dist/components/types/appointment.js +1 -0
- package/dist/components/types/common.d.ts +24 -0
- package/dist/components/types/common.js +1 -0
- package/dist/components/types/enquiry.d.ts +59 -0
- package/dist/components/types/enquiry.js +1 -0
- package/dist/components/types/index.d.ts +4 -0
- package/dist/components/types/index.js +4 -0
- package/dist/components/types.d.ts +1 -52
- package/dist/components/types.js +1 -23
- package/dist/components/utils/date.d.ts +4 -0
- package/dist/components/utils/date.js +65 -0
- package/dist/components/utils/formatting.d.ts +4 -0
- package/dist/components/utils/formatting.js +9 -0
- package/dist/components/utils/index.d.ts +3 -0
- package/dist/components/utils/index.js +3 -0
- package/dist/components/utils/validation.d.ts +4 -0
- package/dist/components/utils/validation.js +37 -0
- package/dist/components/utils.d.ts +1 -5
- package/dist/components/utils.js +1 -15
- package/dist/components/validation.d.ts +1 -2
- package/dist/components/validation.js +1 -7
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.js +1 -1
- package/dist/core/theme/index.d.ts +1 -0
- package/dist/core/theme/index.js +1 -0
- package/dist/core/theme/responsive.d.ts +15 -0
- package/dist/core/theme/responsive.js +113 -0
- package/dist/core/theme/themes.js +16 -4
- package/dist/core/theme/types.d.ts +8 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -1
- package/dist/react/ThemeProvider.d.ts +2 -1
- package/dist/react/ThemeProvider.js +49 -10
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +1 -1
- package/dist/services/AppointmentService.d.ts +80 -2
- package/dist/services/AppointmentService.js +131 -5
- package/dist/services/AuthService.js +1 -1
- package/dist/services/WorkspaceService.d.ts +58 -3
- package/dist/services/WorkspaceService.js +10 -1
- package/dist/vanilla/AppointmentCalendarWidget.d.ts +17 -7
- package/dist/vanilla/AppointmentCalendarWidget.js +1401 -380
- package/dist/vanilla/EnquiryFormWidget.d.ts +1 -0
- package/dist/vanilla/EnquiryFormWidget.js +25 -43
- package/dist/vanilla/client/MedosClient.d.ts +1 -0
- package/dist/vanilla/components/AppointmentConfirmationStep.d.ts +1 -0
- package/dist/vanilla/components/AppointmentDateTimeModal.d.ts +1 -0
- package/dist/vanilla/components/AppointmentSummaryStep.d.ts +12 -0
- package/dist/vanilla/components/BookingOptionStep.d.ts +14 -0
- package/dist/vanilla/components/Icons/CloseIcon.d.ts +9 -0
- package/dist/vanilla/components/PatientSelectionStep.d.ts +12 -0
- package/dist/vanilla/components/VanillaCalendar.js +33 -18
- package/dist/vanilla/components/VanillaIcons.d.ts +5 -0
- package/dist/vanilla/components/VanillaIcons.js +92 -0
- package/dist/vanilla/components/VanillaSelect.d.ts +3 -0
- package/dist/vanilla/components/VanillaSelect.js +93 -5
- package/dist/vanilla/components/appointment-booking/appointment-modal-styles.d.ts +272 -0
- package/dist/vanilla/components/appointment-booking/components/AppointmentConfirmationStep.d.ts +28 -0
- package/dist/vanilla/components/appointment-booking/components/AppointmentDateTimeModal.d.ts +18 -0
- package/dist/vanilla/components/appointment-booking/components/AppointmentSummaryStep.d.ts +12 -0
- package/dist/vanilla/components/appointment-booking/components/BookingOptionStep.d.ts +14 -0
- package/dist/vanilla/components/appointment-booking/components/DoctorSelectModal.d.ts +14 -0
- package/dist/vanilla/components/appointment-booking/components/PatientDetailsStep.d.ts +3 -0
- package/dist/vanilla/components/appointment-booking/components/PatientSelectionStep.d.ts +12 -0
- package/dist/vanilla/components/appointment-booking/components/PhoneVerificationStep.d.ts +3 -0
- package/dist/vanilla/components/appointment-booking/components/SuccessStep.d.ts +5 -0
- package/dist/vanilla/components/appointment-booking/components/index.d.ts +9 -0
- package/dist/vanilla/components/appointment-booking/hooks/useAppointmentFlow.d.ts +0 -1
- package/dist/vanilla/components/appointment-booking/index.d.ts +2 -4
- package/dist/vanilla/components/appointment-booking/types.d.ts +167 -0
- package/dist/vanilla/components/appointment-modal-styles.d.ts +259 -0
- package/dist/vanilla/components/constant.d.ts +2 -0
- package/dist/vanilla/components/constants/constant.d.ts +2 -0
- package/dist/vanilla/components/constants/index.d.ts +3 -0
- package/dist/vanilla/components/constants/options.d.ts +13 -0
- package/dist/vanilla/components/constants/validation.d.ts +6 -0
- package/dist/vanilla/components/enquiry-form/EnquiryForm.d.ts +7 -0
- package/dist/vanilla/components/enquiry-form/components/ContactInformationStep.d.ts +13 -0
- package/dist/vanilla/components/enquiry-form/components/ContactPreferenceStep.d.ts +9 -0
- package/dist/vanilla/components/enquiry-form/components/InquiryDetailsStep.d.ts +10 -0
- package/dist/vanilla/components/enquiry-form/components/index.d.ts +3 -0
- package/dist/vanilla/components/enquiry-form/index.d.ts +2 -0
- package/dist/vanilla/components/index.d.ts +7 -3
- package/dist/vanilla/components/shared/icons/Check.d.ts +6 -0
- package/dist/vanilla/components/shared/icons/ChevronDownIcon.d.ts +4 -0
- package/dist/vanilla/components/shared/icons/ChevronLeft.d.ts +3 -0
- package/dist/vanilla/components/shared/icons/ChevronRight.d.ts +3 -0
- package/dist/vanilla/components/shared/icons/CloseIcon.d.ts +9 -0
- package/dist/vanilla/components/shared/icons/ConfirmationCheck.d.ts +1 -0
- package/dist/vanilla/components/shared/icons/ConsultationType.d.ts +1 -0
- package/dist/vanilla/components/shared/icons/Date&TimeIcon.d.ts +1 -0
- package/dist/vanilla/components/shared/icons/MapIcon.d.ts +1 -0
- package/dist/vanilla/components/shared/icons/MedosLogo.d.ts +3 -0
- package/dist/vanilla/components/shared/icons/PaymentMethodIcon.d.ts +1 -0
- package/dist/vanilla/components/shared/icons/SuccessIcon.d.ts +8 -0
- package/dist/vanilla/components/shared/icons/UserIcon.d.ts +1 -0
- package/dist/vanilla/components/shared/icons/index.d.ts +13 -0
- package/dist/vanilla/components/shared/index.d.ts +2 -0
- package/dist/vanilla/components/shared/ui/Calendar.d.ts +5 -0
- package/dist/vanilla/components/shared/ui/SelectDropdown.d.ts +41 -0
- package/dist/vanilla/components/shared/ui/index.d.ts +2 -0
- package/dist/vanilla/components/styles/appointment.d.ts +4 -0
- package/dist/vanilla/components/styles/enquiry.d.ts +2 -0
- package/dist/vanilla/components/styles/index.d.ts +2 -0
- package/dist/vanilla/components/styles/shared.d.ts +3 -0
- package/dist/vanilla/components/styles.d.ts +1 -6
- package/dist/vanilla/components/theme-styles.d.ts +5 -4
- package/dist/vanilla/components/types/appointment.d.ts +42 -0
- package/dist/vanilla/components/types/common.d.ts +24 -0
- package/dist/vanilla/components/types/enquiry.d.ts +59 -0
- package/dist/vanilla/components/types/index.d.ts +4 -0
- package/dist/vanilla/components/types.d.ts +1 -52
- package/dist/vanilla/components/utils/date.d.ts +4 -0
- package/dist/vanilla/components/utils/formatting.d.ts +4 -0
- package/dist/vanilla/components/utils/index.d.ts +3 -0
- package/dist/vanilla/components/utils/validation.d.ts +4 -0
- package/dist/vanilla/components/utils.d.ts +1 -5
- package/dist/vanilla/components/validation.d.ts +1 -2
- package/dist/vanilla/constants/index.d.ts +1 -1
- package/dist/vanilla/core/theme/index.d.ts +1 -0
- package/dist/vanilla/core/theme/responsive.d.ts +15 -0
- package/dist/vanilla/core/theme/types.d.ts +8 -0
- package/dist/vanilla/enquiry-widget.js +3632 -90
- package/dist/vanilla/index.d.ts +4 -2
- package/dist/vanilla/react/ThemeProvider.d.ts +2 -1
- package/dist/vanilla/react/index.d.ts +3 -3
- package/dist/vanilla/services/AppointmentService.d.ts +80 -2
- package/dist/vanilla/services/WorkspaceService.d.ts +58 -3
- package/dist/vanilla/vanilla/AppointmentCalendarWidget.d.ts +17 -7
- package/dist/vanilla/vanilla/EnquiryFormWidget.d.ts +1 -0
- package/dist/vanilla/vanilla/components/VanillaIcons.d.ts +5 -0
- package/dist/vanilla/vanilla/components/VanillaSelect.d.ts +3 -0
- package/dist/vanilla/widget.css +1045 -205
- package/dist/vanilla/widget.js +10365 -5737
- package/package.json +2 -2
|
@@ -2,20 +2,59 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import React, { createContext, useMemo } from "react";
|
|
3
3
|
import { defaultTheme, themes } from "../core/theme/themes";
|
|
4
4
|
import { mergeTheme, generateCssVariablesObject } from "../core/theme/utils";
|
|
5
|
+
import { MedosClient } from "../client/MedosClient";
|
|
5
6
|
const ThemeContext = createContext(undefined);
|
|
6
|
-
export function MedosThemeProvider({ children, theme, cssVariablePrefix = "medos", }) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export function MedosThemeProvider({ children, theme, cssVariablePrefix = "medos", onThemeError, }) {
|
|
8
|
+
const [apiTheme, setApiTheme] = React.useState(null);
|
|
9
|
+
React.useEffect(() => {
|
|
10
|
+
if (theme !== undefined) {
|
|
11
|
+
return;
|
|
10
12
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
let isMounted = true;
|
|
14
|
+
const fetchThemeFromApi = async () => {
|
|
15
|
+
try {
|
|
16
|
+
const fetchedTheme = await MedosClient.fetchTheme();
|
|
17
|
+
if (isMounted) {
|
|
18
|
+
if (fetchedTheme &&
|
|
19
|
+
(fetchedTheme === "default" || fetchedTheme === "modern")) {
|
|
20
|
+
setApiTheme(fetchedTheme);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
setApiTheme(null);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (isMounted) {
|
|
29
|
+
if (onThemeError) {
|
|
30
|
+
onThemeError(error);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
console.warn("Failed to fetch theme from API, using default theme:", error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
fetchThemeFromApi();
|
|
39
|
+
return () => {
|
|
40
|
+
isMounted = false;
|
|
41
|
+
};
|
|
42
|
+
}, [theme, onThemeError]);
|
|
43
|
+
const resolvedTheme = useMemo(() => {
|
|
44
|
+
if (theme !== undefined) {
|
|
45
|
+
if (typeof theme === "string") {
|
|
46
|
+
return themes[theme] || defaultTheme;
|
|
47
|
+
}
|
|
48
|
+
if ("name" in theme && "colors" in theme && "typography" in theme) {
|
|
49
|
+
return theme;
|
|
50
|
+
}
|
|
51
|
+
return mergeTheme(theme);
|
|
13
52
|
}
|
|
14
|
-
if (
|
|
15
|
-
return
|
|
53
|
+
if (apiTheme) {
|
|
54
|
+
return themes[apiTheme] || defaultTheme;
|
|
16
55
|
}
|
|
17
|
-
return
|
|
18
|
-
}, [theme]);
|
|
56
|
+
return defaultTheme;
|
|
57
|
+
}, [theme, apiTheme]);
|
|
19
58
|
const cssVars = useMemo(() => generateCssVariablesObject(resolvedTheme, cssVariablePrefix), [resolvedTheme, cssVariablePrefix]);
|
|
20
59
|
const contextValue = useMemo(() => ({
|
|
21
60
|
theme: resolvedTheme,
|
package/dist/react/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export { MedosThemeProvider } from "./ThemeProvider";
|
|
|
3
3
|
export type { MedosThemeProviderProps } from "./ThemeProvider";
|
|
4
4
|
export { useTheme, useThemeContext, useCssVar } from "./hooks/useTheme";
|
|
5
5
|
export { AppointmentCalender } from "../components/appointment-booking";
|
|
6
|
-
export type { AppointmentCalenderProps } from "../components/appointment-booking";
|
|
7
|
-
export { EnquiryForm } from "../components/
|
|
8
|
-
export type { EnquiryFormProps } from "../components/
|
|
6
|
+
export type { AppointmentCalenderProps } from "../components/appointment-booking/types";
|
|
7
|
+
export { EnquiryForm } from "../components/enquiry-form";
|
|
8
|
+
export type { EnquiryFormProps } from "../components/types/enquiry";
|
package/dist/react/index.js
CHANGED
|
@@ -2,4 +2,4 @@ export * from "../core";
|
|
|
2
2
|
export { MedosThemeProvider } from "./ThemeProvider";
|
|
3
3
|
export { useTheme, useThemeContext, useCssVar } from "./hooks/useTheme";
|
|
4
4
|
export { AppointmentCalender } from "../components/appointment-booking";
|
|
5
|
-
export { EnquiryForm } from "../components/
|
|
5
|
+
export { EnquiryForm } from "../components/enquiry-form";
|
|
@@ -11,6 +11,7 @@ export type Slot = {
|
|
|
11
11
|
[key: string]: any;
|
|
12
12
|
};
|
|
13
13
|
type PatientPayload = {
|
|
14
|
+
id?: number;
|
|
14
15
|
firstName: string;
|
|
15
16
|
lastName: string;
|
|
16
17
|
email?: string;
|
|
@@ -18,6 +19,8 @@ type PatientPayload = {
|
|
|
18
19
|
phoneNumber: string;
|
|
19
20
|
age?: number;
|
|
20
21
|
gender?: "MALE" | "FEMALE" | "OTHER";
|
|
22
|
+
dob?: string;
|
|
23
|
+
bloodGroup?: string;
|
|
21
24
|
};
|
|
22
25
|
type PatientAddressPayload = {
|
|
23
26
|
addressLine1: string;
|
|
@@ -26,6 +29,11 @@ type PatientAddressPayload = {
|
|
|
26
29
|
country: string;
|
|
27
30
|
zipcode: string;
|
|
28
31
|
landmark?: string;
|
|
32
|
+
addressLine2?: string;
|
|
33
|
+
completeAddress?: string;
|
|
34
|
+
countryCode?: string;
|
|
35
|
+
phoneNumber?: string;
|
|
36
|
+
patientId?: number;
|
|
29
37
|
};
|
|
30
38
|
type BookAppointmentPayload = {
|
|
31
39
|
workspaceId?: string | number;
|
|
@@ -35,13 +43,79 @@ type BookAppointmentPayload = {
|
|
|
35
43
|
appointmentDate: string;
|
|
36
44
|
fromDateTimeTs: string;
|
|
37
45
|
toDateTimeTs: string;
|
|
38
|
-
consultationCharge?: string;
|
|
46
|
+
consultationCharge?: string | number;
|
|
39
47
|
type?: "CONSULTATION" | string;
|
|
40
48
|
source?: string;
|
|
49
|
+
bookingType?: "PACKAGE_PURCHASE" | "ONE_TIME_APPOINTMENT" | "USE_ACTIVE_PACKAGE";
|
|
50
|
+
paymentMode?: "CASH" | "CARD" | string;
|
|
51
|
+
packageConfigId?: number;
|
|
52
|
+
patientPackageId?: number;
|
|
53
|
+
packageAmount?: number;
|
|
41
54
|
patientPayload: PatientPayload;
|
|
42
55
|
patientAddress: PatientAddressPayload;
|
|
43
56
|
attachments?: File[];
|
|
44
57
|
};
|
|
58
|
+
export type UnifiedBookAppointmentPayload = {
|
|
59
|
+
workspaceId: number;
|
|
60
|
+
workspaceAddressId: number;
|
|
61
|
+
doctorId: number;
|
|
62
|
+
mode: "ONLINE" | "OFFLINE";
|
|
63
|
+
appointmentDate: string;
|
|
64
|
+
fromDateTimeTs: string;
|
|
65
|
+
toDateTimeTs: string;
|
|
66
|
+
bookingType: "PACKAGE_PURCHASE" | "ONE_TIME_APPOINTMENT" | "USE_ACTIVE_PACKAGE";
|
|
67
|
+
consultationCharge: number;
|
|
68
|
+
packageConfigId?: number;
|
|
69
|
+
patientPackageId?: number;
|
|
70
|
+
packageAmount?: number;
|
|
71
|
+
paymentMode: "CASH" | "CARD" | string;
|
|
72
|
+
type: "CONSULTATION" | string;
|
|
73
|
+
source: string;
|
|
74
|
+
patientPayload: {
|
|
75
|
+
id?: number;
|
|
76
|
+
firstName: string;
|
|
77
|
+
lastName: string;
|
|
78
|
+
email: string;
|
|
79
|
+
countryCode: string;
|
|
80
|
+
phoneNumber: string;
|
|
81
|
+
dob: string;
|
|
82
|
+
age: number;
|
|
83
|
+
gender: "MALE" | "FEMALE" | "OTHER";
|
|
84
|
+
bloodGroup: string;
|
|
85
|
+
};
|
|
86
|
+
patientAddress: {
|
|
87
|
+
completeAddress: string;
|
|
88
|
+
addressLine1: string;
|
|
89
|
+
addressLine2?: string;
|
|
90
|
+
city: string;
|
|
91
|
+
state: string;
|
|
92
|
+
country: string;
|
|
93
|
+
zipcode: string;
|
|
94
|
+
landmark?: string;
|
|
95
|
+
countryCode: string;
|
|
96
|
+
phoneNumber: string;
|
|
97
|
+
patientId: number;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
export type AppointmentResponse = {
|
|
101
|
+
id: number;
|
|
102
|
+
patientName: string;
|
|
103
|
+
patientEmail: string;
|
|
104
|
+
patientPhone: string;
|
|
105
|
+
doctorId: number;
|
|
106
|
+
addressId: number;
|
|
107
|
+
appointmentDate: string;
|
|
108
|
+
startTime: string;
|
|
109
|
+
endTime: string;
|
|
110
|
+
status: string;
|
|
111
|
+
consultationCharge: number;
|
|
112
|
+
paymentMode: string;
|
|
113
|
+
type: string;
|
|
114
|
+
mode: string;
|
|
115
|
+
notes?: string;
|
|
116
|
+
createdAt: string;
|
|
117
|
+
[key: string]: any;
|
|
118
|
+
};
|
|
45
119
|
type AppointmentPayload = {
|
|
46
120
|
workspaceId?: string | number;
|
|
47
121
|
workspaceAddressId: string | number;
|
|
@@ -78,8 +152,12 @@ type AddressesResponse = {
|
|
|
78
152
|
addresses: AddressItem[];
|
|
79
153
|
};
|
|
80
154
|
declare const AppointmentService: {
|
|
155
|
+
arePackagesConfigured(): Promise<boolean>;
|
|
81
156
|
getAddresses(): Promise<AddressesResponse>;
|
|
82
157
|
fetchSlots(workspaceId: number, addressId: number, doctorId: number, appointmentDate: string): Promise<Slot[]>;
|
|
83
|
-
|
|
158
|
+
transformToUnifiedPayload(payload: BookAppointmentPayload): UnifiedBookAppointmentPayload;
|
|
159
|
+
createLegacyAppointment(payload: BookAppointmentPayload): Promise<AppointmentResponse>;
|
|
160
|
+
createAppointment(payload: BookAppointmentPayload): Promise<AppointmentResponse>;
|
|
161
|
+
createUnifiedAppointment(payload: BookAppointmentPayload): Promise<AppointmentResponse>;
|
|
84
162
|
};
|
|
85
163
|
export { AppointmentService, AppointmentPayload, BookAppointmentPayload, PatientPayload, PatientAddressPayload, AddressesResponse, AddressItem, };
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { MedosClient } from "../client/MedosClient";
|
|
2
|
+
import { mapBloodGroupToApi } from "../components/constants/options";
|
|
3
|
+
import { WorkspaceService } from "./WorkspaceService";
|
|
2
4
|
const AppointmentService = {
|
|
5
|
+
async arePackagesConfigured() {
|
|
6
|
+
try {
|
|
7
|
+
const workspace = await WorkspaceService.fetchWorkspace();
|
|
8
|
+
return workspace.arePackagesConfigured === true;
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
console.warn("Failed to check package configuration, defaulting to legacy endpoint:", error);
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
},
|
|
3
15
|
async getAddresses() {
|
|
4
16
|
const client = await MedosClient.ensureInitialized();
|
|
5
17
|
const res = await client.get("/workspaces");
|
|
@@ -73,16 +85,99 @@ const AppointmentService = {
|
|
|
73
85
|
}
|
|
74
86
|
return [];
|
|
75
87
|
},
|
|
76
|
-
|
|
88
|
+
transformToUnifiedPayload(payload) {
|
|
89
|
+
const bookingType = payload.bookingType || "ONE_TIME_APPOINTMENT";
|
|
90
|
+
if (bookingType === "PACKAGE_PURCHASE" ||
|
|
91
|
+
bookingType === "USE_ACTIVE_PACKAGE") {
|
|
92
|
+
if (!payload.packageConfigId) {
|
|
93
|
+
throw new Error("packageConfigId is required when bookingType is PACKAGE_PURCHASE");
|
|
94
|
+
}
|
|
95
|
+
if (!payload.packageAmount) {
|
|
96
|
+
throw new Error("packageAmount is required when bookingType is PACKAGE_PURCHASE");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
let consultationCharge;
|
|
100
|
+
if (bookingType === "PACKAGE_PURCHASE" ||
|
|
101
|
+
bookingType === "USE_ACTIVE_PACKAGE") {
|
|
102
|
+
consultationCharge = 0;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
consultationCharge =
|
|
106
|
+
typeof payload.consultationCharge === "string"
|
|
107
|
+
? Number.parseFloat(payload.consultationCharge) || 0
|
|
108
|
+
: payload.consultationCharge || 0;
|
|
109
|
+
}
|
|
110
|
+
const completeAddress = [
|
|
111
|
+
payload.patientAddress.addressLine1,
|
|
112
|
+
payload.patientAddress.addressLine2,
|
|
113
|
+
payload.patientAddress.city,
|
|
114
|
+
payload.patientAddress.state,
|
|
115
|
+
payload.patientAddress.country,
|
|
116
|
+
payload.patientAddress.zipcode,
|
|
117
|
+
]
|
|
118
|
+
.filter(Boolean)
|
|
119
|
+
.join(", ");
|
|
120
|
+
const unifiedPayload = {
|
|
121
|
+
workspaceId: Number(payload.workspaceId || 0),
|
|
122
|
+
workspaceAddressId: Number(payload.workspaceAddressId),
|
|
123
|
+
doctorId: Number(payload.doctorId),
|
|
124
|
+
mode: (payload.mode || "OFFLINE"),
|
|
125
|
+
appointmentDate: payload.appointmentDate,
|
|
126
|
+
fromDateTimeTs: payload.fromDateTimeTs,
|
|
127
|
+
toDateTimeTs: payload.toDateTimeTs,
|
|
128
|
+
bookingType,
|
|
129
|
+
consultationCharge,
|
|
130
|
+
paymentMode: payload.paymentMode || "CASH",
|
|
131
|
+
type: payload.type || "CONSULTATION",
|
|
132
|
+
source: payload.source || "SDK_POWERED_WEBSITE",
|
|
133
|
+
patientPayload: {
|
|
134
|
+
id: payload.patientPayload.id,
|
|
135
|
+
firstName: payload.patientPayload.firstName,
|
|
136
|
+
lastName: payload.patientPayload.lastName,
|
|
137
|
+
email: payload.patientPayload.email || "",
|
|
138
|
+
countryCode: payload.patientPayload.countryCode,
|
|
139
|
+
phoneNumber: payload.patientPayload.phoneNumber,
|
|
140
|
+
dob: payload.patientPayload.dob || "",
|
|
141
|
+
age: payload.patientPayload.age || 0,
|
|
142
|
+
gender: (payload.patientPayload.gender || "OTHER"),
|
|
143
|
+
bloodGroup: payload.patientPayload.bloodGroup
|
|
144
|
+
? mapBloodGroupToApi(payload.patientPayload.bloodGroup)
|
|
145
|
+
: "UNKNOWN",
|
|
146
|
+
},
|
|
147
|
+
patientAddress: {
|
|
148
|
+
completeAddress,
|
|
149
|
+
addressLine1: payload.patientAddress.addressLine1,
|
|
150
|
+
addressLine2: payload.patientAddress.addressLine2,
|
|
151
|
+
city: payload.patientAddress.city,
|
|
152
|
+
state: payload.patientAddress.state,
|
|
153
|
+
country: payload.patientAddress.country,
|
|
154
|
+
zipcode: payload.patientAddress.zipcode,
|
|
155
|
+
landmark: payload.patientAddress.landmark,
|
|
156
|
+
countryCode: payload.patientAddress.countryCode || "",
|
|
157
|
+
phoneNumber: payload.patientAddress.phoneNumber || "",
|
|
158
|
+
patientId: payload.patientAddress.patientId || 0,
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
if (bookingType === "PACKAGE_PURCHASE" ||
|
|
162
|
+
bookingType === "USE_ACTIVE_PACKAGE") {
|
|
163
|
+
unifiedPayload.packageConfigId = payload.packageConfigId;
|
|
164
|
+
unifiedPayload.packageAmount = payload.packageAmount;
|
|
165
|
+
}
|
|
166
|
+
if (payload.patientPackageId) {
|
|
167
|
+
unifiedPayload.patientPackageId = payload.patientPackageId;
|
|
168
|
+
}
|
|
169
|
+
return unifiedPayload;
|
|
170
|
+
},
|
|
171
|
+
async createLegacyAppointment(payload) {
|
|
77
172
|
const client = await MedosClient.ensureInitialized();
|
|
78
|
-
const
|
|
173
|
+
const legacyPayload = {
|
|
79
174
|
workspaceAddressId: payload.workspaceAddressId,
|
|
80
175
|
doctorId: payload.doctorId,
|
|
81
176
|
mode: payload.mode || "OFFLINE",
|
|
82
177
|
appointmentDate: payload.appointmentDate,
|
|
83
178
|
fromDateTimeTs: payload.fromDateTimeTs,
|
|
84
179
|
toDateTimeTs: payload.toDateTimeTs,
|
|
85
|
-
consultationCharge: payload.consultationCharge
|
|
180
|
+
consultationCharge: payload.consultationCharge,
|
|
86
181
|
type: payload.type || "CONSULTATION",
|
|
87
182
|
source: payload.source || "SDK_POWERED_WEBSITE",
|
|
88
183
|
patientPayload: payload.patientPayload,
|
|
@@ -90,7 +185,7 @@ const AppointmentService = {
|
|
|
90
185
|
};
|
|
91
186
|
if (payload.attachments && payload.attachments.length > 0) {
|
|
92
187
|
const formData = new FormData();
|
|
93
|
-
const payloadString = JSON.stringify(
|
|
188
|
+
const payloadString = JSON.stringify(legacyPayload);
|
|
94
189
|
formData.append("payload", payloadString);
|
|
95
190
|
payload.attachments.forEach((file) => {
|
|
96
191
|
formData.append("attachments", file);
|
|
@@ -99,7 +194,38 @@ const AppointmentService = {
|
|
|
99
194
|
return res.data;
|
|
100
195
|
}
|
|
101
196
|
else {
|
|
102
|
-
const res = await client.post("/appointments/book-appointment",
|
|
197
|
+
const res = await client.post("/appointments/book-appointment", legacyPayload, {
|
|
198
|
+
headers: {
|
|
199
|
+
"Content-Type": "application/json",
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
return res.data;
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
async createAppointment(payload) {
|
|
206
|
+
const packagesConfigured = await this.arePackagesConfigured();
|
|
207
|
+
if (packagesConfigured) {
|
|
208
|
+
return this.createUnifiedAppointment(payload);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
return this.createLegacyAppointment(payload);
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
async createUnifiedAppointment(payload) {
|
|
215
|
+
const client = await MedosClient.ensureInitialized();
|
|
216
|
+
const unifiedPayload = this.transformToUnifiedPayload(payload);
|
|
217
|
+
if (payload.attachments && payload.attachments.length > 0) {
|
|
218
|
+
const formData = new FormData();
|
|
219
|
+
const payloadString = JSON.stringify(unifiedPayload);
|
|
220
|
+
formData.append("payload", payloadString);
|
|
221
|
+
payload.attachments.forEach((file) => {
|
|
222
|
+
formData.append("attachments", file);
|
|
223
|
+
});
|
|
224
|
+
const res = await client.post("/appointments/book-appointment-unified", formData);
|
|
225
|
+
return res.data;
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
const res = await client.post("/appointments/book-appointment-unified", unifiedPayload, {
|
|
103
229
|
headers: {
|
|
104
230
|
"Content-Type": "application/json",
|
|
105
231
|
},
|
|
@@ -1,9 +1,64 @@
|
|
|
1
|
-
|
|
1
|
+
import { ThemeName } from "../core/theme/themes";
|
|
2
|
+
interface Address {
|
|
3
|
+
id: number;
|
|
4
|
+
createdAt: string;
|
|
5
|
+
deleted: boolean;
|
|
6
|
+
createdAtEpoch: number;
|
|
7
|
+
completeAddress: string;
|
|
8
|
+
addressLine1: string;
|
|
9
|
+
addressLine2: string;
|
|
10
|
+
city: string;
|
|
11
|
+
state: string;
|
|
12
|
+
country: string;
|
|
13
|
+
zipcode: string;
|
|
14
|
+
landmark: string;
|
|
15
|
+
phoneNumber: string;
|
|
16
|
+
latitude: number;
|
|
17
|
+
longitude: number;
|
|
18
|
+
userId: number;
|
|
19
|
+
}
|
|
20
|
+
interface ConsultationType {
|
|
21
|
+
fee: number;
|
|
22
|
+
currency: string;
|
|
23
|
+
type: string;
|
|
24
|
+
}
|
|
25
|
+
interface User {
|
|
2
26
|
id: number;
|
|
3
|
-
|
|
27
|
+
createdAt: string;
|
|
28
|
+
lastUpdatedAt: string;
|
|
29
|
+
deleted: boolean;
|
|
30
|
+
createdAtEpoch: number;
|
|
31
|
+
lastUpdatedAtEpoch: number;
|
|
32
|
+
firstName: string;
|
|
33
|
+
lastName: string;
|
|
34
|
+
email: string;
|
|
35
|
+
gender: string;
|
|
36
|
+
countryCode: string;
|
|
37
|
+
phoneNumber: string;
|
|
38
|
+
platform: string;
|
|
39
|
+
isKycCompleted: boolean;
|
|
40
|
+
}
|
|
41
|
+
interface Doctor {
|
|
42
|
+
consultationTypes: ConsultationType[];
|
|
43
|
+
user: User;
|
|
44
|
+
}
|
|
45
|
+
interface AddressDoctor {
|
|
46
|
+
address: Address;
|
|
47
|
+
doctors: Doctor[];
|
|
48
|
+
doctorCount: number;
|
|
49
|
+
}
|
|
50
|
+
interface WorkspaceResponse {
|
|
51
|
+
totalDoctors: number;
|
|
52
|
+
totalAddresses: number;
|
|
53
|
+
addressDoctors: AddressDoctor[];
|
|
54
|
+
workspaceId: number;
|
|
55
|
+
theme?: ThemeName;
|
|
56
|
+
arePackagesConfigured?: boolean;
|
|
4
57
|
[key: string]: any;
|
|
5
58
|
}
|
|
6
59
|
declare const WorkspaceService: {
|
|
7
60
|
fetchWorkspace(): Promise<WorkspaceResponse>;
|
|
61
|
+
fetchTheme(): Promise<ThemeName | undefined>;
|
|
8
62
|
};
|
|
9
|
-
export { WorkspaceService
|
|
63
|
+
export { WorkspaceService };
|
|
64
|
+
export type { WorkspaceResponse, Address, ConsultationType, User, Doctor, AddressDoctor, };
|
|
@@ -4,7 +4,7 @@ const WorkspaceService = {
|
|
|
4
4
|
try {
|
|
5
5
|
const client = await MedosClient.ensureInitialized();
|
|
6
6
|
const res = await client.get("/workspaces");
|
|
7
|
-
if (!res.data || typeof res.data.
|
|
7
|
+
if (!res.data || typeof res.data.workspaceId !== "number") {
|
|
8
8
|
throw new Error("Invalid workspace response");
|
|
9
9
|
}
|
|
10
10
|
return res.data;
|
|
@@ -13,5 +13,14 @@ const WorkspaceService = {
|
|
|
13
13
|
throw new Error(`Failed to fetch workspace: ${error.message}`);
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
|
+
async fetchTheme() {
|
|
17
|
+
try {
|
|
18
|
+
const workspace = await this.fetchWorkspace();
|
|
19
|
+
return workspace.theme;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
throw new Error(`Failed to fetch workspace theme: ${error.message}`);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
16
25
|
};
|
|
17
26
|
export { WorkspaceService };
|
|
@@ -25,6 +25,7 @@ declare class AppointmentCalendarWidget {
|
|
|
25
25
|
private loadSlots;
|
|
26
26
|
private canProceedFromMergedStep;
|
|
27
27
|
private updateSubmitButtonState;
|
|
28
|
+
private updatePatientDetailsButtonState;
|
|
28
29
|
private sendOtp;
|
|
29
30
|
private verifyOtp;
|
|
30
31
|
private submitAppointment;
|
|
@@ -35,18 +36,27 @@ declare class AppointmentCalendarWidget {
|
|
|
35
36
|
private render;
|
|
36
37
|
private initializeCustomComponents;
|
|
37
38
|
private renderStep;
|
|
38
|
-
private
|
|
39
|
-
private
|
|
40
|
-
private
|
|
41
|
-
private
|
|
42
|
-
private
|
|
43
|
-
private
|
|
39
|
+
private renderPhoneVerificationStep;
|
|
40
|
+
private renderBookingOptionStep;
|
|
41
|
+
private renderPackageExplorerStep;
|
|
42
|
+
private renderLocationDoctorStep;
|
|
43
|
+
private renderNewAppointmentStep;
|
|
44
|
+
private renderPatientSelectionStep;
|
|
45
|
+
private renderPatientDetailsStep;
|
|
46
|
+
private renderAppointmentSummaryStep;
|
|
47
|
+
private renderSuccessStep;
|
|
44
48
|
private formatDate;
|
|
45
49
|
private formatTime;
|
|
46
50
|
private calculateDuration;
|
|
47
|
-
private renderStep5;
|
|
48
51
|
private attachEventListeners;
|
|
52
|
+
private getPlaceholderPatients;
|
|
49
53
|
private escapeHtml;
|
|
54
|
+
private isValidDateOfBirth;
|
|
55
|
+
private isValidBloodGroup;
|
|
56
|
+
private safeMapBloodGroupToApi;
|
|
57
|
+
private safeFormatDateOfBirth;
|
|
58
|
+
private getDateOfBirthErrorMessage;
|
|
59
|
+
private displayFieldValidationError;
|
|
50
60
|
destroy(): void;
|
|
51
61
|
}
|
|
52
62
|
export declare function initAppointmentCalendar(options: AppointmentCalendarWidgetOptions): AppointmentCalendarWidget;
|