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
|
@@ -21,6 +21,7 @@ declare class MedosClient {
|
|
|
21
21
|
static fetchAppointments(workspaceId: number, addressId: number, doctorId: number, appointmentDate: string): Promise<any[]>;
|
|
22
22
|
static sendPhoneVerificationOtp(payload: SendPhoneVerificationOtpPayload): Promise<any>;
|
|
23
23
|
static verifyPhoneVerificationOtp(payload: VerifyPhoneVerificationOtpPayload): Promise<any>;
|
|
24
|
+
static fetchTheme(): Promise<string | undefined>;
|
|
24
25
|
static get client(): AxiosInstance;
|
|
25
26
|
static ensureInitialized(): Promise<AxiosInstance>;
|
|
26
27
|
static isInitialized(): boolean;
|
|
@@ -2,7 +2,7 @@ import axios from "axios";
|
|
|
2
2
|
import { AuthService } from "../services/AuthService";
|
|
3
3
|
import { AppointmentService, } from "../services/AppointmentService";
|
|
4
4
|
import { PatientService, } from "../services/PatientService";
|
|
5
|
-
import { API_BASE_URL } from "../constants";
|
|
5
|
+
import { API_BASE_URL } from "../components/constants";
|
|
6
6
|
class MedosClient {
|
|
7
7
|
static async init({ apiKey }) {
|
|
8
8
|
if (!apiKey) {
|
|
@@ -134,6 +134,13 @@ class MedosClient {
|
|
|
134
134
|
}
|
|
135
135
|
return PatientService.verifyPhoneVerificationOtp(payload);
|
|
136
136
|
}
|
|
137
|
+
static async fetchTheme() {
|
|
138
|
+
if (!this.instance) {
|
|
139
|
+
throw new Error("MedosClient not initialized. Call MedosClient.init() first.");
|
|
140
|
+
}
|
|
141
|
+
const { WorkspaceService } = await import("../services/WorkspaceService");
|
|
142
|
+
return WorkspaceService.fetchTheme();
|
|
143
|
+
}
|
|
137
144
|
static get client() {
|
|
138
145
|
if (!this.instance && !this.initPromise) {
|
|
139
146
|
throw new Error("MedosClient not initialized. Call MedosClient.init() or MedosClient.initWithSession() first.");
|
|
@@ -90,38 +90,39 @@ const appointmentReducer = (state, action) => {
|
|
|
90
90
|
};
|
|
91
91
|
export const AppointmentCalender = ({ onError, }) => {
|
|
92
92
|
const [state, dispatch] = useReducer(appointmentReducer, INITIAL_STATE);
|
|
93
|
-
const
|
|
93
|
+
const handleDateChange = useCallback(async (date) => {
|
|
94
|
+
dispatch({ type: "SET_SELECTED_DATE", payload: date });
|
|
94
95
|
if (!state.workspaceId ||
|
|
95
96
|
!state.selectedAddress ||
|
|
96
97
|
!state.selectedDoctor) {
|
|
97
98
|
dispatch({ type: "SET_SLOTS", payload: [] });
|
|
98
99
|
return;
|
|
99
100
|
}
|
|
101
|
+
let mounted = true;
|
|
100
102
|
dispatch({ type: "SET_LOADING", payload: true });
|
|
101
103
|
dispatch({ type: "SET_ERROR", payload: null });
|
|
102
104
|
try {
|
|
103
105
|
const dateStr = formatDateToISO(date);
|
|
104
106
|
const fetchedSlots = await AppointmentService.fetchSlots(state.workspaceId, state.selectedAddress, state.selectedDoctor, dateStr);
|
|
105
|
-
|
|
107
|
+
if (mounted) {
|
|
108
|
+
dispatch({ type: "SET_SLOTS", payload: fetchedSlots || [] });
|
|
109
|
+
}
|
|
106
110
|
}
|
|
107
111
|
catch (e) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
112
|
+
if (mounted) {
|
|
113
|
+
const msg = e.message || "Failed to load slots";
|
|
114
|
+
dispatch({ type: "SET_ERROR", payload: msg });
|
|
115
|
+
onError?.(e);
|
|
116
|
+
}
|
|
111
117
|
}
|
|
112
118
|
finally {
|
|
113
|
-
|
|
119
|
+
if (mounted)
|
|
120
|
+
dispatch({ type: "SET_LOADING", payload: false });
|
|
114
121
|
}
|
|
122
|
+
return () => {
|
|
123
|
+
mounted = false;
|
|
124
|
+
};
|
|
115
125
|
}, [state.workspaceId, state.selectedAddress, state.selectedDoctor, onError]);
|
|
116
|
-
const handleDateChange = useCallback(async (date) => {
|
|
117
|
-
dispatch({ type: "SET_SELECTED_DATE", payload: date });
|
|
118
|
-
fetchSlotsForDate(date);
|
|
119
|
-
}, [fetchSlotsForDate]);
|
|
120
|
-
useEffect(() => {
|
|
121
|
-
if (state.step === 1 && state.selectedDate) {
|
|
122
|
-
fetchSlotsForDate(state.selectedDate);
|
|
123
|
-
}
|
|
124
|
-
}, [state.step, state.selectedDate, fetchSlotsForDate]);
|
|
125
126
|
useEffect(() => {
|
|
126
127
|
let mounted = true;
|
|
127
128
|
(async () => {
|
|
@@ -148,8 +149,6 @@ export const AppointmentCalender = ({ onError, }) => {
|
|
|
148
149
|
payload: address.doctors[0].id,
|
|
149
150
|
});
|
|
150
151
|
dispatch({ type: "SET_STEP", payload: 1 });
|
|
151
|
-
const today = new Date();
|
|
152
|
-
dispatch({ type: "SET_SELECTED_DATE", payload: today });
|
|
153
152
|
}
|
|
154
153
|
}
|
|
155
154
|
}
|
|
@@ -175,7 +174,7 @@ export const AppointmentCalender = ({ onError, }) => {
|
|
|
175
174
|
return () => {
|
|
176
175
|
mounted = false;
|
|
177
176
|
};
|
|
178
|
-
}, []);
|
|
177
|
+
}, [onError]);
|
|
179
178
|
const goBack = useCallback(() => {
|
|
180
179
|
if (state.step === 3) {
|
|
181
180
|
dispatch({ type: "SET_OTP_SENT", payload: false });
|
|
@@ -234,7 +233,7 @@ export const AppointmentCalender = ({ onError, }) => {
|
|
|
234
233
|
finally {
|
|
235
234
|
dispatch({ type: "SET_OTP_SENDING", payload: false });
|
|
236
235
|
}
|
|
237
|
-
}, [state.countryCode, state.patientPhone]);
|
|
236
|
+
}, [state.countryCode, state.patientPhone, onError]);
|
|
238
237
|
const verifyOtp = useCallback(async () => {
|
|
239
238
|
dispatch({ type: "SET_ERROR", payload: null });
|
|
240
239
|
if (!state.countryCode || !state.patientPhone || !state.otpCode) {
|
|
@@ -269,7 +268,7 @@ export const AppointmentCalender = ({ onError, }) => {
|
|
|
269
268
|
finally {
|
|
270
269
|
dispatch({ type: "SET_OTP_VERIFYING", payload: false });
|
|
271
270
|
}
|
|
272
|
-
}, [state.countryCode, state.patientPhone, state.otpCode]);
|
|
271
|
+
}, [state.countryCode, state.patientPhone, state.otpCode, onError]);
|
|
273
272
|
const submitAppointment = useCallback(async () => {
|
|
274
273
|
dispatch({ type: "SET_ERROR", payload: null });
|
|
275
274
|
if (!state.selectedDoctor ||
|
|
@@ -362,8 +361,6 @@ export const AppointmentCalender = ({ onError, }) => {
|
|
|
362
361
|
dispatch({ type: "SET_SELECTED_ADDRESS", payload: addrId });
|
|
363
362
|
dispatch({ type: "SET_SELECTED_DOCTOR", payload: docId });
|
|
364
363
|
dispatch({ type: "SET_STEP", payload: 1 });
|
|
365
|
-
const today = new Date();
|
|
366
|
-
dispatch({ type: "SET_SELECTED_DATE", payload: today });
|
|
367
364
|
}, []);
|
|
368
365
|
const handleDateTimeModalContinue = useCallback((mode, date, slot, charge) => {
|
|
369
366
|
dispatch({ type: "SET_CONSULTATION_MODE", payload: mode });
|
|
@@ -22,6 +22,7 @@ interface AppointmentConfirmationStepProps {
|
|
|
22
22
|
selectedDoctor?: Doctor | null;
|
|
23
23
|
selectedAddress?: AddressItem | null;
|
|
24
24
|
onClose: () => void;
|
|
25
|
+
onGoBackToSlots?: () => void;
|
|
25
26
|
}
|
|
26
27
|
declare const AppointmentConfirmationStep: React.FC<AppointmentConfirmationStepProps>;
|
|
27
28
|
export default AppointmentConfirmationStep;
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useTheme } from "../react/hooks/useTheme";
|
|
3
3
|
import { SuccessIcon } from "./Icons/SuccessIcon";
|
|
4
|
-
|
|
4
|
+
import { CloseIcon } from "./Icons/CloseIcon";
|
|
5
|
+
import { formatDate, formatTime, calculateDuration } from "./utils";
|
|
6
|
+
const AppointmentConfirmationStep = ({ appointment, patient, selectedDoctor, selectedAddress, onClose, onGoBackToSlots, }) => {
|
|
5
7
|
const theme = useTheme();
|
|
6
|
-
const
|
|
8
|
+
const getDuration = () => {
|
|
7
9
|
if (appointment.duration)
|
|
8
10
|
return appointment.duration;
|
|
9
11
|
if (appointment.fromTime && appointment.toTime) {
|
|
10
|
-
|
|
11
|
-
const end = new Date(`2000-01-01T${appointment.toTime}`);
|
|
12
|
-
const diffMs = end.getTime() - start.getTime();
|
|
13
|
-
const diffMinutes = Math.round(diffMs / (1000 * 60));
|
|
14
|
-
return diffMinutes;
|
|
12
|
+
return calculateDuration(`2000-01-01T${appointment.fromTime}`, `2000-01-01T${appointment.toTime}`);
|
|
15
13
|
}
|
|
16
14
|
return 60;
|
|
17
15
|
};
|
|
@@ -27,34 +25,7 @@ const AppointmentConfirmationStep = ({ appointment, patient, selectedDoctor, sel
|
|
|
27
25
|
].filter(Boolean);
|
|
28
26
|
return parts.join(" ") || "Patient";
|
|
29
27
|
};
|
|
30
|
-
const
|
|
31
|
-
try {
|
|
32
|
-
const date = new Date(dateStr);
|
|
33
|
-
return date.toLocaleDateString("en-US", {
|
|
34
|
-
weekday: "long",
|
|
35
|
-
year: "numeric",
|
|
36
|
-
month: "long",
|
|
37
|
-
day: "numeric",
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
return dateStr;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const formatTime = (timeStr) => {
|
|
45
|
-
try {
|
|
46
|
-
const time = new Date(`2000-01-01T${timeStr}`);
|
|
47
|
-
return time.toLocaleTimeString("en-US", {
|
|
48
|
-
hour: "numeric",
|
|
49
|
-
minute: "2-digit",
|
|
50
|
-
hour12: true,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
return timeStr;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
const duration = calculateDuration();
|
|
28
|
+
const duration = getDuration();
|
|
58
29
|
const patientName = getPatientName();
|
|
59
30
|
return (_jsxs("div", { style: {
|
|
60
31
|
display: "flex",
|
|
@@ -63,14 +34,35 @@ const AppointmentConfirmationStep = ({ appointment, patient, selectedDoctor, sel
|
|
|
63
34
|
fontFamily: theme.typography.fontFamily,
|
|
64
35
|
background: theme.colors.background,
|
|
65
36
|
minHeight: "500px",
|
|
66
|
-
|
|
37
|
+
position: "relative",
|
|
38
|
+
}, children: [_jsxs("div", { style: {
|
|
39
|
+
display: "flex",
|
|
40
|
+
justifyContent: "space-between",
|
|
41
|
+
alignItems: "center",
|
|
67
42
|
padding: "20px 24px",
|
|
68
|
-
fontSize: 24,
|
|
69
|
-
fontWeight: "bold",
|
|
70
|
-
color: theme.colors.primary,
|
|
71
43
|
borderBottom: `2px solid ${theme.colors.border}`,
|
|
72
44
|
background: theme.colors.surface,
|
|
73
|
-
}, children:
|
|
45
|
+
}, children: [_jsx("h2", { style: {
|
|
46
|
+
fontSize: 24,
|
|
47
|
+
fontWeight: "bold",
|
|
48
|
+
color: theme.colors.text,
|
|
49
|
+
margin: 0,
|
|
50
|
+
}, children: "Appointment Confirmed" }), _jsx("button", { onClick: onGoBackToSlots || onClose, style: {
|
|
51
|
+
background: "none",
|
|
52
|
+
border: "none",
|
|
53
|
+
cursor: "pointer",
|
|
54
|
+
padding: "8px",
|
|
55
|
+
borderRadius: "6px",
|
|
56
|
+
display: "flex",
|
|
57
|
+
alignItems: "center",
|
|
58
|
+
justifyContent: "center",
|
|
59
|
+
transition: "background-color 0.2s ease",
|
|
60
|
+
backgroundColor: "transparent",
|
|
61
|
+
}, onMouseEnter: (e) => {
|
|
62
|
+
e.currentTarget.style.backgroundColor = theme.colors.border;
|
|
63
|
+
}, onMouseLeave: (e) => {
|
|
64
|
+
e.currentTarget.style.backgroundColor = "transparent";
|
|
65
|
+
}, title: "Close and select new slot", children: _jsx(CloseIcon, { size: 16, color: theme.colors.text }) })] }), _jsxs("div", { style: {
|
|
74
66
|
flex: 1,
|
|
75
67
|
display: "flex",
|
|
76
68
|
flexDirection: "column",
|
|
@@ -81,7 +73,7 @@ const AppointmentConfirmationStep = ({ appointment, patient, selectedDoctor, sel
|
|
|
81
73
|
borderTop: "none",
|
|
82
74
|
background: theme.colors.surface,
|
|
83
75
|
textAlign: "center",
|
|
84
|
-
}, children: [_jsx("
|
|
76
|
+
}, children: [_jsx("h3", { style: {
|
|
85
77
|
fontSize: 20,
|
|
86
78
|
fontWeight: "600",
|
|
87
79
|
color: theme.colors.success,
|
|
@@ -90,7 +82,7 @@ const AppointmentConfirmationStep = ({ appointment, patient, selectedDoctor, sel
|
|
|
90
82
|
width: "100%",
|
|
91
83
|
maxWidth: 500,
|
|
92
84
|
marginBottom: 32,
|
|
93
|
-
}, children: [_jsx("
|
|
85
|
+
}, children: [_jsx("h4", { style: {
|
|
94
86
|
fontSize: 18,
|
|
95
87
|
fontWeight: "600",
|
|
96
88
|
color: theme.colors.success,
|
|
@@ -12,6 +12,7 @@ type AppointmentModalProps = {
|
|
|
12
12
|
onCancel: () => void;
|
|
13
13
|
onContinue: (mode: AppointmentMode, date: Date, slot: Slot, charge: string, paymentMode: PaymentMode) => void;
|
|
14
14
|
onDateChange?: (date: Date) => void;
|
|
15
|
+
initialStep?: "consultation" | "datetime";
|
|
15
16
|
};
|
|
16
17
|
export declare const AppointmentDateTimeModal: React.FC<AppointmentModalProps>;
|
|
17
18
|
export {};
|