pih-appointment-widget 0.0.8 → 0.0.9
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/pih-appointment-widget.umd.js +50 -73
- package/dist/pih-appointment-widget.umd.min.js +1 -1
- package/dist/services/appointmentService.js +44 -58
- package/dist/services/httpService.js +69 -0
- package/package.json +1 -1
- package/src/services/appointmentService.js +49 -64
- package/src/services/httpService.js +55 -0
|
@@ -1,32 +1,39 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom')
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom'
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MyPackage = {}, global.React, global.ReactDOM
|
|
5
|
-
})(this, (function (exports, React, ReactDOM
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MyPackage = {}, global.React, global.ReactDOM));
|
|
5
|
+
})(this, (function (exports, React, ReactDOM) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
|
-
function _interopNamespace(e) {
|
|
10
|
-
if (e && e.__esModule) return e;
|
|
11
|
-
var n = Object.create(null);
|
|
12
|
-
if (e) {
|
|
13
|
-
Object.keys(e).forEach(function (k) {
|
|
14
|
-
if (k !== 'default') {
|
|
15
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () { return e[k]; }
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
n["default"] = e;
|
|
24
|
-
return Object.freeze(n);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
9
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
28
10
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
29
|
-
|
|
11
|
+
|
|
12
|
+
const getApi = async function (url) {
|
|
13
|
+
let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
14
|
+
const urlWithParams = new URL(url);
|
|
15
|
+
urlWithParams.search = new URLSearchParams(params).toString();
|
|
16
|
+
const options = {
|
|
17
|
+
method: "GET",
|
|
18
|
+
headers: {
|
|
19
|
+
"Content-Type": "application/json"
|
|
20
|
+
// "X-CLIENT-APP": header,
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return fetch(urlWithParams, options).then(response => {
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
return {
|
|
26
|
+
err: "Something went wrong!"
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return response.json();
|
|
30
|
+
}).catch(error => {
|
|
31
|
+
console.error("Fetch error:", error);
|
|
32
|
+
return {
|
|
33
|
+
err: error
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
};
|
|
30
37
|
|
|
31
38
|
// API Configuration Constants
|
|
32
39
|
// All values are hardcoded defaults
|
|
@@ -49,48 +56,9 @@
|
|
|
49
56
|
doctorId: 6694
|
|
50
57
|
};
|
|
51
58
|
|
|
52
|
-
// Request timeout (milliseconds)
|
|
53
|
-
const REQUEST_TIMEOUT = 10000;
|
|
54
|
-
|
|
55
59
|
// Join call URL (will be dynamic from auth API later)
|
|
56
60
|
const JOIN_CALL_URL = "https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/eyJhbGciOiJIUzI1NiJ9.eyJtZXRhZGF0YSI6InVzZXItcm9sZTpkb2N0b3IiLCJuYW1lIjoiRHIuIE1hZ2VkIEZhaG15IiwidmlkZW8iOnsicm9vbUpvaW4iOnRydWUsInJvb20iOiIxMzUwMDgiLCJjYW5QdWJsaXNoIjp0cnVlLCJjYW5TdWJzY3JpYmUiOnRydWUsImNhblB1Ymxpc2hEYXRhIjp0cnVlfSwiaXNzIjoiQVBJa2JTTDg5Y0hxVlhZIiwiZXhwIjoxNzcxMzQxNjYyLCJuYmYiOjAsInN1YiI6ImhpbmF2aW5tYXRoQGdtYWlsLmNvbSJ9.3iJCdselxCHZ6IPzzgG3fGrIwInSszgqLeSgo3EX5bs";
|
|
57
61
|
|
|
58
|
-
// Create axios instance factory - allows dynamic configuration for SDK usage
|
|
59
|
-
const createApiClient = baseURL => {
|
|
60
|
-
const client = axios__namespace.create({
|
|
61
|
-
baseURL,
|
|
62
|
-
headers: {
|
|
63
|
-
"Content-Type": "application/json"
|
|
64
|
-
},
|
|
65
|
-
timeout: REQUEST_TIMEOUT
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// Request interceptor to add auth token
|
|
69
|
-
client.interceptors.request.use(config => {
|
|
70
|
-
const token = localStorage.getItem("authToken");
|
|
71
|
-
if (token) {
|
|
72
|
-
config.headers.Authorization = "Bearer ".concat(token);
|
|
73
|
-
}
|
|
74
|
-
return config;
|
|
75
|
-
}, error => {
|
|
76
|
-
return Promise.reject(error);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// Response interceptor for error handling
|
|
80
|
-
client.interceptors.response.use(response => response, error => {
|
|
81
|
-
var _error$response;
|
|
82
|
-
if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 401) {
|
|
83
|
-
// Handle unauthorized access
|
|
84
|
-
console.error("Unauthorized access - redirecting to login");
|
|
85
|
-
}
|
|
86
|
-
return Promise.reject(error);
|
|
87
|
-
});
|
|
88
|
-
return client;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
// Default client for backward compatibility
|
|
92
|
-
const apiClient = createApiClient();
|
|
93
|
-
|
|
94
62
|
/**
|
|
95
63
|
* Fetch appointments by status
|
|
96
64
|
* @param {string} status - Appointment status (inprogress, completed, cancelled, upcoming)
|
|
@@ -111,19 +79,28 @@
|
|
|
111
79
|
}
|
|
112
80
|
|
|
113
81
|
// Use provided config or fall back to defaults from apiConfig.js
|
|
114
|
-
const
|
|
82
|
+
const baseURL = config.apiBaseUrl || API_BASE_URL;
|
|
115
83
|
const hospitalId = config.hospitalId || DEFAULT_PARAMS.hospitalId;
|
|
116
84
|
const doctorId = config.doctorId || DEFAULT_PARAMS.doctorId;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
85
|
+
|
|
86
|
+
// Build query params
|
|
87
|
+
const params = {
|
|
88
|
+
hospitalId,
|
|
89
|
+
doctorId,
|
|
90
|
+
fromDate,
|
|
91
|
+
toDate,
|
|
92
|
+
statuses: apiStatus
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// Build full URL
|
|
96
|
+
const url = "".concat(baseURL).concat(API_PATHS.APPOINTMENTS);
|
|
97
|
+
|
|
98
|
+
// Use httpService getApi
|
|
99
|
+
const response = await getApi(url, params, "PIH-Appointment-Widget");
|
|
100
|
+
if (response.err) {
|
|
101
|
+
throw new Error(response.err);
|
|
102
|
+
}
|
|
103
|
+
return response;
|
|
127
104
|
} catch (error) {
|
|
128
105
|
console.error("Error fetching ".concat(status, " appointments:"), error);
|
|
129
106
|
throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom"),require("axios")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","axios"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MyPackage={},e.React,e.ReactDOM,e.axios)}(this,function(e,t,n,a){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var l=o(t),r=o(n),d=i(a);const p="/appointment/V1/consultant/all-appointments",s="dMtEGhak",c=6694,u=e=>{const t=d.create({baseURL:e,headers:{"Content-Type":"application/json"},timeout:1e4});return t.interceptors.request.use(e=>{const t=localStorage.getItem("authToken");return t&&(e.headers.Authorization="Bearer ".concat(t)),e},e=>Promise.reject(e)),t.interceptors.response.use(e=>e,e=>{var t;return 401===(null===(t=e.response)||void 0===t?void 0:t.status)&&console.error("Unauthorized access - redirecting to login"),Promise.reject(e)}),t},x=u(),f=e=>{let{config:n={}}=e;const a=n.apiBaseUrl||"https://afiyaapiqa.powermindinc.com",o=n.hospitalId||s,i=n.doctorId||c,r=n.joinCallUrl||"https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/eyJhbGciOiJIUzI1NiJ9.eyJtZXRhZGF0YSI6InVzZXItcm9sZTpkb2N0b3IiLCJuYW1lIjoiRHIuIE1hZ2VkIEZhaG15IiwidmlkZW8iOnsicm9vbUpvaW4iOnRydWUsInJvb20iOiIxMzUwMDgiLCJjYW5QdWJsaXNoIjp0cnVlLCJjYW5TdWJzY3JpYmUiOnRydWUsImNhblB1Ymxpc2hEYXRhIjp0cnVlfSwiaXNzIjoiQVBJa2JTTDg5Y0hxVlhZIiwiZXhwIjoxNzcxMzQxNjYyLCJuYmYiOjAsInN1YiI6ImhpbmF2aW5tYXRoQGdtYWlsLmNvbSJ9.3iJCdselxCHZ6IPzzgG3fGrIwInSszgqLeSgo3EX5bs",d=()=>(new Date).toISOString().split("T")[0],[f,m]=t.useState("upcoming"),[g,h]=t.useState([]),[y,E]=t.useState(null),[b,F]=t.useState(!1),[w,v]=t.useState(null),[C,S]=t.useState(window.innerWidth<768),[k,z]=t.useState("today"),[D,I]=t.useState("today"),[W,M]=t.useState(!1),[j,R]=t.useState("asc"),[A,B]=t.useState(""),[N,T]=t.useState(!1),[Y,L]=t.useState(!1),[H,O]=t.useState(!1),[J,X]=t.useState({x:window.innerWidth-550,y:80}),[P,U]=t.useState({width:550,height:450}),[V,Z]=t.useState(!1),[G,q]=t.useState({x:0,y:0}),[_,Q]=t.useState(!1),[K,$]=t.useState(null),[ee,te]=t.useState({x:0,y:0,width:0,height:0}),[ne,ae]=t.useState(1),oe=g.filter(e=>{if(!A.trim())return!0;const t=A.toLowerCase(),n=(e.patientName||"").toLowerCase(),a=String(e.patientId||"").toLowerCase();return n.includes(t)||a.includes(t)}),ie=20*(ne-1),le=ie+20,re=oe.slice(ie,le),de=Math.ceil(oe.length/20),pe=oe.length,[se,ce]=t.useState(d()),[ue,xe]=t.useState(d()),[fe,me]=t.useState(),[ge,he]=t.useState(),ye=e=>(null==e?void 0:e.id)||(null==e?void 0:e._id)||(null==e?void 0:e.appointmentId)||(null==e?void 0:e.patientId)||JSON.stringify(e),Ee=e=>null!=e&&e.image?e.image:null,be=e=>e?e.charAt(0).toUpperCase():"?",Fe=e=>{if(!e)return"#4C4DDC";const t=["#4C4DDC","#1CC3CE","#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F"];return t[e.charCodeAt(0)%t.length]},we=t.useCallback(async()=>{F(!0),v(null);try{const e={apiBaseUrl:a,hospitalId:o,doctorId:i},t=await async function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};try{let o=(e||"").toUpperCase();"INPROGRESS"===o&&(o="IN_PROGRESS");const i=a.apiBaseUrl?u(a.apiBaseUrl):x,l=a.hospitalId||s,r=a.doctorId||c;return(await i.get(p,{params:{hospitalId:l,doctorId:r,fromDate:t,toDate:n,statuses:o}})).data}catch(t){throw console.error("Error fetching ".concat(e," appointments:"),t),t}}(f,se,ue,e),n=t.data||t.appointments||t||[];h(n),n.length>0?E(n[0]):E(null)}catch(e){console.error("Error fetching appointments:",e),v(e.message||"Failed to fetch appointments")}finally{F(!1)}},[f,se,ue,a,o,i]),ve=e=>{E(e)},Ce=t.useCallback(e=>{if(!H)if(V){const t=e.clientX-G.x,n=e.clientY-G.y,a=window.innerWidth-P.width,o=window.innerHeight-P.height;X({x:Math.max(0,Math.min(t,a)),y:Math.max(0,Math.min(n,o))})}else if(_){const t=e.clientX-ee.x,n=e.clientY-ee.y;let a=ee.width,o=ee.height,i=ee.posX,l=ee.posY;const r=300,d=250,p=window.innerWidth-40,s=window.innerHeight-100;if("right"===K)a=Math.min(Math.max(ee.width+t,r),p),i+a>window.innerWidth&&(a=window.innerWidth-i);else if("left"===K){const e=Math.min(Math.max(ee.width-t,r),p),n=e-ee.width;a=e,i=Math.max(0,ee.posX-n),0===i&&(a=ee.posX+ee.width)}else if("bottom"===K)o=Math.min(Math.max(ee.height+n,d),s),l+o>window.innerHeight&&(o=window.innerHeight-l);else if("top"===K){const e=Math.min(Math.max(ee.height-n,d),s),t=e-ee.height;o=e,l=Math.max(0,ee.posY-t),0===l&&(o=ee.posY+ee.height)}U({width:a,height:o}),X({x:i,y:l})}},[V,_,G,K,ee,J,P,H]),Se=()=>{Z(!1),Q(!1),$(null)},ke=(e,t)=>{t.preventDefault(),t.stopPropagation(),Q(!0),$(e),te({x:t.clientX,y:t.clientY,width:P.width,height:P.height,posX:J.x,posY:J.y})};t.useEffect(()=>{if(V||_)return window.addEventListener("mousemove",Ce),window.addEventListener("mouseup",Se),()=>{window.removeEventListener("mousemove",Ce),window.removeEventListener("mouseup",Se)}},[V,_,Ce]),t.useEffect(()=>{if(!N||H)return;const e=()=>{if(!(window.innerWidth<768)){const e=Y?350:P.width,t=Y?60:P.height,n=window.innerWidth-40,a=window.innerHeight-100,o=Math.min(e,n),i=Math.min(t,a);o===P.width&&i===P.height||U({width:o,height:i});const l=window.innerWidth-o-20,r=window.innerHeight-i-20;X(e=>({x:Math.min(e.x,l),y:Math.min(e.y,r)}))}};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[N,Y,H,P]),t.useEffect(()=>{ae(1)},[f,k,se,ue,A]),t.useEffect(()=>{we()},[we]),t.useEffect(()=>{const e=document.createElement("link");e.href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap",e.rel="stylesheet",document.head.appendChild(e);const t=document.createElement("style");t.innerHTML="\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n \n @media (max-width: 768px) {\n .appointments-grid {\n grid-template-columns: 1.5fr 1fr 0.8fr !important;\n }\n .appointments-header-grid {\n grid-template-columns: 1.5fr 1fr 0.8fr !important;\n }\n .hide-on-mobile {\n display: none !important;\n }\n }\n @media (max-width: 480px) {\n .appointments-header-grid {\n font-size: 10px !important;\n }\n .appointments-grid {\n font-size: 11px !important;\n }\n }\n ",document.head.appendChild(t);const n=()=>{S(window.innerWidth<768)};return window.addEventListener("resize",n),()=>{document.head.removeChild(e),document.head.removeChild(t),window.removeEventListener("resize",n)}},[]),t.useEffect(()=>{const e=e=>{!W||e.target.closest("button")||e.target.closest('input[type="date"]')||M(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[W]);let ze='"Nunito", serif';return l.default.createElement("div",{style:{fontFamily:ze,background:"#F5F5F7",boxSizing:"border-box",height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"}},l.default.createElement("div",{style:{background:"#FFFFFF",padding:C?"10px 12px":"12px 24px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #E5E5E5",flexWrap:"nowrap",gap:C?"8px":"0"}},l.default.createElement("div",{style:{position:"relative",width:C?"calc(100% - 90px)":"480px",maxWidth:C?"none":"480px"}},l.default.createElement("input",{type:"text",placeholder:"Search by patient name or ID",value:A,onChange:e=>B(e.target.value),style:{width:"100%",padding:C?"8px 32px 8px 10px":"8px 36px 8px 14px",border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:C?"12px":"13px",fontFamily:ze,background:"#FFFFFF",outline:"none",boxSizing:"border-box"}}),A&&l.default.createElement("button",{onClick:()=>B(""),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:"#999",fontSize:"16px"},title:"Clear search"},"✕")),l.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:C?"10px":"16px"}},l.default.createElement("div",{style:{position:"relative",cursor:"pointer"}},l.default.createElement("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#555",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},l.default.createElement("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),l.default.createElement("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})),l.default.createElement("span",{style:{position:"absolute",top:"-5px",right:"-5px",background:"#1CC3CE",color:"white",borderRadius:"50%",width:"16px",height:"16px",fontSize:"10px",fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center"}},"1")),l.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},!C&&l.default.createElement("span",{style:{fontSize:"13px",color:"#555"}},"Hello, ",l.default.createElement("strong",{style:{color:"#1a1a1a"}},"Sameera")),l.default.createElement("img",{src:"https://w7.pngwing.com/pngs/340/946/png-transparent-avatar-user-computer-icons-software-developer-avatar-child-face-heroes-thumbnail.png",alt:"User",style:{width:"32px",height:"32px",borderRadius:"50%",objectFit:"cover"}})))),l.default.createElement("div",{style:{padding:C?"12px":"16px 24px",flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}},l.default.createElement("div",{style:{marginBottom:C?"10px":"14px"}},l.default.createElement("h1",{style:{fontSize:C?"18px":"22px",fontWeight:700,color:"#1a1a1a",margin:"0 0 2px 0"}},"Tele Consultation"),l.default.createElement("p",{style:{fontSize:C?"11px":"12px",color:"#999",margin:0}},"Displaying All Tele Consultation Appointments")),l.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:C?"flex-start":"center",marginBottom:C?"10px":"14px",flexDirection:C?"column":"row",gap:C?"12px":"0"}},l.default.createElement("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",width:C?"100%":"auto"}},l.default.createElement("button",{onClick:()=>m("upcoming"),style:{background:"upcoming"===f?"#4C4DDC":"#FFFFFF",padding:C?"8px 10px":"9px 16px",border:"upcoming"===f?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:C?"10px":"13px",color:"upcoming"===f?"white":"#555555",fontWeight:600,fontFamily:ze,cursor:"pointer",flex:C?"1 1 auto":"none",minWidth:C?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Upcoming Appointments"),l.default.createElement("button",{onClick:()=>m("completed"),style:{background:"completed"===f?"#4C4DDC":"#FFFFFF",padding:C?"8px 10px":"9px 16px",border:"completed"===f?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:C?"10px":"13px",color:"completed"===f?"white":"#555555",fontWeight:600,fontFamily:ze,cursor:"pointer",flex:C?"1 1 auto":"none",minWidth:C?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Completed Appointments"),l.default.createElement("button",{onClick:()=>m("cancelled"),style:{background:"cancelled"===f?"#4C4DDC":"#FFFFFF",padding:C?"8px 10px":"9px 16px",border:"cancelled"===f?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:C?"10px":"13px",color:"cancelled"===f?"white":"#555555",fontWeight:600,fontFamily:ze,cursor:"pointer",flex:C?"1 1 auto":"none",minWidth:C?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Cancelled Appointments")),l.default.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center",width:"auto",position:"relative",justifyContent:C?"flex-start":"flex-end"}},l.default.createElement("button",{onClick:()=>{W||(me(se),he(ue),I(k)),M(!W)},style:{padding:"8px 12px",fontFamily:ze,fontWeight:600,border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:C?"11px":"13px",color:"#1a1a1a",background:"#FFFFFF",display:"flex",alignItems:"center",gap:C?"4px":"6px",cursor:"pointer",flex:"none",minWidth:C?"100px":"auto",justifyContent:"center"}},l.default.createElement("svg",{width:C?"12":"14",height:C?"12":"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},l.default.createElement("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),l.default.createElement("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),l.default.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),l.default.createElement("line",{x1:"3",y1:"10",x2:"21",y2:"10"})),l.default.createElement("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},(()=>{switch(k){case"today":default:return"Today";case"tomorrow":return"Tomorrow";case"currentWeek":return"Current Week";case"thisMonth":return"This Month";case"currentYear":return"Current Year";case"custom":return C?"Custom":"".concat(se," to ").concat(ue)}})()),l.default.createElement("svg",{width:C?"8":"10",height:C?"8":"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},l.default.createElement("polyline",{points:"6 9 12 15 18 9"}))),W&&l.default.createElement("div",{style:{position:"absolute",top:"100%",right:C?"auto":0,left:C?0:"auto",marginTop:"4px",background:"#FFFFFF",border:"1px solid #E5E5E5",borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.15)",padding:"8px",zIndex:1e3,minWidth:C?"280px":"240px",width:C?"calc(100vw - 24px)":"auto",maxWidth:C?"calc(100vw - 24px)":"280px"}},l.default.createElement("div",{style:{marginBottom:"custom"===D?"12px":"0"}},["thisMonth","today","tomorrow","currentWeek","currentYear","custom"].map(e=>l.default.createElement("button",{key:e,onClick:()=>{if(I(e),"custom"!==e){const t=(e=>{const t=new Date;let n,a;switch(e){case"today":default:n=a=d();break;case"tomorrow":const e=new Date(t);e.setDate(e.getDate()+1),n=a=e.toISOString().split("T")[0];break;case"currentWeek":const o=new Date(t),i=new Date(t),l=t.getDay(),r=0===l?-6:1-l;o.setDate(t.getDate()+r),i.setDate(o.getDate()+6),n=o.toISOString().split("T")[0],a=i.toISOString().split("T")[0];break;case"thisMonth":const p=new Date(t.getFullYear(),t.getMonth(),1),s=new Date(t.getFullYear(),t.getMonth()+1,0);n=p.toISOString().split("T")[0],a=s.toISOString().split("T")[0];break;case"currentYear":n="".concat(t.getFullYear(),"-01-01"),a="".concat(t.getFullYear(),"-12-31")}return{from:n,to:a}})(e);z(e),ce(t.from),xe(t.to),me(t.from),he(t.to),M(!1)}else me(""),he("")},style:{width:"100%",padding:"10px 12px",background:D===e?"#E8EEF4":"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:ze,cursor:"pointer",textAlign:"left",fontWeight:D===e?600:400,color:D===e?"#4C4DDC":"#1a1a1a",marginBottom:"4px",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{D!==e&&(t.target.style.background="#F5F5F5")},onMouseLeave:t=>{D!==e&&(t.target.style.background="#FFFFFF")}},l.default.createElement("span",null,{thisMonth:"This Month",today:"Today",tomorrow:"Tomorrow",currentWeek:"Current Week",currentYear:"Current Year",custom:"Custom"}[e]),D===e&&l.default.createElement("span",{style:{color:"#4C4DDC",fontSize:"16px"}},"✓")))),"custom"===D&&l.default.createElement("div",{style:{paddingTop:"8px",borderTop:"1px solid #E5E5E5"}},l.default.createElement("div",{style:{marginBottom:"8px"}},l.default.createElement("input",{type:"date",value:fe,onChange:e=>me(e.target.value),placeholder:"Start Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:ze,boxSizing:"border-box",cursor:"pointer"}})),l.default.createElement("div",{style:{marginBottom:"12px"}},l.default.createElement("input",{type:"date",value:ge,onChange:e=>he(e.target.value),placeholder:"End Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:ze,boxSizing:"border-box",cursor:"pointer"}})),l.default.createElement("div",{style:{display:"flex",gap:"8px"}},l.default.createElement("button",{onClick:()=>{I(k),me(se),he(ue),M(!1)},style:{flex:1,padding:"10px 12px",background:"#FFFFFF",color:"#4C4DDC",border:"1px solid #4C4DDC",borderRadius:"4px",fontSize:"13px",fontFamily:ze,fontWeight:600,cursor:"pointer"}},"Cancel"),l.default.createElement("button",{onClick:()=>{fe&&ge&&(z("custom"),ce(fe),xe(ge),M(!1))},style:{flex:1,padding:"10px 12px",background:"#4C4DDC",color:"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:ze,fontWeight:600,cursor:"pointer"}},"Submit")))))),l.default.createElement("div",{style:{display:"flex",flexDirection:C?"column":"row",gap:C?"12px":"14px",flex:1,minHeight:0,overflow:C?"auto":"hidden"}},l.default.createElement("div",{style:{flex:C?"none":"1 1 65%",width:C?"100%":"auto",display:"flex",flexDirection:"column",minHeight:C?"400px":"auto"}},l.default.createElement("div",{style:{background:"#FFFFFF",borderRadius:"8px",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden",display:"flex",flexDirection:"column",height:C?"auto":"100%"}},l.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:C?"12px 14px":"14px 18px",borderBottom:"1px solid #F1F1F1"}},l.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:C?"6px":"8px"}},l.default.createElement("span",{style:{fontSize:C?"14px":"15px",fontWeight:700,color:"#1a1a1a"}},"Appointments"),l.default.createElement("span",{style:{background:"#4C4DDC",color:"#fff",fontSize:C?"10px":"11px",fontWeight:600,padding:C?"2px 7px":"3px 8px",borderRadius:"12px"}},pe))),l.default.createElement("div",{className:"appointments-header-grid",style:{display:"grid",gridTemplateColumns:C?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:C?"8px":"12px",padding:C?"8px 12px":"10px 18px",background:"#F5F5F5",fontSize:C?"10px":"12px",fontWeight:600,color:"#666"}},l.default.createElement("div",null,"Patients name"),!C&&l.default.createElement("div",null,"Patient ID"),l.default.createElement("div",{onClick:()=>{const e="asc"===j?"desc":"asc";R(e);const t=[...g].sort((t,n)=>{const a=new Date(t.appointmentDate||t.date||0),o=new Date(n.appointmentDate||n.date||0);return"asc"===e?a-o:o-a});h(t),ae(1),t.length>0&&E(t[0])},style:{display:"flex",alignItems:"center",gap:"3px",cursor:"pointer",userSelect:"none"}},"Date",l.default.createElement("span",{style:{opacity:.7,fontSize:"10px"}},"asc"===j?"▲":"▼")),!C&&l.default.createElement("div",null,"Slot"),!C&&l.default.createElement("div",null,"Doctor")),l.default.createElement("div",{style:{overflow:"auto",flex:1}},b?l.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"40px",color:"#888"}},l.default.createElement("div",{style:{textAlign:"center"}},l.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 10px"}}),"Loading appointments...")):w?l.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#FF0000"}},l.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"⚠️ Error"),l.default.createElement("div",{style:{fontSize:"13px"}},w),l.default.createElement("button",{onClick:we,style:{marginTop:"16px",padding:"8px 16px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontFamily:ze}},"Retry")):0===re.length?l.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#888"}},l.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),l.default.createElement("div",{style:{fontSize:"13px"}},A?'No appointments found for "'.concat(A,'"'):"No appointments found"),A&&l.default.createElement("button",{onClick:()=>B(""),style:{marginTop:"12px",padding:"6px 12px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px",fontFamily:ze}},"Clear Search")):re.map(e=>l.default.createElement("div",{key:ye(e),role:"button",tabIndex:0,onClick:()=>ve(e),onKeyDown:t=>"Enter"===t.key&&ve(e),className:"appointments-grid",style:{display:"grid",gridTemplateColumns:C?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:C?"8px":"12px",padding:C?"10px 12px":"12px 18px",background:ye(y)===ye(e)?"#E8EEF4":"#FFFFFF",borderTop:"1px solid #F1F1F1",alignItems:"center",cursor:"pointer",fontSize:C?"11px":"13px"}},l.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:C?"8px":"10px"}},Ee(e)?l.default.createElement("img",{src:e.image,alt:"",style:{width:C?"32px":"36px",height:C?"32px":"36px",borderRadius:"50%",objectFit:"cover"}}):l.default.createElement("div",{style:{width:C?"32px":"36px",height:C?"32px":"36px",borderRadius:"50%",background:Fe(e.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:600,fontSize:C?"14px":"16px"}},be(e.patientName)),l.default.createElement("div",null,l.default.createElement("div",{style:{fontWeight:600,color:"#1a1a1a",fontSize:C?"11px":"13px"}},e.patientName),l.default.createElement("div",{style:{fontSize:C?"9px":"11px",color:"#888"}},e.email))),!C&&l.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.patientId),l.default.createElement("div",{style:{color:"#555",fontSize:C?"10px":"12px"}},(()=>{const t=e.appointmentDate||"",n=t.match(/\s(\d{1,2}:\d{2}(?:\s*(?:AM|PM))?)$/i);return n?l.default.createElement(l.default.Fragment,null,l.default.createElement("div",null,t.slice(0,n.index).trim()),l.default.createElement("div",{style:{fontSize:C?"9px":"11px",color:"#888"}},n[1].trim())):l.default.createElement("div",null,t)})()),!C&&l.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.appointmentTime||"-"),!C&&l.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.doctorName||e.doctor||"-")))),!b&&!w&&re.length>0&&l.default.createElement("div",{style:{padding:C?"12px 14px":"14px 18px",borderTop:"1px solid #F1F1F1",display:"flex",justifyContent:"space-between",alignItems:"center",background:"#FFFFFF",flexWrap:C?"wrap":"nowrap",gap:C?"10px":"0"}},l.default.createElement("div",{style:{fontSize:C?"11px":"12px",color:"#666"}},"Showing page ",ne," of ",de," (",pe," total)"),l.default.createElement("div",{style:{display:"flex",gap:"6px",alignItems:"center"}},l.default.createElement("button",{onClick:()=>ae(e=>Math.max(1,e-1)),disabled:1===ne,style:{padding:C?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:1===ne?"#F5F5F5":"#FFFFFF",color:1===ne?"#999":"#1a1a1a",fontSize:C?"11px":"12px",fontFamily:ze,fontWeight:600,cursor:1===ne?"not-allowed":"pointer",opacity:1===ne?.5:1}},"Previous"),l.default.createElement("div",{style:{display:"flex",gap:"4px"}},[...Array(Math.min(5,de))].map((e,t)=>{let n;return n=de<=5||ne<=3?t+1:ne>=de-2?de-4+t:ne-2+t,l.default.createElement("button",{key:n,onClick:()=>ae(n),style:{padding:C?"6px 10px":"6px 12px",border:ne===n?"none":"1px solid #E5E5E5",borderRadius:"4px",background:ne===n?"#4C4DDC":"#FFFFFF",color:ne===n?"#FFFFFF":"#1a1a1a",fontSize:C?"11px":"12px",fontFamily:ze,fontWeight:600,cursor:"pointer",minWidth:C?"32px":"36px"}},n)})),l.default.createElement("button",{onClick:()=>ae(e=>Math.min(de,e+1)),disabled:ne===de,style:{padding:C?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:ne===de?"#F5F5F5":"#FFFFFF",color:ne===de?"#999":"#1a1a1a",fontSize:C?"11px":"12px",fontFamily:ze,fontWeight:600,cursor:ne===de?"not-allowed":"pointer",opacity:ne===de?.5:1}},"Next"))))),l.default.createElement("div",{style:{flex:C?"none":"1 1 35%",width:C?"100%":"auto",display:y||!C?"flex":"none",flexDirection:"column",minHeight:"auto"}},l.default.createElement("div",{style:{border:"1px solid #E5E5E5",borderRadius:"8px",overflow:"hidden",background:"#FFFFFF",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",display:"flex",flexDirection:"column",height:C?"auto":"100%"}},y?l.default.createElement(l.default.Fragment,null,l.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:C?"12px 14px":"16px 18px",background:"#E8EEF4",borderBottom:"1px solid #E5E5E5"}},l.default.createElement("div",null,l.default.createElement("div",{style:{color:"#002668",fontSize:C?"14px":"16px",fontWeight:"700"}},y.patientName||"N/A"),l.default.createElement("div",{style:{color:"#002668",fontSize:C?"11px":"13px"}},y.patientId||y.mrn||"N/A")),l.default.createElement("div",null,Ee(y)?l.default.createElement("img",{style:{width:C?"36px":"44px",height:C?"36px":"44px",borderRadius:"50%",objectFit:"cover"},src:y.image,alt:y.patientName}):l.default.createElement("div",{style:{width:C?"36px":"44px",height:C?"36px":"44px",borderRadius:"50%",background:Fe(y.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:700,fontSize:C?"16px":"20px"}},be(y.patientName)))),l.default.createElement("div",{style:{padding:C?"12px 14px":"14px 18px",gap:C?"10px":"12px",display:"flex",flexDirection:"column",background:"white",overflow:"auto",flex:1,position:"relative"}},l.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},l.default.createElement("div",{style:{textAlign:"left"}},l.default.createElement("div",{style:{fontSize:C?"10px":"11px",color:"#888",marginBottom:"3px"}},"Speciality"),l.default.createElement("div",{style:{fontWeight:"700",fontSize:C?"12px":"13px"}},(null==y?void 0:y.specialisation)||(null==y?void 0:y.speciality)||"N/A")),l.default.createElement("div",{style:{textAlign:"right"}},l.default.createElement("div",{style:{fontSize:C?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Type"),l.default.createElement("div",{style:{fontWeight:"700",fontSize:C?"12px":"13px"}},(null==y?void 0:y.type)||(null==y?void 0:y.appointmentType)||"Online"))),l.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},l.default.createElement("div",{style:{textAlign:"left"}},l.default.createElement("div",{style:{fontSize:C?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Date"),l.default.createElement("div",{style:{fontWeight:"700",fontSize:C?"12px":"13px"}},(null==y?void 0:y.date)||(null==y?void 0:y.appointmentDate)||"N/A")),l.default.createElement("div",{style:{textAlign:"right"}},l.default.createElement("div",{style:{fontSize:C?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Time"),l.default.createElement("div",{style:{fontWeight:"700",fontSize:C?"12px":"13px"}},(null==y?void 0:y.time)||(null==y?void 0:y.appointmentTime)||"N/A"))),l.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},l.default.createElement("div",{style:{textAlign:"left"}},l.default.createElement("div",{style:{fontSize:C?"10px":"11px",color:"#888",marginBottom:"3px"}},"Doctor"),l.default.createElement("div",{style:{fontWeight:"700",fontSize:C?"12px":"13px"}},(null==y?void 0:y.doctor)||(null==y?void 0:y.doctorName)||"N/A"))),l.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},l.default.createElement("div",{style:{textAlign:"left"}},l.default.createElement("div",{style:{fontSize:C?"10px":"11px",color:"#888",marginBottom:"3px"}},"Hospital"),l.default.createElement("div",{style:{fontWeight:"700",fontSize:C?"12px":"13px"}},(null==y?void 0:y.hospital)||(null==y?void 0:y.hospitalName)||"N/A"))),l.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},l.default.createElement("div",{style:{textAlign:"left"}},l.default.createElement("div",{style:{fontSize:C?"10px":"11px",color:"#888",marginBottom:"3px"}},"Reason for Appointment"),l.default.createElement("div",{style:{fontWeight:"600",fontSize:C?"11px":"12px",lineHeight:"1.4"}},(null==y?void 0:y.reason)||(null==y?void 0:y.reasonForAppointment)||"No reason provided"))),l.default.createElement("div",{style:{display:"flex",flexDirection:C?"column":"row",gap:"6px",marginTop:"10px"}},l.default.createElement("button",{onClick:()=>{y&&(r?(T(!0),L(!1),O(!1)):alert("Call link not available"))},style:{flex:1,background:"#1CC3CE",color:"#FFFFFF",border:"1px solid #1CC3CE",borderRadius:"6px",padding:C?"10px 8px":"8px 6px",fontFamily:ze,fontWeight:600,fontSize:C?"11px":"12px",cursor:"pointer"}},"Join Call >")))):l.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",padding:"40px",color:"#888",textAlign:"center"}},l.default.createElement("div",null,l.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),l.default.createElement("div",{style:{fontSize:"13px"}},"Select an appointment to view details"))))))),N&&l.default.createElement("div",{style:{position:"fixed",left:H?"0":C?"10px":"".concat(J.x,"px"),top:H?"0":C?"70px":"".concat(J.y,"px"),right:H?"0":C?"10px":"auto",bottom:H?"0":"auto",width:H?"100vw":C?"calc(100vw - 20px)":Y?"350px":"".concat(P.width,"px"),height:H?"100vh":Y?"auto":C?"300px":"".concat(P.height,"px"),background:"#FFFFFF",borderRadius:H?"0":"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",zIndex:1e4,overflow:"hidden",display:"flex",flexDirection:"column",transition:V||_?"none":"all 0.3s ease"}},l.default.createElement("div",{onMouseDown:C||H?void 0:e=>{Z(!0);const t=e.currentTarget.getBoundingClientRect();q({x:e.clientX-t.left,y:e.clientY-t.top})},style:{background:"linear-gradient(135deg, #4C4DDC 0%, #3A3BBD 100%)",color:"#FFFFFF",padding:C?"8px 10px":"10px 12px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:!C&&!H&&(V?"grabbing":"grab"),userSelect:"none"}},l.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:C?"6px":"8px",flex:1,minWidth:0}},l.default.createElement("div",{style:{width:C?"6px":"8px",height:C?"6px":"8px",borderRadius:"50%",background:"#FF4444",animation:"pulse 2s infinite",flexShrink:0}}),l.default.createElement("span",{style:{fontSize:C?"11px":"13px",fontWeight:600,fontFamily:ze,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"Video Call - ",(null==y?void 0:y.patientName)||"Patient")),l.default.createElement("div",{style:{display:"flex",gap:C?"4px":"6px",alignItems:"center",flexShrink:0}},!H&&l.default.createElement("button",{onClick:()=>{H&&O(!1),L(!Y)},style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:C?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:C?"28px":"32px",height:C?"28px":"32px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:Y?"Restore":"Minimize"},Y?l.default.createElement("svg",{width:C?"14":"16",height:C?"14":"16",viewBox:"0 0 16 16",fill:"none"},l.default.createElement("rect",{x:"3",y:"3",width:"10",height:"10",stroke:"white",strokeWidth:"1.8",fill:"none"})):l.default.createElement("svg",{width:C?"14":"16",height:C?"14":"16",viewBox:"0 0 16 16",fill:"none"},l.default.createElement("line",{x1:"3",y1:"8",x2:"13",y2:"8",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round"}))),l.default.createElement("button",{onClick:()=>{Y&&L(!1),O(!H)},style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:C?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:C?"28px":"32px",height:C?"28px":"32px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:H?"Exit Fullscreen":"Fullscreen"},H?l.default.createElement("svg",{width:C?"14":"16",height:C?"14":"16",viewBox:"0 0 16 16",fill:"none"},l.default.createElement("path",{d:"M10 3H13V6M6 13H3V10M13 10V13H10M3 6V3H6",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})):l.default.createElement("svg",{width:C?"14":"16",height:C?"14":"16",viewBox:"0 0 16 16",fill:"none"},l.default.createElement("path",{d:"M3 6V3H6M13 10V13H10M10 3H13V6M6 13H3V10",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}))),l.default.createElement("button",{onClick:()=>{T(!1),L(!1),O(!1)},style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:C?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:C?"28px":"32px",height:C?"28px":"32px",fontWeight:"bold",fontSize:C?"18px":"22px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:"Close"},"×"))),!Y&&l.default.createElement("div",{style:{flex:1,background:"#000000",position:"relative"}},l.default.createElement("iframe",{src:r,style:{width:"100%",height:"100%",border:"none"},allow:"camera; microphone; display-capture; autoplay",allowFullScreen:!0,title:"Video Call"})),!C&&!H&&!Y&&l.default.createElement(l.default.Fragment,null,l.default.createElement("div",{onMouseDown:e=>ke("left",e),style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:"8px",height:"60px",cursor:"ew-resize",background:"transparent",zIndex:10001}}),l.default.createElement("div",{onMouseDown:e=>ke("right",e),style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:"8px",height:"60px",cursor:"ew-resize",background:"transparent",zIndex:10001}}),l.default.createElement("div",{onMouseDown:e=>ke("top",e),style:{position:"absolute",left:"50%",transform:"translateX(-50%)",top:0,width:"60px",height:"8px",cursor:"ns-resize",background:"transparent",zIndex:10001}}),l.default.createElement("div",{onMouseDown:e=>ke("bottom",e),style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:0,width:"60px",height:"8px",cursor:"ns-resize",background:"transparent",zIndex:10001}}),l.default.createElement("div",{style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:"4px",height:"30px",background:"rgba(76, 77, 220, 0.6)",borderRadius:"0 2px 2px 0",opacity:_&&"left"===K?1:0,transition:"opacity 0.2s ease",pointerEvents:"none",zIndex:10002}}),l.default.createElement("div",{style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:"4px",height:"30px",background:"rgba(76, 77, 220, 0.6)",borderRadius:"2px 0 0 2px",opacity:_&&"right"===K?1:0,transition:"opacity 0.2s ease",pointerEvents:"none",zIndex:10002}})),l.default.createElement("style",null,"\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n ")))};let m=null;const g={showWidget:(e,t)=>{m||(m=document.createElement("div"),document.body.appendChild(m));const n=()=>l.default.createElement(l.default.Fragment,null,l.default.createElement(f,{config:e}));r.default.render(l.default.createElement(n,null),m)},closePopup:()=>{m&&(r.default.unmountComponentAtNode(m),m=null)}};window.BookingSDK=g,e.AppointmentPage=f,e.default=g,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MyPackage={},e.React,e.ReactDOM)}(this,function(e,t,n){"use strict";function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=a(t),i=a(n);const l="https://afiyaapiqa.powermindinc.com",r="/appointment/V1/consultant/all-appointments",d="dMtEGhak",p=6694,s=async function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};try{let o=(e||"").toUpperCase();"INPROGRESS"===o&&(o="IN_PROGRESS");const i=a.apiBaseUrl||l,s=a.hospitalId||d,c={hospitalId:s,doctorId:a.doctorId||p,fromDate:t,toDate:n,statuses:o},u="".concat(i).concat(r),x=await async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=new URL(e);return n.search=new URLSearchParams(t).toString(),fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.ok?e.json():{err:"Something went wrong!"}).catch(e=>(console.error("Fetch error:",e),{err:e}))}(u,c,"PIH-Appointment-Widget");if(x.err)throw new Error(x.err);return x}catch(t){throw console.error("Error fetching ".concat(e," appointments:"),t),t}},c=e=>{let{config:n={}}=e;const a=n.apiBaseUrl||l,i=n.hospitalId||d,r=n.doctorId||p,c=n.joinCallUrl||"https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/eyJhbGciOiJIUzI1NiJ9.eyJtZXRhZGF0YSI6InVzZXItcm9sZTpkb2N0b3IiLCJuYW1lIjoiRHIuIE1hZ2VkIEZhaG15IiwidmlkZW8iOnsicm9vbUpvaW4iOnRydWUsInJvb20iOiIxMzUwMDgiLCJjYW5QdWJsaXNoIjp0cnVlLCJjYW5TdWJzY3JpYmUiOnRydWUsImNhblB1Ymxpc2hEYXRhIjp0cnVlfSwiaXNzIjoiQVBJa2JTTDg5Y0hxVlhZIiwiZXhwIjoxNzcxMzQxNjYyLCJuYmYiOjAsInN1YiI6ImhpbmF2aW5tYXRoQGdtYWlsLmNvbSJ9.3iJCdselxCHZ6IPzzgG3fGrIwInSszgqLeSgo3EX5bs",u=()=>(new Date).toISOString().split("T")[0],[x,f]=t.useState("upcoming"),[m,g]=t.useState([]),[h,y]=t.useState(null),[E,F]=t.useState(!1),[b,w]=t.useState(null),[v,S]=t.useState(window.innerWidth<768),[C,k]=t.useState("today"),[z,D]=t.useState("today"),[I,W]=t.useState(!1),[M,R]=t.useState("asc"),[j,A]=t.useState(""),[N,T]=t.useState(!1),[B,L]=t.useState(!1),[Y,H]=t.useState(!1),[O,J]=t.useState({x:window.innerWidth-550,y:80}),[X,V]=t.useState({width:550,height:450}),[U,P]=t.useState(!1),[G,Z]=t.useState({x:0,y:0}),[q,Q]=t.useState(!1),[_,K]=t.useState(null),[$,ee]=t.useState({x:0,y:0,width:0,height:0}),[te,ne]=t.useState(1),ae=m.filter(e=>{if(!j.trim())return!0;const t=j.toLowerCase(),n=(e.patientName||"").toLowerCase(),a=String(e.patientId||"").toLowerCase();return n.includes(t)||a.includes(t)}),oe=20*(te-1),ie=oe+20,le=ae.slice(oe,ie),re=Math.ceil(ae.length/20),de=ae.length,[pe,se]=t.useState(u()),[ce,ue]=t.useState(u()),[xe,fe]=t.useState(),[me,ge]=t.useState(),he=e=>(null==e?void 0:e.id)||(null==e?void 0:e._id)||(null==e?void 0:e.appointmentId)||(null==e?void 0:e.patientId)||JSON.stringify(e),ye=e=>null!=e&&e.image?e.image:null,Ee=e=>e?e.charAt(0).toUpperCase():"?",Fe=e=>{if(!e)return"#4C4DDC";const t=["#4C4DDC","#1CC3CE","#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F"];return t[e.charCodeAt(0)%t.length]},be=t.useCallback(async()=>{F(!0),w(null);try{const e={apiBaseUrl:a,hospitalId:i,doctorId:r},t=await s(x,pe,ce,e),n=t.data||t.appointments||t||[];g(n),n.length>0?y(n[0]):y(null)}catch(e){console.error("Error fetching appointments:",e),w(e.message||"Failed to fetch appointments")}finally{F(!1)}},[x,pe,ce,a,i,r]),we=e=>{y(e)},ve=t.useCallback(e=>{if(!Y)if(U){const t=e.clientX-G.x,n=e.clientY-G.y,a=window.innerWidth-X.width,o=window.innerHeight-X.height;J({x:Math.max(0,Math.min(t,a)),y:Math.max(0,Math.min(n,o))})}else if(q){const t=e.clientX-$.x,n=e.clientY-$.y;let a=$.width,o=$.height,i=$.posX,l=$.posY;const r=300,d=250,p=window.innerWidth-40,s=window.innerHeight-100;if("right"===_)a=Math.min(Math.max($.width+t,r),p),i+a>window.innerWidth&&(a=window.innerWidth-i);else if("left"===_){const e=Math.min(Math.max($.width-t,r),p),n=e-$.width;a=e,i=Math.max(0,$.posX-n),0===i&&(a=$.posX+$.width)}else if("bottom"===_)o=Math.min(Math.max($.height+n,d),s),l+o>window.innerHeight&&(o=window.innerHeight-l);else if("top"===_){const e=Math.min(Math.max($.height-n,d),s),t=e-$.height;o=e,l=Math.max(0,$.posY-t),0===l&&(o=$.posY+$.height)}V({width:a,height:o}),J({x:i,y:l})}},[U,q,G,_,$,O,X,Y]),Se=()=>{P(!1),Q(!1),K(null)},Ce=(e,t)=>{t.preventDefault(),t.stopPropagation(),Q(!0),K(e),ee({x:t.clientX,y:t.clientY,width:X.width,height:X.height,posX:O.x,posY:O.y})};t.useEffect(()=>{if(U||q)return window.addEventListener("mousemove",ve),window.addEventListener("mouseup",Se),()=>{window.removeEventListener("mousemove",ve),window.removeEventListener("mouseup",Se)}},[U,q,ve]),t.useEffect(()=>{if(!N||Y)return;const e=()=>{if(!(window.innerWidth<768)){const e=B?350:X.width,t=B?60:X.height,n=window.innerWidth-40,a=window.innerHeight-100,o=Math.min(e,n),i=Math.min(t,a);o===X.width&&i===X.height||V({width:o,height:i});const l=window.innerWidth-o-20,r=window.innerHeight-i-20;J(e=>({x:Math.min(e.x,l),y:Math.min(e.y,r)}))}};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[N,B,Y,X]),t.useEffect(()=>{ne(1)},[x,C,pe,ce,j]),t.useEffect(()=>{be()},[be]),t.useEffect(()=>{const e=document.createElement("link");e.href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap",e.rel="stylesheet",document.head.appendChild(e);const t=document.createElement("style");t.innerHTML="\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n \n @media (max-width: 768px) {\n .appointments-grid {\n grid-template-columns: 1.5fr 1fr 0.8fr !important;\n }\n .appointments-header-grid {\n grid-template-columns: 1.5fr 1fr 0.8fr !important;\n }\n .hide-on-mobile {\n display: none !important;\n }\n }\n @media (max-width: 480px) {\n .appointments-header-grid {\n font-size: 10px !important;\n }\n .appointments-grid {\n font-size: 11px !important;\n }\n }\n ",document.head.appendChild(t);const n=()=>{S(window.innerWidth<768)};return window.addEventListener("resize",n),()=>{document.head.removeChild(e),document.head.removeChild(t),window.removeEventListener("resize",n)}},[]),t.useEffect(()=>{const e=e=>{!I||e.target.closest("button")||e.target.closest('input[type="date"]')||W(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[I]);let ke='"Nunito", serif';return o.default.createElement("div",{style:{fontFamily:ke,background:"#F5F5F7",boxSizing:"border-box",height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"}},o.default.createElement("div",{style:{background:"#FFFFFF",padding:v?"10px 12px":"12px 24px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #E5E5E5",flexWrap:"nowrap",gap:v?"8px":"0"}},o.default.createElement("div",{style:{position:"relative",width:v?"calc(100% - 90px)":"480px",maxWidth:v?"none":"480px"}},o.default.createElement("input",{type:"text",placeholder:"Search by patient name or ID",value:j,onChange:e=>A(e.target.value),style:{width:"100%",padding:v?"8px 32px 8px 10px":"8px 36px 8px 14px",border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:v?"12px":"13px",fontFamily:ke,background:"#FFFFFF",outline:"none",boxSizing:"border-box"}}),j&&o.default.createElement("button",{onClick:()=>A(""),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:"#999",fontSize:"16px"},title:"Clear search"},"✕")),o.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:v?"10px":"16px"}},o.default.createElement("div",{style:{position:"relative",cursor:"pointer"}},o.default.createElement("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#555",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},o.default.createElement("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),o.default.createElement("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})),o.default.createElement("span",{style:{position:"absolute",top:"-5px",right:"-5px",background:"#1CC3CE",color:"white",borderRadius:"50%",width:"16px",height:"16px",fontSize:"10px",fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center"}},"1")),o.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},!v&&o.default.createElement("span",{style:{fontSize:"13px",color:"#555"}},"Hello, ",o.default.createElement("strong",{style:{color:"#1a1a1a"}},"Sameera")),o.default.createElement("img",{src:"https://w7.pngwing.com/pngs/340/946/png-transparent-avatar-user-computer-icons-software-developer-avatar-child-face-heroes-thumbnail.png",alt:"User",style:{width:"32px",height:"32px",borderRadius:"50%",objectFit:"cover"}})))),o.default.createElement("div",{style:{padding:v?"12px":"16px 24px",flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}},o.default.createElement("div",{style:{marginBottom:v?"10px":"14px"}},o.default.createElement("h1",{style:{fontSize:v?"18px":"22px",fontWeight:700,color:"#1a1a1a",margin:"0 0 2px 0"}},"Tele Consultation"),o.default.createElement("p",{style:{fontSize:v?"11px":"12px",color:"#999",margin:0}},"Displaying All Tele Consultation Appointments")),o.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:v?"flex-start":"center",marginBottom:v?"10px":"14px",flexDirection:v?"column":"row",gap:v?"12px":"0"}},o.default.createElement("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",width:v?"100%":"auto"}},o.default.createElement("button",{onClick:()=>f("upcoming"),style:{background:"upcoming"===x?"#4C4DDC":"#FFFFFF",padding:v?"8px 10px":"9px 16px",border:"upcoming"===x?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:v?"10px":"13px",color:"upcoming"===x?"white":"#555555",fontWeight:600,fontFamily:ke,cursor:"pointer",flex:v?"1 1 auto":"none",minWidth:v?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Upcoming Appointments"),o.default.createElement("button",{onClick:()=>f("completed"),style:{background:"completed"===x?"#4C4DDC":"#FFFFFF",padding:v?"8px 10px":"9px 16px",border:"completed"===x?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:v?"10px":"13px",color:"completed"===x?"white":"#555555",fontWeight:600,fontFamily:ke,cursor:"pointer",flex:v?"1 1 auto":"none",minWidth:v?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Completed Appointments"),o.default.createElement("button",{onClick:()=>f("cancelled"),style:{background:"cancelled"===x?"#4C4DDC":"#FFFFFF",padding:v?"8px 10px":"9px 16px",border:"cancelled"===x?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:v?"10px":"13px",color:"cancelled"===x?"white":"#555555",fontWeight:600,fontFamily:ke,cursor:"pointer",flex:v?"1 1 auto":"none",minWidth:v?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Cancelled Appointments")),o.default.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center",width:"auto",position:"relative",justifyContent:v?"flex-start":"flex-end"}},o.default.createElement("button",{onClick:()=>{I||(fe(pe),ge(ce),D(C)),W(!I)},style:{padding:"8px 12px",fontFamily:ke,fontWeight:600,border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:v?"11px":"13px",color:"#1a1a1a",background:"#FFFFFF",display:"flex",alignItems:"center",gap:v?"4px":"6px",cursor:"pointer",flex:"none",minWidth:v?"100px":"auto",justifyContent:"center"}},o.default.createElement("svg",{width:v?"12":"14",height:v?"12":"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},o.default.createElement("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),o.default.createElement("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),o.default.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),o.default.createElement("line",{x1:"3",y1:"10",x2:"21",y2:"10"})),o.default.createElement("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},(()=>{switch(C){case"today":default:return"Today";case"tomorrow":return"Tomorrow";case"currentWeek":return"Current Week";case"thisMonth":return"This Month";case"currentYear":return"Current Year";case"custom":return v?"Custom":"".concat(pe," to ").concat(ce)}})()),o.default.createElement("svg",{width:v?"8":"10",height:v?"8":"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},o.default.createElement("polyline",{points:"6 9 12 15 18 9"}))),I&&o.default.createElement("div",{style:{position:"absolute",top:"100%",right:v?"auto":0,left:v?0:"auto",marginTop:"4px",background:"#FFFFFF",border:"1px solid #E5E5E5",borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.15)",padding:"8px",zIndex:1e3,minWidth:v?"280px":"240px",width:v?"calc(100vw - 24px)":"auto",maxWidth:v?"calc(100vw - 24px)":"280px"}},o.default.createElement("div",{style:{marginBottom:"custom"===z?"12px":"0"}},["thisMonth","today","tomorrow","currentWeek","currentYear","custom"].map(e=>o.default.createElement("button",{key:e,onClick:()=>{if(D(e),"custom"!==e){const t=(e=>{const t=new Date;let n,a;switch(e){case"today":default:n=a=u();break;case"tomorrow":const e=new Date(t);e.setDate(e.getDate()+1),n=a=e.toISOString().split("T")[0];break;case"currentWeek":const o=new Date(t),i=new Date(t),l=t.getDay(),r=0===l?-6:1-l;o.setDate(t.getDate()+r),i.setDate(o.getDate()+6),n=o.toISOString().split("T")[0],a=i.toISOString().split("T")[0];break;case"thisMonth":const d=new Date(t.getFullYear(),t.getMonth(),1),p=new Date(t.getFullYear(),t.getMonth()+1,0);n=d.toISOString().split("T")[0],a=p.toISOString().split("T")[0];break;case"currentYear":n="".concat(t.getFullYear(),"-01-01"),a="".concat(t.getFullYear(),"-12-31")}return{from:n,to:a}})(e);k(e),se(t.from),ue(t.to),fe(t.from),ge(t.to),W(!1)}else fe(""),ge("")},style:{width:"100%",padding:"10px 12px",background:z===e?"#E8EEF4":"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:ke,cursor:"pointer",textAlign:"left",fontWeight:z===e?600:400,color:z===e?"#4C4DDC":"#1a1a1a",marginBottom:"4px",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{z!==e&&(t.target.style.background="#F5F5F5")},onMouseLeave:t=>{z!==e&&(t.target.style.background="#FFFFFF")}},o.default.createElement("span",null,{thisMonth:"This Month",today:"Today",tomorrow:"Tomorrow",currentWeek:"Current Week",currentYear:"Current Year",custom:"Custom"}[e]),z===e&&o.default.createElement("span",{style:{color:"#4C4DDC",fontSize:"16px"}},"✓")))),"custom"===z&&o.default.createElement("div",{style:{paddingTop:"8px",borderTop:"1px solid #E5E5E5"}},o.default.createElement("div",{style:{marginBottom:"8px"}},o.default.createElement("input",{type:"date",value:xe,onChange:e=>fe(e.target.value),placeholder:"Start Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:ke,boxSizing:"border-box",cursor:"pointer"}})),o.default.createElement("div",{style:{marginBottom:"12px"}},o.default.createElement("input",{type:"date",value:me,onChange:e=>ge(e.target.value),placeholder:"End Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:ke,boxSizing:"border-box",cursor:"pointer"}})),o.default.createElement("div",{style:{display:"flex",gap:"8px"}},o.default.createElement("button",{onClick:()=>{D(C),fe(pe),ge(ce),W(!1)},style:{flex:1,padding:"10px 12px",background:"#FFFFFF",color:"#4C4DDC",border:"1px solid #4C4DDC",borderRadius:"4px",fontSize:"13px",fontFamily:ke,fontWeight:600,cursor:"pointer"}},"Cancel"),o.default.createElement("button",{onClick:()=>{xe&&me&&(k("custom"),se(xe),ue(me),W(!1))},style:{flex:1,padding:"10px 12px",background:"#4C4DDC",color:"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:ke,fontWeight:600,cursor:"pointer"}},"Submit")))))),o.default.createElement("div",{style:{display:"flex",flexDirection:v?"column":"row",gap:v?"12px":"14px",flex:1,minHeight:0,overflow:v?"auto":"hidden"}},o.default.createElement("div",{style:{flex:v?"none":"1 1 65%",width:v?"100%":"auto",display:"flex",flexDirection:"column",minHeight:v?"400px":"auto"}},o.default.createElement("div",{style:{background:"#FFFFFF",borderRadius:"8px",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden",display:"flex",flexDirection:"column",height:v?"auto":"100%"}},o.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:v?"12px 14px":"14px 18px",borderBottom:"1px solid #F1F1F1"}},o.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:v?"6px":"8px"}},o.default.createElement("span",{style:{fontSize:v?"14px":"15px",fontWeight:700,color:"#1a1a1a"}},"Appointments"),o.default.createElement("span",{style:{background:"#4C4DDC",color:"#fff",fontSize:v?"10px":"11px",fontWeight:600,padding:v?"2px 7px":"3px 8px",borderRadius:"12px"}},de))),o.default.createElement("div",{className:"appointments-header-grid",style:{display:"grid",gridTemplateColumns:v?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:v?"8px":"12px",padding:v?"8px 12px":"10px 18px",background:"#F5F5F5",fontSize:v?"10px":"12px",fontWeight:600,color:"#666"}},o.default.createElement("div",null,"Patients name"),!v&&o.default.createElement("div",null,"Patient ID"),o.default.createElement("div",{onClick:()=>{const e="asc"===M?"desc":"asc";R(e);const t=[...m].sort((t,n)=>{const a=new Date(t.appointmentDate||t.date||0),o=new Date(n.appointmentDate||n.date||0);return"asc"===e?a-o:o-a});g(t),ne(1),t.length>0&&y(t[0])},style:{display:"flex",alignItems:"center",gap:"3px",cursor:"pointer",userSelect:"none"}},"Date",o.default.createElement("span",{style:{opacity:.7,fontSize:"10px"}},"asc"===M?"▲":"▼")),!v&&o.default.createElement("div",null,"Slot"),!v&&o.default.createElement("div",null,"Doctor")),o.default.createElement("div",{style:{overflow:"auto",flex:1}},E?o.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"40px",color:"#888"}},o.default.createElement("div",{style:{textAlign:"center"}},o.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 10px"}}),"Loading appointments...")):b?o.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#FF0000"}},o.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"⚠️ Error"),o.default.createElement("div",{style:{fontSize:"13px"}},b),o.default.createElement("button",{onClick:be,style:{marginTop:"16px",padding:"8px 16px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontFamily:ke}},"Retry")):0===le.length?o.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#888"}},o.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),o.default.createElement("div",{style:{fontSize:"13px"}},j?'No appointments found for "'.concat(j,'"'):"No appointments found"),j&&o.default.createElement("button",{onClick:()=>A(""),style:{marginTop:"12px",padding:"6px 12px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px",fontFamily:ke}},"Clear Search")):le.map(e=>o.default.createElement("div",{key:he(e),role:"button",tabIndex:0,onClick:()=>we(e),onKeyDown:t=>"Enter"===t.key&&we(e),className:"appointments-grid",style:{display:"grid",gridTemplateColumns:v?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:v?"8px":"12px",padding:v?"10px 12px":"12px 18px",background:he(h)===he(e)?"#E8EEF4":"#FFFFFF",borderTop:"1px solid #F1F1F1",alignItems:"center",cursor:"pointer",fontSize:v?"11px":"13px"}},o.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:v?"8px":"10px"}},ye(e)?o.default.createElement("img",{src:e.image,alt:"",style:{width:v?"32px":"36px",height:v?"32px":"36px",borderRadius:"50%",objectFit:"cover"}}):o.default.createElement("div",{style:{width:v?"32px":"36px",height:v?"32px":"36px",borderRadius:"50%",background:Fe(e.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:600,fontSize:v?"14px":"16px"}},Ee(e.patientName)),o.default.createElement("div",null,o.default.createElement("div",{style:{fontWeight:600,color:"#1a1a1a",fontSize:v?"11px":"13px"}},e.patientName),o.default.createElement("div",{style:{fontSize:v?"9px":"11px",color:"#888"}},e.email))),!v&&o.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.patientId),o.default.createElement("div",{style:{color:"#555",fontSize:v?"10px":"12px"}},(()=>{const t=e.appointmentDate||"",n=t.match(/\s(\d{1,2}:\d{2}(?:\s*(?:AM|PM))?)$/i);return n?o.default.createElement(o.default.Fragment,null,o.default.createElement("div",null,t.slice(0,n.index).trim()),o.default.createElement("div",{style:{fontSize:v?"9px":"11px",color:"#888"}},n[1].trim())):o.default.createElement("div",null,t)})()),!v&&o.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.appointmentTime||"-"),!v&&o.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.doctorName||e.doctor||"-")))),!E&&!b&&le.length>0&&o.default.createElement("div",{style:{padding:v?"12px 14px":"14px 18px",borderTop:"1px solid #F1F1F1",display:"flex",justifyContent:"space-between",alignItems:"center",background:"#FFFFFF",flexWrap:v?"wrap":"nowrap",gap:v?"10px":"0"}},o.default.createElement("div",{style:{fontSize:v?"11px":"12px",color:"#666"}},"Showing page ",te," of ",re," (",de," total)"),o.default.createElement("div",{style:{display:"flex",gap:"6px",alignItems:"center"}},o.default.createElement("button",{onClick:()=>ne(e=>Math.max(1,e-1)),disabled:1===te,style:{padding:v?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:1===te?"#F5F5F5":"#FFFFFF",color:1===te?"#999":"#1a1a1a",fontSize:v?"11px":"12px",fontFamily:ke,fontWeight:600,cursor:1===te?"not-allowed":"pointer",opacity:1===te?.5:1}},"Previous"),o.default.createElement("div",{style:{display:"flex",gap:"4px"}},[...Array(Math.min(5,re))].map((e,t)=>{let n;return n=re<=5||te<=3?t+1:te>=re-2?re-4+t:te-2+t,o.default.createElement("button",{key:n,onClick:()=>ne(n),style:{padding:v?"6px 10px":"6px 12px",border:te===n?"none":"1px solid #E5E5E5",borderRadius:"4px",background:te===n?"#4C4DDC":"#FFFFFF",color:te===n?"#FFFFFF":"#1a1a1a",fontSize:v?"11px":"12px",fontFamily:ke,fontWeight:600,cursor:"pointer",minWidth:v?"32px":"36px"}},n)})),o.default.createElement("button",{onClick:()=>ne(e=>Math.min(re,e+1)),disabled:te===re,style:{padding:v?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:te===re?"#F5F5F5":"#FFFFFF",color:te===re?"#999":"#1a1a1a",fontSize:v?"11px":"12px",fontFamily:ke,fontWeight:600,cursor:te===re?"not-allowed":"pointer",opacity:te===re?.5:1}},"Next"))))),o.default.createElement("div",{style:{flex:v?"none":"1 1 35%",width:v?"100%":"auto",display:h||!v?"flex":"none",flexDirection:"column",minHeight:"auto"}},o.default.createElement("div",{style:{border:"1px solid #E5E5E5",borderRadius:"8px",overflow:"hidden",background:"#FFFFFF",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",display:"flex",flexDirection:"column",height:v?"auto":"100%"}},h?o.default.createElement(o.default.Fragment,null,o.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:v?"12px 14px":"16px 18px",background:"#E8EEF4",borderBottom:"1px solid #E5E5E5"}},o.default.createElement("div",null,o.default.createElement("div",{style:{color:"#002668",fontSize:v?"14px":"16px",fontWeight:"700"}},h.patientName||"N/A"),o.default.createElement("div",{style:{color:"#002668",fontSize:v?"11px":"13px"}},h.patientId||h.mrn||"N/A")),o.default.createElement("div",null,ye(h)?o.default.createElement("img",{style:{width:v?"36px":"44px",height:v?"36px":"44px",borderRadius:"50%",objectFit:"cover"},src:h.image,alt:h.patientName}):o.default.createElement("div",{style:{width:v?"36px":"44px",height:v?"36px":"44px",borderRadius:"50%",background:Fe(h.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:700,fontSize:v?"16px":"20px"}},Ee(h.patientName)))),o.default.createElement("div",{style:{padding:v?"12px 14px":"14px 18px",gap:v?"10px":"12px",display:"flex",flexDirection:"column",background:"white",overflow:"auto",flex:1,position:"relative"}},o.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},o.default.createElement("div",{style:{textAlign:"left"}},o.default.createElement("div",{style:{fontSize:v?"10px":"11px",color:"#888",marginBottom:"3px"}},"Speciality"),o.default.createElement("div",{style:{fontWeight:"700",fontSize:v?"12px":"13px"}},(null==h?void 0:h.specialisation)||(null==h?void 0:h.speciality)||"N/A")),o.default.createElement("div",{style:{textAlign:"right"}},o.default.createElement("div",{style:{fontSize:v?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Type"),o.default.createElement("div",{style:{fontWeight:"700",fontSize:v?"12px":"13px"}},(null==h?void 0:h.type)||(null==h?void 0:h.appointmentType)||"Online"))),o.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},o.default.createElement("div",{style:{textAlign:"left"}},o.default.createElement("div",{style:{fontSize:v?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Date"),o.default.createElement("div",{style:{fontWeight:"700",fontSize:v?"12px":"13px"}},(null==h?void 0:h.date)||(null==h?void 0:h.appointmentDate)||"N/A")),o.default.createElement("div",{style:{textAlign:"right"}},o.default.createElement("div",{style:{fontSize:v?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Time"),o.default.createElement("div",{style:{fontWeight:"700",fontSize:v?"12px":"13px"}},(null==h?void 0:h.time)||(null==h?void 0:h.appointmentTime)||"N/A"))),o.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},o.default.createElement("div",{style:{textAlign:"left"}},o.default.createElement("div",{style:{fontSize:v?"10px":"11px",color:"#888",marginBottom:"3px"}},"Doctor"),o.default.createElement("div",{style:{fontWeight:"700",fontSize:v?"12px":"13px"}},(null==h?void 0:h.doctor)||(null==h?void 0:h.doctorName)||"N/A"))),o.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},o.default.createElement("div",{style:{textAlign:"left"}},o.default.createElement("div",{style:{fontSize:v?"10px":"11px",color:"#888",marginBottom:"3px"}},"Hospital"),o.default.createElement("div",{style:{fontWeight:"700",fontSize:v?"12px":"13px"}},(null==h?void 0:h.hospital)||(null==h?void 0:h.hospitalName)||"N/A"))),o.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},o.default.createElement("div",{style:{textAlign:"left"}},o.default.createElement("div",{style:{fontSize:v?"10px":"11px",color:"#888",marginBottom:"3px"}},"Reason for Appointment"),o.default.createElement("div",{style:{fontWeight:"600",fontSize:v?"11px":"12px",lineHeight:"1.4"}},(null==h?void 0:h.reason)||(null==h?void 0:h.reasonForAppointment)||"No reason provided"))),o.default.createElement("div",{style:{display:"flex",flexDirection:v?"column":"row",gap:"6px",marginTop:"10px"}},o.default.createElement("button",{onClick:()=>{h&&(c?(T(!0),L(!1),H(!1)):alert("Call link not available"))},style:{flex:1,background:"#1CC3CE",color:"#FFFFFF",border:"1px solid #1CC3CE",borderRadius:"6px",padding:v?"10px 8px":"8px 6px",fontFamily:ke,fontWeight:600,fontSize:v?"11px":"12px",cursor:"pointer"}},"Join Call >")))):o.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",padding:"40px",color:"#888",textAlign:"center"}},o.default.createElement("div",null,o.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),o.default.createElement("div",{style:{fontSize:"13px"}},"Select an appointment to view details"))))))),N&&o.default.createElement("div",{style:{position:"fixed",left:Y?"0":v?"10px":"".concat(O.x,"px"),top:Y?"0":v?"70px":"".concat(O.y,"px"),right:Y?"0":v?"10px":"auto",bottom:Y?"0":"auto",width:Y?"100vw":v?"calc(100vw - 20px)":B?"350px":"".concat(X.width,"px"),height:Y?"100vh":B?"auto":v?"300px":"".concat(X.height,"px"),background:"#FFFFFF",borderRadius:Y?"0":"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",zIndex:1e4,overflow:"hidden",display:"flex",flexDirection:"column",transition:U||q?"none":"all 0.3s ease"}},o.default.createElement("div",{onMouseDown:v||Y?void 0:e=>{P(!0);const t=e.currentTarget.getBoundingClientRect();Z({x:e.clientX-t.left,y:e.clientY-t.top})},style:{background:"linear-gradient(135deg, #4C4DDC 0%, #3A3BBD 100%)",color:"#FFFFFF",padding:v?"8px 10px":"10px 12px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:!v&&!Y&&(U?"grabbing":"grab"),userSelect:"none"}},o.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:v?"6px":"8px",flex:1,minWidth:0}},o.default.createElement("div",{style:{width:v?"6px":"8px",height:v?"6px":"8px",borderRadius:"50%",background:"#FF4444",animation:"pulse 2s infinite",flexShrink:0}}),o.default.createElement("span",{style:{fontSize:v?"11px":"13px",fontWeight:600,fontFamily:ke,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"Video Call - ",(null==h?void 0:h.patientName)||"Patient")),o.default.createElement("div",{style:{display:"flex",gap:v?"4px":"6px",alignItems:"center",flexShrink:0}},!Y&&o.default.createElement("button",{onClick:()=>{Y&&H(!1),L(!B)},style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:v?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:v?"28px":"32px",height:v?"28px":"32px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:B?"Restore":"Minimize"},B?o.default.createElement("svg",{width:v?"14":"16",height:v?"14":"16",viewBox:"0 0 16 16",fill:"none"},o.default.createElement("rect",{x:"3",y:"3",width:"10",height:"10",stroke:"white",strokeWidth:"1.8",fill:"none"})):o.default.createElement("svg",{width:v?"14":"16",height:v?"14":"16",viewBox:"0 0 16 16",fill:"none"},o.default.createElement("line",{x1:"3",y1:"8",x2:"13",y2:"8",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round"}))),o.default.createElement("button",{onClick:()=>{B&&L(!1),H(!Y)},style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:v?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:v?"28px":"32px",height:v?"28px":"32px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:Y?"Exit Fullscreen":"Fullscreen"},Y?o.default.createElement("svg",{width:v?"14":"16",height:v?"14":"16",viewBox:"0 0 16 16",fill:"none"},o.default.createElement("path",{d:"M10 3H13V6M6 13H3V10M13 10V13H10M3 6V3H6",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})):o.default.createElement("svg",{width:v?"14":"16",height:v?"14":"16",viewBox:"0 0 16 16",fill:"none"},o.default.createElement("path",{d:"M3 6V3H6M13 10V13H10M10 3H13V6M6 13H3V10",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}))),o.default.createElement("button",{onClick:()=>{T(!1),L(!1),H(!1)},style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:v?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:v?"28px":"32px",height:v?"28px":"32px",fontWeight:"bold",fontSize:v?"18px":"22px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:"Close"},"×"))),!B&&o.default.createElement("div",{style:{flex:1,background:"#000000",position:"relative"}},o.default.createElement("iframe",{src:c,style:{width:"100%",height:"100%",border:"none"},allow:"camera; microphone; display-capture; autoplay",allowFullScreen:!0,title:"Video Call"})),!v&&!Y&&!B&&o.default.createElement(o.default.Fragment,null,o.default.createElement("div",{onMouseDown:e=>Ce("left",e),style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:"8px",height:"60px",cursor:"ew-resize",background:"transparent",zIndex:10001}}),o.default.createElement("div",{onMouseDown:e=>Ce("right",e),style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:"8px",height:"60px",cursor:"ew-resize",background:"transparent",zIndex:10001}}),o.default.createElement("div",{onMouseDown:e=>Ce("top",e),style:{position:"absolute",left:"50%",transform:"translateX(-50%)",top:0,width:"60px",height:"8px",cursor:"ns-resize",background:"transparent",zIndex:10001}}),o.default.createElement("div",{onMouseDown:e=>Ce("bottom",e),style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:0,width:"60px",height:"8px",cursor:"ns-resize",background:"transparent",zIndex:10001}}),o.default.createElement("div",{style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:"4px",height:"30px",background:"rgba(76, 77, 220, 0.6)",borderRadius:"0 2px 2px 0",opacity:q&&"left"===_?1:0,transition:"opacity 0.2s ease",pointerEvents:"none",zIndex:10002}}),o.default.createElement("div",{style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:"4px",height:"30px",background:"rgba(76, 77, 220, 0.6)",borderRadius:"2px 0 0 2px",opacity:q&&"right"===_?1:0,transition:"opacity 0.2s ease",pointerEvents:"none",zIndex:10002}})),o.default.createElement("style",null,"\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n ")))};let u=null;const x={showWidget:(e,t)=>{u||(u=document.createElement("div"),document.body.appendChild(u));const n=()=>o.default.createElement(o.default.Fragment,null,o.default.createElement(c,{config:e}));i.default.render(o.default.createElement(n,null),u)},closePopup:()=>{u&&(i.default.unmountComponentAtNode(u),u=null)}};window.BookingSDK=x,e.AppointmentPage=c,e.default=x,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
@@ -3,46 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.joinAppointmentCall = exports.getAppointmentsByStatus = exports.getAppointmentDetails =
|
|
7
|
-
var
|
|
6
|
+
exports.joinAppointmentCall = exports.getAppointmentsByStatus = exports.getAppointmentDetails = void 0;
|
|
7
|
+
var _httpService = require("./httpService");
|
|
8
8
|
var _apiConfig = require("../constants/apiConfig");
|
|
9
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
10
|
-
// Create axios instance factory - allows dynamic configuration for SDK usage
|
|
11
|
-
const createApiClient = baseURL => {
|
|
12
|
-
const client = axios.create({
|
|
13
|
-
baseURL,
|
|
14
|
-
headers: {
|
|
15
|
-
"Content-Type": "application/json"
|
|
16
|
-
},
|
|
17
|
-
timeout: _apiConfig.REQUEST_TIMEOUT
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// Request interceptor to add auth token
|
|
21
|
-
client.interceptors.request.use(config => {
|
|
22
|
-
const token = localStorage.getItem("authToken");
|
|
23
|
-
if (token) {
|
|
24
|
-
config.headers.Authorization = "Bearer ".concat(token);
|
|
25
|
-
}
|
|
26
|
-
return config;
|
|
27
|
-
}, error => {
|
|
28
|
-
return Promise.reject(error);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// Response interceptor for error handling
|
|
32
|
-
client.interceptors.response.use(response => response, error => {
|
|
33
|
-
var _error$response;
|
|
34
|
-
if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 401) {
|
|
35
|
-
// Handle unauthorized access
|
|
36
|
-
console.error("Unauthorized access - redirecting to login");
|
|
37
|
-
}
|
|
38
|
-
return Promise.reject(error);
|
|
39
|
-
});
|
|
40
|
-
return client;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// Default client for backward compatibility
|
|
44
|
-
const apiClient = createApiClient();
|
|
45
|
-
|
|
46
9
|
/**
|
|
47
10
|
* Fetch appointments by status
|
|
48
11
|
* @param {string} status - Appointment status (inprogress, completed, cancelled, upcoming)
|
|
@@ -63,19 +26,28 @@ const getAppointmentsByStatus = async function (status, fromDate, toDate) {
|
|
|
63
26
|
}
|
|
64
27
|
|
|
65
28
|
// Use provided config or fall back to defaults from apiConfig.js
|
|
66
|
-
const
|
|
29
|
+
const baseURL = config.apiBaseUrl || _apiConfig.API_BASE_URL;
|
|
67
30
|
const hospitalId = config.hospitalId || _apiConfig.DEFAULT_PARAMS.hospitalId;
|
|
68
31
|
const doctorId = config.doctorId || _apiConfig.DEFAULT_PARAMS.doctorId;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
32
|
+
|
|
33
|
+
// Build query params
|
|
34
|
+
const params = {
|
|
35
|
+
hospitalId,
|
|
36
|
+
doctorId,
|
|
37
|
+
fromDate,
|
|
38
|
+
toDate,
|
|
39
|
+
statuses: apiStatus
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// Build full URL
|
|
43
|
+
const url = "".concat(baseURL).concat(_apiConfig.API_PATHS.APPOINTMENTS);
|
|
44
|
+
|
|
45
|
+
// Use httpService getApi
|
|
46
|
+
const response = await (0, _httpService.getApi)(url, params, "PIH-Appointment-Widget");
|
|
47
|
+
if (response.err) {
|
|
48
|
+
throw new Error(response.err);
|
|
49
|
+
}
|
|
50
|
+
return response;
|
|
79
51
|
} catch (error) {
|
|
80
52
|
console.error("Error fetching ".concat(status, " appointments:"), error);
|
|
81
53
|
throw error;
|
|
@@ -85,13 +57,20 @@ const getAppointmentsByStatus = async function (status, fromDate, toDate) {
|
|
|
85
57
|
/**
|
|
86
58
|
* Fetch appointment details by ID
|
|
87
59
|
* @param {string|number} appointmentId - The appointment ID
|
|
60
|
+
* @param {object} config - Optional configuration { apiBaseUrl }
|
|
88
61
|
* @returns {Promise} Appointment details
|
|
89
62
|
*/
|
|
90
63
|
exports.getAppointmentsByStatus = getAppointmentsByStatus;
|
|
91
|
-
const getAppointmentDetails = async appointmentId
|
|
64
|
+
const getAppointmentDetails = async function (appointmentId) {
|
|
65
|
+
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
92
66
|
try {
|
|
93
|
-
const
|
|
94
|
-
|
|
67
|
+
const baseURL = config.apiBaseUrl || _apiConfig.API_BASE_URL;
|
|
68
|
+
const url = "".concat(baseURL).concat(_apiConfig.API_PATHS.APPOINTMENT_DETAILS, "/").concat(appointmentId);
|
|
69
|
+
const response = await (0, _httpService.getApi)(url, {}, "PIH-Appointment-Widget");
|
|
70
|
+
if (response.err) {
|
|
71
|
+
throw new Error(response.err);
|
|
72
|
+
}
|
|
73
|
+
return response;
|
|
95
74
|
} catch (error) {
|
|
96
75
|
console.error("Error fetching appointment details:", error);
|
|
97
76
|
throw error;
|
|
@@ -101,17 +80,24 @@ const getAppointmentDetails = async appointmentId => {
|
|
|
101
80
|
/**
|
|
102
81
|
* Join appointment call
|
|
103
82
|
* @param {string|number} appointmentId - The appointment ID
|
|
83
|
+
* @param {object} config - Optional configuration { apiBaseUrl }
|
|
104
84
|
* @returns {Promise} Call details/link
|
|
105
85
|
*/
|
|
106
86
|
exports.getAppointmentDetails = getAppointmentDetails;
|
|
107
|
-
const joinAppointmentCall = async appointmentId
|
|
87
|
+
const joinAppointmentCall = async function (appointmentId) {
|
|
88
|
+
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
108
89
|
try {
|
|
109
|
-
const
|
|
110
|
-
|
|
90
|
+
const baseURL = config.apiBaseUrl || _apiConfig.API_BASE_URL;
|
|
91
|
+
const url = "".concat(baseURL).concat(_apiConfig.API_PATHS.JOIN_CALL, "/").concat(appointmentId, "/join");
|
|
92
|
+
const token = localStorage.getItem("authToken") || "";
|
|
93
|
+
const response = await (0, _httpService.postApi)(url, {}, "PIH-Appointment-Widget", {}, token);
|
|
94
|
+
if (response.err) {
|
|
95
|
+
throw new Error(response.err);
|
|
96
|
+
}
|
|
97
|
+
return response;
|
|
111
98
|
} catch (error) {
|
|
112
99
|
console.error("Error joining appointment call:", error);
|
|
113
100
|
throw error;
|
|
114
101
|
}
|
|
115
102
|
};
|
|
116
|
-
exports.joinAppointmentCall = joinAppointmentCall;
|
|
117
|
-
var _default = exports.default = apiClient;
|
|
103
|
+
exports.joinAppointmentCall = joinAppointmentCall;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.postApi = exports.getApi = void 0;
|
|
7
|
+
const getApi = async function (url) {
|
|
8
|
+
let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
9
|
+
let header = arguments.length > 2 ? arguments[2] : undefined;
|
|
10
|
+
const urlWithParams = new URL(url);
|
|
11
|
+
urlWithParams.search = new URLSearchParams(params).toString();
|
|
12
|
+
const options = {
|
|
13
|
+
method: "GET",
|
|
14
|
+
headers: {
|
|
15
|
+
"Content-Type": "application/json"
|
|
16
|
+
// "X-CLIENT-APP": header,
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return fetch(urlWithParams, options).then(response => {
|
|
20
|
+
if (!response.ok) {
|
|
21
|
+
return {
|
|
22
|
+
err: "Something went wrong!"
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return response.json();
|
|
26
|
+
}).catch(error => {
|
|
27
|
+
console.error("Fetch error:", error);
|
|
28
|
+
return {
|
|
29
|
+
err: error
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.getApi = getApi;
|
|
34
|
+
const postApi = async function (url) {
|
|
35
|
+
let body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
36
|
+
let header = arguments.length > 2 ? arguments[2] : undefined;
|
|
37
|
+
let params = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
38
|
+
let token = arguments.length > 4 ? arguments[4] : undefined;
|
|
39
|
+
const urlWithParams = new URL(url);
|
|
40
|
+
Object.keys(params).forEach(key => {
|
|
41
|
+
urlWithParams.searchParams.append(key, params[key]);
|
|
42
|
+
});
|
|
43
|
+
const options = {
|
|
44
|
+
method: "POST",
|
|
45
|
+
headers: {
|
|
46
|
+
"Content-Type": "application/json"
|
|
47
|
+
// Authorization: `Bearer ${token}`,
|
|
48
|
+
},
|
|
49
|
+
body: JSON.stringify(body)
|
|
50
|
+
};
|
|
51
|
+
return fetch(urlWithParams.toString(), options).then(response => {
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
return response.json().then(errorData => {
|
|
54
|
+
var _errorData$resultInfo;
|
|
55
|
+
const errorMessage = (errorData === null || errorData === void 0 || (_errorData$resultInfo = errorData.resultInfo) === null || _errorData$resultInfo === void 0 ? void 0 : _errorData$resultInfo.message) || "Something went wrong!";
|
|
56
|
+
return {
|
|
57
|
+
err: errorMessage
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return response.json();
|
|
62
|
+
}).catch(error => {
|
|
63
|
+
console.error("Fetch error:", error);
|
|
64
|
+
return {
|
|
65
|
+
err: error.message || "Network error"
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
exports.postApi = postApi;
|
package/package.json
CHANGED
|
@@ -1,52 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { getApi, postApi } from "./httpService";
|
|
2
2
|
import {
|
|
3
|
+
API_BASE_URL,
|
|
3
4
|
API_PATHS,
|
|
4
|
-
DEFAULT_PARAMS,
|
|
5
|
-
REQUEST_TIMEOUT,
|
|
5
|
+
DEFAULT_PARAMS,
|
|
6
6
|
} from "../constants/apiConfig";
|
|
7
7
|
|
|
8
|
-
// Create axios instance factory - allows dynamic configuration for SDK usage
|
|
9
|
-
const createApiClient = (baseURL) => {
|
|
10
|
-
const client = axios.create({
|
|
11
|
-
baseURL,
|
|
12
|
-
headers: {
|
|
13
|
-
"Content-Type": "application/json",
|
|
14
|
-
},
|
|
15
|
-
timeout: REQUEST_TIMEOUT,
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
// Request interceptor to add auth token
|
|
19
|
-
client.interceptors.request.use(
|
|
20
|
-
(config) => {
|
|
21
|
-
const token = localStorage.getItem("authToken");
|
|
22
|
-
if (token) {
|
|
23
|
-
config.headers.Authorization = `Bearer ${token}`;
|
|
24
|
-
}
|
|
25
|
-
return config;
|
|
26
|
-
},
|
|
27
|
-
(error) => {
|
|
28
|
-
return Promise.reject(error);
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
// Response interceptor for error handling
|
|
33
|
-
client.interceptors.response.use(
|
|
34
|
-
(response) => response,
|
|
35
|
-
(error) => {
|
|
36
|
-
if (error.response?.status === 401) {
|
|
37
|
-
// Handle unauthorized access
|
|
38
|
-
console.error("Unauthorized access - redirecting to login");
|
|
39
|
-
}
|
|
40
|
-
return Promise.reject(error);
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
return client;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// Default client for backward compatibility
|
|
48
|
-
const apiClient = createApiClient();
|
|
49
|
-
|
|
50
8
|
/**
|
|
51
9
|
* Fetch appointments by status
|
|
52
10
|
* @param {string} status - Appointment status (inprogress, completed, cancelled, upcoming)
|
|
@@ -66,20 +24,30 @@ export const getAppointmentsByStatus = async (status, fromDate, toDate, config =
|
|
|
66
24
|
}
|
|
67
25
|
|
|
68
26
|
// Use provided config or fall back to defaults from apiConfig.js
|
|
69
|
-
const
|
|
27
|
+
const baseURL = config.apiBaseUrl || API_BASE_URL;
|
|
70
28
|
const hospitalId = config.hospitalId || DEFAULT_PARAMS.hospitalId;
|
|
71
29
|
const doctorId = config.doctorId || DEFAULT_PARAMS.doctorId;
|
|
72
30
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
31
|
+
// Build query params
|
|
32
|
+
const params = {
|
|
33
|
+
hospitalId,
|
|
34
|
+
doctorId,
|
|
35
|
+
fromDate,
|
|
36
|
+
toDate,
|
|
37
|
+
statuses: apiStatus,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Build full URL
|
|
41
|
+
const url = `${baseURL}${API_PATHS.APPOINTMENTS}`;
|
|
42
|
+
|
|
43
|
+
// Use httpService getApi
|
|
44
|
+
const response = await getApi(url, params, "PIH-Appointment-Widget");
|
|
45
|
+
|
|
46
|
+
if (response.err) {
|
|
47
|
+
throw new Error(response.err);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return response;
|
|
83
51
|
} catch (error) {
|
|
84
52
|
console.error(`Error fetching ${status} appointments:`, error);
|
|
85
53
|
throw error;
|
|
@@ -89,12 +57,21 @@ export const getAppointmentsByStatus = async (status, fromDate, toDate, config =
|
|
|
89
57
|
/**
|
|
90
58
|
* Fetch appointment details by ID
|
|
91
59
|
* @param {string|number} appointmentId - The appointment ID
|
|
60
|
+
* @param {object} config - Optional configuration { apiBaseUrl }
|
|
92
61
|
* @returns {Promise} Appointment details
|
|
93
62
|
*/
|
|
94
|
-
export const getAppointmentDetails = async (appointmentId) => {
|
|
63
|
+
export const getAppointmentDetails = async (appointmentId, config = {}) => {
|
|
95
64
|
try {
|
|
96
|
-
const
|
|
97
|
-
|
|
65
|
+
const baseURL = config.apiBaseUrl || API_BASE_URL;
|
|
66
|
+
const url = `${baseURL}${API_PATHS.APPOINTMENT_DETAILS}/${appointmentId}`;
|
|
67
|
+
|
|
68
|
+
const response = await getApi(url, {}, "PIH-Appointment-Widget");
|
|
69
|
+
|
|
70
|
+
if (response.err) {
|
|
71
|
+
throw new Error(response.err);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return response;
|
|
98
75
|
} catch (error) {
|
|
99
76
|
console.error("Error fetching appointment details:", error);
|
|
100
77
|
throw error;
|
|
@@ -104,16 +81,24 @@ export const getAppointmentDetails = async (appointmentId) => {
|
|
|
104
81
|
/**
|
|
105
82
|
* Join appointment call
|
|
106
83
|
* @param {string|number} appointmentId - The appointment ID
|
|
84
|
+
* @param {object} config - Optional configuration { apiBaseUrl }
|
|
107
85
|
* @returns {Promise} Call details/link
|
|
108
86
|
*/
|
|
109
|
-
export const joinAppointmentCall = async (appointmentId) => {
|
|
87
|
+
export const joinAppointmentCall = async (appointmentId, config = {}) => {
|
|
110
88
|
try {
|
|
111
|
-
const
|
|
112
|
-
|
|
89
|
+
const baseURL = config.apiBaseUrl || API_BASE_URL;
|
|
90
|
+
const url = `${baseURL}${API_PATHS.JOIN_CALL}/${appointmentId}/join`;
|
|
91
|
+
const token = localStorage.getItem("authToken") || "";
|
|
92
|
+
|
|
93
|
+
const response = await postApi(url, {}, "PIH-Appointment-Widget", {}, token);
|
|
94
|
+
|
|
95
|
+
if (response.err) {
|
|
96
|
+
throw new Error(response.err);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return response;
|
|
113
100
|
} catch (error) {
|
|
114
101
|
console.error("Error joining appointment call:", error);
|
|
115
102
|
throw error;
|
|
116
103
|
}
|
|
117
104
|
};
|
|
118
|
-
|
|
119
|
-
export default apiClient;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export const getApi = async (url, params = {}, header) => {
|
|
2
|
+
const urlWithParams = new URL(url);
|
|
3
|
+
urlWithParams.search = new URLSearchParams(params).toString();
|
|
4
|
+
|
|
5
|
+
const options = {
|
|
6
|
+
method: "GET",
|
|
7
|
+
headers: {
|
|
8
|
+
"Content-Type": "application/json",
|
|
9
|
+
// "X-CLIENT-APP": header,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
return fetch(urlWithParams, options)
|
|
14
|
+
.then((response) => {
|
|
15
|
+
if (!response.ok) {
|
|
16
|
+
return { err: "Something went wrong!" };
|
|
17
|
+
}
|
|
18
|
+
return response.json();
|
|
19
|
+
})
|
|
20
|
+
.catch((error) => {
|
|
21
|
+
console.error("Fetch error:", error);
|
|
22
|
+
return { err: error };
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export const postApi = async (url, body = {}, header, params = {}, token) => {
|
|
26
|
+
const urlWithParams = new URL(url);
|
|
27
|
+
Object.keys(params).forEach((key) => {
|
|
28
|
+
urlWithParams.searchParams.append(key, params[key]);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const options = {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: {
|
|
34
|
+
"Content-Type": "application/json",
|
|
35
|
+
// Authorization: `Bearer ${token}`,
|
|
36
|
+
},
|
|
37
|
+
body: JSON.stringify(body),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return fetch(urlWithParams.toString(), options)
|
|
41
|
+
.then((response) => {
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
return response.json().then((errorData) => {
|
|
44
|
+
const errorMessage =
|
|
45
|
+
errorData?.resultInfo?.message || "Something went wrong!";
|
|
46
|
+
return { err: errorMessage };
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return response.json();
|
|
50
|
+
})
|
|
51
|
+
.catch((error) => {
|
|
52
|
+
console.error("Fetch error:", error);
|
|
53
|
+
return { err: error.message || "Network error" };
|
|
54
|
+
});
|
|
55
|
+
};
|