medos-sdk 1.1.9 → 1.1.11

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.
Files changed (118) hide show
  1. package/dist/client/MedosClient.d.ts +1 -0
  2. package/dist/client/MedosClient.js +7 -0
  3. package/dist/components/AppointmentCalender.js +22 -8
  4. package/dist/components/AppointmentConfirmationStep.d.ts +4 -0
  5. package/dist/components/AppointmentConfirmationStep.js +50 -52
  6. package/dist/components/AppointmentDateTimeModal.d.ts +4 -0
  7. package/dist/components/AppointmentDateTimeModal.js +216 -165
  8. package/dist/components/AppointmentSummaryStep.d.ts +12 -0
  9. package/dist/components/AppointmentSummaryStep.js +168 -0
  10. package/dist/components/BookingOptionStep.d.ts +14 -0
  11. package/dist/components/BookingOptionStep.js +346 -0
  12. package/dist/components/ContactInformationStep.js +13 -6
  13. package/dist/components/ContactPreferenceStep.js +16 -6
  14. package/dist/components/DoctorSelectModal.d.ts +5 -0
  15. package/dist/components/DoctorSelectModal.js +169 -74
  16. package/dist/components/EnquiryForm.js +84 -72
  17. package/dist/components/Icons/CloseIcon.d.ts +9 -0
  18. package/dist/components/Icons/CloseIcon.js +5 -0
  19. package/dist/components/InquiryDetailsStep.js +11 -6
  20. package/dist/components/PatientDetailsStep.js +17 -12
  21. package/dist/components/PatientSelectionStep.d.ts +12 -0
  22. package/dist/components/PatientSelectionStep.js +254 -0
  23. package/dist/components/PhoneVerificationStep.js +1 -1
  24. package/dist/components/SuccessStep.js +1 -1
  25. package/dist/components/appointment-booking/AppointmentCalender.d.ts +5 -0
  26. package/dist/components/appointment-booking/AppointmentCalender.js +247 -0
  27. package/dist/components/appointment-booking/hooks/index.d.ts +3 -0
  28. package/dist/components/appointment-booking/hooks/index.js +3 -0
  29. package/dist/components/appointment-booking/hooks/useAppointmentFlow.d.ts +8 -0
  30. package/dist/components/appointment-booking/hooks/useAppointmentFlow.js +318 -0
  31. package/dist/components/appointment-booking/hooks/useAppointmentState.d.ts +9 -0
  32. package/dist/components/appointment-booking/hooks/useAppointmentState.js +125 -0
  33. package/dist/components/appointment-booking/hooks/useInitializeAddresses.d.ts +1 -0
  34. package/dist/components/appointment-booking/hooks/useInitializeAddresses.js +55 -0
  35. package/dist/components/appointment-booking/index.d.ts +5 -0
  36. package/dist/components/appointment-booking/index.js +3 -0
  37. package/dist/components/appointment-booking/types.d.ts +291 -0
  38. package/dist/components/appointment-booking/types.js +49 -0
  39. package/dist/components/appointment-modal-styles.d.ts +259 -0
  40. package/dist/components/appointment-modal-styles.js +395 -0
  41. package/dist/components/constant.d.ts +2 -0
  42. package/dist/components/constant.js +15 -0
  43. package/dist/components/custom-calendar.js +20 -11
  44. package/dist/components/styles.js +93 -52
  45. package/dist/components/theme-styles.d.ts +5 -4
  46. package/dist/components/theme-styles.js +221 -125
  47. package/dist/components/types.d.ts +12 -139
  48. package/dist/components/types.js +15 -32
  49. package/dist/components/uiComponents/SelectDropdown.d.ts +1 -1
  50. package/dist/components/uiComponents/SelectDropdown.js +24 -24
  51. package/dist/components/utils.d.ts +3 -0
  52. package/dist/components/utils.js +59 -0
  53. package/dist/components/validation.d.ts +2 -0
  54. package/dist/components/validation.js +41 -0
  55. package/dist/core/theme/index.d.ts +1 -0
  56. package/dist/core/theme/index.js +1 -0
  57. package/dist/core/theme/responsive.d.ts +15 -0
  58. package/dist/core/theme/responsive.js +113 -0
  59. package/dist/core/theme/themes.js +16 -4
  60. package/dist/core/theme/types.d.ts +8 -0
  61. package/dist/enquiry-form/validation.js +1 -1
  62. package/dist/index.d.ts +3 -1
  63. package/dist/index.js +2 -1
  64. package/dist/react/ThemeProvider.d.ts +2 -1
  65. package/dist/react/ThemeProvider.js +49 -10
  66. package/dist/react/index.d.ts +2 -1
  67. package/dist/react/index.js +1 -1
  68. package/dist/services/AppointmentService.d.ts +80 -2
  69. package/dist/services/AppointmentService.js +114 -5
  70. package/dist/services/WorkspaceService.d.ts +58 -3
  71. package/dist/services/WorkspaceService.js +10 -1
  72. package/dist/vanilla/AppointmentCalendarWidget.d.ts +9 -7
  73. package/dist/vanilla/AppointmentCalendarWidget.js +834 -384
  74. package/dist/vanilla/EnquiryFormWidget.d.ts +1 -0
  75. package/dist/vanilla/EnquiryFormWidget.js +25 -43
  76. package/dist/vanilla/client/MedosClient.d.ts +1 -0
  77. package/dist/vanilla/components/AppointmentConfirmationStep.d.ts +4 -0
  78. package/dist/vanilla/components/AppointmentDateTimeModal.d.ts +4 -0
  79. package/dist/vanilla/components/AppointmentSummaryStep.d.ts +12 -0
  80. package/dist/vanilla/components/BookingOptionStep.d.ts +14 -0
  81. package/dist/vanilla/components/DoctorSelectModal.d.ts +5 -0
  82. package/dist/vanilla/components/Icons/CloseIcon.d.ts +9 -0
  83. package/dist/vanilla/components/PatientSelectionStep.d.ts +12 -0
  84. package/dist/vanilla/components/VanillaCalendar.js +33 -18
  85. package/dist/vanilla/components/VanillaIcons.d.ts +5 -0
  86. package/dist/vanilla/components/VanillaIcons.js +92 -0
  87. package/dist/vanilla/components/VanillaSelect.d.ts +3 -0
  88. package/dist/vanilla/components/VanillaSelect.js +93 -5
  89. package/dist/vanilla/components/appointment-booking/AppointmentCalender.d.ts +5 -0
  90. package/dist/vanilla/components/appointment-booking/hooks/index.d.ts +3 -0
  91. package/dist/vanilla/components/appointment-booking/hooks/useAppointmentFlow.d.ts +8 -0
  92. package/dist/vanilla/components/appointment-booking/hooks/useAppointmentState.d.ts +9 -0
  93. package/dist/vanilla/components/appointment-booking/hooks/useInitializeAddresses.d.ts +1 -0
  94. package/dist/vanilla/components/appointment-booking/index.d.ts +5 -0
  95. package/dist/vanilla/components/appointment-booking/types.d.ts +291 -0
  96. package/dist/vanilla/components/appointment-modal-styles.d.ts +259 -0
  97. package/dist/vanilla/components/constant.d.ts +2 -0
  98. package/dist/vanilla/components/theme-styles.d.ts +5 -4
  99. package/dist/vanilla/components/types.d.ts +12 -139
  100. package/dist/vanilla/components/uiComponents/SelectDropdown.d.ts +1 -1
  101. package/dist/vanilla/components/utils.d.ts +3 -0
  102. package/dist/vanilla/components/validation.d.ts +2 -0
  103. package/dist/vanilla/core/theme/index.d.ts +1 -0
  104. package/dist/vanilla/core/theme/responsive.d.ts +15 -0
  105. package/dist/vanilla/core/theme/types.d.ts +8 -0
  106. package/dist/vanilla/enquiry-widget.js +374 -53
  107. package/dist/vanilla/index.d.ts +3 -1
  108. package/dist/vanilla/react/ThemeProvider.d.ts +2 -1
  109. package/dist/vanilla/react/index.d.ts +2 -1
  110. package/dist/vanilla/services/AppointmentService.d.ts +80 -2
  111. package/dist/vanilla/services/WorkspaceService.d.ts +58 -3
  112. package/dist/vanilla/vanilla/AppointmentCalendarWidget.d.ts +9 -7
  113. package/dist/vanilla/vanilla/EnquiryFormWidget.d.ts +1 -0
  114. package/dist/vanilla/vanilla/components/VanillaIcons.d.ts +5 -0
  115. package/dist/vanilla/vanilla/components/VanillaSelect.d.ts +3 -0
  116. package/dist/vanilla/widget.css +833 -207
  117. package/dist/vanilla/widget.js +6463 -5687
  118. package/package.json +1 -1
