medos-sdk 1.1.11 → 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.
Files changed (195) hide show
  1. package/dist/client/MedosClient.js +1 -1
  2. package/dist/components/appointment-booking/AppointmentCalender.js +10 -72
  3. package/dist/components/appointment-booking/appointment-modal-styles.d.ts +272 -0
  4. package/dist/components/appointment-booking/appointment-modal-styles.js +419 -0
  5. package/dist/components/appointment-booking/components/AppointmentConfirmationStep.d.ts +28 -0
  6. package/dist/components/appointment-booking/components/AppointmentConfirmationStep.js +107 -0
  7. package/dist/components/appointment-booking/components/AppointmentDateTimeModal.d.ts +18 -0
  8. package/dist/components/appointment-booking/components/AppointmentDateTimeModal.js +306 -0
  9. package/dist/components/appointment-booking/components/AppointmentSummaryStep.d.ts +12 -0
  10. package/dist/components/appointment-booking/components/AppointmentSummaryStep.js +194 -0
  11. package/dist/components/appointment-booking/components/BookingOptionStep.d.ts +14 -0
  12. package/dist/components/appointment-booking/components/BookingOptionStep.js +350 -0
  13. package/dist/components/appointment-booking/components/DoctorSelectModal.d.ts +14 -0
  14. package/dist/components/appointment-booking/components/DoctorSelectModal.js +213 -0
  15. package/dist/components/appointment-booking/components/PatientDetailsStep.d.ts +3 -0
  16. package/dist/components/appointment-booking/components/PatientDetailsStep.js +96 -0
  17. package/dist/components/appointment-booking/components/PatientSelectionStep.d.ts +12 -0
  18. package/dist/components/appointment-booking/components/PatientSelectionStep.js +254 -0
  19. package/dist/components/appointment-booking/components/PhoneVerificationStep.d.ts +3 -0
  20. package/dist/components/appointment-booking/components/PhoneVerificationStep.js +49 -0
  21. package/dist/components/appointment-booking/components/SuccessStep.d.ts +5 -0
  22. package/dist/components/appointment-booking/components/SuccessStep.js +9 -0
  23. package/dist/components/appointment-booking/components/index.d.ts +9 -0
  24. package/dist/components/appointment-booking/components/index.js +9 -0
  25. package/dist/components/appointment-booking/hooks/useAppointmentFlow.js +1 -0
  26. package/dist/components/appointment-booking/index.d.ts +2 -4
  27. package/dist/components/appointment-booking/index.js +2 -2
  28. package/dist/components/appointment-booking/types.d.ts +4 -0
  29. package/dist/components/constants/constant.d.ts +2 -0
  30. package/dist/components/constants/constant.js +15 -0
  31. package/dist/components/constants/index.d.ts +3 -0
  32. package/dist/components/constants/index.js +24 -0
  33. package/dist/components/constants/options.d.ts +13 -0
  34. package/dist/components/constants/options.js +35 -0
  35. package/dist/components/constants/validation.d.ts +6 -0
  36. package/dist/components/constants/validation.js +16 -0
  37. package/dist/components/enquiry-form/EnquiryForm.d.ts +7 -0
  38. package/dist/components/enquiry-form/EnquiryForm.js +238 -0
  39. package/dist/components/enquiry-form/components/ContactInformationStep.d.ts +13 -0
  40. package/dist/components/enquiry-form/components/ContactInformationStep.js +21 -0
  41. package/dist/components/enquiry-form/components/ContactPreferenceStep.d.ts +9 -0
  42. package/dist/components/enquiry-form/components/ContactPreferenceStep.js +20 -0
  43. package/dist/components/enquiry-form/components/InquiryDetailsStep.d.ts +10 -0
  44. package/dist/components/enquiry-form/components/InquiryDetailsStep.js +20 -0
  45. package/dist/components/enquiry-form/components/index.d.ts +3 -0
  46. package/dist/components/enquiry-form/components/index.js +3 -0
  47. package/dist/components/enquiry-form/index.d.ts +2 -0
  48. package/dist/components/enquiry-form/index.js +2 -0
  49. package/dist/components/index.d.ts +7 -0
  50. package/dist/components/index.js +7 -0
  51. package/dist/components/shared/icons/Check.d.ts +6 -0
  52. package/dist/components/shared/icons/Check.js +2 -0
  53. package/dist/components/shared/icons/ChevronDownIcon.d.ts +4 -0
  54. package/dist/components/shared/icons/ChevronDownIcon.js +2 -0
  55. package/dist/components/shared/icons/ChevronLeft.d.ts +3 -0
  56. package/dist/components/shared/icons/ChevronLeft.js +3 -0
  57. package/dist/components/shared/icons/ChevronRight.d.ts +3 -0
  58. package/dist/components/shared/icons/ChevronRight.js +3 -0
  59. package/dist/components/shared/icons/CloseIcon.d.ts +9 -0
  60. package/dist/components/shared/icons/CloseIcon.js +5 -0
  61. package/dist/components/shared/icons/ConfirmationCheck.d.ts +1 -0
  62. package/dist/components/shared/icons/ConfirmationCheck.js +9 -0
  63. package/dist/components/shared/icons/ConsultationType.d.ts +1 -0
  64. package/dist/components/shared/icons/ConsultationType.js +2 -0
  65. package/dist/components/shared/icons/Date&TimeIcon.d.ts +1 -0
  66. package/dist/components/shared/icons/Date&TimeIcon.js +2 -0
  67. package/dist/components/shared/icons/MapIcon.d.ts +1 -0
  68. package/dist/components/shared/icons/MapIcon.js +2 -0
  69. package/dist/components/shared/icons/MedosLogo.d.ts +3 -0
  70. package/dist/components/shared/icons/MedosLogo.js +3 -0
  71. package/dist/components/shared/icons/PaymentMethodIcon.d.ts +1 -0
  72. package/dist/components/shared/icons/PaymentMethodIcon.js +2 -0
  73. package/dist/components/shared/icons/SuccessIcon.d.ts +8 -0
  74. package/dist/components/shared/icons/SuccessIcon.js +14 -0
  75. package/dist/components/shared/icons/UserIcon.d.ts +1 -0
  76. package/dist/components/shared/icons/UserIcon.js +2 -0
  77. package/dist/components/shared/icons/index.d.ts +13 -0
  78. package/dist/components/shared/icons/index.js +13 -0
  79. package/dist/components/shared/index.d.ts +2 -0
  80. package/dist/components/shared/index.js +2 -0
  81. package/dist/components/shared/ui/Calendar.d.ts +5 -0
  82. package/dist/components/shared/ui/Calendar.js +167 -0
  83. package/dist/components/shared/ui/SelectDropdown.d.ts +41 -0
  84. package/dist/components/shared/ui/SelectDropdown.js +301 -0
  85. package/dist/components/shared/ui/index.d.ts +2 -0
  86. package/dist/components/shared/ui/index.js +2 -0
  87. package/dist/components/styles/appointment.d.ts +4 -0
  88. package/dist/components/styles/appointment.js +220 -0
  89. package/dist/components/styles/enquiry.d.ts +2 -0
  90. package/dist/components/styles/enquiry.js +3 -0
  91. package/dist/components/styles/index.d.ts +2 -0
  92. package/dist/components/styles/index.js +2 -0
  93. package/dist/components/styles/shared.d.ts +3 -0
  94. package/dist/components/styles/shared.js +78 -0
  95. package/dist/components/styles.d.ts +1 -6
  96. package/dist/components/styles.js +1 -298
  97. package/dist/components/theme-styles.js +18 -0
  98. package/dist/components/types/appointment.d.ts +42 -0
  99. package/dist/components/types/appointment.js +1 -0
  100. package/dist/components/types/common.d.ts +24 -0
  101. package/dist/components/types/common.js +1 -0
  102. package/dist/components/types/enquiry.d.ts +59 -0
  103. package/dist/components/types/enquiry.js +1 -0
  104. package/dist/components/types/index.d.ts +4 -0
  105. package/dist/components/types/index.js +4 -0
  106. package/dist/components/types.d.ts +1 -54
  107. package/dist/components/types.js +1 -38
  108. package/dist/components/utils/date.d.ts +4 -0
  109. package/dist/components/utils/date.js +65 -0
  110. package/dist/components/utils/formatting.d.ts +4 -0
  111. package/dist/components/utils/formatting.js +9 -0
  112. package/dist/components/utils/index.d.ts +3 -0
  113. package/dist/components/utils/index.js +3 -0
  114. package/dist/components/utils/validation.d.ts +4 -0
  115. package/dist/components/utils/validation.js +37 -0
  116. package/dist/components/utils.d.ts +1 -8
  117. package/dist/components/utils.js +1 -74
  118. package/dist/components/validation.d.ts +1 -4
  119. package/dist/components/validation.js +1 -48
  120. package/dist/constants/index.d.ts +1 -1
  121. package/dist/constants/index.js +1 -1
  122. package/dist/index.d.ts +2 -2
  123. package/dist/index.js +1 -1
  124. package/dist/react/index.d.ts +3 -3
  125. package/dist/react/index.js +1 -1
  126. package/dist/services/AppointmentService.js +26 -9
  127. package/dist/services/AuthService.js +1 -1
  128. package/dist/vanilla/AppointmentCalendarWidget.d.ts +8 -0
  129. package/dist/vanilla/AppointmentCalendarWidget.js +598 -20
  130. package/dist/vanilla/components/appointment-booking/appointment-modal-styles.d.ts +272 -0
  131. package/dist/vanilla/components/appointment-booking/components/AppointmentConfirmationStep.d.ts +28 -0
  132. package/dist/vanilla/components/appointment-booking/components/AppointmentDateTimeModal.d.ts +18 -0
  133. package/dist/vanilla/components/appointment-booking/components/AppointmentSummaryStep.d.ts +12 -0
  134. package/dist/vanilla/components/appointment-booking/components/BookingOptionStep.d.ts +14 -0
  135. package/dist/vanilla/components/appointment-booking/components/DoctorSelectModal.d.ts +14 -0
  136. package/dist/vanilla/components/appointment-booking/components/PatientDetailsStep.d.ts +3 -0
  137. package/dist/vanilla/components/appointment-booking/components/PatientSelectionStep.d.ts +12 -0
  138. package/dist/vanilla/components/appointment-booking/components/PhoneVerificationStep.d.ts +3 -0
  139. package/dist/vanilla/components/appointment-booking/components/SuccessStep.d.ts +5 -0
  140. package/dist/vanilla/components/appointment-booking/components/index.d.ts +9 -0
  141. package/dist/vanilla/components/appointment-booking/index.d.ts +2 -4
  142. package/dist/vanilla/components/appointment-booking/types.d.ts +4 -0
  143. package/dist/vanilla/components/constants/constant.d.ts +2 -0
  144. package/dist/vanilla/components/constants/index.d.ts +3 -0
  145. package/dist/vanilla/components/constants/options.d.ts +13 -0
  146. package/dist/vanilla/components/constants/validation.d.ts +6 -0
  147. package/dist/vanilla/components/enquiry-form/EnquiryForm.d.ts +7 -0
  148. package/dist/vanilla/components/enquiry-form/components/ContactInformationStep.d.ts +13 -0
  149. package/dist/vanilla/components/enquiry-form/components/ContactPreferenceStep.d.ts +9 -0
  150. package/dist/vanilla/components/enquiry-form/components/InquiryDetailsStep.d.ts +10 -0
  151. package/dist/vanilla/components/enquiry-form/components/index.d.ts +3 -0
  152. package/dist/vanilla/components/enquiry-form/index.d.ts +2 -0
  153. package/dist/vanilla/components/index.d.ts +7 -3
  154. package/dist/vanilla/components/shared/icons/Check.d.ts +6 -0
  155. package/dist/vanilla/components/shared/icons/ChevronDownIcon.d.ts +4 -0
  156. package/dist/vanilla/components/shared/icons/ChevronLeft.d.ts +3 -0
  157. package/dist/vanilla/components/shared/icons/ChevronRight.d.ts +3 -0
  158. package/dist/vanilla/components/shared/icons/CloseIcon.d.ts +9 -0
  159. package/dist/vanilla/components/shared/icons/ConfirmationCheck.d.ts +1 -0
  160. package/dist/vanilla/components/shared/icons/ConsultationType.d.ts +1 -0
  161. package/dist/vanilla/components/shared/icons/Date&TimeIcon.d.ts +1 -0
  162. package/dist/vanilla/components/shared/icons/MapIcon.d.ts +1 -0
  163. package/dist/vanilla/components/shared/icons/MedosLogo.d.ts +3 -0
  164. package/dist/vanilla/components/shared/icons/PaymentMethodIcon.d.ts +1 -0
  165. package/dist/vanilla/components/shared/icons/SuccessIcon.d.ts +8 -0
  166. package/dist/vanilla/components/shared/icons/UserIcon.d.ts +1 -0
  167. package/dist/vanilla/components/shared/icons/index.d.ts +13 -0
  168. package/dist/vanilla/components/shared/index.d.ts +2 -0
  169. package/dist/vanilla/components/shared/ui/Calendar.d.ts +5 -0
  170. package/dist/vanilla/components/shared/ui/SelectDropdown.d.ts +41 -0
  171. package/dist/vanilla/components/shared/ui/index.d.ts +2 -0
  172. package/dist/vanilla/components/styles/appointment.d.ts +4 -0
  173. package/dist/vanilla/components/styles/enquiry.d.ts +2 -0
  174. package/dist/vanilla/components/styles/index.d.ts +2 -0
  175. package/dist/vanilla/components/styles/shared.d.ts +3 -0
  176. package/dist/vanilla/components/styles.d.ts +1 -6
  177. package/dist/vanilla/components/types/appointment.d.ts +42 -0
  178. package/dist/vanilla/components/types/common.d.ts +24 -0
  179. package/dist/vanilla/components/types/enquiry.d.ts +59 -0
  180. package/dist/vanilla/components/types/index.d.ts +4 -0
  181. package/dist/vanilla/components/types.d.ts +1 -54
  182. package/dist/vanilla/components/utils/date.d.ts +4 -0
  183. package/dist/vanilla/components/utils/formatting.d.ts +4 -0
  184. package/dist/vanilla/components/utils/index.d.ts +3 -0
  185. package/dist/vanilla/components/utils/validation.d.ts +4 -0
  186. package/dist/vanilla/components/utils.d.ts +1 -8
  187. package/dist/vanilla/components/validation.d.ts +1 -4
  188. package/dist/vanilla/constants/index.d.ts +1 -1
  189. package/dist/vanilla/enquiry-widget.js +3277 -56
  190. package/dist/vanilla/index.d.ts +2 -2
  191. package/dist/vanilla/react/index.d.ts +3 -3
  192. package/dist/vanilla/vanilla/AppointmentCalendarWidget.d.ts +8 -0
  193. package/dist/vanilla/widget.css +214 -0
  194. package/dist/vanilla/widget.js +4047 -187
  195. package/package.json +2 -2
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ export interface BaseComponentProps {
3
+ className?: string;
4
+ style?: React.CSSProperties;
5
+ }
6
+ export interface BaseFormProps {
7
+ onSubmit?: () => void | Promise<void>;
8
+ onBack?: () => void;
9
+ onNext?: () => void;
10
+ isLoading?: boolean;
11
+ error?: string | null;
12
+ }
13
+ export interface BaseStepProps extends BaseFormProps {
14
+ onContinue?: () => void;
15
+ onReset?: () => void;
16
+ }
17
+ export interface SelectOption {
18
+ value: string;
19
+ label: string;
20
+ }
21
+ export interface CountryCodeOption {
22
+ code: string;
23
+ label: string;
24
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,59 @@
1
+ export interface EnquiryFormState {
2
+ step: number;
3
+ loading: boolean;
4
+ error: string | null;
5
+ patientName: string;
6
+ patientEmail: string;
7
+ countryCode: string;
8
+ patientPhone: string;
9
+ inquirySubject: string;
10
+ inquiryMessage: string;
11
+ preferredContactMethod: "PHONE" | "EMAIL" | "BOTH";
12
+ submitted: boolean;
13
+ }
14
+ export interface EnquirySubmission {
15
+ patientName: string;
16
+ patientEmail: string;
17
+ countryCode: string;
18
+ patientPhone: string;
19
+ inquirySubject: string;
20
+ inquiryMessage: string;
21
+ preferredContactMethod: "PHONE" | "EMAIL" | "BOTH";
22
+ }
23
+ export interface EnquiryFormProps {
24
+ onSuccess?: (enquiry: EnquirySubmission) => void;
25
+ onError?: (error: Error) => void;
26
+ }
27
+ export type EnquiryFormAction = {
28
+ type: "SET_STEP";
29
+ payload: number;
30
+ } | {
31
+ type: "SET_LOADING";
32
+ payload: boolean;
33
+ } | {
34
+ type: "SET_ERROR";
35
+ payload: string | null;
36
+ } | {
37
+ type: "SET_PATIENT_NAME";
38
+ payload: string;
39
+ } | {
40
+ type: "SET_PATIENT_EMAIL";
41
+ payload: string;
42
+ } | {
43
+ type: "SET_COUNTRY_CODE";
44
+ payload: string;
45
+ } | {
46
+ type: "SET_PATIENT_PHONE";
47
+ payload: string;
48
+ } | {
49
+ type: "SET_INQUIRY_SUBJECT";
50
+ payload: string;
51
+ } | {
52
+ type: "SET_INQUIRY_MESSAGE";
53
+ payload: string;
54
+ } | {
55
+ type: "SET_PREFERRED_CONTACT_METHOD";
56
+ payload: "PHONE" | "EMAIL" | "BOTH";
57
+ } | {
58
+ type: "RESET_FORM";
59
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from "./common";
2
+ export * from "./appointment";
3
+ export * from "./enquiry";
4
+ export * from "../constants";
@@ -0,0 +1,4 @@
1
+ export * from "./common";
2
+ export * from "./appointment";
3
+ export * from "./enquiry";
4
+ export * from "../constants";
@@ -1,54 +1 @@
1
- export type { AppointmentState, AppointmentAction, Patient, SessionPack, AvailablePackage, BookingOptionType, } from "./appointment-booking/types";
2
- export { INITIAL_STATE } from "./appointment-booking/types";
3
- export type PhoneVerificationStepProps = {
4
- state: any;
5
- dispatch: React.Dispatch<any>;
6
- onSendOtp: () => Promise<void>;
7
- onVerifyOtp: () => Promise<void>;
8
- onBack: () => void;
9
- onContinue: () => void;
10
- };
11
- export type PatientDetailsStepProps = {
12
- state: any;
13
- dispatch: React.Dispatch<any>;
14
- onBack: () => void;
15
- onSubmit: () => Promise<void>;
16
- isFirstStep?: boolean;
17
- };
18
- export type SuccessStepProps = {
19
- onReset: () => void;
20
- };
21
- export type PhoneInputSectionProps = {
22
- countryCode: string;
23
- patientPhone: string;
24
- onCountryCodeChange: (code: string) => void;
25
- onPhoneChange: (phone: string) => void;
26
- };
27
- export type OtpInputSectionProps = {
28
- countryCode: string;
29
- patientPhone: string;
30
- otpCode: string;
31
- otpVerified: boolean;
32
- onOtpChange: (code: string) => void;
33
- };
34
- export type PatientInfoSectionProps = {
35
- state: any;
36
- dispatch: React.Dispatch<any>;
37
- };
38
- export type AddressInfoSectionProps = {
39
- state: any;
40
- dispatch: React.Dispatch<any>;
41
- };
42
- export declare const COUNTRY_CODES: {
43
- code: string;
44
- label: string;
45
- }[];
46
- export declare const GENDER_OPTIONS: {
47
- value: string;
48
- label: string;
49
- }[];
50
- export declare const BLOOD_GROUP_OPTIONS: {
51
- value: string;
52
- label: string;
53
- }[];
54
- export declare const mapBloodGroupToApi: (uiBloodGroup: string) => string;
1
+ export * from "./types";
@@ -1,38 +1 @@
1
- export { INITIAL_STATE } from "./appointment-booking/types";
2
- export const COUNTRY_CODES = [
3
- { code: "+91", label: "🇮🇳 +91" },
4
- { code: "+1", label: "🇺🇸 +1" },
5
- { code: "+44", label: "🇬🇧 +44" },
6
- { code: "+86", label: "🇨🇳 +86" },
7
- { code: "+81", label: "🇯🇵 +81" },
8
- ];
9
- export const GENDER_OPTIONS = [
10
- { value: "MALE", label: "Male" },
11
- { value: "FEMALE", label: "Female" },
12
- { value: "OTHER", label: "Other" },
13
- ];
14
- export const BLOOD_GROUP_OPTIONS = [
15
- { value: "A+", label: "A+" },
16
- { value: "A-", label: "A-" },
17
- { value: "B+", label: "B+" },
18
- { value: "B-", label: "B-" },
19
- { value: "AB+", label: "AB+" },
20
- { value: "AB-", label: "AB-" },
21
- { value: "O+", label: "O+" },
22
- { value: "O-", label: "O-" },
23
- { value: "UNKNOWN", label: "Unknown" },
24
- ];
25
- export const mapBloodGroupToApi = (uiBloodGroup) => {
26
- const bloodGroupMap = {
27
- "A+": "A_POSITIVE",
28
- "A-": "A_NEGATIVE",
29
- "B+": "B_POSITIVE",
30
- "B-": "B_NEGATIVE",
31
- "AB+": "AB_POSITIVE",
32
- "AB-": "AB_NEGATIVE",
33
- "O+": "O_POSITIVE",
34
- "O-": "O_NEGATIVE",
35
- UNKNOWN: "UNKNOWN",
36
- };
37
- return bloodGroupMap[uiBloodGroup] || "UNKNOWN";
38
- };
1
+ export * from "./types";
@@ -0,0 +1,4 @@
1
+ export declare const formatDateToISO: (date: Date) => string;
2
+ export declare const formatDate: (date: Date | string | null) => string;
3
+ export declare const formatTime: (timeStr: string | number) => string;
4
+ export declare const calculateDuration: (startTime?: string | number, endTime?: string | number, defaultDuration?: number) => number;
@@ -0,0 +1,65 @@
1
+ export const formatDateToISO = (date) => {
2
+ const year = String(date.getFullYear()).padStart(4, "0");
3
+ const month = String(date.getMonth() + 1).padStart(2, "0");
4
+ const day = String(date.getDate()).padStart(2, "0");
5
+ return `${year}-${month}-${day}`;
6
+ };
7
+ export const formatDate = (date) => {
8
+ if (!date)
9
+ return "Not selected";
10
+ try {
11
+ const dateObj = typeof date === "string" ? new Date(date) : date;
12
+ return dateObj.toLocaleDateString("en-US", {
13
+ weekday: "long",
14
+ year: "numeric",
15
+ month: "long",
16
+ day: "numeric",
17
+ });
18
+ }
19
+ catch {
20
+ return String(date);
21
+ }
22
+ };
23
+ export const formatTime = (timeStr) => {
24
+ try {
25
+ if (typeof timeStr === "number" || !Number.isNaN(Number(timeStr))) {
26
+ const time = new Date(Number(timeStr));
27
+ return time.toLocaleTimeString("en-US", {
28
+ hour: "numeric",
29
+ minute: "2-digit",
30
+ hour12: true,
31
+ });
32
+ }
33
+ if (timeStr.includes(":") && timeStr.length <= 5) {
34
+ const time = new Date(`2000-01-01T${timeStr}`);
35
+ return time.toLocaleTimeString("en-US", {
36
+ hour: "numeric",
37
+ minute: "2-digit",
38
+ hour12: true,
39
+ });
40
+ }
41
+ const time = new Date(timeStr);
42
+ return time.toLocaleTimeString("en-US", {
43
+ hour: "numeric",
44
+ minute: "2-digit",
45
+ hour12: true,
46
+ });
47
+ }
48
+ catch {
49
+ return String(timeStr);
50
+ }
51
+ };
52
+ export const calculateDuration = (startTime, endTime, defaultDuration = 60) => {
53
+ if (!startTime || !endTime)
54
+ return defaultDuration;
55
+ try {
56
+ const start = new Date(startTime);
57
+ const end = new Date(endTime);
58
+ const diffMs = end.getTime() - start.getTime();
59
+ const diffMinutes = Math.round(diffMs / (1000 * 60));
60
+ return diffMinutes > 0 ? diffMinutes : defaultDuration;
61
+ }
62
+ catch {
63
+ return defaultDuration;
64
+ }
65
+ };
@@ -0,0 +1,4 @@
1
+ export declare const parsePatientName: (fullName: string) => {
2
+ firstName: string;
3
+ lastName: string;
4
+ };
@@ -0,0 +1,9 @@
1
+ export const parsePatientName = (fullName) => {
2
+ const nameParts = fullName.trim().split(/\s+/);
3
+ const firstName = nameParts[0] || "Patient";
4
+ const lastName = nameParts.slice(1).join(" ") || "";
5
+ return {
6
+ firstName,
7
+ lastName,
8
+ };
9
+ };
@@ -0,0 +1,3 @@
1
+ export { formatDateToISO, formatDate, formatTime, calculateDuration, } from "./date";
2
+ export { validatePhoneNumber, validateCountryCode, validateBloodGroup, validateDateOfBirth, } from "./validation";
3
+ export { parsePatientName } from "./formatting";
@@ -0,0 +1,3 @@
1
+ export { formatDateToISO, formatDate, formatTime, calculateDuration, } from "./date";
2
+ export { validatePhoneNumber, validateCountryCode, validateBloodGroup, validateDateOfBirth, } from "./validation";
3
+ export { parsePatientName } from "./formatting";
@@ -0,0 +1,4 @@
1
+ export declare const validatePhoneNumber: (phone: string) => boolean;
2
+ export declare const validateCountryCode: (code: string) => boolean;
3
+ export declare const validateBloodGroup: (bloodGroup: string) => boolean;
4
+ export declare const validateDateOfBirth: (dob: string) => boolean;
@@ -0,0 +1,37 @@
1
+ import { PHONE_MIN_LENGTH, PHONE_MAX_LENGTH, COUNTRY_CODE_REGEX, DATE_FORMAT_REGEX, MIN_BIRTH_YEAR, VALID_BLOOD_GROUPS, } from "../constants/validation";
2
+ export const validatePhoneNumber = (phone) => {
3
+ const cleaned = phone.replace(/\D/g, "");
4
+ return (cleaned.length >= PHONE_MIN_LENGTH && cleaned.length <= PHONE_MAX_LENGTH);
5
+ };
6
+ export const validateCountryCode = (code) => {
7
+ return COUNTRY_CODE_REGEX.test(code);
8
+ };
9
+ export const validateBloodGroup = (bloodGroup) => {
10
+ return VALID_BLOOD_GROUPS.includes(bloodGroup);
11
+ };
12
+ export const validateDateOfBirth = (dob) => {
13
+ if (!dob)
14
+ return false;
15
+ if (!DATE_FORMAT_REGEX.test(dob))
16
+ return false;
17
+ const [yearStr, monthStr, dayStr] = dob.split("-");
18
+ const year = parseInt(yearStr, 10);
19
+ const month = parseInt(monthStr, 10);
20
+ const day = parseInt(dayStr, 10);
21
+ if (month < 1 || month > 12 || day < 1 || day > 31)
22
+ return false;
23
+ const date = new Date(year, month - 1, day);
24
+ if (date.getFullYear() !== year ||
25
+ date.getMonth() !== month - 1 ||
26
+ date.getDate() !== day) {
27
+ return false;
28
+ }
29
+ const today = new Date();
30
+ today.setHours(0, 0, 0, 0);
31
+ date.setHours(0, 0, 0, 0);
32
+ if (date > today)
33
+ return false;
34
+ if (year < MIN_BIRTH_YEAR)
35
+ return false;
36
+ return true;
37
+ };
@@ -1,8 +1 @@
1
- export declare const formatDateToISO: (date: Date) => string;
2
- export declare const formatDate: (date: Date | string | null) => string;
3
- export declare const formatTime: (timeStr: string | number) => string;
4
- export declare const calculateDuration: (startTime?: string | number, endTime?: string | number, defaultDuration?: number) => number;
5
- export declare const parsePatientName: (fullName: string) => {
6
- firstName: string;
7
- lastName: string;
8
- };
1
+ export * from "./utils/index";
@@ -1,74 +1 @@
1
- export const formatDateToISO = (date) => {
2
- const year = String(date.getFullYear()).padStart(4, "0");
3
- const month = String(date.getMonth() + 1).padStart(2, "0");
4
- const day = String(date.getDate()).padStart(2, "0");
5
- return `${year}-${month}-${day}`;
6
- };
7
- export const formatDate = (date) => {
8
- if (!date)
9
- return "Not selected";
10
- try {
11
- const dateObj = typeof date === "string" ? new Date(date) : date;
12
- return dateObj.toLocaleDateString("en-US", {
13
- weekday: "long",
14
- year: "numeric",
15
- month: "long",
16
- day: "numeric",
17
- });
18
- }
19
- catch {
20
- return String(date);
21
- }
22
- };
23
- export const formatTime = (timeStr) => {
24
- try {
25
- if (typeof timeStr === "number" || !Number.isNaN(Number(timeStr))) {
26
- const time = new Date(Number(timeStr));
27
- return time.toLocaleTimeString("en-US", {
28
- hour: "numeric",
29
- minute: "2-digit",
30
- hour12: true,
31
- });
32
- }
33
- if (timeStr.includes(":") && timeStr.length <= 5) {
34
- const time = new Date(`2000-01-01T${timeStr}`);
35
- return time.toLocaleTimeString("en-US", {
36
- hour: "numeric",
37
- minute: "2-digit",
38
- hour12: true,
39
- });
40
- }
41
- const time = new Date(timeStr);
42
- return time.toLocaleTimeString("en-US", {
43
- hour: "numeric",
44
- minute: "2-digit",
45
- hour12: true,
46
- });
47
- }
48
- catch {
49
- return String(timeStr);
50
- }
51
- };
52
- export const calculateDuration = (startTime, endTime, defaultDuration = 60) => {
53
- if (!startTime || !endTime)
54
- return defaultDuration;
55
- try {
56
- const start = new Date(startTime);
57
- const end = new Date(endTime);
58
- const diffMs = end.getTime() - start.getTime();
59
- const diffMinutes = Math.round(diffMs / (1000 * 60));
60
- return diffMinutes > 0 ? diffMinutes : defaultDuration;
61
- }
62
- catch {
63
- return defaultDuration;
64
- }
65
- };
66
- export const parsePatientName = (fullName) => {
67
- const nameParts = fullName.trim().split(/\s+/);
68
- const firstName = nameParts[0] || "Patient";
69
- const lastName = nameParts.slice(1).join(" ") || "";
70
- return {
71
- firstName,
72
- lastName,
73
- };
74
- };
1
+ export * from "./utils/index";
@@ -1,4 +1 @@
1
- export declare const validatePhoneNumber: (phone: string) => boolean;
2
- export declare const validateCountryCode: (code: string) => boolean;
3
- export declare const validateBloodGroup: (bloodGroup: string) => boolean;
4
- export declare const validateDateOfBirth: (dob: string) => boolean;
1
+ export * from "./utils/validation";
@@ -1,48 +1 @@
1
- export const validatePhoneNumber = (phone) => {
2
- const cleaned = phone.replace(/\D/g, "");
3
- return cleaned.length >= 7 && cleaned.length <= 15;
4
- };
5
- export const validateCountryCode = (code) => {
6
- return /^\+[1-9]\d{0,3}$/.test(code);
7
- };
8
- export const validateBloodGroup = (bloodGroup) => {
9
- const validBloodGroups = [
10
- "A+",
11
- "A-",
12
- "B+",
13
- "B-",
14
- "AB+",
15
- "AB-",
16
- "O+",
17
- "O-",
18
- "UNKNOWN",
19
- ];
20
- return validBloodGroups.includes(bloodGroup);
21
- };
22
- export const validateDateOfBirth = (dob) => {
23
- if (!dob)
24
- return false;
25
- const dateRegex = /^\d{4}-\d{2}-\d{2}$/;
26
- if (!dateRegex.test(dob))
27
- return false;
28
- const [yearStr, monthStr, dayStr] = dob.split("-");
29
- const year = parseInt(yearStr, 10);
30
- const month = parseInt(monthStr, 10);
31
- const day = parseInt(dayStr, 10);
32
- if (month < 1 || month > 12 || day < 1 || day > 31)
33
- return false;
34
- const date = new Date(year, month - 1, day);
35
- if (date.getFullYear() !== year ||
36
- date.getMonth() !== month - 1 ||
37
- date.getDate() !== day) {
38
- return false;
39
- }
40
- const today = new Date();
41
- today.setHours(0, 0, 0, 0);
42
- date.setHours(0, 0, 0, 0);
43
- if (date > today)
44
- return false;
45
- if (year < 1900)
46
- return false;
47
- return true;
48
- };
1
+ export * from "./utils/validation";
@@ -1 +1 @@
1
- export declare const API_BASE_URL = "https://api.medos.one/v1";
1
+ export declare const API_BASE_URL = "https://api-dev.medapi.in/v1";
@@ -1 +1 @@
1
- export const API_BASE_URL = "https://api.medos.one/v1";
1
+ export const API_BASE_URL = "https://api-dev.medapi.in/v1";
package/dist/index.d.ts CHANGED
@@ -5,8 +5,8 @@ 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
7
  export { AppointmentCalender } from "./components/appointment-booking";
8
- export { EnquiryForm } from "./components/EnquiryForm";
9
- export type { EnquiryFormProps } from "./components/EnquiryForm";
8
+ export { EnquiryForm } from "./components/enquiry-form";
9
+ export type { EnquiryFormProps } from "./components/types/enquiry";
10
10
  export * from "./appointments/provider";
11
11
  export * from "./appointments/types";
12
12
  export * from "./appointment-calendar/provider";
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ 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
6
  export { AppointmentCalender } from "./components/appointment-booking";
7
- export { EnquiryForm } from "./components/EnquiryForm";
7
+ export { EnquiryForm } from "./components/enquiry-form";
8
8
  export * from "./appointments/provider";
9
9
  export * from "./appointments/types";
10
10
  export * from "./appointment-calendar/provider";
@@ -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/EnquiryForm";
8
- export type { EnquiryFormProps } from "../components/EnquiryForm";
6
+ export type { AppointmentCalenderProps } from "../components/appointment-booking/types";
7
+ export { EnquiryForm } from "../components/enquiry-form";
8
+ export type { EnquiryFormProps } from "../components/types/enquiry";
@@ -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/EnquiryForm";
5
+ export { EnquiryForm } from "../components/enquiry-form";
@@ -1,5 +1,5 @@
1
1
  import { MedosClient } from "../client/MedosClient";
2
- import { mapBloodGroupToApi } from "../components/types";
2
+ import { mapBloodGroupToApi } from "../components/constants/options";
3
3
  import { WorkspaceService } from "./WorkspaceService";
4
4
  const AppointmentService = {
5
5
  async arePackagesConfigured() {
@@ -86,9 +86,27 @@ const AppointmentService = {
86
86
  return [];
87
87
  },
88
88
  transformToUnifiedPayload(payload) {
89
- const consultationCharge = typeof payload.consultationCharge === "string"
90
- ? Number.parseFloat(payload.consultationCharge) || 0
91
- : payload.consultationCharge || 0;
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
+ }
92
110
  const completeAddress = [
93
111
  payload.patientAddress.addressLine1,
94
112
  payload.patientAddress.addressLine2,
@@ -107,7 +125,7 @@ const AppointmentService = {
107
125
  appointmentDate: payload.appointmentDate,
108
126
  fromDateTimeTs: payload.fromDateTimeTs,
109
127
  toDateTimeTs: payload.toDateTimeTs,
110
- bookingType: payload.bookingType || "ONE_TIME_APPOINTMENT",
128
+ bookingType,
111
129
  consultationCharge,
112
130
  paymentMode: payload.paymentMode || "CASH",
113
131
  type: payload.type || "CONSULTATION",
@@ -140,15 +158,14 @@ const AppointmentService = {
140
158
  patientId: payload.patientAddress.patientId || 0,
141
159
  },
142
160
  };
143
- if (payload.packageConfigId) {
161
+ if (bookingType === "PACKAGE_PURCHASE" ||
162
+ bookingType === "USE_ACTIVE_PACKAGE") {
144
163
  unifiedPayload.packageConfigId = payload.packageConfigId;
164
+ unifiedPayload.packageAmount = payload.packageAmount;
145
165
  }
146
166
  if (payload.patientPackageId) {
147
167
  unifiedPayload.patientPackageId = payload.patientPackageId;
148
168
  }
149
- if (payload.packageAmount) {
150
- unifiedPayload.packageAmount = payload.packageAmount;
151
- }
152
169
  return unifiedPayload;
153
170
  },
154
171
  async createLegacyAppointment(payload) {
@@ -1,5 +1,5 @@
1
1
  import axios from "axios";
2
- import { API_BASE_URL } from "../constants";
2
+ import { API_BASE_URL } from "../components";
3
3
  let sessionToken = null;
4
4
  const AuthService = {
5
5
  async init(apiKey) {
@@ -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;
@@ -41,6 +42,7 @@ declare class AppointmentCalendarWidget {
41
42
  private renderLocationDoctorStep;
42
43
  private renderNewAppointmentStep;
43
44
  private renderPatientSelectionStep;
45
+ private renderPatientDetailsStep;
44
46
  private renderAppointmentSummaryStep;
45
47
  private renderSuccessStep;
46
48
  private formatDate;
@@ -49,6 +51,12 @@ declare class AppointmentCalendarWidget {
49
51
  private attachEventListeners;
50
52
  private getPlaceholderPatients;
51
53
  private escapeHtml;
54
+ private isValidDateOfBirth;
55
+ private isValidBloodGroup;
56
+ private safeMapBloodGroupToApi;
57
+ private safeFormatDateOfBirth;
58
+ private getDateOfBirthErrorMessage;
59
+ private displayFieldValidationError;
52
60
  destroy(): void;
53
61
  }
54
62
  export declare function initAppointmentCalendar(options: AppointmentCalendarWidgetOptions): AppointmentCalendarWidget;