@@ -82,6 +82,12 @@ export interface ThemeTransitions {
82
82
  normal: string;
83
83
  slow: string;
84
84
  }
85
+ export interface ThemeBreakpoints {
86
+ mobile: string;
87
+ tablet: string;
88
+ desktop: string;
89
+ wide: string;
90
+ }
85
91
  export interface MedosTheme {
86
92
  name: string;
87
93
  colors: ThemeColors;
@@ -90,6 +96,7 @@ export interface MedosTheme {
90
96
  shadows: ThemeShadows;
91
97
  radii: ThemeRadii;
92
98
  transitions: ThemeTransitions;
99
+ breakpoints: ThemeBreakpoints;
93
100
  }
94
101
  export type PartialTheme = {
95
102
  name?: string;
@@ -99,6 +106,7 @@ export type PartialTheme = {
99
106
  shadows?: Partial<ThemeShadows>;
100
107
  radii?: Partial<ThemeRadii>;
101
108
  transitions?: Partial<ThemeTransitions>;
109
+ breakpoints?: Partial<ThemeBreakpoints>;
102
110
  };
103
111
  export interface ThemeConfig {
104
112
  theme?: MedosTheme | PartialTheme;
@@ -14,7 +14,7 @@ export const validateSubject = (subject) => {
14
14
  };
15
15
  export const validateMessage = (message) => {
16
16
  const trimmed = message.trim();
17
- return trimmed.length > 0 && trimmed.length <= 1000;
17
+ return trimmed.length > 0;
18
18
  };
19
19
  export const validateCountryCode = (code) => {
20
20
  return /^\+[1-9]\d{0,3}$/.test(code);
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { MedosThemeProvider } from "./react/ThemeProvider";
4
4
  export type { MedosThemeProviderProps } from "./react/ThemeProvider";
5
5
  export { defaultTheme, modernTheme } from "./core/theme/themes";
6
6
  export { useTheme, useThemeContext, useCssVar } from "./react/hooks/useTheme";
7
- export { AppointmentCalender } from "./components/AppointmentCalender";
7
+ export { AppointmentCalender } from "./components/appointment-booking";
8
8
  export { EnquiryForm } from "./components/EnquiryForm";
9
9
  export type { EnquiryFormProps } from "./components/EnquiryForm";
10
10
  export * from "./appointments/provider";
@@ -14,3 +14,5 @@ export * from "./appointment-calendar/types";
14
14
  export * from "./enquiry-form/provider";
15
15
  export * from "./enquiry-form/types";
16
16
  export { PatientService, SendPhoneVerificationOtpPayload, VerifyPhoneVerificationOtpPayload, } from "./services/PatientService";
17
+ export { WorkspaceService } from "./services/WorkspaceService";
18
+ export type { WorkspaceResponse, Address, ConsultationType, User, Doctor, AddressDoctor, } from "./services/WorkspaceService";
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ export * from "./core/theme";
3
3
  export { MedosThemeProvider } from "./react/ThemeProvider";
4
4
  export { defaultTheme, modernTheme } from "./core/theme/themes";
5
5
  export { useTheme, useThemeContext, useCssVar } from "./react/hooks/useTheme";
6
- export { AppointmentCalender } from "./components/AppointmentCalender";
6
+ export { AppointmentCalender } from "./components/appointment-booking";
7
7
  export { EnquiryForm } from "./components/EnquiryForm";
8
8
  export * from "./appointments/provider";
9
9
  export * from "./appointments/types";
@@ -12,3 +12,4 @@ export * from "./appointment-calendar/types";
12
12
  export * from "./enquiry-form/provider";
13
13
  export * from "./enquiry-form/types";
14
14
  export { PatientService, } from "./services/PatientService";
15
+ export { WorkspaceService } from "./services/WorkspaceService";
@@ -10,8 +10,9 @@ export interface MedosThemeProviderProps {
10
10
  children: React.ReactNode;
11
11
  theme?: ThemeName | MedosTheme | PartialTheme;
12
12
  cssVariablePrefix?: string;
13
+ onThemeError?: (error: Error) => void;
13
14
  }
14
- export declare function MedosThemeProvider({ children, theme, cssVariablePrefix, }: MedosThemeProviderProps): import("react/jsx-runtime").JSX.Element;
15
+ export declare function MedosThemeProvider({ children, theme, cssVariablePrefix, onThemeError, }: Readonly<MedosThemeProviderProps>): import("react/jsx-runtime").JSX.Element;
15
16
  export declare function useThemeContext(): ThemeContextValue;
16
17
  export declare function useTheme(): MedosTheme;
17
18
  export declare function useCssVar(category: string, key: string, fallback?: string): string;
@@ -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 resolvedTheme = useMemo(() => {
8
- if (!theme) {
9
- return defaultTheme;
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
- if (typeof theme === "string") {
12
- return themes[theme] || defaultTheme;
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 ("name" in theme && "colors" in theme && "typography" in theme) {
15
- return theme;
53
+ if (apiTheme) {
54
+ return themes[apiTheme] || defaultTheme;
16
55
  }
17
- return mergeTheme(theme);
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,
@@ -2,6 +2,7 @@ export * from "../core";
2
2
  export { MedosThemeProvider } from "./ThemeProvider";
3
3
  export type { MedosThemeProviderProps } from "./ThemeProvider";
4
4
  export { useTheme, useThemeContext, useCssVar } from "./hooks/useTheme";
5
- export { AppointmentCalender } from "../components/AppointmentCalender";
5
+ export { AppointmentCalender } from "../components/appointment-booking";
6
+ export type { AppointmentCalenderProps } from "../components/appointment-booking";
6
7
  export { EnquiryForm } from "../components/EnquiryForm";
7
8
  export type { EnquiryFormProps } from "../components/EnquiryForm";
@@ -1,5 +1,5 @@
1
1
  export * from "../core";
2
2
  export { MedosThemeProvider } from "./ThemeProvider";
3
3
  export { useTheme, useThemeContext, useCssVar } from "./hooks/useTheme";
4
- export { AppointmentCalender } from "../components/AppointmentCalender";
4
+ export { AppointmentCalender } from "../components/appointment-booking";
5
5
  export { EnquiryForm } from "../components/EnquiryForm";
@@ -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
- createAppointment(payload: BookAppointmentPayload): Promise<any>;
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/types";
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,82 @@ const AppointmentService = {
73
85
  }
74
86
  return [];
75
87
  },
76
- async createAppointment(payload) {
88
+ transformToUnifiedPayload(payload) {
89
+ const consultationCharge = typeof payload.consultationCharge === "string"
90
+ ? Number.parseFloat(payload.consultationCharge) || 0
91
+ : payload.consultationCharge || 0;
92
+ const completeAddress = [
93
+ payload.patientAddress.addressLine1,
94
+ payload.patientAddress.addressLine2,
95
+ payload.patientAddress.city,
96
+ payload.patientAddress.state,
97
+ payload.patientAddress.country,
98
+ payload.patientAddress.zipcode,
99
+ ]
100
+ .filter(Boolean)
101
+ .join(", ");
102
+ const unifiedPayload = {
103
+ workspaceId: Number(payload.workspaceId || 0),
104
+ workspaceAddressId: Number(payload.workspaceAddressId),
105
+ doctorId: Number(payload.doctorId),
106
+ mode: (payload.mode || "OFFLINE"),
107
+ appointmentDate: payload.appointmentDate,
108
+ fromDateTimeTs: payload.fromDateTimeTs,
109
+ toDateTimeTs: payload.toDateTimeTs,
110
+ bookingType: payload.bookingType || "ONE_TIME_APPOINTMENT",
111
+ consultationCharge,
112
+ paymentMode: payload.paymentMode || "CASH",
113
+ type: payload.type || "CONSULTATION",
114
+ source: payload.source || "SDK_POWERED_WEBSITE",
115
+ patientPayload: {
116
+ id: payload.patientPayload.id,
117
+ firstName: payload.patientPayload.firstName,
118
+ lastName: payload.patientPayload.lastName,
119
+ email: payload.patientPayload.email || "",
120
+ countryCode: payload.patientPayload.countryCode,
121
+ phoneNumber: payload.patientPayload.phoneNumber,
122
+ dob: payload.patientPayload.dob || "",
123
+ age: payload.patientPayload.age || 0,
124
+ gender: (payload.patientPayload.gender || "OTHER"),
125
+ bloodGroup: payload.patientPayload.bloodGroup
126
+ ? mapBloodGroupToApi(payload.patientPayload.bloodGroup)
127
+ : "UNKNOWN",
128
+ },
129
+ patientAddress: {
130
+ completeAddress,
131
+ addressLine1: payload.patientAddress.addressLine1,
132
+ addressLine2: payload.patientAddress.addressLine2,
133
+ city: payload.patientAddress.city,
134
+ state: payload.patientAddress.state,
135
+ country: payload.patientAddress.country,
136
+ zipcode: payload.patientAddress.zipcode,
137
+ landmark: payload.patientAddress.landmark,
138
+ countryCode: payload.patientAddress.countryCode || "",
139
+ phoneNumber: payload.patientAddress.phoneNumber || "",
140
+ patientId: payload.patientAddress.patientId || 0,
141
+ },
142
+ };
143
+ if (payload.packageConfigId) {
144
+ unifiedPayload.packageConfigId = payload.packageConfigId;
145
+ }
146
+ if (payload.patientPackageId) {
147
+ unifiedPayload.patientPackageId = payload.patientPackageId;
148
+ }
149
+ if (payload.packageAmount) {
150
+ unifiedPayload.packageAmount = payload.packageAmount;
151
+ }
152
+ return unifiedPayload;
153
+ },
154
+ async createLegacyAppointment(payload) {
77
155
  const client = await MedosClient.ensureInitialized();
78
- const appointmentData = {
156
+ const legacyPayload = {
79
157
  workspaceAddressId: payload.workspaceAddressId,
80
158
  doctorId: payload.doctorId,
81
159
  mode: payload.mode || "OFFLINE",
82
160
  appointmentDate: payload.appointmentDate,
83
161
  fromDateTimeTs: payload.fromDateTimeTs,
84
162
  toDateTimeTs: payload.toDateTimeTs,
85
- consultationCharge: payload.consultationCharge || "0",
163
+ consultationCharge: payload.consultationCharge,
86
164
  type: payload.type || "CONSULTATION",
87
165
  source: payload.source || "SDK_POWERED_WEBSITE",
88
166
  patientPayload: payload.patientPayload,
@@ -90,7 +168,7 @@ const AppointmentService = {
90
168
  };
91
169
  if (payload.attachments && payload.attachments.length > 0) {
92
170
  const formData = new FormData();
93
- const payloadString = JSON.stringify(appointmentData);
171
+ const payloadString = JSON.stringify(legacyPayload);
94
172
  formData.append("payload", payloadString);
95
173
  payload.attachments.forEach((file) => {
96
174
  formData.append("attachments", file);
@@ -99,7 +177,38 @@ const AppointmentService = {
99
177
  return res.data;
100
178
  }
101
179
  else {
102
- const res = await client.post("/appointments/book-appointment", appointmentData, {
180
+ const res = await client.post("/appointments/book-appointment", legacyPayload, {
181
+ headers: {
182
+ "Content-Type": "application/json",
183
+ },
184
+ });
185
+ return res.data;
186
+ }
187
+ },
188
+ async createAppointment(payload) {
189
+ const packagesConfigured = await this.arePackagesConfigured();
190
+ if (packagesConfigured) {
191
+ return this.createUnifiedAppointment(payload);
192
+ }
193
+ else {
194
+ return this.createLegacyAppointment(payload);
195
+ }
196
+ },
197
+ async createUnifiedAppointment(payload) {
198
+ const client = await MedosClient.ensureInitialized();
199
+ const unifiedPayload = this.transformToUnifiedPayload(payload);
200
+ if (payload.attachments && payload.attachments.length > 0) {
201
+ const formData = new FormData();
202
+ const payloadString = JSON.stringify(unifiedPayload);
203
+ formData.append("payload", payloadString);
204
+ payload.attachments.forEach((file) => {
205
+ formData.append("attachments", file);
206
+ });
207
+ const res = await client.post("/appointments/book-appointment-unified", formData);
208
+ return res.data;
209
+ }
210
+ else {
211
+ const res = await client.post("/appointments/book-appointment-unified", unifiedPayload, {
103
212
  headers: {
104
213
  "Content-Type": "application/json",
105
214
  },
@@ -1,9 +1,64 @@
1
- interface WorkspaceResponse {
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
- name?: string;
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, WorkspaceResponse };
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.id !== "number") {
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 };
@@ -35,17 +35,19 @@ declare class AppointmentCalendarWidget {
35
35
  private render;
36
36
  private initializeCustomComponents;
37
37
  private renderStep;
38
- private renderStep0;
39
- private renderStep1;
40
- private renderStep2;
41
- private renderStep3;
42
- private renderStep4;
43
- private renderSuccessIcon;
38
+ private renderPhoneVerificationStep;
39
+ private renderBookingOptionStep;
40
+ private renderPackageExplorerStep;
41
+ private renderLocationDoctorStep;
42
+ private renderNewAppointmentStep;
43
+ private renderPatientSelectionStep;
44
+ private renderAppointmentSummaryStep;
45
+ private renderSuccessStep;
44
46
  private formatDate;
45
47
  private formatTime;
46
48
  private calculateDuration;
47
- private renderStep5;
48
49
  private attachEventListeners;
50
+ private getPlaceholderPatients;
49
51
  private escapeHtml;
50
52
  destroy(): void;
51
53
  }