diff --git a/public/App/Doctor/doctor-app.bundle.js b/public/App/Doctor/doctor-app.bundle.js index 3ba064f..fdc9595 100644 --- a/public/App/Doctor/doctor-app.bundle.js +++ b/public/App/Doctor/doctor-app.bundle.js @@ -1,4 +1,3 @@ -import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; const { useState, useEffect @@ -22,201 +21,168 @@ const MobileAppsModal = ({ window.location.href = '/app/nursing'; } }; - return /*#__PURE__*/_jsx("div", { + return /*#__PURE__*/React.createElement("div", { className: "modal fade show d-block", style: { backgroundColor: 'rgba(15, 23, 42, 0.7)', zIndex: 1055, backdropFilter: 'blur(4px)' }, - tabIndex: "-1", - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered px-2", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content border-0 shadow-lg rounded-4 overflow-hidden", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header text-white p-3", - style: { - background: 'linear-gradient(135deg, #0f172a 0%, #1e293b 100%)' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("img", { - src: "/assets/img/logo.png", - alt: "Hospital Logo", - style: { - height: '28px', - width: 'auto', - filter: 'brightness(0) invert(1)' - }, - onError: e => { - e.target.style.display = 'none'; - } - }), /*#__PURE__*/_jsxs("h6", { - className: "modal-title fw-bold mb-0 text-white", - style: { - fontSize: '15px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-grid-fill me-1 text-primary" - }), " HMS Mobile & PWA Apps Launcher"] - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: onClose - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-3 bg-light", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label fw-bold small text-secondary mb-2", - style: { - letterSpacing: '0.5px' - }, - children: "1. SELECT APPLICATION" - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "col-4", - children: /*#__PURE__*/_jsxs("div", { - className: `card p-2 text-center h-100 ${currentApp === 'nursing' ? 'border-2 border-primary bg-primary-subtle shadow-sm' : 'border bg-white text-dark'}`, - style: { - cursor: 'pointer', - borderRadius: '12px' - }, - onClick: () => navigateToApp('nursing'), - children: [/*#__PURE__*/_jsx("div", { - className: "my-1", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-heart-pulse-fill fs-3 text-primary" - }) - }), /*#__PURE__*/_jsx("div", { - className: "fw-bold small text-truncate", - style: { - fontSize: '12px' - }, - children: "Nursing Care" - }), currentApp === 'nursing' ? /*#__PURE__*/_jsx("span", { - className: "badge bg-primary mt-1", - style: { - fontSize: '9px' - }, - children: "● Active App" - }) : /*#__PURE__*/_jsx("span", { - className: "badge bg-info-subtle text-info-emphasis border border-info-subtle mt-1", - style: { - fontSize: '9px' - }, - children: "Active PWA" - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-4", - children: /*#__PURE__*/_jsxs("div", { - className: `card p-2 text-center h-100 ${currentApp === 'doctor' ? 'border-2 border-primary bg-primary-subtle shadow-sm' : 'border bg-white text-dark'}`, - style: { - cursor: 'pointer', - borderRadius: '12px' - }, - onClick: () => navigateToApp('doctor'), - children: [/*#__PURE__*/_jsx("div", { - className: "my-1", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-person-badge-fill fs-3 text-primary" - }) - }), /*#__PURE__*/_jsx("div", { - className: "fw-bold small text-truncate", - style: { - fontSize: '12px' - }, - children: "Doctor App" - }), currentApp === 'doctor' ? /*#__PURE__*/_jsx("span", { - className: "badge bg-primary mt-1", - style: { - fontSize: '9px' - }, - children: "● Active App" - }) : /*#__PURE__*/_jsx("span", { - className: "badge bg-success mt-1", - style: { - fontSize: '9px' - }, - children: "Active PWA" - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-4", - children: /*#__PURE__*/_jsxs("div", { - className: "card p-2 text-center border bg-white text-muted opacity-75 h-100", - style: { - borderRadius: '12px', - cursor: 'not-allowed' - }, - children: [/*#__PURE__*/_jsx("div", { - className: "my-1", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-capsule fs-3 text-secondary" - }) - }), /*#__PURE__*/_jsx("div", { - className: "fw-bold small text-truncate", - style: { - fontSize: '12px' - }, - children: "Pharmacy App" - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary mt-1", - style: { - fontSize: '9px' - }, - children: "Coming Soon" - })] - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "p-3 bg-white rounded-3 border text-center shadow-sm", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-center gap-2 mb-2", - children: [/*#__PURE__*/_jsx("img", { - src: "/assets/img/logo.png", - alt: "Logo", - style: { - height: '28px' - }, - onError: e => e.target.style.display = 'none' - }), /*#__PURE__*/_jsxs("div", { - className: "text-start", - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold small text-dark", - children: "HMS Unified Mobile Portal" - }), /*#__PURE__*/_jsxs("div", { - className: "small text-muted", - style: { - fontSize: '10px' - }, - children: ["Domain: ", window.location.host] - })] - })] - }), /*#__PURE__*/_jsx("p", { - className: "small text-muted mb-2", - style: { - fontSize: '11px' - }, - children: "Tap any active app card above to switch between modules in your mobile app." - }), /*#__PURE__*/_jsxs("a", { - href: "/app", - className: "btn btn-outline-primary btn-sm w-100 fw-bold rounded-pill", - style: { - fontSize: '12px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-house-door me-1" - }), " Open Mobile App Hub"] - })] - })] - })] - }) - }) - }); + tabIndex: "-1" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered px-2" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content border-0 shadow-lg rounded-4 overflow-hidden" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header text-white p-3", + style: { + background: 'linear-gradient(135deg, #0f172a 0%, #1e293b 100%)' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("img", { + src: "/assets/img/logo.png", + alt: "Hospital Logo", + style: { + height: '28px', + width: 'auto', + filter: 'brightness(0) invert(1)' + }, + onError: e => { + e.target.style.display = 'none'; + } + }), /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold mb-0 text-white", + style: { + fontSize: '15px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-grid-fill me-1 text-primary" + }), " HMS Mobile & PWA Apps Launcher")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: onClose + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3 bg-light" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-secondary mb-2", + style: { + letterSpacing: '0.5px' + } + }, "1. SELECT APPLICATION"), /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("div", { + className: `card p-2 text-center h-100 ${currentApp === 'nursing' ? 'border-2 border-primary bg-primary-subtle shadow-sm' : 'border bg-white text-dark'}`, + style: { + cursor: 'pointer', + borderRadius: '12px' + }, + onClick: () => navigateToApp('nursing') + }, /*#__PURE__*/React.createElement("div", { + className: "my-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-heart-pulse-fill fs-3 text-primary" + })), /*#__PURE__*/React.createElement("div", { + className: "fw-bold small text-truncate", + style: { + fontSize: '12px' + } + }, "Nursing Care"), currentApp === 'nursing' ? /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary mt-1", + style: { + fontSize: '9px' + } + }, "● Active App") : /*#__PURE__*/React.createElement("span", { + className: "badge bg-info-subtle text-info-emphasis border border-info-subtle mt-1", + style: { + fontSize: '9px' + } + }, "Active PWA"))), /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("div", { + className: `card p-2 text-center h-100 ${currentApp === 'doctor' ? 'border-2 border-primary bg-primary-subtle shadow-sm' : 'border bg-white text-dark'}`, + style: { + cursor: 'pointer', + borderRadius: '12px' + }, + onClick: () => navigateToApp('doctor') + }, /*#__PURE__*/React.createElement("div", { + className: "my-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-badge-fill fs-3 text-primary" + })), /*#__PURE__*/React.createElement("div", { + className: "fw-bold small text-truncate", + style: { + fontSize: '12px' + } + }, "Doctor App"), currentApp === 'doctor' ? /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary mt-1", + style: { + fontSize: '9px' + } + }, "● Active App") : /*#__PURE__*/React.createElement("span", { + className: "badge bg-success mt-1", + style: { + fontSize: '9px' + } + }, "Active PWA"))), /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("div", { + className: "card p-2 text-center border bg-white text-muted opacity-75 h-100", + style: { + borderRadius: '12px', + cursor: 'not-allowed' + } + }, /*#__PURE__*/React.createElement("div", { + className: "my-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-capsule fs-3 text-secondary" + })), /*#__PURE__*/React.createElement("div", { + className: "fw-bold small text-truncate", + style: { + fontSize: '12px' + } + }, "Pharmacy App"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary mt-1", + style: { + fontSize: '9px' + } + }, "Coming Soon")))), /*#__PURE__*/React.createElement("div", { + className: "p-3 bg-white rounded-3 border text-center shadow-sm" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-center gap-2 mb-2" + }, /*#__PURE__*/React.createElement("img", { + src: "/assets/img/logo.png", + alt: "Logo", + style: { + height: '28px' + }, + onError: e => e.target.style.display = 'none' + }), /*#__PURE__*/React.createElement("div", { + className: "text-start" + }, /*#__PURE__*/React.createElement("div", { + className: "fw-bold small text-dark" + }, "HMS Unified Mobile Portal"), /*#__PURE__*/React.createElement("div", { + className: "small text-muted", + style: { + fontSize: '10px' + } + }, "Domain: ", window.location.host))), /*#__PURE__*/React.createElement("p", { + className: "small text-muted mb-2", + style: { + fontSize: '11px' + } + }, "Tap any active app card above to switch between modules in your mobile app."), /*#__PURE__*/React.createElement("a", { + href: "/app", + className: "btn btn-outline-primary btn-sm w-100 fw-bold rounded-pill", + style: { + fontSize: '12px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-house-door me-1" + }), " Open Mobile App Hub")))))); }; function DoctorApp() { const [showAppsModal, setShowAppsModal] = useState(false); @@ -737,36 +703,30 @@ function DoctorApp() { const text = entry.treatment_text || entry.general_note || ''; const match = text.match(/\[IMAGE_ATTACHMENT:(.*?)\]/); const cleanText = text.replace(/\[IMAGE_ATTACHMENT:.*?\]/, '').replace('[Doctor Note] ', ''); - return /*#__PURE__*/_jsxs("div", { - children: [cleanText && /*#__PURE__*/_jsx("div", { - className: "small fw-semibold", - children: cleanText - }), match && match[1] && /*#__PURE__*/_jsxs("div", { - className: "mt-2", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-primary mb-1 d-inline-flex align-items-center gap-1", - style: { - fontSize: '10px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-paperclip" - }), " Doctor Handwritten Note Photo"] - }), /*#__PURE__*/_jsx("a", { - href: match[1], - target: "_blank", - rel: "noreferrer", - children: /*#__PURE__*/_jsx("img", { - src: match[1], - alt: "Doctor Handwritten Note", - className: "img-fluid rounded-3 border shadow-sm d-block mt-1", - style: { - maxHeight: '240px', - objectFit: 'cover' - } - }) - })] - })] - }); + return /*#__PURE__*/React.createElement("div", null, cleanText && /*#__PURE__*/React.createElement("div", { + className: "small fw-semibold" + }, cleanText), match && match[1] && /*#__PURE__*/React.createElement("div", { + className: "mt-2" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary mb-1 d-inline-flex align-items-center gap-1", + style: { + fontSize: '10px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-paperclip" + }), " Doctor Handwritten Note Photo"), /*#__PURE__*/React.createElement("a", { + href: match[1], + target: "_blank", + rel: "noreferrer" + }, /*#__PURE__*/React.createElement("img", { + src: match[1], + alt: "Doctor Handwritten Note", + className: "img-fluid rounded-3 border shadow-sm d-block mt-1", + style: { + maxHeight: '240px', + objectFit: 'cover' + } + })))); }; // ------------------------------------------------------------- @@ -774,1619 +734,1252 @@ function DoctorApp() { // ------------------------------------------------------------- if (!authenticatedDoctor) { const isQuickUnlock = Boolean(pairedDoctor && !showPairingForm); - return /*#__PURE__*/_jsxs("div", { - className: "lock-screen-overlay", - children: [/*#__PURE__*/_jsx(MobileAppsModal, { - show: showAppsModal, - onClose: () => setShowAppsModal(false), - currentApp: "doctor" - }), /*#__PURE__*/_jsxs("div", { - className: "lock-card", - children: [/*#__PURE__*/_jsxs("div", { - className: "p-4 text-center bg-primary text-white position-relative", - style: { - background: 'linear-gradient(135deg, #0f172a 0%, #1e293b 100%)' - }, - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-light position-absolute top-0 end-0 m-2 rounded-circle", - style: { - width: '32px', - height: '32px', - padding: 0 - }, - onClick: () => setShowAppsModal(true), - title: "HMS Mobile & PWA Apps Launcher", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-grid-3x3-gap-fill", - style: { - fontSize: '12px' - } - }) - }), /*#__PURE__*/_jsx("img", { - src: "/assets/img/logo.png", - alt: "Hospital Logo", - className: "d-block mx-auto mb-2", - style: { - maxHeight: '40px', - filter: 'brightness(0) invert(1)' - }, - onError: e => { - e.target.style.display = 'none'; - } - }), /*#__PURE__*/_jsx("h5", { - className: "fw-bold mb-1", - children: "Doctor EMR Mobile Portal" - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-center gap-1 opacity-75 small", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-check text-success" - }), /*#__PURE__*/_jsx("span", { - children: "Hospital Intranet & Device Protected" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "p-4", - children: [pinError && /*#__PURE__*/_jsx("div", { - className: "alert alert-danger py-2 px-3 small mb-3", - children: pinError - }), !isSettingNewPin ? isQuickUnlock ? - /*#__PURE__*/ - /* ------------------------------------------------------------- - PAIRED DEVICE QUICK UNLOCK - ------------------------------------------------------------- */ - _jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "text-center mb-4", - children: [/*#__PURE__*/_jsx("div", { - className: "avatar-circle mx-auto mb-2", - style: { - width: '54px', - height: '54px', - fontSize: '18px' - }, - children: getInitials(pairedDoctor.name || pairedDoctor.doc_id) - }), /*#__PURE__*/_jsx("h6", { - className: "fw-bold text-dark mb-0", - children: pairedDoctor.name || 'Doctor' - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary-subtle text-dark border font-monospace mt-1", - children: pairedDoctor.doc_id - }), /*#__PURE__*/_jsxs("div", { - className: "text-muted small mt-1", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-phone-fill me-1 text-primary" - }), " Trusted Hospital Device"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label fw-bold small text-muted", - children: "Enter PIN or Password to Unlock" - }), /*#__PURE__*/_jsx("input", { - type: "password", - maxLength: "20", - className: "form-control text-center fs-3 letter-spacing-2", - placeholder: "••••", - value: pinInput, - autoFocus: true, - onChange: e => setPinInput(e.target.value), - onKeyUp: e => e.key === 'Enter' && handleVerifyPin() - }), /*#__PURE__*/_jsx("small", { - className: "text-muted text-center d-block mt-1", - style: { - fontSize: '11px' - }, - children: "30-day verified session active" - })] - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-primary btn-lg w-100 py-3 fw-bold shadow-sm mb-2", - onClick: handleVerifyPin, - disabled: isVerifying, - children: isVerifying ? /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm me-2" - }), "Verifying..."] - }) : /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-unlock-fill me-2" - }), " Unlock Doctor Portal"] - }) - }), /*#__PURE__*/_jsx("div", { - className: "text-center mt-3 pt-2 border-top", - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-link btn-sm text-secondary text-decoration-none p-0", - onClick: () => { - setShowPairingForm(true); - setPinError(''); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-repeat me-1" - }), " Switch Doctor / Re-Pair Device"] - }) - })] - }) : - /*#__PURE__*/ - /* ------------------------------------------------------------- - FIRST-TIME DEVICE REGISTRATION / PAIRING FORM - ------------------------------------------------------------- */ - _jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "alert alert-primary py-2 px-3 small d-flex align-items-center gap-2 mb-3", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-lock-fill fs-5 text-primary" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold", - children: "First-Time Device Pairing" - }), /*#__PURE__*/_jsx("div", { - style: { - fontSize: '11px' - }, - children: "Enter Doctor ID and Device Security Code from Doctor Master." - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label fw-bold small text-dark mb-1", - children: ["Doctor ID or Username ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "input-group", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-light", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-person-badge" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control", - placeholder: "e.g. DOC-123 or doctor username", - value: docIdInput, - onChange: e => setDocIdInput(e.target.value) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label fw-bold small text-dark mb-1", - children: ["Device Security Code ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "input-group", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-light", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-key-fill text-warning" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - maxLength: "10", - className: "form-control font-monospace fw-bold", - placeholder: "6-digit code from Admin", - value: deviceCodeInput, - onChange: e => setDeviceCodeInput(e.target.value) - })] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - style: { - fontSize: '11px' - }, - children: "Displayed on HMS Admin > Doctors" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-4", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label fw-bold small text-dark mb-1", - children: ["App PIN or Password ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "input-group", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-light", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-lock-fill" - }) - }), /*#__PURE__*/_jsx("input", { - type: "password", - maxLength: "20", - className: "form-control", - placeholder: "••••", - value: pinInput, - onChange: e => setPinInput(e.target.value), - onKeyUp: e => e.key === 'Enter' && handleVerifyPin() - })] - })] - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-primary btn-lg w-100 py-3 fw-bold shadow-sm", - onClick: handleVerifyPin, - disabled: isVerifying, - children: isVerifying ? /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm me-2" - }), "Pairing Device..."] - }) : /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-check me-2" - }), " Register Device & Unlock"] - }) - }), pairedDoctor && /*#__PURE__*/_jsx("div", { - className: "text-center mt-3 pt-2 border-top", - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-link btn-sm text-secondary text-decoration-none p-0", - onClick: () => { - setShowPairingForm(false); - setPinError(''); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-left me-1" - }), " Back to Quick Unlock"] - }) - })] - }) : - /*#__PURE__*/ - /* ------------------------------------------------------------- - INITIAL PIN CREATION (IF DOCTOR DOES NOT HAVE A PIN YET) - ------------------------------------------------------------- */ - _jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "alert alert-info py-2 small mb-3", - children: "Initial PIN Setup for Doctor Profile. Set a 4-6 digit Security PIN." - }), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label fw-bold small", - children: "New Security PIN" - }), /*#__PURE__*/_jsx("input", { - type: "password", - maxLength: "6", - className: "form-control text-center fs-3", - placeholder: "••••", - value: newPin, - onChange: e => setNewPin(e.target.value) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label fw-bold small", - children: "Confirm New PIN" - }), /*#__PURE__*/_jsx("input", { - type: "password", - maxLength: "6", - className: "form-control text-center fs-3", - placeholder: "••••", - value: confirmPin, - onChange: e => setConfirmPin(e.target.value) - })] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-success btn-lg w-100 py-3 fw-bold shadow-sm", - onClick: handleSaveNewPin, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle-fill me-2" - }), " Save PIN & Unlock"] - })] - })] - })] - })] - }); + return /*#__PURE__*/React.createElement("div", { + className: "lock-screen-overlay" + }, /*#__PURE__*/React.createElement(MobileAppsModal, { + show: showAppsModal, + onClose: () => setShowAppsModal(false), + currentApp: "doctor" + }), /*#__PURE__*/React.createElement("div", { + className: "lock-card" + }, /*#__PURE__*/React.createElement("div", { + className: "p-4 text-center bg-primary text-white position-relative", + style: { + background: 'linear-gradient(135deg, #0f172a 0%, #1e293b 100%)' + } + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-light position-absolute top-0 end-0 m-2 rounded-circle", + style: { + width: '32px', + height: '32px', + padding: 0 + }, + onClick: () => setShowAppsModal(true), + title: "HMS Mobile & PWA Apps Launcher" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-grid-3x3-gap-fill", + style: { + fontSize: '12px' + } + })), /*#__PURE__*/React.createElement("img", { + src: "/assets/img/logo.png", + alt: "Hospital Logo", + className: "d-block mx-auto mb-2", + style: { + maxHeight: '40px', + filter: 'brightness(0) invert(1)' + }, + onError: e => { + e.target.style.display = 'none'; + } + }), /*#__PURE__*/React.createElement("h5", { + className: "fw-bold mb-1" + }, "Doctor EMR Mobile Portal"), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-center gap-1 opacity-75 small" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-check text-success" + }), /*#__PURE__*/React.createElement("span", null, "Hospital Intranet & Device Protected"))), /*#__PURE__*/React.createElement("div", { + className: "p-4" + }, pinError && /*#__PURE__*/React.createElement("div", { + className: "alert alert-danger py-2 px-3 small mb-3" + }, pinError), !isSettingNewPin ? isQuickUnlock ? + /*#__PURE__*/ + /* ------------------------------------------------------------- + PAIRED DEVICE QUICK UNLOCK + ------------------------------------------------------------- */ + React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "text-center mb-4" + }, /*#__PURE__*/React.createElement("div", { + className: "avatar-circle mx-auto mb-2", + style: { + width: '54px', + height: '54px', + fontSize: '18px' + } + }, getInitials(pairedDoctor.name || pairedDoctor.doc_id)), /*#__PURE__*/React.createElement("h6", { + className: "fw-bold text-dark mb-0" + }, pairedDoctor.name || 'Doctor'), /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-dark border font-monospace mt-1" + }, pairedDoctor.doc_id), /*#__PURE__*/React.createElement("div", { + className: "text-muted small mt-1", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-phone-fill me-1 text-primary" + }), " Trusted Hospital Device")), /*#__PURE__*/React.createElement("div", { + className: "mb-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-muted" + }, "Enter PIN or Password to Unlock"), /*#__PURE__*/React.createElement("input", { + type: "password", + maxLength: "20", + className: "form-control text-center fs-3 letter-spacing-2", + placeholder: "••••", + value: pinInput, + autoFocus: true, + onChange: e => setPinInput(e.target.value), + onKeyUp: e => e.key === 'Enter' && handleVerifyPin() + }), /*#__PURE__*/React.createElement("small", { + className: "text-muted text-center d-block mt-1", + style: { + fontSize: '11px' + } + }, "30-day verified session active")), /*#__PURE__*/React.createElement("button", { + className: "btn btn-primary btn-lg w-100 py-3 fw-bold shadow-sm mb-2", + onClick: handleVerifyPin, + disabled: isVerifying + }, isVerifying ? /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm me-2" + }), "Verifying...") : /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-unlock-fill me-2" + }), " Unlock Doctor Portal")), /*#__PURE__*/React.createElement("div", { + className: "text-center mt-3 pt-2 border-top" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-link btn-sm text-secondary text-decoration-none p-0", + onClick: () => { + setShowPairingForm(true); + setPinError(''); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-repeat me-1" + }), " Switch Doctor / Re-Pair Device"))) : + /*#__PURE__*/ + /* ------------------------------------------------------------- + FIRST-TIME DEVICE REGISTRATION / PAIRING FORM + ------------------------------------------------------------- */ + React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "alert alert-primary py-2 px-3 small d-flex align-items-center gap-2 mb-3" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-lock-fill fs-5 text-primary" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold" + }, "First-Time Device Pairing"), /*#__PURE__*/React.createElement("div", { + style: { + fontSize: '11px' + } + }, "Enter Doctor ID and Device Security Code from Doctor Master."))), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-dark mb-1" + }, "Doctor ID or Username ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("div", { + className: "input-group" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-badge" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control", + placeholder: "e.g. DOC-123 or doctor username", + value: docIdInput, + onChange: e => setDocIdInput(e.target.value) + }))), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-dark mb-1" + }, "Device Security Code ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("div", { + className: "input-group" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-key-fill text-warning" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + maxLength: "10", + className: "form-control font-monospace fw-bold", + placeholder: "6-digit code from Admin", + value: deviceCodeInput, + onChange: e => setDeviceCodeInput(e.target.value) + })), /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '11px' + } + }, "Displayed on HMS Admin > Doctors")), /*#__PURE__*/React.createElement("div", { + className: "mb-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-dark mb-1" + }, "App PIN or Password ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("div", { + className: "input-group" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-lock-fill" + })), /*#__PURE__*/React.createElement("input", { + type: "password", + maxLength: "20", + className: "form-control", + placeholder: "••••", + value: pinInput, + onChange: e => setPinInput(e.target.value), + onKeyUp: e => e.key === 'Enter' && handleVerifyPin() + }))), /*#__PURE__*/React.createElement("button", { + className: "btn btn-primary btn-lg w-100 py-3 fw-bold shadow-sm", + onClick: handleVerifyPin, + disabled: isVerifying + }, isVerifying ? /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm me-2" + }), "Pairing Device...") : /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-check me-2" + }), " Register Device & Unlock")), pairedDoctor && /*#__PURE__*/React.createElement("div", { + className: "text-center mt-3 pt-2 border-top" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-link btn-sm text-secondary text-decoration-none p-0", + onClick: () => { + setShowPairingForm(false); + setPinError(''); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-left me-1" + }), " Back to Quick Unlock"))) : + /*#__PURE__*/ + /* ------------------------------------------------------------- + INITIAL PIN CREATION (IF DOCTOR DOES NOT HAVE A PIN YET) + ------------------------------------------------------------- */ + React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "alert alert-info py-2 small mb-3" + }, "Initial PIN Setup for Doctor Profile. Set a 4-6 digit Security PIN."), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small" + }, "New Security PIN"), /*#__PURE__*/React.createElement("input", { + type: "password", + maxLength: "6", + className: "form-control text-center fs-3", + placeholder: "••••", + value: newPin, + onChange: e => setNewPin(e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small" + }, "Confirm New PIN"), /*#__PURE__*/React.createElement("input", { + type: "password", + maxLength: "6", + className: "form-control text-center fs-3", + placeholder: "••••", + value: confirmPin, + onChange: e => setConfirmPin(e.target.value) + })), /*#__PURE__*/React.createElement("button", { + className: "btn btn-success btn-lg w-100 py-3 fw-bold shadow-sm", + onClick: handleSaveNewPin + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle-fill me-2" + }), " Save PIN & Unlock"))))); } // ------------------------------------------------------------- // RENDER: UNLOCKED DOCTOR PWA APP // ------------------------------------------------------------- - return /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx(MobileAppsModal, { - show: showAppsModal, - onClose: () => setShowAppsModal(false), - currentApp: "doctor" - }), /*#__PURE__*/_jsxs("header", { - className: "doctor-header d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("div", { - className: "avatar-circle", - children: getInitials(authenticatedDoctor.name) - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "mb-0 fw-bold", - children: authenticatedDoctor.name - }), /*#__PURE__*/_jsxs("small", { - className: "text-light opacity-75", - style: { - fontSize: '11px' - }, - children: ["Doctor EMR ", /*#__PURE__*/_jsx("span", { - className: "badge bg-success ms-1", - style: { - fontSize: '9px' - }, - children: "● Active Session" - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("button", { - className: "btn btn-sm btn-outline-light rounded-circle p-2", - style: { - width: '36px', - height: '36px' - }, - onClick: () => setShowAppsModal(true), - title: "HMS Mobile & PWA Apps Launcher", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-grid-3x3-gap-fill" - }) - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-sm btn-outline-light rounded-circle p-2", - style: { - width: '36px', - height: '36px' - }, - onClick: () => { - fetchOpdAppointments(authenticatedDoctor.id, opdDateMode); - fetchIpdPatients(authenticatedDoctor.id); - }, - title: "Refresh Queue", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-clockwise" - }) - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-sm btn-outline-danger rounded-circle p-2", - style: { - width: '36px', - height: '36px' - }, - onClick: handleLogout, - title: "Lock Device Access", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-lock-fill" - }) - })] - })] - }), /*#__PURE__*/_jsxs("main", { - className: "container-fluid py-3 px-2 px-md-3", - children: [!activeOpd && !activePatient ? /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "segmented-tabs mb-3", - children: [/*#__PURE__*/_jsxs("button", { - className: `segmented-tab ${mainTab === 'opd' ? 'active' : ''}`, - onClick: () => setMainTab('opd'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-calendar-check-fill me-2" - }), " OPD Appointments (", opdAppointments.length, ")"] - }), /*#__PURE__*/_jsxs("button", { - className: `segmented-tab ${mainTab === 'ipd' ? 'active' : ''}`, - onClick: () => setMainTab('ipd'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hospital-fill me-2" - }), " Admitted IPDs (", activeIpdSource.length, ")"] - })] - }), mainTab === 'opd' ? /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-between mb-3 bg-white p-2 rounded-4 border shadow-sm flex-wrap gap-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex gap-1 bg-light p-1 rounded-pill border", - children: [/*#__PURE__*/_jsxs("button", { - className: `btn btn-sm rounded-pill px-3 py-1 fw-bold ${opdDateMode === 'today' ? 'btn-primary shadow-sm' : 'btn-light text-secondary'}`, - onClick: () => { - setOpdDateMode('today'); - fetchOpdAppointments(authenticatedDoctor.id, 'today'); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-calendar-event me-1" - }), " Today's OPDs (", opdCounts.today_total || 0, ")"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm rounded-pill px-3 py-1 fw-bold ${opdDateMode === 'all' ? 'btn-primary shadow-sm' : 'btn-light text-secondary'}`, - onClick: () => { - setOpdDateMode('all'); - fetchOpdAppointments(authenticatedDoctor.id, 'all'); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-calendar3 me-1" - }), " All Dates (", opdCounts.all_total || 0, ")"] - })] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-primary-subtle text-primary border border-primary-subtle px-2 py-1 rounded-pill small", - style: { - fontSize: '11px' - }, - children: opdDateMode === 'today' ? '● Current Date Only' : '● All Appointments' - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2 mb-3 overflow-auto no-scrollbar pb-1", - children: [/*#__PURE__*/_jsxs("button", { - className: `btn btn-sm rounded-pill text-nowrap px-3 ${opdFilter === 'all' ? 'btn-primary fw-bold shadow-sm' : 'btn-white bg-white text-secondary border'}`, - onClick: () => setOpdFilter('all'), - children: ["All ", /*#__PURE__*/_jsx("span", { - className: `badge ms-1 ${opdFilter === 'all' ? 'bg-white text-primary' : 'bg-light text-dark'}`, - children: opdCounts.all - })] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm rounded-pill text-nowrap px-3 ${opdFilter === 'waiting' ? 'btn-primary fw-bold shadow-sm' : 'btn-white bg-white text-secondary border'}`, - onClick: () => setOpdFilter('waiting'), - children: ["Waiting ", /*#__PURE__*/_jsx("span", { - className: `badge ms-1 ${opdFilter === 'waiting' ? 'bg-white text-primary' : 'bg-light text-dark'}`, - children: opdCounts.waiting - })] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm rounded-pill text-nowrap px-3 ${opdFilter === 'visited' ? 'btn-info text-dark fw-bold shadow-sm' : 'btn-white bg-white text-secondary border'}`, - onClick: () => setOpdFilter('visited'), - children: ["Visited ", /*#__PURE__*/_jsx("span", { - className: `badge ms-1 ${opdFilter === 'visited' ? 'bg-white text-dark' : 'bg-light text-dark'}`, - children: opdCounts.visited - })] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm rounded-pill text-nowrap px-3 ${opdFilter === 'booked' ? 'btn-secondary fw-bold shadow-sm' : 'btn-white bg-white text-secondary border'}`, - onClick: () => setOpdFilter('booked'), - children: ["Booked ", /*#__PURE__*/_jsx("span", { - className: `badge ms-1 ${opdFilter === 'booked' ? 'bg-white text-secondary' : 'bg-light text-dark'}`, - children: opdCounts.booked - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "input-group mb-3 shadow-sm rounded-pill overflow-hidden bg-white border", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-white border-0 ps-3 text-secondary", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-search" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control border-0 py-2 shadow-none", - placeholder: "Search Patient Name, UHID, OPD Code...", - value: searchQuery, - onChange: e => setSearchQuery(e.target.value) - }), searchQuery && /*#__PURE__*/_jsx("button", { - className: "btn bg-white border-0 pe-3 text-secondary", - onClick: () => setSearchQuery(''), - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-x-circle-fill" - }) - })] - }), /*#__PURE__*/_jsx("div", { - className: "d-block d-md-none", - children: filteredOpdAppointments.length === 0 ? /*#__PURE__*/_jsxs("div", { - className: "text-center text-muted py-5 bg-white rounded-4 border shadow-sm", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-x fs-1 text-secondary opacity-50 d-block mb-2" - }), opdDateMode === 'today' ? "No OPD appointments registered for today's date." : "No OPD appointments found for selected filter."] - }) : filteredOpdAppointments.map(app => { - const statusClass = app.status_key === 'waiting' ? 'waiting' : app.status_key === 'visited' ? 'visited' : 'booked'; - return /*#__PURE__*/_jsxs("div", { - className: `mobile-patient-card ${statusClass}`, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-2 pb-2 border-bottom", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsxs("span", { - className: "queue-badge", - children: ["Q #", app.queue_no || app.opd_no || '1'] - }), /*#__PURE__*/_jsxs("span", { - className: `status-pill ${statusClass}`, - children: ["● ", app.status_label] - })] - }), /*#__PURE__*/_jsx("code", { - className: "fw-bold text-slate-800 fs-6", - children: app.opd_code - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-start gap-3 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "patient-avatar-circle", - children: getInitials(app.patient_display_name) - }), /*#__PURE__*/_jsxs("div", { - className: "flex-grow-1", - children: [/*#__PURE__*/_jsx("h5", { - className: "fw-bold text-slate-900 mb-1", - style: { - fontSize: '16px' - }, - children: app.patient_display_name - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap gap-1 align-items-center mt-1", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-slate-100 text-dark border px-2 py-1", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-fill text-primary me-1" - }), app.age_display || '47 Year', " • ", app.gender_label] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-rose-50 text-danger border border-danger-subtle px-2 py-1", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-card-text me-1" - }), app.uhid || '-'] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-emerald-50 text-success border border-success-subtle px-2 py-1", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-wallet2 me-1" - }), app.opd_type || 'Cash'] - })] - })] - })] - }), /*#__PURE__*/_jsx("div", { - children: /*#__PURE__*/_jsxs("button", { - className: "btn btn-action-primary w-100 py-2.5", - onClick: () => openOpdConsultation(app), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-medical-fill me-2" - }), " Consult Patient"] - }) - })] - }, app.opd_id); - }) - }), /*#__PURE__*/_jsx("div", { - className: "card shadow-sm border-0 d-none d-md-block rounded-4 overflow-hidden", - children: /*#__PURE__*/_jsx("div", { - className: "card-body p-0 table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-hover align-middle mb-0", - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "Status" - }), /*#__PURE__*/_jsx("th", { - children: "OPD No." - }), /*#__PURE__*/_jsx("th", { - children: "Current Patient" - }), /*#__PURE__*/_jsx("th", { - children: "Q No." - }), /*#__PURE__*/_jsx("th", { - children: "UHID" - }), /*#__PURE__*/_jsx("th", { - children: "OPD Type" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - children: "Action" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: filteredOpdAppointments.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsx("td", { - colSpan: "7", - className: "text-center text-muted py-4", - children: "No OPD appointments found for selected filter." - }) - }) : filteredOpdAppointments.map(app => { - const statusBadgeClass = app.status_key === 'waiting' ? 'bg-primary' : app.status_key === 'visited' ? 'bg-info text-dark' : app.status_key === 'booked' ? 'bg-secondary' : 'bg-danger'; - return /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: `badge ${statusBadgeClass} text-uppercase px-2 py-1`, - children: app.status_label - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("strong", { - className: "text-dark", - children: app.opd_code - }) - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-primary", - children: app.patient_display_name - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: ["(", app.age_display || '47 Year', " / ", app.gender_label, ")"] - })] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: "badge bg-dark text-white fs-6", - children: app.queue_no || app.opd_no || '1' - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("code", { - children: app.uhid || '-' - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: app.opd_type || 'Cash' - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-action-primary px-3", - onClick: () => openOpdConsultation(app), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-medical me-1" - }), " Consult"] - }) - })] - }, app.opd_id); - }) - })] - }) - }) - })] - }) : - /*#__PURE__*/ - /* ------------------------------------------------------------- - ADMITTED IPD PATIENTS LIST (ASSIGNED TO DOCTOR / ALL ADMISSIONS) - ------------------------------------------------------------- */ - _jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-between mb-3 bg-white p-2 rounded-4 border shadow-sm flex-wrap gap-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex gap-1 bg-light p-1 rounded-pill border", - children: [/*#__PURE__*/_jsxs("button", { - className: `btn btn-sm rounded-pill px-3 py-1 fw-bold ${ipdViewMode === 'mine' ? 'btn-success text-white shadow-sm' : 'btn-light text-secondary'}`, - onClick: () => setIpdViewMode('mine'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-check-fill me-1" - }), " My Assigned Patients (", myIpdPatients.length, ")"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm rounded-pill px-3 py-1 fw-bold ${ipdViewMode === 'all' ? 'btn-success text-white shadow-sm' : 'btn-light text-secondary'}`, - onClick: () => setIpdViewMode('all'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hospital-fill me-1" - }), " All Hospital Admissions (", allIpdPatients.length, ")"] - })] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-success-subtle text-success border border-success-subtle px-2 py-1 rounded-pill small", - style: { - fontSize: '11px' - }, - children: ipdViewMode === 'mine' ? '● Doctor Assignments' : '● Hospital Wide IPDs' - })] - }), /*#__PURE__*/_jsxs("div", { - className: "input-group mb-3 shadow-sm rounded-pill overflow-hidden bg-white border", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-white border-0 ps-3 text-secondary", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-search" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control border-0 py-2 shadow-none", - placeholder: "Search Admitted Patient Name, UHID, IPD Code...", - value: searchQuery, - onChange: e => setSearchQuery(e.target.value) - })] - }), /*#__PURE__*/_jsx("div", { - className: "d-block d-md-none", - children: filteredIpdPatients.length === 0 ? /*#__PURE__*/_jsxs("div", { - className: "text-center text-muted py-5 bg-white rounded-4 border shadow-sm", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hospital fs-1 d-block text-secondary opacity-50 mb-2" - }), "No Admitted IPD Patients found."] - }) : filteredIpdPatients.map(pat => /*#__PURE__*/_jsxs("div", { - className: "mobile-patient-card", - style: { - borderLeft: '6px solid #16a34a' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-2 pb-2 border-bottom", - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-success-subtle text-success border border-success-subtle px-2 py-1 rounded-pill fw-bold", - style: { - fontSize: '11px' - }, - children: "● Current Admission" - }), /*#__PURE__*/_jsx("code", { - className: "fw-bold text-dark fs-6", - children: pat.ipd_code - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-start gap-3 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "patient-avatar-circle", - style: { - background: '#f0fdf4', - color: '#16a34a', - borderColor: '#bbf7d0' - }, - children: getInitials(pat.patient_display_name) - }), /*#__PURE__*/_jsxs("div", { - className: "flex-grow-1", - children: [/*#__PURE__*/_jsx("h5", { - className: "fw-bold text-slate-900 mb-1", - style: { - fontSize: '16px' - }, - children: pat.patient_display_name - }), /*#__PURE__*/_jsx("small", { - className: "text-muted d-block mb-2", - style: { - fontSize: '12px' - }, - children: pat.rname ? `S/D/W of ${pat.rname}` : `(${pat.age_display} • ${pat.gender_label})` - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap gap-1", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-primary-subtle text-primary border border-primary-subtle px-2 py-1", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-door-closed me-1" - }), pat.bed_label] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-rose-50 text-danger border border-danger-subtle px-2 py-1", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-card-text me-1" - }), pat.uhid] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-light text-dark border px-2 py-1", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-badge me-1" - }), pat.assigned_doctors || pat.r_doc_name || `Dr. ${authenticatedDoctor.name}`] - })] - })] - })] - }), /*#__PURE__*/_jsx("div", { - children: /*#__PURE__*/_jsxs("button", { - className: "btn btn-action-success w-100 py-2.5", - onClick: () => openIpdWorkspace(pat), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-heart-pulse-fill me-2" - }), " Open Bedside Workspace"] - }) - })] - }, pat.ipd_id)) - }), /*#__PURE__*/_jsx("div", { - className: "card shadow-sm border-0 d-none d-md-block rounded-4 overflow-hidden", - children: /*#__PURE__*/_jsx("div", { - className: "card-body p-0 table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-hover align-middle mb-0", - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "IPD Code" - }), /*#__PURE__*/_jsx("th", { - children: "Name / Patient Code" - }), /*#__PURE__*/_jsx("th", { - children: "Bed No. [Type]" - }), /*#__PURE__*/_jsx("th", { - children: "Register Date" - }), /*#__PURE__*/_jsx("th", { - children: "Dr. Name" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - children: "Action" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: filteredIpdPatients.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "6", - className: "text-center text-muted py-4", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hospital fs-1 d-block text-secondary mb-2" - }), "No Admitted IPD Patients found."] - }) - }) : filteredIpdPatients.map(pat => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("strong", { - className: "text-dark d-block", - children: pat.ipd_code - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-success", - style: { - fontSize: '9px' - }, - children: "CURRENT ADMISSION" - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsxs("small", { - className: "text-danger fw-bold d-block", - children: ["[", pat.uhid, "]"] - }), /*#__PURE__*/_jsx("div", { - className: "fw-bold text-primary", - children: pat.patient_display_name - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: pat.rname ? `S/D/W of ${pat.rname}` : `(${pat.age_display} / ${pat.gender_label})` - })] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: "badge bg-primary-subtle text-primary border", - children: pat.bed_label - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("small", { - className: "text-dark fw-semibold", - children: pat.register_date || 'Today' - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("small", { - className: "text-dark fw-semibold", - children: pat.assigned_doctors || pat.r_doc_name || `Dr. ${authenticatedDoctor.name}` - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-action-success px-3", - onClick: () => openIpdWorkspace(pat), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-heart-pulse-fill me-1" - }), " Bedside Workspace"] - }) - })] - }, pat.ipd_id)) - })] - }) - }) - })] - })] - }) : activePatient ? - /*#__PURE__*/ - /* ------------------------------------------------------------- - IPD BEDSIDE WORKSPACE & CLINICAL ROUNDS - ------------------------------------------------------------- */ - _jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-3", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-dark rounded-pill px-3", - onClick: () => setActivePatient(null), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-left me-1" - }), " Back to Admitted IPDs"] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-success-subtle text-success border border-success-subtle px-3 py-1 rounded-pill fw-bold", - children: "● CURRENT ADMISSION" - })] - }), /*#__PURE__*/_jsx("div", { - className: "card shadow-sm mb-3 border-0 bg-primary text-white rounded-4", - style: { - background: 'linear-gradient(135deg, #0f172a 0%, #1e293b 100%)' - }, - children: /*#__PURE__*/_jsxs("div", { - className: "card-body p-3", - children: [/*#__PURE__*/_jsx("h5", { - className: "fw-bold mb-1", - children: activePatient.patient_display_name - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap gap-2 opacity-90 small mt-2", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-white text-dark", - children: [activePatient.age_display, " • ", activePatient.gender_label] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-white text-danger", - children: ["UHID: ", activePatient.uhid] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-white text-primary", - children: ["IPD: ", activePatient.ipd_code] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-white text-success", - children: ["Bed: ", activePatient.bed_label] - })] - })] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "card p-3 shadow-sm border-0 mb-3 rounded-4", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-2", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label fw-bold small text-dark mb-0", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-pencil-square text-primary me-1" - }), " Write Clinical Round Note or Attach Photo"] - }), /*#__PURE__*/_jsxs("label", { - className: "btn btn-sm btn-outline-primary rounded-pill px-3 py-1 fw-bold", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-camera-fill me-1" - }), " Take Photo / Attach", /*#__PURE__*/_jsx("input", { - type: "file", - accept: "image/*", - capture: "environment", - className: "d-none", - onChange: handleImageCapture - })] - })] - }), noteImagePreview && /*#__PURE__*/_jsxs("div", { - className: "position-relative mb-2 p-2 border rounded-3 bg-light text-center", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-primary position-absolute top-0 start-0 m-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-camera me-1" - }), " Handwritten Note Attached"] - }), /*#__PURE__*/_jsx("img", { - src: noteImagePreview, - alt: "Handwritten Note Preview", - className: "img-fluid rounded-3 border shadow-sm", - style: { - maxHeight: '180px', - objectFit: 'contain' - } - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-sm btn-danger position-absolute top-0 end-0 m-2 rounded-circle p-1", - style: { - width: '28px', - height: '28px' - }, - onClick: clearCapturedImage, - title: "Remove Photo", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-x-lg" - }) - })] - }), /*#__PURE__*/_jsx("textarea", { - className: "form-control mb-2 rounded-3", - rows: "3", - placeholder: "Enter clinical observations, daily round progress note, or bedside treatment instructions...", - value: newTreatmentNote, - onChange: e => setNewTreatmentNote(e.target.value) - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-action-primary btn-sm fw-bold align-self-end px-4", - onClick: handleSaveTreatmentNote, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-send-fill me-1" - }), " Save Round Note & Share with Nursing"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card p-3 shadow-sm border-0 rounded-4", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold mb-3", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-journal-medical me-1" - }), " Bedside Clinical Log History"] - }), workspaceEntries.length === 0 ? /*#__PURE__*/_jsx("p", { - className: "text-muted small", - children: "No bedside log entries recorded yet." - }) : workspaceEntries.map(e => /*#__PURE__*/_jsxs("div", { - className: "p-3 border rounded-3 bg-light mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-1", - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-secondary", - style: { - fontSize: '10px' - }, - children: e.entry_type - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted", - style: { - fontSize: '10px' - }, - children: [e.recorded_at, " - by ", e.recorded_by] - })] - }), renderNoteContent(e)] - }, e.id))] - })] - }) : activeOpd ? - /*#__PURE__*/ - /* ------------------------------------------------------------- - OPD CONSULTATION & PRESCRIPTION FORM - ------------------------------------------------------------- */ - _jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-3", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-dark rounded-pill px-3", - onClick: () => setActiveOpd(null), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-left me-1" - }), " Back to Appointments"] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-secondary fw-bold rounded-pill px-3", - onClick: () => window.open(`/Opd/opd_lettre_pdf/${activeOpd.opd_id}?layout=content_only`, '_blank'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer me-1" - }), " Print PDF"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-action-success fw-bold rounded-pill px-3", - onClick: handleSaveOpdPrescription, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle-fill me-1" - }), " Save & Mark Visited"] - })] - })] - }), /*#__PURE__*/_jsx("div", { - className: "card shadow-sm mb-3 border-0 rounded-4 text-white", - style: { - background: 'linear-gradient(135deg, #0f172a 0%, #1e293b 100%)' - }, - children: /*#__PURE__*/_jsx("div", { - className: "card-body p-3", - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-start", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h5", { - className: "fw-bold mb-1", - children: activeOpd.patient_display_name - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap gap-1 opacity-90 small mt-2", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-white text-dark", - children: [activeOpd.age_display || '47 Year', " • ", activeOpd.gender_label] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-white text-danger", - children: ["UHID: ", activeOpd.uhid] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-white text-primary", - children: ["OPD: ", activeOpd.opd_code] - })] - })] - }), /*#__PURE__*/_jsxs("span", { - className: "queue-badge fs-6", - children: ["Q #", activeOpd.queue_no || '1'] - })] - }) - }) - }), /*#__PURE__*/_jsxs("div", { - className: "card p-3 shadow-sm border-0 mb-3 rounded-4 bg-primary-subtle border-primary-subtle", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold mb-0 text-primary", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-camera-fill me-1" - }), " Attach Photo of Handwritten Rx Note"] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted d-block", - style: { - fontSize: '11px' - }, - children: "Snap a picture of your paper prescription to send to Pharmacy / Patient" - })] - }), /*#__PURE__*/_jsxs("label", { - className: "btn btn-sm btn-primary rounded-pill px-3 py-1.5 fw-bold", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-camera me-1" - }), " Snap Photo", /*#__PURE__*/_jsx("input", { - type: "file", - accept: "image/*", - capture: "environment", - className: "d-none", - onChange: handleImageCapture - })] - })] - }), noteImagePreview && /*#__PURE__*/_jsxs("div", { - className: "position-relative mt-2 p-2 border rounded-3 bg-white text-center", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-success position-absolute top-0 start-0 m-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle me-1" - }), " Rx Photo Attached"] - }), /*#__PURE__*/_jsx("img", { - src: noteImagePreview, - alt: "Handwritten Rx Preview", - className: "img-fluid rounded-3 border shadow-sm", - style: { - maxHeight: '200px', - objectFit: 'contain' - } - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-sm btn-danger position-absolute top-0 end-0 m-2 rounded-circle p-1", - style: { - width: '28px', - height: '28px' - }, - onClick: clearCapturedImage, - title: "Remove Photo", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-x-lg" - }) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card p-3 shadow-sm border-0 mb-3 rounded-4", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold mb-2 text-danger small", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-heart-pulse-fill me-1" - }), " Patient Vitals (BP, Pulse, Temp, SpO2, Weight)"] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-4 col-md-2", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1", - style: { - fontSize: '11px' - }, - children: "BP Sys/Dia" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control px-1 text-center", - placeholder: "120", - value: prescForm.bp_systolic, - onChange: e => setPrescForm({ - ...prescForm, - bp_systolic: e.target.value - }) - }), /*#__PURE__*/_jsx("span", { - className: "input-group-text px-1", - children: "/" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control px-1 text-center", - placeholder: "80", - value: prescForm.bp_diastolic, - onChange: e => setPrescForm({ - ...prescForm, - bp_diastolic: e.target.value - }) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-4 col-md-2", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1", - style: { - fontSize: '11px' - }, - children: "Pulse" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm text-center", - placeholder: "72", - value: prescForm.pulse, - onChange: e => setPrescForm({ - ...prescForm, - pulse: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-4 col-md-2", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1", - style: { - fontSize: '11px' - }, - children: "SpO2 %" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm text-center", - placeholder: "98", - value: prescForm.spo2, - onChange: e => setPrescForm({ - ...prescForm, - spo2: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-4 col-md-2", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1", - style: { - fontSize: '11px' - }, - children: "Temp °F" - }), /*#__PURE__*/_jsx("input", { - type: "number", - step: "0.1", - className: "form-control form-control-sm text-center", - placeholder: "98.6", - value: prescForm.temp, - onChange: e => setPrescForm({ - ...prescForm, - temp: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-4 col-md-2", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1", - style: { - fontSize: '11px' - }, - children: "Weight (kg)" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm text-center", - placeholder: "70", - value: prescForm.weight, - onChange: e => setPrescForm({ - ...prescForm, - weight: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-4 col-md-2", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1", - style: { - fontSize: '11px' - }, - children: "Height (cm)" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm text-center", - placeholder: "165", - value: prescForm.height, - onChange: e => setPrescForm({ - ...prescForm, - height: e.target.value - }) - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card p-3 shadow-sm border-0 mb-3 rounded-4", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label fw-bold small text-dark mb-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-chat-square-text text-primary me-1" - }), " Chief Complaints"] - }), /*#__PURE__*/_jsx("div", { - className: "d-flex gap-1 flex-wrap mb-2", - children: COMPLAINT_CHIPS.map(c => /*#__PURE__*/_jsxs("button", { - type: "button", - className: "chip-btn", - onClick: () => appendChipText('chief_complaints', c), - children: ["+ ", c] - }, c)) - }), /*#__PURE__*/_jsx("textarea", { - className: "form-control form-control-sm rounded-3", - rows: "2", - placeholder: "Enter chief complaints...", - value: prescForm.chief_complaints, - onChange: e => setPrescForm({ - ...prescForm, - chief_complaints: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card p-3 shadow-sm border-0 mb-3 rounded-4", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label fw-bold small text-dark mb-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clipboard2-pulse text-info me-1" - }), " Clinical Examination & Findings"] - }), /*#__PURE__*/_jsx("div", { - className: "d-flex gap-1 flex-wrap mb-2", - children: EXAMINATION_CHIPS.map(e => /*#__PURE__*/_jsxs("button", { - type: "button", - className: "chip-btn", - onClick: () => appendChipText('finding_examinations', e), - children: ["+ ", e] - }, e)) - }), /*#__PURE__*/_jsx("textarea", { - className: "form-control form-control-sm rounded-3", - rows: "2", - placeholder: "Enter clinical examination & findings...", - value: prescForm.finding_examinations, - onChange: e => setPrescForm({ - ...prescForm, - finding_examinations: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card p-3 shadow-sm border-0 mb-3 rounded-4", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label fw-bold small text-dark mb-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-stethoscope text-primary me-1" - }), " Provisional Diagnosis"] - }), /*#__PURE__*/_jsx("div", { - className: "d-flex gap-1 flex-wrap mb-2", - children: DIAGNOSIS_CHIPS.map(d => /*#__PURE__*/_jsxs("button", { - type: "button", - className: "chip-btn", - onClick: () => appendChipText('provisional_diagnosis', d), - children: ["+ ", d] - }, d)) - }), /*#__PURE__*/_jsx("textarea", { - className: "form-control form-control-sm rounded-3", - rows: "2", - placeholder: "Enter diagnosis...", - value: prescForm.provisional_diagnosis, - onChange: e => setPrescForm({ - ...prescForm, - provisional_diagnosis: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card p-3 shadow-sm border-0 mb-3 rounded-4", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-2", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label fw-bold small text-dark mb-0", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-capsule text-success me-1" - }), " Prescribed Medicines (Rx)"] - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-sm btn-outline-success py-0 px-2 fw-bold rounded-pill", - style: { - fontSize: '11px' - }, - onClick: () => addMedicineRow(), - children: "+ Add Drug" - })] - }), /*#__PURE__*/_jsx("div", { - className: "d-flex gap-1 flex-wrap mb-2", - children: DRUG_CHIPS.map(drug => /*#__PURE__*/_jsxs("button", { - type: "button", - className: "chip-btn", - onClick: () => addMedicineRow(drug), - children: ["+ ", drug] - }, drug)) - }), medicines.map((med, idx) => /*#__PURE__*/_jsxs("div", { - className: "p-2 border rounded-3 bg-light mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-1", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-secondary", - style: { - fontSize: '10px' - }, - children: ["Item #", idx + 1] - }), medicines.length > 1 && /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-link text-danger p-0", - onClick: () => removeMedicineRow(idx), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-trash" - }), " Remove"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2", - children: [/*#__PURE__*/_jsx("div", { - className: "col-12 col-md-4", - children: /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "Medicine / Drug Name", - value: med.drug_name, - onChange: e => updateMedicineRow(idx, 'drug_name', e.target.value) - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-4 col-md-2", - children: /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "Dosage (1 Tab)", - value: med.dosage, - onChange: e => updateMedicineRow(idx, 'dosage', e.target.value) - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-4 col-md-3", - children: /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: med.frequency, - onChange: e => updateMedicineRow(idx, 'frequency', e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "1-0-1", - children: "1-0-1 (BD)" - }), /*#__PURE__*/_jsx("option", { - value: "1-1-1", - children: "1-1-1 (TID)" - }), /*#__PURE__*/_jsx("option", { - value: "1-0-0", - children: "1-0-0 (OD Morning)" - }), /*#__PURE__*/_jsx("option", { - value: "0-0-1", - children: "0-0-1 (OD Night)" - }), /*#__PURE__*/_jsx("option", { - value: "SOS", - children: "SOS (When needed)" - }), /*#__PURE__*/_jsx("option", { - value: "STAT", - children: "STAT (Immediately)" - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-4 col-md-3", - children: /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: med.duration, - onChange: e => updateMedicineRow(idx, 'duration', e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "3 Days", - children: "3 Days" - }), /*#__PURE__*/_jsx("option", { - value: "5 Days", - children: "5 Days" - }), /*#__PURE__*/_jsx("option", { - value: "7 Days", - children: "7 Days" - }), /*#__PURE__*/_jsx("option", { - value: "15 Days", - children: "15 Days" - }), /*#__PURE__*/_jsx("option", { - value: "1 Month", - children: "1 Month" - })] - }) - })] - })] - }, idx))] - }), /*#__PURE__*/_jsxs("div", { - className: "card p-3 shadow-sm border-0 mb-3 rounded-4", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label fw-bold small text-dark mb-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-medical text-warning me-1" - }), " Lab & Pathology Orders"] - }), /*#__PURE__*/_jsx("div", { - className: "d-flex gap-1 flex-wrap mb-2", - children: LAB_CHIPS.map(lab => /*#__PURE__*/_jsxs("button", { - type: "button", - className: "chip-btn", - onClick: () => appendChipText('investigation', lab), - children: ["+ ", lab] - }, lab)) - }), /*#__PURE__*/_jsx("textarea", { - className: "form-control form-control-sm mb-3 rounded-3", - rows: "2", - placeholder: "Lab / Pathology / Radiology tests...", - value: prescForm.investigation, - onChange: e => setPrescForm({ - ...prescForm, - investigation: e.target.value - }) - }), /*#__PURE__*/_jsxs("label", { - className: "form-label fw-bold small text-dark mb-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-card-text me-1" - }), " General Advice & Instructions"] - }), /*#__PURE__*/_jsx("textarea", { - className: "form-control form-control-sm mb-3 rounded-3", - rows: "2", - placeholder: "Doctor's advice to patient...", - value: prescForm.advice, - onChange: e => setPrescForm({ - ...prescForm, - advice: e.target.value - }) - }), /*#__PURE__*/_jsxs("label", { - className: "form-label fw-bold small text-dark mb-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-calendar-event me-1" - }), " Follow-up Next Visit"] - }), /*#__PURE__*/_jsx("div", { - className: "d-flex gap-1 mb-2", - children: ['After 3 Days', 'After 7 Days', 'After 15 Days', 'After 1 Month'].map(d => /*#__PURE__*/_jsx("button", { - type: "button", - className: "chip-btn", - onClick: () => setPrescForm({ - ...prescForm, - next_visit: d - }), - children: d - }, d)) - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm rounded-3", - placeholder: "Follow-up advice", - value: prescForm.next_visit, - onChange: e => setPrescForm({ - ...prescForm, - next_visit: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2 mb-4", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-outline-secondary btn-lg w-50 fw-bold py-2.5 rounded-3 shadow-sm", - onClick: () => window.open(`/Opd/opd_lettre_pdf/${activeOpd.opd_id}?layout=content_only`, '_blank'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer me-1" - }), " Print PDF"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-action-success btn-lg w-50 fw-bold py-2.5 rounded-3 shadow-sm", - onClick: handleSaveOpdPrescription, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle-fill me-1" - }), " Save & Complete Visit"] - })] - })] - }) : null, cropSrc && /*#__PURE__*/_jsx("div", { - className: "modal show d-block", - style: { - backgroundColor: 'rgba(0,0,0,0.85)', - zIndex: 10000 - }, - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered modal-lg", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content rounded-4 border-0 shadow-lg overflow-hidden", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2", - children: [/*#__PURE__*/_jsxs("h6", { - className: "modal-title fw-bold mb-0", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-crop me-2 text-primary" - }), " Crop Document Photo"] - }), /*#__PURE__*/_jsx("button", { - className: "btn-close btn-close-white", - onClick: cancelCrop - })] - }), /*#__PURE__*/_jsx("div", { - className: "modal-body p-2 text-center bg-black", - style: { - maxHeight: '65vh', - overflow: 'hidden' - }, - children: /*#__PURE__*/_jsx("div", { - style: { - maxHeight: '60vh', - width: '100%' - }, - children: /*#__PURE__*/_jsx("img", { - ref: imageRef, - src: cropSrc, - alt: "Crop Target", - style: { - maxWidth: '100%', - display: 'block' - } - }) - }) - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer p-2 bg-dark d-flex justify-content-between align-items-center flex-wrap gap-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex gap-1", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-light px-2", - onClick: () => cropper && cropper.rotate(-90), - title: "Rotate Left 90°", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-counterclockwise" - }), " 90°"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-light px-2", - onClick: () => cropper && cropper.rotate(90), - title: "Rotate Right 90°", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-clockwise" - }), " 90°"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-light px-2", - onClick: () => cropper && cropper.reset(), - title: "Reset Crop Box", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-aspect-ratio" - }), " Reset"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2", - children: [/*#__PURE__*/_jsx("button", { - className: "btn btn-sm btn-secondary", - onClick: cancelCrop, - children: "Cancel" - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-success fw-bold px-3", - onClick: applyCrop, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-lg me-1" - }), " Apply Crop & Save Photo"] - })] - })] - })] - }) - }) - })] - })] - }); + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(MobileAppsModal, { + show: showAppsModal, + onClose: () => setShowAppsModal(false), + currentApp: "doctor" + }), /*#__PURE__*/React.createElement("header", { + className: "doctor-header d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "avatar-circle" + }, getInitials(authenticatedDoctor.name)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "mb-0 fw-bold" + }, authenticatedDoctor.name), /*#__PURE__*/React.createElement("small", { + className: "text-light opacity-75", + style: { + fontSize: '11px' + } + }, "Doctor EMR ", /*#__PURE__*/React.createElement("span", { + className: "badge bg-success ms-1", + style: { + fontSize: '9px' + } + }, "● Active Session")))), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-light rounded-circle p-2", + style: { + width: '36px', + height: '36px' + }, + onClick: () => setShowAppsModal(true), + title: "HMS Mobile & PWA Apps Launcher" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-grid-3x3-gap-fill" + })), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-light rounded-circle p-2", + style: { + width: '36px', + height: '36px' + }, + onClick: () => { + fetchOpdAppointments(authenticatedDoctor.id, opdDateMode); + fetchIpdPatients(authenticatedDoctor.id); + }, + title: "Refresh Queue" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-clockwise" + })), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-danger rounded-circle p-2", + style: { + width: '36px', + height: '36px' + }, + onClick: handleLogout, + title: "Lock Device Access" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-lock-fill" + })))), /*#__PURE__*/React.createElement("main", { + className: "container-fluid py-3 px-2 px-md-3" + }, !activeOpd && !activePatient ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "segmented-tabs mb-3" + }, /*#__PURE__*/React.createElement("button", { + className: `segmented-tab ${mainTab === 'opd' ? 'active' : ''}`, + onClick: () => setMainTab('opd') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-calendar-check-fill me-2" + }), " OPD Appointments (", opdAppointments.length, ")"), /*#__PURE__*/React.createElement("button", { + className: `segmented-tab ${mainTab === 'ipd' ? 'active' : ''}`, + onClick: () => setMainTab('ipd') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hospital-fill me-2" + }), " Admitted IPDs (", activeIpdSource.length, ")")), mainTab === 'opd' ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-between mb-3 bg-white p-2 rounded-4 border shadow-sm flex-wrap gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1 bg-light p-1 rounded-pill border" + }, /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm rounded-pill px-3 py-1 fw-bold ${opdDateMode === 'today' ? 'btn-primary shadow-sm' : 'btn-light text-secondary'}`, + onClick: () => { + setOpdDateMode('today'); + fetchOpdAppointments(authenticatedDoctor.id, 'today'); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-calendar-event me-1" + }), " Today's OPDs (", opdCounts.today_total || 0, ")"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm rounded-pill px-3 py-1 fw-bold ${opdDateMode === 'all' ? 'btn-primary shadow-sm' : 'btn-light text-secondary'}`, + onClick: () => { + setOpdDateMode('all'); + fetchOpdAppointments(authenticatedDoctor.id, 'all'); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-calendar3 me-1" + }), " All Dates (", opdCounts.all_total || 0, ")")), /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary border border-primary-subtle px-2 py-1 rounded-pill small", + style: { + fontSize: '11px' + } + }, opdDateMode === 'today' ? '● Current Date Only' : '● All Appointments')), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2 mb-3 overflow-auto no-scrollbar pb-1" + }, /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm rounded-pill text-nowrap px-3 ${opdFilter === 'all' ? 'btn-primary fw-bold shadow-sm' : 'btn-white bg-white text-secondary border'}`, + onClick: () => setOpdFilter('all') + }, "All ", /*#__PURE__*/React.createElement("span", { + className: `badge ms-1 ${opdFilter === 'all' ? 'bg-white text-primary' : 'bg-light text-dark'}` + }, opdCounts.all)), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm rounded-pill text-nowrap px-3 ${opdFilter === 'waiting' ? 'btn-primary fw-bold shadow-sm' : 'btn-white bg-white text-secondary border'}`, + onClick: () => setOpdFilter('waiting') + }, "Waiting ", /*#__PURE__*/React.createElement("span", { + className: `badge ms-1 ${opdFilter === 'waiting' ? 'bg-white text-primary' : 'bg-light text-dark'}` + }, opdCounts.waiting)), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm rounded-pill text-nowrap px-3 ${opdFilter === 'visited' ? 'btn-info text-dark fw-bold shadow-sm' : 'btn-white bg-white text-secondary border'}`, + onClick: () => setOpdFilter('visited') + }, "Visited ", /*#__PURE__*/React.createElement("span", { + className: `badge ms-1 ${opdFilter === 'visited' ? 'bg-white text-dark' : 'bg-light text-dark'}` + }, opdCounts.visited)), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm rounded-pill text-nowrap px-3 ${opdFilter === 'booked' ? 'btn-secondary fw-bold shadow-sm' : 'btn-white bg-white text-secondary border'}`, + onClick: () => setOpdFilter('booked') + }, "Booked ", /*#__PURE__*/React.createElement("span", { + className: `badge ms-1 ${opdFilter === 'booked' ? 'bg-white text-secondary' : 'bg-light text-dark'}` + }, opdCounts.booked))), /*#__PURE__*/React.createElement("div", { + className: "input-group mb-3 shadow-sm rounded-pill overflow-hidden bg-white border" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-white border-0 ps-3 text-secondary" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control border-0 py-2 shadow-none", + placeholder: "Search Patient Name, UHID, OPD Code...", + value: searchQuery, + onChange: e => setSearchQuery(e.target.value) + }), searchQuery && /*#__PURE__*/React.createElement("button", { + className: "btn bg-white border-0 pe-3 text-secondary", + onClick: () => setSearchQuery('') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x-circle-fill" + }))), /*#__PURE__*/React.createElement("div", { + className: "d-block d-md-none" + }, filteredOpdAppointments.length === 0 ? /*#__PURE__*/React.createElement("div", { + className: "text-center text-muted py-5 bg-white rounded-4 border shadow-sm" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-x fs-1 text-secondary opacity-50 d-block mb-2" + }), opdDateMode === 'today' ? "No OPD appointments registered for today's date." : "No OPD appointments found for selected filter.") : filteredOpdAppointments.map(app => { + const statusClass = app.status_key === 'waiting' ? 'waiting' : app.status_key === 'visited' ? 'visited' : 'booked'; + return /*#__PURE__*/React.createElement("div", { + key: app.opd_id, + className: `mobile-patient-card ${statusClass}` + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-2 pb-2 border-bottom" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("span", { + className: "queue-badge" + }, "Q #", app.queue_no || app.opd_no || '1'), /*#__PURE__*/React.createElement("span", { + className: `status-pill ${statusClass}` + }, "● ", app.status_label)), /*#__PURE__*/React.createElement("code", { + className: "fw-bold text-slate-800 fs-6" + }, app.opd_code)), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-start gap-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "patient-avatar-circle" + }, getInitials(app.patient_display_name)), /*#__PURE__*/React.createElement("div", { + className: "flex-grow-1" + }, /*#__PURE__*/React.createElement("h5", { + className: "fw-bold text-slate-900 mb-1", + style: { + fontSize: '16px' + } + }, app.patient_display_name), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap gap-1 align-items-center mt-1" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-slate-100 text-dark border px-2 py-1", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-fill text-primary me-1" + }), app.age_display || '47 Year', " • ", app.gender_label), /*#__PURE__*/React.createElement("span", { + className: "badge bg-rose-50 text-danger border border-danger-subtle px-2 py-1", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-card-text me-1" + }), app.uhid || '-'), /*#__PURE__*/React.createElement("span", { + className: "badge bg-emerald-50 text-success border border-success-subtle px-2 py-1", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-wallet2 me-1" + }), app.opd_type || 'Cash')))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("button", { + className: "btn btn-action-primary w-100 py-2.5", + onClick: () => openOpdConsultation(app) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-medical-fill me-2" + }), " Consult Patient"))); + })), /*#__PURE__*/React.createElement("div", { + className: "card shadow-sm border-0 d-none d-md-block rounded-4 overflow-hidden" + }, /*#__PURE__*/React.createElement("div", { + className: "card-body p-0 table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-hover align-middle mb-0" + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "Status"), /*#__PURE__*/React.createElement("th", null, "OPD No."), /*#__PURE__*/React.createElement("th", null, "Current Patient"), /*#__PURE__*/React.createElement("th", null, "Q No."), /*#__PURE__*/React.createElement("th", null, "UHID"), /*#__PURE__*/React.createElement("th", null, "OPD Type"), /*#__PURE__*/React.createElement("th", { + className: "text-center" + }, "Action"))), /*#__PURE__*/React.createElement("tbody", null, filteredOpdAppointments.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "7", + className: "text-center text-muted py-4" + }, "No OPD appointments found for selected filter.")) : filteredOpdAppointments.map(app => { + const statusBadgeClass = app.status_key === 'waiting' ? 'bg-primary' : app.status_key === 'visited' ? 'bg-info text-dark' : app.status_key === 'booked' ? 'bg-secondary' : 'bg-danger'; + return /*#__PURE__*/React.createElement("tr", { + key: app.opd_id + }, /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: `badge ${statusBadgeClass} text-uppercase px-2 py-1` + }, app.status_label)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("strong", { + className: "text-dark" + }, app.opd_code)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-primary" + }, app.patient_display_name), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "(", app.age_display || '47 Year', " / ", app.gender_label, ")")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-dark text-white fs-6" + }, app.queue_no || app.opd_no || '1')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("code", null, app.uhid || '-')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, app.opd_type || 'Cash')), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-action-primary px-3", + onClick: () => openOpdConsultation(app) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-medical me-1" + }), " Consult"))); + })))))) : + /*#__PURE__*/ + /* ------------------------------------------------------------- + ADMITTED IPD PATIENTS LIST (ASSIGNED TO DOCTOR / ALL ADMISSIONS) + ------------------------------------------------------------- */ + React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-between mb-3 bg-white p-2 rounded-4 border shadow-sm flex-wrap gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1 bg-light p-1 rounded-pill border" + }, /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm rounded-pill px-3 py-1 fw-bold ${ipdViewMode === 'mine' ? 'btn-success text-white shadow-sm' : 'btn-light text-secondary'}`, + onClick: () => setIpdViewMode('mine') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-check-fill me-1" + }), " My Assigned Patients (", myIpdPatients.length, ")"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm rounded-pill px-3 py-1 fw-bold ${ipdViewMode === 'all' ? 'btn-success text-white shadow-sm' : 'btn-light text-secondary'}`, + onClick: () => setIpdViewMode('all') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hospital-fill me-1" + }), " All Hospital Admissions (", allIpdPatients.length, ")")), /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success border border-success-subtle px-2 py-1 rounded-pill small", + style: { + fontSize: '11px' + } + }, ipdViewMode === 'mine' ? '● Doctor Assignments' : '● Hospital Wide IPDs')), /*#__PURE__*/React.createElement("div", { + className: "input-group mb-3 shadow-sm rounded-pill overflow-hidden bg-white border" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-white border-0 ps-3 text-secondary" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control border-0 py-2 shadow-none", + placeholder: "Search Admitted Patient Name, UHID, IPD Code...", + value: searchQuery, + onChange: e => setSearchQuery(e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "d-block d-md-none" + }, filteredIpdPatients.length === 0 ? /*#__PURE__*/React.createElement("div", { + className: "text-center text-muted py-5 bg-white rounded-4 border shadow-sm" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hospital fs-1 d-block text-secondary opacity-50 mb-2" + }), "No Admitted IPD Patients found.") : filteredIpdPatients.map(pat => /*#__PURE__*/React.createElement("div", { + key: pat.ipd_id, + className: "mobile-patient-card", + style: { + borderLeft: '6px solid #16a34a' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-2 pb-2 border-bottom" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success border border-success-subtle px-2 py-1 rounded-pill fw-bold", + style: { + fontSize: '11px' + } + }, "● Current Admission"), /*#__PURE__*/React.createElement("code", { + className: "fw-bold text-dark fs-6" + }, pat.ipd_code)), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-start gap-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "patient-avatar-circle", + style: { + background: '#f0fdf4', + color: '#16a34a', + borderColor: '#bbf7d0' + } + }, getInitials(pat.patient_display_name)), /*#__PURE__*/React.createElement("div", { + className: "flex-grow-1" + }, /*#__PURE__*/React.createElement("h5", { + className: "fw-bold text-slate-900 mb-1", + style: { + fontSize: '16px' + } + }, pat.patient_display_name), /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block mb-2", + style: { + fontSize: '12px' + } + }, pat.rname ? `S/D/W of ${pat.rname}` : `(${pat.age_display} • ${pat.gender_label})`), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap gap-1" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary border border-primary-subtle px-2 py-1", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-door-closed me-1" + }), pat.bed_label), /*#__PURE__*/React.createElement("span", { + className: "badge bg-rose-50 text-danger border border-danger-subtle px-2 py-1", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-card-text me-1" + }), pat.uhid), /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border px-2 py-1", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-badge me-1" + }), pat.assigned_doctors || pat.r_doc_name || `Dr. ${authenticatedDoctor.name}`)))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("button", { + className: "btn btn-action-success w-100 py-2.5", + onClick: () => openIpdWorkspace(pat) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-heart-pulse-fill me-2" + }), " Open Bedside Workspace"))))), /*#__PURE__*/React.createElement("div", { + className: "card shadow-sm border-0 d-none d-md-block rounded-4 overflow-hidden" + }, /*#__PURE__*/React.createElement("div", { + className: "card-body p-0 table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-hover align-middle mb-0" + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "IPD Code"), /*#__PURE__*/React.createElement("th", null, "Name / Patient Code"), /*#__PURE__*/React.createElement("th", null, "Bed No. [Type]"), /*#__PURE__*/React.createElement("th", null, "Register Date"), /*#__PURE__*/React.createElement("th", null, "Dr. Name"), /*#__PURE__*/React.createElement("th", { + className: "text-center" + }, "Action"))), /*#__PURE__*/React.createElement("tbody", null, filteredIpdPatients.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "6", + className: "text-center text-muted py-4" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hospital fs-1 d-block text-secondary mb-2" + }), "No Admitted IPD Patients found.")) : filteredIpdPatients.map(pat => /*#__PURE__*/React.createElement("tr", { + key: pat.ipd_id + }, /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("strong", { + className: "text-dark d-block" + }, pat.ipd_code), /*#__PURE__*/React.createElement("span", { + className: "badge bg-success", + style: { + fontSize: '9px' + } + }, "CURRENT ADMISSION")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("small", { + className: "text-danger fw-bold d-block" + }, "[", pat.uhid, "]"), /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-primary" + }, pat.patient_display_name), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, pat.rname ? `S/D/W of ${pat.rname}` : `(${pat.age_display} / ${pat.gender_label})`)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary border" + }, pat.bed_label)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("small", { + className: "text-dark fw-semibold" + }, pat.register_date || 'Today')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("small", { + className: "text-dark fw-semibold" + }, pat.assigned_doctors || pat.r_doc_name || `Dr. ${authenticatedDoctor.name}`)), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-action-success px-3", + onClick: () => openIpdWorkspace(pat) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-heart-pulse-fill me-1" + }), " Bedside Workspace")))))))))) : activePatient ? + /*#__PURE__*/ + /* ------------------------------------------------------------- + IPD BEDSIDE WORKSPACE & CLINICAL ROUNDS + ------------------------------------------------------------- */ + React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-3" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-dark rounded-pill px-3", + onClick: () => setActivePatient(null) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-left me-1" + }), " Back to Admitted IPDs"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success border border-success-subtle px-3 py-1 rounded-pill fw-bold" + }, "● CURRENT ADMISSION")), /*#__PURE__*/React.createElement("div", { + className: "card shadow-sm mb-3 border-0 bg-primary text-white rounded-4", + style: { + background: 'linear-gradient(135deg, #0f172a 0%, #1e293b 100%)' + } + }, /*#__PURE__*/React.createElement("div", { + className: "card-body p-3" + }, /*#__PURE__*/React.createElement("h5", { + className: "fw-bold mb-1" + }, activePatient.patient_display_name), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap gap-2 opacity-90 small mt-2" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-white text-dark" + }, activePatient.age_display, " • ", activePatient.gender_label), /*#__PURE__*/React.createElement("span", { + className: "badge bg-white text-danger" + }, "UHID: ", activePatient.uhid), /*#__PURE__*/React.createElement("span", { + className: "badge bg-white text-primary" + }, "IPD: ", activePatient.ipd_code), /*#__PURE__*/React.createElement("span", { + className: "badge bg-white text-success" + }, "Bed: ", activePatient.bed_label)))), /*#__PURE__*/React.createElement("div", { + className: "card p-3 shadow-sm border-0 mb-3 rounded-4" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-dark mb-0" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-pencil-square text-primary me-1" + }), " Write Clinical Round Note or Attach Photo"), /*#__PURE__*/React.createElement("label", { + className: "btn btn-sm btn-outline-primary rounded-pill px-3 py-1 fw-bold", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-camera-fill me-1" + }), " Take Photo / Attach", /*#__PURE__*/React.createElement("input", { + type: "file", + accept: "image/*", + capture: "environment", + className: "d-none", + onChange: handleImageCapture + }))), noteImagePreview && /*#__PURE__*/React.createElement("div", { + className: "position-relative mb-2 p-2 border rounded-3 bg-light text-center" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary position-absolute top-0 start-0 m-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-camera me-1" + }), " Handwritten Note Attached"), /*#__PURE__*/React.createElement("img", { + src: noteImagePreview, + alt: "Handwritten Note Preview", + className: "img-fluid rounded-3 border shadow-sm", + style: { + maxHeight: '180px', + objectFit: 'contain' + } + }), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-danger position-absolute top-0 end-0 m-2 rounded-circle p-1", + style: { + width: '28px', + height: '28px' + }, + onClick: clearCapturedImage, + title: "Remove Photo" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x-lg" + }))), /*#__PURE__*/React.createElement("textarea", { + className: "form-control mb-2 rounded-3", + rows: "3", + placeholder: "Enter clinical observations, daily round progress note, or bedside treatment instructions...", + value: newTreatmentNote, + onChange: e => setNewTreatmentNote(e.target.value) + }), /*#__PURE__*/React.createElement("button", { + className: "btn btn-action-primary btn-sm fw-bold align-self-end px-4", + onClick: handleSaveTreatmentNote + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-send-fill me-1" + }), " Save Round Note & Share with Nursing")), /*#__PURE__*/React.createElement("div", { + className: "card p-3 shadow-sm border-0 rounded-4" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold mb-3" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-journal-medical me-1" + }), " Bedside Clinical Log History"), workspaceEntries.length === 0 ? /*#__PURE__*/React.createElement("p", { + className: "text-muted small" + }, "No bedside log entries recorded yet.") : workspaceEntries.map(e => /*#__PURE__*/React.createElement("div", { + key: e.id, + className: "p-3 border rounded-3 bg-light mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-1" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary", + style: { + fontSize: '10px' + } + }, e.entry_type), /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '10px' + } + }, e.recorded_at, " - by ", e.recorded_by)), renderNoteContent(e))))) : activeOpd ? + /*#__PURE__*/ + /* ------------------------------------------------------------- + OPD CONSULTATION & PRESCRIPTION FORM + ------------------------------------------------------------- */ + React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-3" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-dark rounded-pill px-3", + onClick: () => setActiveOpd(null) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-left me-1" + }), " Back to Appointments"), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-secondary fw-bold rounded-pill px-3", + onClick: () => window.open(`/Opd/opd_lettre_pdf/${activeOpd.opd_id}?layout=content_only`, '_blank') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer me-1" + }), " Print PDF"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-action-success fw-bold rounded-pill px-3", + onClick: handleSaveOpdPrescription + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle-fill me-1" + }), " Save & Mark Visited"))), /*#__PURE__*/React.createElement("div", { + className: "card shadow-sm mb-3 border-0 rounded-4 text-white", + style: { + background: 'linear-gradient(135deg, #0f172a 0%, #1e293b 100%)' + } + }, /*#__PURE__*/React.createElement("div", { + className: "card-body p-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-start" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h5", { + className: "fw-bold mb-1" + }, activeOpd.patient_display_name), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap gap-1 opacity-90 small mt-2" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-white text-dark" + }, activeOpd.age_display || '47 Year', " • ", activeOpd.gender_label), /*#__PURE__*/React.createElement("span", { + className: "badge bg-white text-danger" + }, "UHID: ", activeOpd.uhid), /*#__PURE__*/React.createElement("span", { + className: "badge bg-white text-primary" + }, "OPD: ", activeOpd.opd_code))), /*#__PURE__*/React.createElement("span", { + className: "queue-badge fs-6" + }, "Q #", activeOpd.queue_no || '1')))), /*#__PURE__*/React.createElement("div", { + className: "card p-3 shadow-sm border-0 mb-3 rounded-4 bg-primary-subtle border-primary-subtle" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold mb-0 text-primary" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-camera-fill me-1" + }), " Attach Photo of Handwritten Rx Note"), /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block", + style: { + fontSize: '11px' + } + }, "Snap a picture of your paper prescription to send to Pharmacy / Patient")), /*#__PURE__*/React.createElement("label", { + className: "btn btn-sm btn-primary rounded-pill px-3 py-1.5 fw-bold" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-camera me-1" + }), " Snap Photo", /*#__PURE__*/React.createElement("input", { + type: "file", + accept: "image/*", + capture: "environment", + className: "d-none", + onChange: handleImageCapture + }))), noteImagePreview && /*#__PURE__*/React.createElement("div", { + className: "position-relative mt-2 p-2 border rounded-3 bg-white text-center" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-success position-absolute top-0 start-0 m-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle me-1" + }), " Rx Photo Attached"), /*#__PURE__*/React.createElement("img", { + src: noteImagePreview, + alt: "Handwritten Rx Preview", + className: "img-fluid rounded-3 border shadow-sm", + style: { + maxHeight: '200px', + objectFit: 'contain' + } + }), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-danger position-absolute top-0 end-0 m-2 rounded-circle p-1", + style: { + width: '28px', + height: '28px' + }, + onClick: clearCapturedImage, + title: "Remove Photo" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x-lg" + })))), /*#__PURE__*/React.createElement("div", { + className: "card p-3 shadow-sm border-0 mb-3 rounded-4" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold mb-2 text-danger small" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-heart-pulse-fill me-1" + }), " Patient Vitals (BP, Pulse, Temp, SpO2, Weight)"), /*#__PURE__*/React.createElement("div", { + className: "row g-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-4 col-md-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1", + style: { + fontSize: '11px' + } + }, "BP Sys/Dia"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control px-1 text-center", + placeholder: "120", + value: prescForm.bp_systolic, + onChange: e => setPrescForm({ + ...prescForm, + bp_systolic: e.target.value + }) + }), /*#__PURE__*/React.createElement("span", { + className: "input-group-text px-1" + }, "/"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control px-1 text-center", + placeholder: "80", + value: prescForm.bp_diastolic, + onChange: e => setPrescForm({ + ...prescForm, + bp_diastolic: e.target.value + }) + }))), /*#__PURE__*/React.createElement("div", { + className: "col-4 col-md-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1", + style: { + fontSize: '11px' + } + }, "Pulse"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm text-center", + placeholder: "72", + value: prescForm.pulse, + onChange: e => setPrescForm({ + ...prescForm, + pulse: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-4 col-md-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1", + style: { + fontSize: '11px' + } + }, "SpO2 %"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm text-center", + placeholder: "98", + value: prescForm.spo2, + onChange: e => setPrescForm({ + ...prescForm, + spo2: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-4 col-md-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1", + style: { + fontSize: '11px' + } + }, "Temp °F"), /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.1", + className: "form-control form-control-sm text-center", + placeholder: "98.6", + value: prescForm.temp, + onChange: e => setPrescForm({ + ...prescForm, + temp: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-4 col-md-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1", + style: { + fontSize: '11px' + } + }, "Weight (kg)"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm text-center", + placeholder: "70", + value: prescForm.weight, + onChange: e => setPrescForm({ + ...prescForm, + weight: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-4 col-md-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1", + style: { + fontSize: '11px' + } + }, "Height (cm)"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm text-center", + placeholder: "165", + value: prescForm.height, + onChange: e => setPrescForm({ + ...prescForm, + height: e.target.value + }) + })))), /*#__PURE__*/React.createElement("div", { + className: "card p-3 shadow-sm border-0 mb-3 rounded-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-dark mb-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-chat-square-text text-primary me-1" + }), " Chief Complaints"), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1 flex-wrap mb-2" + }, COMPLAINT_CHIPS.map(c => /*#__PURE__*/React.createElement("button", { + key: c, + type: "button", + className: "chip-btn", + onClick: () => appendChipText('chief_complaints', c) + }, "+ ", c))), /*#__PURE__*/React.createElement("textarea", { + className: "form-control form-control-sm rounded-3", + rows: "2", + placeholder: "Enter chief complaints...", + value: prescForm.chief_complaints, + onChange: e => setPrescForm({ + ...prescForm, + chief_complaints: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "card p-3 shadow-sm border-0 mb-3 rounded-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-dark mb-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clipboard2-pulse text-info me-1" + }), " Clinical Examination & Findings"), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1 flex-wrap mb-2" + }, EXAMINATION_CHIPS.map(e => /*#__PURE__*/React.createElement("button", { + key: e, + type: "button", + className: "chip-btn", + onClick: () => appendChipText('finding_examinations', e) + }, "+ ", e))), /*#__PURE__*/React.createElement("textarea", { + className: "form-control form-control-sm rounded-3", + rows: "2", + placeholder: "Enter clinical examination & findings...", + value: prescForm.finding_examinations, + onChange: e => setPrescForm({ + ...prescForm, + finding_examinations: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "card p-3 shadow-sm border-0 mb-3 rounded-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-dark mb-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-stethoscope text-primary me-1" + }), " Provisional Diagnosis"), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1 flex-wrap mb-2" + }, DIAGNOSIS_CHIPS.map(d => /*#__PURE__*/React.createElement("button", { + key: d, + type: "button", + className: "chip-btn", + onClick: () => appendChipText('provisional_diagnosis', d) + }, "+ ", d))), /*#__PURE__*/React.createElement("textarea", { + className: "form-control form-control-sm rounded-3", + rows: "2", + placeholder: "Enter diagnosis...", + value: prescForm.provisional_diagnosis, + onChange: e => setPrescForm({ + ...prescForm, + provisional_diagnosis: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "card p-3 shadow-sm border-0 mb-3 rounded-4" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-dark mb-0" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-capsule text-success me-1" + }), " Prescribed Medicines (Rx)"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-success py-0 px-2 fw-bold rounded-pill", + style: { + fontSize: '11px' + }, + onClick: () => addMedicineRow() + }, "+ Add Drug")), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1 flex-wrap mb-2" + }, DRUG_CHIPS.map(drug => /*#__PURE__*/React.createElement("button", { + key: drug, + type: "button", + className: "chip-btn", + onClick: () => addMedicineRow(drug) + }, "+ ", drug))), medicines.map((med, idx) => /*#__PURE__*/React.createElement("div", { + key: idx, + className: "p-2 border rounded-3 bg-light mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-1" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary", + style: { + fontSize: '10px' + } + }, "Item #", idx + 1), medicines.length > 1 && /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-link text-danger p-0", + onClick: () => removeMedicineRow(idx) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-trash" + }), " Remove")), /*#__PURE__*/React.createElement("div", { + className: "row g-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-12 col-md-4" + }, /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "Medicine / Drug Name", + value: med.drug_name, + onChange: e => updateMedicineRow(idx, 'drug_name', e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "col-4 col-md-2" + }, /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "Dosage (1 Tab)", + value: med.dosage, + onChange: e => updateMedicineRow(idx, 'dosage', e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "col-4 col-md-3" + }, /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: med.frequency, + onChange: e => updateMedicineRow(idx, 'frequency', e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "1-0-1" + }, "1-0-1 (BD)"), /*#__PURE__*/React.createElement("option", { + value: "1-1-1" + }, "1-1-1 (TID)"), /*#__PURE__*/React.createElement("option", { + value: "1-0-0" + }, "1-0-0 (OD Morning)"), /*#__PURE__*/React.createElement("option", { + value: "0-0-1" + }, "0-0-1 (OD Night)"), /*#__PURE__*/React.createElement("option", { + value: "SOS" + }, "SOS (When needed)"), /*#__PURE__*/React.createElement("option", { + value: "STAT" + }, "STAT (Immediately)"))), /*#__PURE__*/React.createElement("div", { + className: "col-4 col-md-3" + }, /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: med.duration, + onChange: e => updateMedicineRow(idx, 'duration', e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "3 Days" + }, "3 Days"), /*#__PURE__*/React.createElement("option", { + value: "5 Days" + }, "5 Days"), /*#__PURE__*/React.createElement("option", { + value: "7 Days" + }, "7 Days"), /*#__PURE__*/React.createElement("option", { + value: "15 Days" + }, "15 Days"), /*#__PURE__*/React.createElement("option", { + value: "1 Month" + }, "1 Month"))))))), /*#__PURE__*/React.createElement("div", { + className: "card p-3 shadow-sm border-0 mb-3 rounded-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-dark mb-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-medical text-warning me-1" + }), " Lab & Pathology Orders"), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1 flex-wrap mb-2" + }, LAB_CHIPS.map(lab => /*#__PURE__*/React.createElement("button", { + key: lab, + type: "button", + className: "chip-btn", + onClick: () => appendChipText('investigation', lab) + }, "+ ", lab))), /*#__PURE__*/React.createElement("textarea", { + className: "form-control form-control-sm mb-3 rounded-3", + rows: "2", + placeholder: "Lab / Pathology / Radiology tests...", + value: prescForm.investigation, + onChange: e => setPrescForm({ + ...prescForm, + investigation: e.target.value + }) + }), /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-dark mb-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-card-text me-1" + }), " General Advice & Instructions"), /*#__PURE__*/React.createElement("textarea", { + className: "form-control form-control-sm mb-3 rounded-3", + rows: "2", + placeholder: "Doctor's advice to patient...", + value: prescForm.advice, + onChange: e => setPrescForm({ + ...prescForm, + advice: e.target.value + }) + }), /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-dark mb-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-calendar-event me-1" + }), " Follow-up Next Visit"), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1 mb-2" + }, ['After 3 Days', 'After 7 Days', 'After 15 Days', 'After 1 Month'].map(d => /*#__PURE__*/React.createElement("button", { + key: d, + type: "button", + className: "chip-btn", + onClick: () => setPrescForm({ + ...prescForm, + next_visit: d + }) + }, d))), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm rounded-3", + placeholder: "Follow-up advice", + value: prescForm.next_visit, + onChange: e => setPrescForm({ + ...prescForm, + next_visit: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2 mb-4" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-secondary btn-lg w-50 fw-bold py-2.5 rounded-3 shadow-sm", + onClick: () => window.open(`/Opd/opd_lettre_pdf/${activeOpd.opd_id}?layout=content_only`, '_blank') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer me-1" + }), " Print PDF"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-action-success btn-lg w-50 fw-bold py-2.5 rounded-3 shadow-sm", + onClick: handleSaveOpdPrescription + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle-fill me-1" + }), " Save & Complete Visit"))) : null, cropSrc && /*#__PURE__*/React.createElement("div", { + className: "modal show d-block", + style: { + backgroundColor: 'rgba(0,0,0,0.85)', + zIndex: 10000 + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered modal-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content rounded-4 border-0 shadow-lg overflow-hidden" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2" + }, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold mb-0" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-crop me-2 text-primary" + }), " Crop Document Photo"), /*#__PURE__*/React.createElement("button", { + className: "btn-close btn-close-white", + onClick: cancelCrop + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-2 text-center bg-black", + style: { + maxHeight: '65vh', + overflow: 'hidden' + } + }, /*#__PURE__*/React.createElement("div", { + style: { + maxHeight: '60vh', + width: '100%' + } + }, /*#__PURE__*/React.createElement("img", { + ref: imageRef, + src: cropSrc, + alt: "Crop Target", + style: { + maxWidth: '100%', + display: 'block' + } + }))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer p-2 bg-dark d-flex justify-content-between align-items-center flex-wrap gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-light px-2", + onClick: () => cropper && cropper.rotate(-90), + title: "Rotate Left 90°" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-counterclockwise" + }), " 90°"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-light px-2", + onClick: () => cropper && cropper.rotate(90), + title: "Rotate Right 90°" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-clockwise" + }), " 90°"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-light px-2", + onClick: () => cropper && cropper.reset(), + title: "Reset Crop Box" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-aspect-ratio" + }), " Reset")), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-secondary", + onClick: cancelCrop + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-success fw-bold px-3", + onClick: applyCrop + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-lg me-1" + }), " Apply Crop & Save Photo")))))))); } const root = ReactDOM.createRoot(document.getElementById('root')); -root.render(/*#__PURE__*/_jsx(DoctorApp, {})); \ No newline at end of file +root.render(/*#__PURE__*/React.createElement(DoctorApp, null)); \ No newline at end of file diff --git a/public/App/MedicalStore/medicalstore-app.bundle.js b/public/App/MedicalStore/medicalstore-app.bundle.js index cbac7b6..a67e004 100644 --- a/public/App/MedicalStore/medicalstore-app.bundle.js +++ b/public/App/MedicalStore/medicalstore-app.bundle.js @@ -1,4 +1,3 @@ -import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; const { useState, useEffect, @@ -40,37 +39,32 @@ class ErrorBoundary extends React.Component { } render() { if (this.state.hasError) { - return /*#__PURE__*/_jsxs("div", { + return /*#__PURE__*/React.createElement("div", { className: "d-flex flex-column align-items-center justify-content-center vh-100 bg-slate-900 text-white p-4 text-center", style: { background: '#0f172a' - }, - children: [/*#__PURE__*/_jsx("div", { - className: "bg-danger text-white rounded-circle p-3 mb-3 d-flex align-items-center justify-content-center", - style: { - width: 64, - height: 64 - }, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-exclamation-octagon fs-2" - }) - }), /*#__PURE__*/_jsx("h4", { - className: "fw-bold", - children: "Counter Desk Interruption" - }), /*#__PURE__*/_jsx("p", { - className: "text-secondary mb-3", - style: { - maxWidth: 500 - }, - children: this.state.error?.message || 'An unexpected error occurred while rendering the counter desk.' - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-outline-light btn-sm", - onClick: () => window.location.reload(), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-clockwise me-1" - }), " Reload Counter Desk"] - })] - }); + } + }, /*#__PURE__*/React.createElement("div", { + className: "bg-danger text-white rounded-circle p-3 mb-3 d-flex align-items-center justify-content-center", + style: { + width: 64, + height: 64 + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-exclamation-octagon fs-2" + })), /*#__PURE__*/React.createElement("h4", { + className: "fw-bold" + }, "Counter Desk Interruption"), /*#__PURE__*/React.createElement("p", { + className: "text-secondary mb-3", + style: { + maxWidth: 500 + } + }, this.state.error?.message || 'An unexpected error occurred while rendering the counter desk.'), /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-light btn-sm", + onClick: () => window.location.reload() + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-clockwise me-1" + }), " Reload Counter Desk")); } return this.props.children; } @@ -314,897 +308,733 @@ function App() { setTimeout(() => setNotification(null), 4000); }; if (isLoadingStores && !activeStore) { - return /*#__PURE__*/_jsxs("div", { + return /*#__PURE__*/React.createElement("div", { className: "d-flex flex-column align-items-center justify-content-center vh-100 bg-slate-900 text-white", style: { background: '#0f172a' + } + }, /*#__PURE__*/React.createElement("div", { + className: "spinner-border text-info mb-3", + style: { + width: '3rem', + height: '3rem' }, - children: [/*#__PURE__*/_jsx("div", { - className: "spinner-border text-info mb-3", - style: { - width: '3rem', - height: '3rem' - }, - role: "status", - children: /*#__PURE__*/_jsx("span", { - className: "visually-hidden", - children: "Loading Store Counter..." - }) - }), /*#__PURE__*/_jsx("h5", { - className: "fw-bold tracking-wide", - children: "HMS Multi-Building Medical Store" - }), /*#__PURE__*/_jsx("p", { - className: "text-secondary small", - children: "Synchronizing pharmacy counters, terminal licenses & ABDM..." - })] - }); + role: "status" + }, /*#__PURE__*/React.createElement("span", { + className: "visually-hidden" + }, "Loading Store Counter...")), /*#__PURE__*/React.createElement("h5", { + className: "fw-bold tracking-wide" + }, "HMS Multi-Building Medical Store"), /*#__PURE__*/React.createElement("p", { + className: "text-secondary small" + }, "Synchronizing pharmacy counters, terminal licenses & ABDM...")); } if (!activeStore) { - return /*#__PURE__*/_jsxs("div", { + return /*#__PURE__*/React.createElement("div", { className: "d-flex flex-column align-items-center justify-content-center vh-100 bg-slate-900 text-white p-4 text-center", style: { background: '#0f172a' - }, - children: [/*#__PURE__*/_jsx("div", { - className: "bg-danger text-white rounded-circle p-3 mb-3 d-flex align-items-center justify-content-center", - style: { - width: 64, - height: 64 - }, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-exclamation-triangle fs-2" - }) - }), /*#__PURE__*/_jsx("h4", { - className: "fw-bold", - children: "Medical Store Not Found" - }), /*#__PURE__*/_jsxs("p", { - className: "text-secondary mb-3", - style: { - maxWidth: 480 - }, - children: ["Could not locate any active pharmacy store counter for ", /*#__PURE__*/_jsxs("code", { - children: ["/", storeSlugFromUrl || 'default'] - }), ". Please verify store configuration in HMS Admin."] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2", - children: [/*#__PURE__*/_jsxs("a", { - href: "/MedicalStore/storeA", - className: "btn btn-outline-light btn-sm", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shop me-1" - }), " Try Main Store (storeA)"] - }), /*#__PURE__*/_jsxs("a", { - href: "/app/admin/medical-stores", - className: "btn btn-primary-custom btn-sm", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-gear me-1" - }), " Open HMS Store Settings"] - })] - })] - }); + } + }, /*#__PURE__*/React.createElement("div", { + className: "bg-danger text-white rounded-circle p-3 mb-3 d-flex align-items-center justify-content-center", + style: { + width: 64, + height: 64 + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-exclamation-triangle fs-2" + })), /*#__PURE__*/React.createElement("h4", { + className: "fw-bold" + }, "Medical Store Not Found"), /*#__PURE__*/React.createElement("p", { + className: "text-secondary mb-3", + style: { + maxWidth: 480 + } + }, "Could not locate any active pharmacy store counter for ", /*#__PURE__*/React.createElement("code", null, "/", storeSlugFromUrl || 'default'), ". Please verify store configuration in HMS Admin."), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2" + }, /*#__PURE__*/React.createElement("a", { + href: "/MedicalStore/storeA", + className: "btn btn-outline-light btn-sm" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shop me-1" + }), " Try Main Store (storeA)"), /*#__PURE__*/React.createElement("a", { + href: "/app/admin/medical-stores", + className: "btn btn-primary-custom btn-sm" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-gear me-1" + }), " Open HMS Store Settings"))); } - return /*#__PURE__*/_jsxs("div", { - children: [!isDeviceAuthorized && activeStore && /*#__PURE__*/_jsx("div", { - className: "machine-lock-backdrop", - children: /*#__PURE__*/_jsxs("div", { - className: "card shadow-lg border-0", - style: { - maxWidth: 460, - width: '100%', - borderRadius: 16 - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header bg-dark text-white p-3 text-center border-0", - style: { - borderTopLeftRadius: 16, - borderTopRightRadius: 16 - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-lock-fill text-warning fs-1 d-block mb-1" - }), /*#__PURE__*/_jsx("h5", { - className: "fw-bold mb-0", - children: "Terminal Machine Verification" - }), /*#__PURE__*/_jsx("small", { - className: "text-slate-300", - style: { - color: '#94a3b8' - }, - children: "Counter Authorization Required" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card-body p-4", - children: [/*#__PURE__*/_jsxs("div", { - className: "text-center mb-3", - children: [/*#__PURE__*/_jsx("h6", { - className: "fw-bold text-dark", - children: activeStore.store_name - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted d-block", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-geo-alt me-1" - }), activeStore.building_name || 'Main Hospital', " • ", activeStore.floor_no || 'Ground Floor'] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-primary-subtle text-primary border border-primary-subtle px-2 py-1 mt-1", - children: ["Link: MedicalStore/", activeStore.store_slug] - })] - }), /*#__PURE__*/_jsxs("p", { - className: "small text-muted text-center mb-3", - children: ["This computer terminal is accessing the counter for the first time. Please enter the ", /*#__PURE__*/_jsx("strong", { - children: "Security Key" - }), " or ", /*#__PURE__*/_jsx("strong", { - children: "6-digit OTP" - }), " provided by HMS Admin."] - }), /*#__PURE__*/_jsxs("form", { - onSubmit: submitDeviceVerification, - children: [/*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-dark mb-1", - children: "Computer / Machine Name" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: machineName, - onChange: e => setMachineName(e.target.value), - required: true - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm w-100 mb-2", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn ${verifyMethod === 'key' ? 'btn-primary' : 'btn-outline-secondary'}`, - onClick: () => setVerifyMethod('key'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-key-fill me-1" - }), " Admin Security Key"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn ${verifyMethod === 'otp' ? 'btn-primary' : 'btn-outline-secondary'}`, - onClick: () => setVerifyMethod('otp'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-123 me-1" - }), " 6-Digit Counter OTP"] - })] - }), /*#__PURE__*/_jsx("input", { - type: verifyMethod === 'otp' ? 'number' : 'text', - className: "form-control text-center fw-bold fs-5 letter-spacing-1", - placeholder: verifyMethod === 'key' ? 'e.g. HMS-XXXXXX-XXX' : 'Enter 6-digit OTP', - value: secKeyInput, - onChange: e => setSecKeyInput(e.target.value), - required: true - })] - }), /*#__PURE__*/_jsx("button", { - type: "submit", - className: "btn btn-success-custom w-100 py-2.5 mt-3 fw-bold", - disabled: isVerifying, - children: isVerifying ? /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hourglass-split me-1" - }), " Verifying Terminal..."] - }) : /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-check me-1" - }), " Verify Machine & Unlock Counter"] - }) - })] - })] - })] - }) - }), /*#__PURE__*/_jsx("header", { - className: "navbar-store", - children: /*#__PURE__*/_jsxs("div", { - className: "container-fluid d-flex flex-wrap align-items-center justify-content-between gap-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-3", - children: [/*#__PURE__*/_jsx("div", { - className: "bg-primary text-white p-2 rounded-3 d-flex align-items-center justify-content-center", - style: { - width: 40, - height: 40 - }, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-capsule fs-5" - }) - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("h6", { - className: "mb-0 fw-bold text-white fs-5", - children: activeStore ? activeStore.store_name : 'Medical Store Counter' - }), activeStore && /*#__PURE__*/_jsxs("span", { - className: "badge bg-info-subtle text-info border border-info px-2 py-0.5 rounded-pill", - style: { - fontSize: '0.65rem' - }, - children: ["/", activeStore.store_slug || activeStore.store_code] - })] - }), /*#__PURE__*/_jsxs("small", { - className: "text-slate-400", - style: { - color: '#94a3b8' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-geo-alt me-1" - }), activeStore ? `${activeStore.building_name || 'Main Building'} • ${activeStore.floor_no || 'Ground Floor'}` : 'Counter'] - })] - })] - }), activeStore && /*#__PURE__*/_jsxs("div", { - className: "d-none d-md-flex align-items-center gap-2", - children: [activeStore.abdm_hfr_id && /*#__PURE__*/_jsxs("span", { - className: "badge bg-success-subtle text-success border border-success px-2 py-1", - title: "ABDM Health Facility Registry", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-fill-check me-1" - }), " HFR: ", activeStore.abdm_hfr_id] - }), /*#__PURE__*/_jsxs("span", { - className: "badge-license", - title: "Retail Allopathic Drug License", - children: ["DL 20B: ", activeStore.drug_license_no_20b || 'N/A'] - }), /*#__PURE__*/_jsxs("span", { - className: "badge-license", - title: "Schedule C/C1 Drug License", - children: ["DL 21B: ", activeStore.drug_license_no_21b || 'N/A'] - }), /*#__PURE__*/_jsxs("span", { - className: "badge-gst", - title: "GSTIN", - children: ["GSTIN: ", activeStore.gstin || 'N/A'] - }), isDeviceAuthorized && /*#__PURE__*/_jsxs("span", { - className: "badge bg-success text-white rounded-pill px-2.5 py-1", - style: { - fontSize: '0.7rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-check me-1" - }), " Terminal Verified"] - })] - }), /*#__PURE__*/_jsx("div", { - className: "d-flex align-items-center", - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm text-white d-flex align-items-center gap-2 px-3 py-1.5 rounded-pill shadow-sm", - style: { - background: 'linear-gradient(135deg, rgba(14, 165, 233, 0.25), rgba(99, 102, 241, 0.25))', - border: '1px solid rgba(56, 189, 248, 0.5)', - backdropFilter: 'blur(4px)' - }, - onClick: () => { - setSelectedUserToSwitch(activeOperator || storeUsers[0] || null); - setOperatorPinInput(''); - setPinError(''); - setShowOperatorModal(true); - }, - title: "Active Medical Store Operator / Cashier (Click to switch)", - children: [/*#__PURE__*/_jsx("div", { - className: "rounded-circle bg-info text-dark d-flex align-items-center justify-content-center fw-bold", - style: { - width: 26, - height: 26, - fontSize: '0.75rem' - }, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-person-badge-fill" - }) - }), /*#__PURE__*/_jsxs("div", { - className: "text-start lh-1", - style: { - fontSize: '0.78rem' - }, - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-white text-truncate", - style: { - maxWidth: 130 - }, - children: activeOperator ? activeOperator.full_name : 'Select Staff' - }), /*#__PURE__*/_jsx("span", { - className: "badge p-0 text-cyan-300", - style: { - fontSize: '0.65rem', - color: '#7dd3fc' - }, - children: activeOperator ? activeOperator.user_role.toUpperCase() : 'COUNTER' - })] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-dark bg-opacity-50 text-white-50 px-1.5 py-0.5 rounded small", - style: { - fontSize: '0.65rem' - }, - children: ["Switch ", /*#__PURE__*/_jsx("i", { - className: "bi bi-key-fill text-warning ms-0.5" - })] - })] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-1.5 px-3 py-1.5 rounded-pill border border-secondary shadow-xs text-white", - style: { - background: '#1e293b', - fontSize: '0.78rem' - }, - title: "Active counter store is locked for billing integrity", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hospital text-info" - }), /*#__PURE__*/_jsx("span", { - className: "fw-bold", - children: activeStore ? activeStore.store_name : 'Counter' - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-secondary-subtle text-secondary py-0.5 px-1.5 rounded", - style: { - fontSize: '0.62rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-lock-fill me-0.5 text-warning" - }), " LOCKED"] - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm text-white rounded-pill px-2.5 py-1 d-flex align-items-center gap-1.5 shadow-sm", - style: { - background: 'rgba(14, 165, 233, 0.2)', - border: '1px solid #0ea5e9' - }, - onClick: () => setShowQrModal(true), - title: "Scan QR Code to open Mobile Rack Collector & Stock Auditor on phone", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-qr-code text-cyan-300" - }), /*#__PURE__*/_jsx("span", { - className: "d-none d-lg-inline small fw-semibold", - children: "Mobile App QR" - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn btn-sm rounded-pill px-2.5 py-1 d-flex align-items-center gap-1.5 ${isMobileMode ? 'btn-warning text-dark fw-bold' : 'btn-outline-light'}`, - onClick: () => setIsMobileMode(!isMobileMode), - title: "Toggle Mobile Companion View", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-phone" - }), /*#__PURE__*/_jsx("span", { - className: "small fw-semibold", - children: isMobileMode ? 'Desktop' : 'Mobile' - })] - }), /*#__PURE__*/_jsx("a", { - href: "/app", - className: "btn btn-sm btn-outline-light", - title: "Return to App Hub", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-grid-fill" - }) - })] - })] - }) - }), notification && /*#__PURE__*/_jsxs("div", { - className: `position-fixed shadow-lg alert alert-${notification.type === 'error' ? 'danger' : notification.type === 'warning' ? 'warning' : 'success'} d-flex align-items-center gap-2 alert-dismissible fade show m-0 py-2.5 px-3`, + return /*#__PURE__*/React.createElement("div", null, !isDeviceAuthorized && activeStore && /*#__PURE__*/React.createElement("div", { + className: "machine-lock-backdrop" + }, /*#__PURE__*/React.createElement("div", { + className: "card shadow-lg border-0", + style: { + maxWidth: 460, + width: '100%', + borderRadius: 16 + } + }, /*#__PURE__*/React.createElement("div", { + className: "card-header bg-dark text-white p-3 text-center border-0", + style: { + borderTopLeftRadius: 16, + borderTopRightRadius: 16 + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-lock-fill text-warning fs-1 d-block mb-1" + }), /*#__PURE__*/React.createElement("h5", { + className: "fw-bold mb-0" + }, "Terminal Machine Verification"), /*#__PURE__*/React.createElement("small", { + className: "text-slate-300", + style: { + color: '#94a3b8' + } + }, "Counter Authorization Required")), /*#__PURE__*/React.createElement("div", { + className: "card-body p-4" + }, /*#__PURE__*/React.createElement("div", { + className: "text-center mb-3" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold text-dark" + }, activeStore.store_name), /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-geo-alt me-1" + }), activeStore.building_name || 'Main Hospital', " • ", activeStore.floor_no || 'Ground Floor'), /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary border border-primary-subtle px-2 py-1 mt-1" + }, "Link: MedicalStore/", activeStore.store_slug)), /*#__PURE__*/React.createElement("p", { + className: "small text-muted text-center mb-3" + }, "This computer terminal is accessing the counter for the first time. Please enter the ", /*#__PURE__*/React.createElement("strong", null, "Security Key"), " or ", /*#__PURE__*/React.createElement("strong", null, "6-digit OTP"), " provided by HMS Admin."), /*#__PURE__*/React.createElement("form", { + onSubmit: submitDeviceVerification + }, /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-dark mb-1" + }, "Computer / Machine Name"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: machineName, + onChange: e => setMachineName(e.target.value), + required: true + })), /*#__PURE__*/React.createElement("div", { + className: "mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm w-100 mb-2" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn ${verifyMethod === 'key' ? 'btn-primary' : 'btn-outline-secondary'}`, + onClick: () => setVerifyMethod('key') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-key-fill me-1" + }), " Admin Security Key"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn ${verifyMethod === 'otp' ? 'btn-primary' : 'btn-outline-secondary'}`, + onClick: () => setVerifyMethod('otp') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-123 me-1" + }), " 6-Digit Counter OTP")), /*#__PURE__*/React.createElement("input", { + type: verifyMethod === 'otp' ? 'number' : 'text', + className: "form-control text-center fw-bold fs-5 letter-spacing-1", + placeholder: verifyMethod === 'key' ? 'e.g. HMS-XXXXXX-XXX' : 'Enter 6-digit OTP', + value: secKeyInput, + onChange: e => setSecKeyInput(e.target.value), + required: true + })), /*#__PURE__*/React.createElement("button", { + type: "submit", + className: "btn btn-success-custom w-100 py-2.5 mt-3 fw-bold", + disabled: isVerifying + }, isVerifying ? /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hourglass-split me-1" + }), " Verifying Terminal...") : /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-check me-1" + }), " Verify Machine & Unlock Counter")))))), /*#__PURE__*/React.createElement("header", { + className: "navbar-store" + }, /*#__PURE__*/React.createElement("div", { + className: "container-fluid d-flex flex-wrap align-items-center justify-content-between gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-3" + }, /*#__PURE__*/React.createElement("div", { + className: "bg-primary text-white p-2 rounded-3 d-flex align-items-center justify-content-center", + style: { + width: 40, + height: 40 + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-capsule fs-5" + })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("h6", { + className: "mb-0 fw-bold text-white fs-5" + }, activeStore ? activeStore.store_name : 'Medical Store Counter'), activeStore && /*#__PURE__*/React.createElement("span", { + className: "badge bg-info-subtle text-info border border-info px-2 py-0.5 rounded-pill", + style: { + fontSize: '0.65rem' + } + }, "/", activeStore.store_slug || activeStore.store_code)), /*#__PURE__*/React.createElement("small", { + className: "text-slate-400", + style: { + color: '#94a3b8' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-geo-alt me-1" + }), activeStore ? `${activeStore.building_name || 'Main Building'} • ${activeStore.floor_no || 'Ground Floor'}` : 'Counter'))), activeStore && /*#__PURE__*/React.createElement("div", { + className: "d-none d-md-flex align-items-center gap-2" + }, activeStore.abdm_hfr_id && /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success border border-success px-2 py-1", + title: "ABDM Health Facility Registry" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-fill-check me-1" + }), " HFR: ", activeStore.abdm_hfr_id), /*#__PURE__*/React.createElement("span", { + className: "badge-license", + title: "Retail Allopathic Drug License" + }, "DL 20B: ", activeStore.drug_license_no_20b || 'N/A'), /*#__PURE__*/React.createElement("span", { + className: "badge-license", + title: "Schedule C/C1 Drug License" + }, "DL 21B: ", activeStore.drug_license_no_21b || 'N/A'), /*#__PURE__*/React.createElement("span", { + className: "badge-gst", + title: "GSTIN" + }, "GSTIN: ", activeStore.gstin || 'N/A'), isDeviceAuthorized && /*#__PURE__*/React.createElement("span", { + className: "badge bg-success text-white rounded-pill px-2.5 py-1", + style: { + fontSize: '0.7rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-check me-1" + }), " Terminal Verified")), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm text-white d-flex align-items-center gap-2 px-3 py-1.5 rounded-pill shadow-sm", + style: { + background: 'linear-gradient(135deg, rgba(14, 165, 233, 0.25), rgba(99, 102, 241, 0.25))', + border: '1px solid rgba(56, 189, 248, 0.5)', + backdropFilter: 'blur(4px)' + }, + onClick: () => { + setSelectedUserToSwitch(activeOperator || storeUsers[0] || null); + setOperatorPinInput(''); + setPinError(''); + setShowOperatorModal(true); + }, + title: "Active Medical Store Operator / Cashier (Click to switch)" + }, /*#__PURE__*/React.createElement("div", { + className: "rounded-circle bg-info text-dark d-flex align-items-center justify-content-center fw-bold", + style: { + width: 26, + height: 26, + fontSize: '0.75rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-badge-fill" + })), /*#__PURE__*/React.createElement("div", { + className: "text-start lh-1", + style: { + fontSize: '0.78rem' + } + }, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-white text-truncate", + style: { + maxWidth: 130 + } + }, activeOperator ? activeOperator.full_name : 'Select Staff'), /*#__PURE__*/React.createElement("span", { + className: "badge p-0 text-cyan-300", + style: { + fontSize: '0.65rem', + color: '#7dd3fc' + } + }, activeOperator ? activeOperator.user_role.toUpperCase() : 'COUNTER')), /*#__PURE__*/React.createElement("span", { + className: "badge bg-dark bg-opacity-50 text-white-50 px-1.5 py-0.5 rounded small", + style: { + fontSize: '0.65rem' + } + }, "Switch ", /*#__PURE__*/React.createElement("i", { + className: "bi bi-key-fill text-warning ms-0.5" + })))), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-1.5 px-3 py-1.5 rounded-pill border border-secondary shadow-xs text-white", + style: { + background: '#1e293b', + fontSize: '0.78rem' + }, + title: "Active counter store is locked for billing integrity" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hospital text-info" + }), /*#__PURE__*/React.createElement("span", { + className: "fw-bold" + }, activeStore ? activeStore.store_name : 'Counter'), /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-secondary py-0.5 px-1.5 rounded", + style: { + fontSize: '0.62rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-lock-fill me-0.5 text-warning" + }), " LOCKED")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm text-white rounded-pill px-2.5 py-1 d-flex align-items-center gap-1.5 shadow-sm", + style: { + background: 'rgba(14, 165, 233, 0.2)', + border: '1px solid #0ea5e9' + }, + onClick: () => setShowQrModal(true), + title: "Scan QR Code to open Mobile Rack Collector & Stock Auditor on phone" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-qr-code text-cyan-300" + }), /*#__PURE__*/React.createElement("span", { + className: "d-none d-lg-inline small fw-semibold" + }, "Mobile App QR")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn btn-sm rounded-pill px-2.5 py-1 d-flex align-items-center gap-1.5 ${isMobileMode ? 'btn-warning text-dark fw-bold' : 'btn-outline-light'}`, + onClick: () => setIsMobileMode(!isMobileMode), + title: "Toggle Mobile Companion View" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-phone" + }), /*#__PURE__*/React.createElement("span", { + className: "small fw-semibold" + }, isMobileMode ? 'Desktop' : 'Mobile')), /*#__PURE__*/React.createElement("a", { + href: "/app", + className: "btn btn-sm btn-outline-light", + title: "Return to App Hub" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-grid-fill" + }))))), notification && /*#__PURE__*/React.createElement("div", { + className: `position-fixed shadow-lg alert alert-${notification.type === 'error' ? 'danger' : notification.type === 'warning' ? 'warning' : 'success'} d-flex align-items-center gap-2 alert-dismissible fade show m-0 py-2.5 px-3`, + style: { + top: '1.25rem', + right: '1.5rem', + zIndex: 999999, + minWidth: '320px', + maxWidth: '480px', + borderWidth: '1.5px', + borderRadius: '10px' + }, + role: "alert" + }, /*#__PURE__*/React.createElement("i", { + className: `bi bi-${notification.type === 'error' ? 'exclamation-triangle-fill' : notification.type === 'warning' ? 'exclamation-circle-fill' : 'check-circle-fill'} fs-5 me-1` + }), /*#__PURE__*/React.createElement("div", { + className: "flex-grow-1 fw-semibold small pe-2" + }, notification.msg), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close p-2", + onClick: () => setNotification(null) + })), /*#__PURE__*/React.createElement("nav", { + className: "nav-tabs-custom d-flex flex-wrap" + }, /*#__PURE__*/React.createElement("button", { + className: `nav-link ${activeTab === 'pos' ? 'active' : ''}`, + onClick: () => setActiveTab('pos') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cart3 me-1" + }), " POS Counter Desk"), /*#__PURE__*/React.createElement("button", { + className: `nav-link ${activeTab === 'invoices' ? 'active' : ''}`, + onClick: () => setActiveTab('invoices') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-receipt me-1" + }), " All Invoices & Sales"), /*#__PURE__*/React.createElement("button", { + className: `nav-link ${activeTab === 'inventory' ? 'active' : ''}`, + onClick: () => setActiveTab('inventory') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-boxes me-1" + }), " Live Stock & Batches"), /*#__PURE__*/React.createElement("button", { + className: `nav-link ${activeTab === 'purchase' ? 'active' : ''}`, + onClick: () => setActiveTab('purchase') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-box-arrow-in-down me-1" + }), " Purchases & Stock Import"), /*#__PURE__*/React.createElement("button", { + className: `nav-link ${activeTab === 'transfer' ? 'active' : ''}`, + onClick: () => setActiveTab('transfer') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-left-right me-1" + }), " Inter-Store Indents"), /*#__PURE__*/React.createElement("button", { + className: `nav-link ${activeTab === 'ledgers' ? 'active' : ''}`, + onClick: () => setActiveTab('ledgers') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-journal-text me-1" + }), " Ledgers, Daybook & GST"), /*#__PURE__*/React.createElement("button", { + className: `nav-link ${activeTab === 'staff' ? 'active' : ''}`, + onClick: () => setActiveTab('staff') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-people-fill me-1" + }), " Staff & Roles")), isMobileMode ? /*#__PURE__*/React.createElement(MobileAppView, { + store: activeStore, + stores: stores, + notify: notify, + activeOperator: activeOperator, + onSwitchOperator: () => setShowOperatorModal(true), + onExitMobile: () => setIsMobileMode(false), + triggerPwaInstall: triggerPwaInstall + }) : /*#__PURE__*/React.createElement("main", { + className: "container-fluid py-3" + }, activeTab === 'pos' && /*#__PURE__*/React.createElement(PosCounter, { + store: activeStore, + notify: notify, + activeOperator: activeOperator, + onSwitchOperator: () => setShowOperatorModal(true), + initialEditInvoice: editInvoiceForPos, + onClearEditInvoice: () => setEditInvoiceForPos(null) + }), activeTab === 'invoices' && /*#__PURE__*/React.createElement(InvoicesView, { + store: activeStore, + notify: notify, + activeOperator: activeOperator, + onEditInPos: invData => { + setEditInvoiceForPos(invData); + setActiveTab('pos'); + } + }), activeTab === 'inventory' && /*#__PURE__*/React.createElement(InventoryView, { + store: activeStore, + notify: notify, + activeOperator: activeOperator + }), activeTab === 'purchase' && /*#__PURE__*/React.createElement(PurchaseView, { + store: activeStore, + notify: notify, + activeOperator: activeOperator + }), activeTab === 'transfer' && /*#__PURE__*/React.createElement(TransferView, { + store: activeStore, + stores: stores, + notify: notify, + activeOperator: activeOperator + }), activeTab === 'ledgers' && /*#__PURE__*/React.createElement(LedgersView, { + store: activeStore, + notify: notify, + activeOperator: activeOperator + }), activeTab === 'staff' && /*#__PURE__*/React.createElement(StaffManagementView, { + store: activeStore, + notify: notify, + activeOperator: activeOperator, + onOperatorUpdated: () => loadStoreUsers(activeStore?.store_id), + onSelectOperator: u => { + setSelectedUserToSwitch(u); + setOperatorPinInput(''); + setPinError(''); + setShowOperatorModal(true); + } + })), showQrModal && /*#__PURE__*/React.createElement("div", { + className: "modal fade show d-block", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.85)', + zIndex: 10700 + }, + tabIndex: "-1" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered", + style: { + maxWidth: 520 + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content border-0 shadow-2xl rounded-4 overflow-hidden", + style: { + background: '#0f172a', + color: '#f8fafc', + border: '1px solid #334155' + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header border-bottom border-secondary py-3 px-4", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "p-2 rounded-3 bg-info bg-opacity-25 text-info" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-qr-code-scan fs-5" + })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold text-white mb-0" + }, "Mobile App QR & Installation"), /*#__PURE__*/React.createElement("small", { + className: "text-slate-400", + style: { + color: '#94a3b8' + } + }, activeStore?.store_name, " • Rack Collector & Stock Auditor"))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setShowQrModal(false) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-4 text-center" + }, serverNetworkInfo && serverNetworkInfo.detected_ips && serverNetworkInfo.detected_ips.length > 1 && /*#__PURE__*/React.createElement("div", { + className: "mb-3 text-start" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-slate-300 small fw-bold text-uppercase", + style: { + color: '#cbd5e1' + } + }, "Hospital WiFi / LAN IP"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm bg-dark text-white border-secondary", + value: selectedLanIp, + onChange: e => setSelectedLanIp(e.target.value) + }, serverNetworkInfo.detected_ips.map(ip => /*#__PURE__*/React.createElement("option", { + key: ip, + value: ip + }, ip, " (WiFi / LAN Network)")), /*#__PURE__*/React.createElement("option", { + value: window.location.hostname + }, window.location.hostname, " (Current Browser Host)"))), (() => { + const portStr = serverNetworkInfo?.port ? ':' + serverNetworkInfo.port : window.location.port ? ':' + window.location.port : ''; + const hostIp = selectedLanIp || serverNetworkInfo?.primary_ip || window.location.hostname; + const targetUrl = `http://${hostIp}${portStr}/MedicalStore/${activeStore?.store_slug || 'storea'}?mode=mobile`; + const qrSrc = `https://api.qrserver.com/v1/create-qr-code/?size=240x240&margin=8&data=${encodeURIComponent(targetUrl)}`; + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "p-3 bg-white rounded-4 shadow d-inline-block mb-3" + }, /*#__PURE__*/React.createElement("img", { + src: qrSrc, + alt: "Scan to open Mobile Pharmacy App", style: { - top: '1.25rem', - right: '1.5rem', - zIndex: 999999, - minWidth: '320px', - maxWidth: '480px', - borderWidth: '1.5px', - borderRadius: '10px' - }, - role: "alert", - children: [/*#__PURE__*/_jsx("i", { - className: `bi bi-${notification.type === 'error' ? 'exclamation-triangle-fill' : notification.type === 'warning' ? 'exclamation-circle-fill' : 'check-circle-fill'} fs-5 me-1` - }), /*#__PURE__*/_jsx("div", { - className: "flex-grow-1 fw-semibold small pe-2", - children: notification.msg - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close p-2", - onClick: () => setNotification(null) - })] - }), /*#__PURE__*/_jsxs("nav", { - className: "nav-tabs-custom d-flex flex-wrap", - children: [/*#__PURE__*/_jsxs("button", { - className: `nav-link ${activeTab === 'pos' ? 'active' : ''}`, - onClick: () => setActiveTab('pos'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cart3 me-1" - }), " POS Counter Desk"] - }), /*#__PURE__*/_jsxs("button", { - className: `nav-link ${activeTab === 'invoices' ? 'active' : ''}`, - onClick: () => setActiveTab('invoices'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-receipt me-1" - }), " All Invoices & Sales"] - }), /*#__PURE__*/_jsxs("button", { - className: `nav-link ${activeTab === 'inventory' ? 'active' : ''}`, - onClick: () => setActiveTab('inventory'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-boxes me-1" - }), " Live Stock & Batches"] - }), /*#__PURE__*/_jsxs("button", { - className: `nav-link ${activeTab === 'purchase' ? 'active' : ''}`, - onClick: () => setActiveTab('purchase'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-box-arrow-in-down me-1" - }), " Purchases & Stock Import"] - }), /*#__PURE__*/_jsxs("button", { - className: `nav-link ${activeTab === 'transfer' ? 'active' : ''}`, - onClick: () => setActiveTab('transfer'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-left-right me-1" - }), " Inter-Store Indents"] - }), /*#__PURE__*/_jsxs("button", { - className: `nav-link ${activeTab === 'ledgers' ? 'active' : ''}`, - onClick: () => setActiveTab('ledgers'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-journal-text me-1" - }), " Ledgers, Daybook & GST"] - }), /*#__PURE__*/_jsxs("button", { - className: `nav-link ${activeTab === 'staff' ? 'active' : ''}`, - onClick: () => setActiveTab('staff'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-people-fill me-1" - }), " Staff & Roles"] - })] - }), isMobileMode ? /*#__PURE__*/_jsx(MobileAppView, { - store: activeStore, - stores: stores, - notify: notify, - activeOperator: activeOperator, - onSwitchOperator: () => setShowOperatorModal(true), - onExitMobile: () => setIsMobileMode(false), - triggerPwaInstall: triggerPwaInstall - }) : /*#__PURE__*/_jsxs("main", { - className: "container-fluid py-3", - children: [activeTab === 'pos' && /*#__PURE__*/_jsx(PosCounter, { - store: activeStore, - notify: notify, - activeOperator: activeOperator, - onSwitchOperator: () => setShowOperatorModal(true), - initialEditInvoice: editInvoiceForPos, - onClearEditInvoice: () => setEditInvoiceForPos(null) - }), activeTab === 'invoices' && /*#__PURE__*/_jsx(InvoicesView, { - store: activeStore, - notify: notify, - activeOperator: activeOperator, - onEditInPos: invData => { - setEditInvoiceForPos(invData); - setActiveTab('pos'); - } - }), activeTab === 'inventory' && /*#__PURE__*/_jsx(InventoryView, { - store: activeStore, - notify: notify, - activeOperator: activeOperator - }), activeTab === 'purchase' && /*#__PURE__*/_jsx(PurchaseView, { - store: activeStore, - notify: notify, - activeOperator: activeOperator - }), activeTab === 'transfer' && /*#__PURE__*/_jsx(TransferView, { - store: activeStore, - stores: stores, - notify: notify, - activeOperator: activeOperator - }), activeTab === 'ledgers' && /*#__PURE__*/_jsx(LedgersView, { - store: activeStore, - notify: notify, - activeOperator: activeOperator - }), activeTab === 'staff' && /*#__PURE__*/_jsx(StaffManagementView, { - store: activeStore, - notify: notify, - activeOperator: activeOperator, - onOperatorUpdated: () => loadStoreUsers(activeStore?.store_id), - onSelectOperator: u => { - setSelectedUserToSwitch(u); - setOperatorPinInput(''); - setPinError(''); - setShowOperatorModal(true); - } - })] - }), showQrModal && /*#__PURE__*/_jsx("div", { - className: "modal fade show d-block", + width: 220, + height: 220, + display: 'block' + } + })), /*#__PURE__*/React.createElement("div", { + className: "p-2.5 rounded-3 mb-3 text-start small border border-secondary", style: { - backgroundColor: 'rgba(15, 23, 42, 0.85)', - zIndex: 10700 - }, - tabIndex: "-1", - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered", - style: { - maxWidth: 520 - }, - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content border-0 shadow-2xl rounded-4 overflow-hidden", - style: { - background: '#0f172a', - color: '#f8fafc', - border: '1px solid #334155' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header border-bottom border-secondary py-3 px-4", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("div", { - className: "p-2 rounded-3 bg-info bg-opacity-25 text-info", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-qr-code-scan fs-5" - }) - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "modal-title fw-bold text-white mb-0", - children: "Mobile App QR & Installation" - }), /*#__PURE__*/_jsxs("small", { - className: "text-slate-400", - style: { - color: '#94a3b8' - }, - children: [activeStore?.store_name, " • Rack Collector & Stock Auditor"] - })] - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setShowQrModal(false) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-4 text-center", - children: [serverNetworkInfo && serverNetworkInfo.detected_ips && serverNetworkInfo.detected_ips.length > 1 && /*#__PURE__*/_jsxs("div", { - className: "mb-3 text-start", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-slate-300 small fw-bold text-uppercase", - style: { - color: '#cbd5e1' - }, - children: "Hospital WiFi / LAN IP" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm bg-dark text-white border-secondary", - value: selectedLanIp, - onChange: e => setSelectedLanIp(e.target.value), - children: [serverNetworkInfo.detected_ips.map(ip => /*#__PURE__*/_jsxs("option", { - value: ip, - children: [ip, " (WiFi / LAN Network)"] - }, ip)), /*#__PURE__*/_jsxs("option", { - value: window.location.hostname, - children: [window.location.hostname, " (Current Browser Host)"] - })] - })] - }), (() => { - const portStr = serverNetworkInfo?.port ? ':' + serverNetworkInfo.port : window.location.port ? ':' + window.location.port : ''; - const hostIp = selectedLanIp || serverNetworkInfo?.primary_ip || window.location.hostname; - const targetUrl = `http://${hostIp}${portStr}/MedicalStore/${activeStore?.store_slug || 'storea'}?mode=mobile`; - const qrSrc = `https://api.qrserver.com/v1/create-qr-code/?size=240x240&margin=8&data=${encodeURIComponent(targetUrl)}`; - return /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "p-3 bg-white rounded-4 shadow d-inline-block mb-3", - children: /*#__PURE__*/_jsx("img", { - src: qrSrc, - alt: "Scan to open Mobile Pharmacy App", - style: { - width: 220, - height: 220, - display: 'block' - } - }) - }), /*#__PURE__*/_jsxs("div", { - className: "p-2.5 rounded-3 mb-3 text-start small border border-secondary", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsx("div", { - className: "text-slate-400 small mb-1", - style: { - color: '#94a3b8' - }, - children: "Mobile Application URL:" - }), /*#__PURE__*/_jsx("div", { - className: "fw-mono text-cyan-300 text-truncate fw-bold", - style: { - color: '#67e8f9' - }, - children: targetUrl - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 text-start small mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "col-4", - children: /*#__PURE__*/_jsxs("div", { - className: "p-2 rounded-3 border border-secondary text-center h-100", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-info mb-1", - children: "1. Scan QR" - }), /*#__PURE__*/_jsx("div", { - className: "text-slate-400", - style: { - fontSize: '0.72rem', - color: '#94a3b8' - }, - children: "Open camera app on your smartphone" - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-4", - children: /*#__PURE__*/_jsxs("div", { - className: "p-2 rounded-3 border border-secondary text-center h-100", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-info mb-1", - children: "2. Rack Drafts" - }), /*#__PURE__*/_jsx("div", { - className: "text-slate-400", - style: { - fontSize: '0.72rem', - color: '#94a3b8' - }, - children: "Collect items & audit shelf stock" - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-4", - children: /*#__PURE__*/_jsxs("div", { - className: "p-2 rounded-3 border border-secondary text-center h-100", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-success mb-1", - children: "3. Install App" - }), /*#__PURE__*/_jsx("div", { - className: "text-slate-400", - style: { - fontSize: '0.72rem', - color: '#94a3b8' - }, - children: "Tap \"Add to Home Screen\" to install" - })] - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap align-items-center justify-content-center gap-2", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-info d-flex align-items-center gap-1.5", - onClick: () => { - navigator.clipboard.writeText(targetUrl); - notify('Mobile app URL copied to clipboard!', 'success'); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-copy" - }), " Copy Link"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-success d-flex align-items-center gap-1.5", - onClick: triggerPwaInstall, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-phone-fill" - }), " 📲 Install App"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-primary d-flex align-items-center gap-1.5 fw-bold", - onClick: () => { - setIsMobileMode(true); - setShowQrModal(false); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-right-circle" - }), " Open Mobile Mode"] - })] - })] - }); - })()] - })] - }) - }) - }), showOperatorModal && /*#__PURE__*/_jsx("div", { - className: "modal fade show d-block", + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("div", { + className: "text-slate-400 small mb-1", style: { - backgroundColor: 'rgba(15, 23, 42, 0.75)', - zIndex: 10600 + color: '#94a3b8' + } + }, "Mobile Application URL:"), /*#__PURE__*/React.createElement("div", { + className: "fw-mono text-cyan-300 text-truncate fw-bold", + style: { + color: '#67e8f9' + } + }, targetUrl)), /*#__PURE__*/React.createElement("div", { + className: "row g-2 text-start small mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("div", { + className: "p-2 rounded-3 border border-secondary text-center h-100", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-info mb-1" + }, "1. Scan QR"), /*#__PURE__*/React.createElement("div", { + className: "text-slate-400", + style: { + fontSize: '0.72rem', + color: '#94a3b8' + } + }, "Open camera app on your smartphone"))), /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("div", { + className: "p-2 rounded-3 border border-secondary text-center h-100", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-info mb-1" + }, "2. Rack Drafts"), /*#__PURE__*/React.createElement("div", { + className: "text-slate-400", + style: { + fontSize: '0.72rem', + color: '#94a3b8' + } + }, "Collect items & audit shelf stock"))), /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("div", { + className: "p-2 rounded-3 border border-secondary text-center h-100", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-success mb-1" + }, "3. Install App"), /*#__PURE__*/React.createElement("div", { + className: "text-slate-400", + style: { + fontSize: '0.72rem', + color: '#94a3b8' + } + }, "Tap \"Add to Home Screen\" to install")))), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap align-items-center justify-content-center gap-2" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-info d-flex align-items-center gap-1.5", + onClick: () => { + navigator.clipboard.writeText(targetUrl); + notify('Mobile app URL copied to clipboard!', 'success'); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-copy" + }), " Copy Link"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-success d-flex align-items-center gap-1.5", + onClick: triggerPwaInstall + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-phone-fill" + }), " 📲 Install App"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-primary d-flex align-items-center gap-1.5 fw-bold", + onClick: () => { + setIsMobileMode(true); + setShowQrModal(false); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-right-circle" + }), " Open Mobile Mode"))); + })())))), showOperatorModal && /*#__PURE__*/React.createElement("div", { + className: "modal fade show d-block", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.75)', + zIndex: 10600 + }, + tabIndex: "-1" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered", + style: { + maxWidth: 500 + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content border-0 shadow-2xl rounded-4 overflow-hidden", + style: { + background: '#0f172a', + color: '#f8fafc', + border: '1px solid #334155' + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header border-bottom border-secondary py-3 px-4", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "p-2 rounded-3 bg-primary bg-opacity-25 text-primary" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-badge-fill fs-5" + })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold text-white mb-0" + }, "Switch Store Operator / Auditor"), /*#__PURE__*/React.createElement("small", { + className: "text-slate-400", + style: { + color: '#94a3b8' + } + }, activeStore?.store_name, " • Counter Session"))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setShowOperatorModal(false) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-slate-300 small fw-bold text-uppercase", + style: { + color: '#cbd5e1' + } + }, "1. Select Staff Member"), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-column gap-2 mb-3", + style: { + maxHeight: 220, + overflowY: 'auto' + } + }, storeUsers.map(u => { + const isSelected = selectedUserToSwitch?.user_id == u.user_id; + const isCurrent = activeOperator?.user_id == u.user_id; + return /*#__PURE__*/React.createElement("div", { + key: u.user_id, + onClick: () => { + setSelectedUserToSwitch(u); + setPinError(''); + setOperatorPinInput(''); }, - tabIndex: "-1", - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered", - style: { - maxWidth: 500 - }, - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content border-0 shadow-2xl rounded-4 overflow-hidden", - style: { - background: '#0f172a', - color: '#f8fafc', - border: '1px solid #334155' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header border-bottom border-secondary py-3 px-4", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("div", { - className: "p-2 rounded-3 bg-primary bg-opacity-25 text-primary", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-person-badge-fill fs-5" - }) - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "modal-title fw-bold text-white mb-0", - children: "Switch Store Operator / Auditor" - }), /*#__PURE__*/_jsxs("small", { - className: "text-slate-400", - style: { - color: '#94a3b8' - }, - children: [activeStore?.store_name, " • Counter Session"] - })] - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setShowOperatorModal(false) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-slate-300 small fw-bold text-uppercase", - style: { - color: '#cbd5e1' - }, - children: "1. Select Staff Member" - }), /*#__PURE__*/_jsx("div", { - className: "d-flex flex-column gap-2 mb-3", - style: { - maxHeight: 220, - overflowY: 'auto' - }, - children: storeUsers.map(u => { - const isSelected = selectedUserToSwitch?.user_id == u.user_id; - const isCurrent = activeOperator?.user_id == u.user_id; - return /*#__PURE__*/_jsxs("div", { - onClick: () => { - setSelectedUserToSwitch(u); - setPinError(''); - setOperatorPinInput(''); - }, - className: `p-2.5 rounded-3 d-flex align-items-center justify-content-between cursor-pointer transition-all ${isSelected ? 'border border-primary' : 'border border-secondary'}`, - style: { - background: isSelected ? 'rgba(14, 165, 233, 0.15)' : '#1e293b', - cursor: 'pointer' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2.5", - children: [/*#__PURE__*/_jsx("div", { - className: "rounded-circle bg-dark text-cyan-400 border border-slate-700 d-flex align-items-center justify-content-center fw-bold", - style: { - width: 34, - height: 34, - fontSize: '0.85rem' - }, - children: u.full_name ? u.full_name[0] : 'U' - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "fw-bold text-white small d-flex align-items-center gap-1.5", - children: [u.full_name, isCurrent && /*#__PURE__*/_jsx("span", { - className: "badge bg-success", - style: { - fontSize: '0.6rem' - }, - children: "CURRENT" - }), u.is_default == 1 && /*#__PURE__*/_jsx("span", { - className: "badge bg-info-subtle text-info", - style: { - fontSize: '0.6rem' - }, - children: "DEFAULT" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "text-slate-400", - style: { - fontSize: '0.72rem', - color: '#94a3b8' - }, - children: ["@", u.username, " • ", /*#__PURE__*/_jsx("span", { - className: "text-capitalize text-info", - children: u.user_role.replace('_', ' ') - }), u.pharmacist_reg_no && ` • Reg: ${u.pharmacist_reg_no}`] - })] - })] - }), /*#__PURE__*/_jsx("i", { - className: `bi bi-${isSelected ? 'check-circle-fill text-primary' : 'circle text-secondary'} fs-5` - })] - }, u.user_id); - }) - }), selectedUserToSwitch && /*#__PURE__*/_jsxs("div", { - className: "mt-3 p-3 rounded-3", - style: { - background: '#1e293b', - border: '1px solid #334155' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-between mb-2", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label text-slate-300 small fw-bold text-uppercase mb-0", - style: { - color: '#cbd5e1' - }, - children: ["2. Enter 4-Digit Security PIN for ", selectedUserToSwitch.full_name] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-dark text-slate-400 small", - style: { - fontSize: '0.65rem' - }, - children: "Default: 1234/1111" - })] - }), /*#__PURE__*/_jsx("input", { - type: "password", - maxLength: "6", - className: "form-control form-control-lg text-center fw-bold fs-4 tracking-widest bg-dark text-white border-secondary", - placeholder: "••••", - value: operatorPinInput, - onChange: e => { - setOperatorPinInput(e.target.value); - setPinError(''); - }, - onKeyDown: e => { - if (e.key === 'Enter') handleSwitchOperator(); - }, - autoFocus: true - }), pinError && /*#__PURE__*/_jsxs("div", { - className: "text-danger small mt-2 d-flex align-items-center gap-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-exclamation-circle-fill" - }), " ", pinError] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer border-top border-secondary py-2 px-4 d-flex justify-content-between", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsx("div", { - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-info d-flex align-items-center gap-1.5", - onClick: () => { - setShowOperatorModal(false); - setShowQrModal(true); - }, - title: "Scan QR code to open installable mobile application on smartphone", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-qr-code-scan" - }), /*#__PURE__*/_jsx("span", { - children: "📱 Mobile App QR Code" - })] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-secondary", - onClick: () => setShowOperatorModal(false), - children: "Cancel" - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-primary px-3 fw-bold d-flex align-items-center gap-1.5", - onClick: handleSwitchOperator, - disabled: isSwitchingOperator || !selectedUserToSwitch || !operatorPinInput, - children: isSwitchingOperator ? /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm" - }), " Verifying..."] - }) : /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-box-arrow-in-right" - }), " Authenticate & Switch"] - }) - })] - })] - })] - }) - }) - })] - }); + className: `p-2.5 rounded-3 d-flex align-items-center justify-content-between cursor-pointer transition-all ${isSelected ? 'border border-primary' : 'border border-secondary'}`, + style: { + background: isSelected ? 'rgba(14, 165, 233, 0.15)' : '#1e293b', + cursor: 'pointer' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2.5" + }, /*#__PURE__*/React.createElement("div", { + className: "rounded-circle bg-dark text-cyan-400 border border-slate-700 d-flex align-items-center justify-content-center fw-bold", + style: { + width: 34, + height: 34, + fontSize: '0.85rem' + } + }, u.full_name ? u.full_name[0] : 'U'), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-white small d-flex align-items-center gap-1.5" + }, u.full_name, isCurrent && /*#__PURE__*/React.createElement("span", { + className: "badge bg-success", + style: { + fontSize: '0.6rem' + } + }, "CURRENT"), u.is_default == 1 && /*#__PURE__*/React.createElement("span", { + className: "badge bg-info-subtle text-info", + style: { + fontSize: '0.6rem' + } + }, "DEFAULT")), /*#__PURE__*/React.createElement("div", { + className: "text-slate-400", + style: { + fontSize: '0.72rem', + color: '#94a3b8' + } + }, "@", u.username, " • ", /*#__PURE__*/React.createElement("span", { + className: "text-capitalize text-info" + }, u.user_role.replace('_', ' ')), u.pharmacist_reg_no && ` • Reg: ${u.pharmacist_reg_no}`))), /*#__PURE__*/React.createElement("i", { + className: `bi bi-${isSelected ? 'check-circle-fill text-primary' : 'circle text-secondary'} fs-5` + })); + })), selectedUserToSwitch && /*#__PURE__*/React.createElement("div", { + className: "mt-3 p-3 rounded-3", + style: { + background: '#1e293b', + border: '1px solid #334155' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-between mb-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-slate-300 small fw-bold text-uppercase mb-0", + style: { + color: '#cbd5e1' + } + }, "2. Enter 4-Digit Security PIN for ", selectedUserToSwitch.full_name), /*#__PURE__*/React.createElement("span", { + className: "badge bg-dark text-slate-400 small", + style: { + fontSize: '0.65rem' + } + }, "Default: 1234/1111")), /*#__PURE__*/React.createElement("input", { + type: "password", + maxLength: "6", + className: "form-control form-control-lg text-center fw-bold fs-4 tracking-widest bg-dark text-white border-secondary", + placeholder: "••••", + value: operatorPinInput, + onChange: e => { + setOperatorPinInput(e.target.value); + setPinError(''); + }, + onKeyDown: e => { + if (e.key === 'Enter') handleSwitchOperator(); + }, + autoFocus: true + }), pinError && /*#__PURE__*/React.createElement("div", { + className: "text-danger small mt-2 d-flex align-items-center gap-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-exclamation-circle-fill" + }), " ", pinError))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer border-top border-secondary py-2 px-4 d-flex justify-content-between", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-info d-flex align-items-center gap-1.5", + onClick: () => { + setShowOperatorModal(false); + setShowQrModal(true); + }, + title: "Scan QR code to open installable mobile application on smartphone" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-qr-code-scan" + }), /*#__PURE__*/React.createElement("span", null, "📱 Mobile App QR Code"))), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-secondary", + onClick: () => setShowOperatorModal(false) + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-primary px-3 fw-bold d-flex align-items-center gap-1.5", + onClick: handleSwitchOperator, + disabled: isSwitchingOperator || !selectedUserToSwitch || !operatorPinInput + }, isSwitchingOperator ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm" + }), " Verifying...") : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-box-arrow-in-right" + }), " Authenticate & Switch")))))))); } // ========================================================================= @@ -1219,12 +1049,11 @@ function PosCounter({ onSwitchOperator }) { if (!store) { - return /*#__PURE__*/_jsxs("div", { - className: "text-center py-5 text-muted", - children: [/*#__PURE__*/_jsx("div", { - className: "spinner-border spinner-border-sm text-primary me-2" - }), "Loading counter desk..."] - }); + return /*#__PURE__*/React.createElement("div", { + className: "text-center py-5 text-muted" + }, /*#__PURE__*/React.createElement("div", { + className: "spinner-border spinner-border-sm text-primary me-2" + }), "Loading counter desk..."); } const [patientQuery, setPatientQuery] = useState(''); const [patientResults, setPatientResults] = useState([]); @@ -2764,4661 +2593,3248 @@ function PosCounter({ window.addEventListener('keydown', handleGlobalKeyDown); return () => window.removeEventListener('keydown', handleGlobalKeyDown); }, [showFhirModal, showReturnModal, isCheckoutOpen, isPrintOpen, paymentMode, selectedPatient, isProcessing, cart, returnCart, splitRemaining, splitCashNum, splitUpiNum, splitCardNum, refundPayable, refundMode]); - return /*#__PURE__*/_jsxs("div", { - className: "pos-counter-wrapper position-relative", - children: [/*#__PURE__*/_jsxs("div", { - className: "row g-3", - children: [/*#__PURE__*/_jsxs("div", { - className: selectedPatient && showHistoryPanel ? "col-12 col-lg-8 col-xl-8" : "col-12", - children: [isRestoredBannerVisible && /*#__PURE__*/_jsxs("div", { - className: "alert alert-info py-2 px-3 d-flex flex-wrap justify-content-between align-items-center mb-2 shadow-sm border-info rounded-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-clockwise text-info fs-5" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("strong", { - className: "text-dark", - children: "Draft Auto-Restored:" - }), /*#__PURE__*/_jsxs("span", { - className: "text-secondary ms-1", - children: ["Recovered ", /*#__PURE__*/_jsxs("strong", { - children: [cart.length, " medicine(s)"] - }), " ", selectedPatient ? /*#__PURE__*/_jsxs(_Fragment, { - children: ["for ", /*#__PURE__*/_jsx("strong", { - children: selectedPatient.name || selectedPatient.patient_name - })] - }) : '', " from your previous session ", draftSavedAt ? `(${draftSavedAt.toLocaleTimeString()})` : '', "."] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2 mt-1 mt-md-0", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-primary py-0.5 px-2.5", - onClick: () => setIsRestoredBannerVisible(false), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-lg me-1" - }), " Continue Working"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-danger py-0.5 px-2.5", - onClick: clearDraftAndReset, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-trash me-1" - }), " Discard Draft"] - })] - })] - }), editingInvoiceBanner && /*#__PURE__*/_jsxs("div", { - className: "alert alert-warning py-2 px-3 d-flex flex-wrap justify-content-between align-items-center mb-2 shadow-sm border-warning rounded-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-pencil-square text-warning-emphasis fs-5" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("strong", { - className: "text-dark", - children: ["Editing Invoice #", editingInvoiceBanner, ":"] - }), /*#__PURE__*/_jsx("span", { - className: "text-secondary ms-1", - children: "Patient and medicines loaded into POS Counter. You can adjust items, quantities, or re-dispense." - })] - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-dark py-0.5 px-2.5 mt-1 mt-md-0", - onClick: clearDraftAndReset, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-x-circle me-1" - }), " Cancel Edit & New Bill"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "counter-card position-relative", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap align-items-center justify-content-between gap-2 mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsxs("span", { - className: "fw-bold text-dark fs-6", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-fill text-primary me-1" - }), " Patient & Prescription"] - }), /*#__PURE__*/_jsx("span", { - className: `badge ${patientType === 'IPD' ? 'bg-danger' : patientType === 'OPD' ? 'bg-primary' : 'bg-secondary'}`, - children: patientType - }), draftStatus === 'saved' && /*#__PURE__*/_jsxs("span", { - className: "badge bg-success-subtle text-success border border-success-subtle px-2 py-0.5 d-inline-flex align-items-center gap-1 shadow-sm", - style: { - fontSize: '0.72rem' - }, - title: draftSavedAt ? `Auto-saved at ${draftSavedAt.toLocaleTimeString()}` : 'Auto-saved in local draft', - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cloud-check-fill" - }), " Draft Auto-Saved (", cart.length, " items)"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-1.5 flex-wrap", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn btn-sm ${draftBillsList.length > 0 ? 'btn-warning text-dark fw-bold' : 'btn-outline-secondary'} py-0.5 px-2.5 d-inline-flex align-items-center gap-1 shadow-sm`, - onClick: () => { - loadDraftBills(); - setShowDraftModal(true); - }, - title: "Draft bills collected from racks via Mobile App", - style: { - fontSize: "0.75rem" - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-phone" - }), /*#__PURE__*/_jsx("span", { - children: "Mobile Drafts" - }), draftBillsList.length > 0 && /*#__PURE__*/_jsx("span", { - className: "badge bg-danger text-white rounded-pill ms-1", - style: { - fontSize: '0.65rem' - }, - children: draftBillsList.length - })] - }), (cart.length > 0 || selectedPatient) && /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-secondary py-0.5 px-2 d-inline-flex align-items-center gap-1 shadow-sm", - onClick: clearDraftAndReset, - title: "Discard draft and start new blank bill", - style: { - fontSize: "0.75rem" - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-plus-circle" - }), " New Bill"] - }), lastInvoice && /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-success py-0.5 px-2.5 fw-semibold d-inline-flex align-items-center gap-1 shadow-sm", - onClick: () => setIsPrintOpen(true), - title: "View & Print Last Bill", - style: { - fontSize: "0.75rem" - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer" - }), " Last Bill: ", /*#__PURE__*/_jsx("strong", { - children: lastInvoice.sale.invoice_no - })] - })] - }), selectedPatient && /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-1.5 flex-wrap", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn btn-sm ${showHistoryPanel ? 'btn-primary text-white' : 'btn-outline-primary'} py-1 px-2.5 d-inline-flex align-items-center gap-1 shadow-sm`, - onClick: () => setShowHistoryPanel(!showHistoryPanel), - title: "Toggle Patient Old Records & Past Dispensed Medicines (Right-Side)", - style: { - fontSize: "0.75rem" - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clock-history" - }), /*#__PURE__*/_jsx("span", { - children: "Old Records" - }), patientHistory && patientHistory.total_sales > 0 && /*#__PURE__*/_jsx("span", { - className: `badge ${showHistoryPanel ? 'bg-white text-primary' : 'bg-primary text-white'} ms-1`, - style: { - fontSize: "0.65rem" - }, - children: patientHistory.total_sales - })] - }), (selectedPatient.has_active_opd || selectedPatient.has_active_ipd) && /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-success py-1 px-2.5", - onClick: loadDoctorPrescription, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-medical me-1" - }), " 1-Click Load Doctor Rx"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-secondary py-1 px-2", - onClick: resetPatient, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-x-circle me-1" - }), " Clear"] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-7 position-relative", - children: [/*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsxs("span", { - className: "input-group-text bg-light text-primary fw-bold", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("kbd", { - className: "me-1", - style: { - background: '#0f172a', - color: '#38bdf8', - fontWeight: 800, - padding: '1px 5px', - borderRadius: '3px' - }, - children: "F4" - }), /*#__PURE__*/_jsx("i", { - className: "bi bi-search" - })] - }), /*#__PURE__*/_jsx("input", { - type: "text", - id: "patient-search-input", - ref: patientSearchRef, - className: "form-control", - placeholder: "Search by UHID, Mobile, Name, OPD No, IPD No... (F4)", - value: patientQuery, - onChange: e => searchPatients(e.target.value), - onKeyDown: handlePatientSearchKeyDown, - autoComplete: "off" - })] - }), patientResults.length > 0 && /*#__PURE__*/_jsx("div", { - className: "search-results-dropdown", - children: patientResults.map((p, pIdx) => { - const isHighlighted = pIdx === selectedPatientIndex; - return /*#__PURE__*/_jsxs("div", { - className: `search-item-row d-flex justify-content-between align-items-center ${isHighlighted ? 'bg-primary-subtle border-primary' : ''}`, - onClick: () => { - selectPatient(p); - setTimeout(() => focusMedicineSearch(), 50); - }, - style: { - cursor: 'pointer' - }, - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "fw-bold text-dark", - children: [p.full_name, " ", /*#__PURE__*/_jsxs("small", { - className: "text-primary", - children: ["(", p.uhid, ")"] - }), isHighlighted && /*#__PURE__*/_jsx("span", { - className: "badge bg-primary text-white ms-2", - style: { - fontSize: '0.65rem' - }, - children: "↵ Enter" - }), (p.abha_id || p.abha_address) && /*#__PURE__*/_jsxs("span", { - className: "badge bg-success-subtle text-success border border-success ms-2", - style: { - fontSize: '0.65rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-fill-check me-1" - }), "ABHA: ", p.abha_id || p.abha_address] - })] - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-telephone me-1" - }), p.mobile || 'No Mobile', " • ", p.gender, " • ", p.age] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "text-end", - children: [p.has_active_ipd && /*#__PURE__*/_jsxs("span", { - className: "badge bg-danger d-block mb-1", - children: ["IPD Admitted: ", p.active_ipd.bed_info?.bed_no || 'Bed'] - }), p.has_active_opd && /*#__PURE__*/_jsx("span", { - className: "badge bg-info d-block", - children: "OPD Visit Today" - })] - })] - }, p.patient_id); - }) - })] - }), /*#__PURE__*/_jsx("div", { - className: "col-md-5", - children: /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "Consultant Doctor Name", - value: doctorName, - onChange: e => setDoctorName(e.target.value) - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 mt-1", - children: [/*#__PURE__*/_jsx("div", { - className: "col-md-6", - children: /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsxs("span", { - className: "input-group-text bg-light text-success fw-bold", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-check me-1" - }), " ABHA No"] - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "14-Digit ABHA (e.g. 12-3456-7890-1234)", - value: walkinAbhaId, - onChange: e => setWalkinAbhaId(e.target.value) - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-6", - children: /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsxs("span", { - className: "input-group-text bg-light text-success fw-bold", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-at me-1" - }), " ABHA Address"] - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "username@abdm", - value: walkinAbhaAddress, - onChange: e => setWalkinAbhaAddress(e.target.value) - })] - }) - })] - }), selectedPatient && /*#__PURE__*/_jsxs("div", { - className: "mt-2 p-2 bg-light rounded-2 d-flex flex-wrap gap-3 align-items-center", - style: { - fontSize: '0.8rem' - }, - children: [/*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("strong", { - children: "Name:" - }), " ", selectedPatient.full_name] - }), /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("strong", { - children: "UHID:" - }), " ", /*#__PURE__*/_jsx("code", { - className: "text-primary", - children: selectedPatient.uhid - })] - }), /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("strong", { - children: "Gender/Age:" - }), " ", selectedPatient.gender, ", ", selectedPatient.age] - }), (selectedPatient.abha_id || selectedPatient.abha_address) && /*#__PURE__*/_jsxs("span", { - className: "badge bg-success text-white py-1 px-2", - style: { - fontSize: '0.75rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-fill-check me-1" - }), " ABDM Linked: ", selectedPatient.abha_id || '', " ", selectedPatient.abha_address ? `(${selectedPatient.abha_address})` : ''] - }), selectedPatient.has_active_ipd && /*#__PURE__*/_jsxs("span", { - className: "text-danger fw-bold", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hospital me-1" - }), selectedPatient.active_ipd.bed_info?.ward_name || 'Ward', " / ", selectedPatient.active_ipd.bed_info?.bed_no || 'Bed', " (Dr. ", selectedPatient.active_ipd.doctor_name, ")"] - }), selectedPatient.has_active_opd && !selectedPatient.has_active_ipd && /*#__PURE__*/_jsxs("span", { - className: "text-primary fw-bold", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-stethoscope me-1" - }), "OPD Dr. ", selectedPatient.active_opd.doctor_name] - })] - }), !selectedPatient && (walkinMobile || walkinUhid) && /*#__PURE__*/_jsxs("div", { - className: "mt-2 p-2 bg-light rounded-2 d-flex flex-wrap gap-3 align-items-center", - style: { - fontSize: '0.8rem' - }, - children: [/*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("strong", { - children: "Customer:" - }), " ", patientQuery || 'Walk-in'] - }), walkinMobile && /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("strong", { - children: "Mobile:" - }), " ", /*#__PURE__*/_jsx("i", { - className: "bi bi-telephone me-1 text-primary" - }), walkinMobile] - }), walkinUhid && /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("strong", { - children: "UHID:" - }), " ", /*#__PURE__*/_jsx("code", { - className: "text-primary", - children: walkinUhid - })] - })] - }), loadedDraft && /*#__PURE__*/_jsxs("div", { - className: "mt-2 p-2 rounded-2 d-flex flex-wrap justify-content-between align-items-center gap-2", - style: { - background: '#fef3c7', - border: '1px solid #f59e0b', - fontSize: '0.8rem' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap align-items-center gap-2", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-warning text-dark fw-bold", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-phone me-1" - }), " Draft: ", loadedDraft.draft_code] - }), /*#__PURE__*/_jsxs("span", { - className: "text-dark", - children: ["Collector: ", /*#__PURE__*/_jsx("strong", { - children: loadedDraft.collected_by_name || 'Staff' - }), loadedDraft.ward_name ? ` • Ward: ${loadedDraft.ward_name} (${loadedDraft.bed_no || ''})` : ''] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-light text-secondary border", - style: { - fontSize: '0.7rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-right-circle me-1 text-success" - }), "Auto-converts to invoice on checkout"] - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-dark py-0 px-2", - onClick: () => { - setLoadedDraft(null); - notify(`Draft [${loadedDraft.draft_code}] unlinked. Cart items kept.`, 'info'); - }, - title: "Unlink this draft without clearing the cart", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-link-45deg me-1" - }), " Unlink Draft"] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "counter-card position-relative", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap align-items-center gap-1.5 mb-2.5 py-1.5 px-2.5 rounded-3 shadow-sm", - style: { - background: '#f8fafc', - border: '1px solid #cbd5e1' - }, - children: [/*#__PURE__*/_jsxs("span", { - className: "fw-bold d-flex align-items-center me-1", - style: { - color: '#0f172a', - fontSize: '0.74rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-keyboard-fill text-primary me-1 fs-6" - }), /*#__PURE__*/_jsx("span", { - children: "Keys:" - })] - }), /*#__PURE__*/_jsxs("span", { - className: "d-inline-flex align-items-center gap-1 px-2 py-0.5 bg-white rounded border shadow-xs", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("kbd", { - style: { - background: '#0f172a', - color: '#38bdf8', - fontWeight: 800, - padding: '1px 5px', - borderRadius: '3px', - fontSize: '0.68rem' - }, - children: "F2" - }), /*#__PURE__*/_jsx("span", { - className: "fw-bold", - style: { - color: '#0f172a' - }, - children: "Search" - })] - }), /*#__PURE__*/_jsxs("span", { - className: "d-inline-flex align-items-center gap-1 px-2 py-0.5 bg-white rounded border shadow-xs", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("kbd", { - style: { - background: '#0f172a', - color: '#38bdf8', - fontWeight: 800, - padding: '1px 5px', - borderRadius: '3px', - fontSize: '0.68rem' - }, - children: "↑ / ↓" - }), /*#__PURE__*/_jsx("span", { - className: "fw-bold", - style: { - color: '#0f172a' - }, - children: "Select" - })] - }), /*#__PURE__*/_jsxs("span", { - className: "d-inline-flex align-items-center gap-1 px-2 py-0.5 bg-white rounded border shadow-xs", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("kbd", { - style: { - background: '#0f172a', - color: '#38bdf8', - fontWeight: 800, - padding: '1px 5px', - borderRadius: '3px', - fontSize: '0.68rem' - }, - children: "↵ Enter" - }), /*#__PURE__*/_jsx("span", { - className: "fw-bold", - style: { - color: '#0f172a' - }, - children: "Batch" - })] - }), /*#__PURE__*/_jsxs("span", { - className: "d-inline-flex align-items-center gap-1 px-2 py-0.5 bg-white rounded border border-primary shadow-xs", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("kbd", { - style: { - background: '#0891b2', - color: '#ffffff', - fontWeight: 800, - padding: '1px 5px', - borderRadius: '3px', - fontSize: '0.68rem' - }, - children: "↵ on Qty" - }), /*#__PURE__*/_jsx("span", { - className: "fw-bold text-primary", - children: "Next Item" - })] - }), /*#__PURE__*/_jsxs("span", { - className: "d-inline-flex align-items-center gap-1 px-2 py-0.5 bg-white rounded border shadow-xs", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("kbd", { - style: { - background: '#0f172a', - color: '#10b981', - fontWeight: 800, - padding: '1px 5px', - borderRadius: '3px', - fontSize: '0.68rem' - }, - children: "Alt+T" - }), /*#__PURE__*/_jsx("span", { - className: "fw-bold", - style: { - color: '#0f172a' - }, - children: "Loose" - })] - }), /*#__PURE__*/_jsxs("span", { - className: "d-inline-flex align-items-center gap-1 px-2 py-0.5 bg-white rounded border shadow-xs", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("kbd", { - style: { - background: '#0f172a', - color: '#38bdf8', - fontWeight: 800, - padding: '1px 5px', - borderRadius: '3px', - fontSize: '0.68rem' - }, - children: "Alt+S" - }), /*#__PURE__*/_jsx("span", { - className: "fw-bold", - style: { - color: '#0f172a' - }, - children: "Strip" - })] - }), /*#__PURE__*/_jsxs("span", { - className: "d-inline-flex align-items-center gap-1 px-2 py-0.5 bg-white rounded border shadow-xs", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("kbd", { - style: { - background: '#0f172a', - color: '#f59e0b', - fontWeight: 800, - padding: '1px 5px', - borderRadius: '3px', - fontSize: '0.68rem' - }, - children: "F4" - }), /*#__PURE__*/_jsx("span", { - className: "fw-bold", - style: { - color: '#0f172a' - }, - children: "Patient" - })] - }), /*#__PURE__*/_jsxs("span", { - className: "d-inline-flex align-items-center gap-1 px-2 py-0.5 bg-white rounded border shadow-xs", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("kbd", { - style: { - background: '#0f172a', - color: '#a855f7', - fontWeight: 800, - padding: '1px 5px', - borderRadius: '3px', - fontSize: '0.68rem' - }, - children: "F8" - }), /*#__PURE__*/_jsx("span", { - className: "fw-bold", - style: { - color: '#0f172a' - }, - children: "Payment" - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs py-0.5 px-2 bg-white rounded border border-danger shadow-xs d-inline-flex align-items-center gap-1", - onClick: openReturnModal, - style: { - fontSize: '0.72rem' - }, - title: "Accept patient returns or exchange on current bill (Alt+R / F6)", - children: [/*#__PURE__*/_jsx("kbd", { - style: { - background: '#e11d48', - color: '#ffffff', - fontWeight: 800, - padding: '1px 5px', - borderRadius: '3px', - fontSize: '0.68rem' - }, - children: "Alt+R / F6" - }), /*#__PURE__*/_jsx("span", { - className: "fw-bold text-danger", - children: "Return / Exch" - })] - }), /*#__PURE__*/_jsxs("span", { - className: "d-inline-flex align-items-center gap-1 px-2.5 py-0.5 rounded text-white shadow-sm", - style: { - background: '#059669', - fontSize: '0.72rem', - border: '1px solid #047857' - }, - children: [/*#__PURE__*/_jsx("kbd", { - style: { - background: '#ffffff', - color: '#065f46', - fontWeight: 800, - padding: '1px 5px', - borderRadius: '3px', - fontSize: '0.68rem' - }, - children: "F9 / Ctrl+↵" - }), /*#__PURE__*/_jsx("span", { - className: "fw-bold", - children: "Bill & Print" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2 mb-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-upc-scan text-primary fs-5" - }), /*#__PURE__*/_jsx("span", { - className: "fw-bold fs-6", - children: "Medicine Lookup & Barcode Dispenser" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "input-group", - children: [/*#__PURE__*/_jsxs("span", { - className: "input-group-text bg-light text-primary fw-bold", - style: { - fontSize: '0.75rem' - }, - children: [/*#__PURE__*/_jsx("kbd", { - className: "me-1", - style: { - background: '#0f172a', - color: '#38bdf8', - fontWeight: 800, - padding: '1px 5px', - borderRadius: '3px' - }, - children: "F2" - }), /*#__PURE__*/_jsx("i", { - className: "bi bi-capsule" - })] - }), /*#__PURE__*/_jsx("input", { - type: "text", - id: "item-search-input", - ref: medicineSearchRef, - className: "form-control fw-semibold", - placeholder: "Type Medicine Name, Generic Molecule, or Scan Box Barcode... (Press F2 anytime)", - value: itemQuery, - onChange: e => searchItems(e.target.value), - onKeyDown: handleMedicineSearchKeyDown, - autoComplete: "off" - }), isSearchingItems && /*#__PURE__*/_jsx("span", { - className: "input-group-text bg-light", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-hourglass-split" - }) - })] - }), itemResults.length > 0 && /*#__PURE__*/_jsx("div", { - className: "search-results-dropdown", - children: itemResults.map(it => /*#__PURE__*/_jsxs("div", { - className: "search-item-row", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-1", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("span", { - className: "fw-bold text-dark fs-6", - children: it.item_name - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary ms-2", - style: { - fontSize: '0.65rem' - }, - children: it.unit_pack - }), it.drug_schedule && it.drug_schedule !== 'OTC' && /*#__PURE__*/_jsx("span", { - className: "badge bg-warning-subtle text-warning border border-warning ms-1", - style: { - fontSize: '0.65rem' - }, - children: it.drug_schedule - })] - }), /*#__PURE__*/_jsx("div", { - children: /*#__PURE__*/_jsxs("span", { - className: "text-muted me-2", - style: { - fontSize: '0.75rem' - }, - children: ["Total Stock: ", it.total_stock] - }) - })] - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted d-block mb-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-diagram-3 me-1" - }), it.generic_name, " • HSN: ", it.hsn_code] - }), it.batches && it.batches.length > 0 ? /*#__PURE__*/_jsx("div", { - className: "d-flex flex-wrap gap-2 mt-1", - children: it.batches.map(b => { - const isHighlighted = selectableBatches[selectedBatchIndex] && selectableBatches[selectedBatchIndex].batch.batch_id === b.batch_id && selectableBatches[selectedBatchIndex].item.item_id === it.item_id; - return /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm ${isHighlighted ? 'btn-warning text-dark border-2 shadow-sm fw-bold' : b.is_expired ? 'btn-outline-danger disabled' : 'btn-outline-dark'} d-flex align-items-center gap-1 py-0.5 px-2`, - style: { - fontSize: '0.75rem', - transform: isHighlighted ? 'scale(1.04)' : 'scale(1)', - transition: 'transform 0.1s' - }, - onClick: () => addItemToCart(it, b, 1), - disabled: b.is_expired, - title: isHighlighted ? 'Press Enter to select this batch' : `Select batch ${b.batch_no}`, - children: [/*#__PURE__*/_jsx("strong", { - children: b.batch_no - }), /*#__PURE__*/_jsxs("span", { - children: ["(Exp: ", b.expiry_display, ")"] - }), /*#__PURE__*/_jsxs("span", { - className: "text-success fw-bold", - children: ["₹", b.mrp] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-primary text-white", - children: [b.current_qty, " left"] - }), it.fefo_batch && it.fefo_batch.batch_id === b.batch_id && /*#__PURE__*/_jsx("span", { - className: "badge-fefo ms-1", - children: "FEFO" - }), b.is_near_expiry && /*#__PURE__*/_jsx("span", { - className: "badge-near-expiry ms-1", - children: "Near Exp" - }), b.is_expired && /*#__PURE__*/_jsx("span", { - className: "badge-expired ms-1", - children: "EXPIRED" - }), isHighlighted && /*#__PURE__*/_jsx("span", { - className: "badge bg-dark text-warning ms-1", - style: { - fontSize: '0.62rem' - }, - children: "↵ Enter" - })] - }, b.batch_id); - }) - }) : /*#__PURE__*/_jsx("span", { - className: "text-danger fw-bold", - style: { - fontSize: '0.75rem' - }, - children: "Out of Stock in this Counter" - })] - }, it.item_id)) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "counter-card p-0 overflow-hidden", - children: [/*#__PURE__*/_jsxs("div", { - className: "p-3 pb-2 d-flex flex-wrap justify-content-between align-items-center gap-2 border-bottom", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsxs("h6", { - className: "mb-0 fw-bold", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cart-check-fill text-success me-1" - }), " Dispensing Cart (", cart.length, " new)"] - }), returnCart.length > 0 && /*#__PURE__*/_jsxs("span", { - className: "badge bg-danger-subtle text-danger border border-danger", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-return-left me-1" - }), returnCart.length, " return/exchange"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2 align-items-center", - children: [(cart.length > 0 || returnCart.length > 0) && /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-success py-0.5 px-2.5 fw-bold d-inline-flex align-items-center gap-1.5 shadow-sm", - onClick: () => setIsCheckoutOpen(true), - style: { - fontSize: '0.75rem', - background: '#10b981', - borderColor: '#059669' - }, - title: "Open Checkout Desk to finalize bill (F8 / F9)", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-wallet2" - }), " Checkout ", refundPayable > 0 ? `(Refund ₹${refundPayable})` : `(₹${netPayable})`, " ", /*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-right" - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-danger py-0.5 px-2.5 fw-semibold d-inline-flex align-items-center gap-1", - onClick: openReturnModal, - style: { - fontSize: '0.75rem' - }, - title: "Add patient return or item exchange (Alt+R / F6)", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-return-left" - }), " Add Return / Exch"] - }), (cart.length > 0 || returnCart.length > 0) && /*#__PURE__*/_jsx("button", { - className: "btn btn-sm btn-link text-muted text-decoration-none p-0", - onClick: () => { - setCart([]); - setReturnCart([]); - }, - children: "Clear All" - })] - })] - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive", - style: { - maxHeight: 380 - }, - children: /*#__PURE__*/_jsxs("table", { - className: "table table-pos mb-0", - children: [/*#__PURE__*/_jsx("thead", { - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "#" - }), /*#__PURE__*/_jsx("th", { - children: "Medicine Name" - }), /*#__PURE__*/_jsx("th", { - children: "Batch / Exp" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 155 - }, - children: "Qty & Unit" - }), /*#__PURE__*/_jsx("th", { - children: "Rate (₹)" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 125 - }, - children: "Disc (% / ₹)" - }), /*#__PURE__*/_jsx("th", { - children: "GST%" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Total (₹)" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 40 - } - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: cart.length === 0 && returnCart.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "9", - className: "text-center py-4 text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-basket3 fs-3 d-block mb-1" - }), "Scan barcode or search medicine to add items, or click ", /*#__PURE__*/_jsx("strong", { - className: "text-danger", - children: "Add Return / Exch" - }), " (Alt+R / F6)."] - }) - }) : cart.map((it, idx) => { - const info = getItemLineInfo(it); - const lineGross = info.lineGross; - const lineDisc = getItemDiscount(it); - const lineNet = Math.max(0, lineGross - lineDisc).toFixed(2); - const upp = info.upp; - return /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - children: idx + 1 - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold", - children: it.item_name - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [it.generic_name, " • HSN: ", it.hsn_code] - }), upp > 1 && /*#__PURE__*/_jsxs("span", { - className: "badge bg-secondary-subtle text-secondary border ms-1", - style: { - fontSize: '0.62rem' - }, - children: ["Pack: ", it.unit_pack || `${upp} Tabs`] - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-light text-dark border", - children: it.batch_no - }), /*#__PURE__*/_jsxs("div", { - className: "text-muted", - style: { - fontSize: '0.7rem' - }, - children: ["Exp: ", it.expiry_display] - })] - }), /*#__PURE__*/_jsx("td", { - children: upp > 1 ? /*#__PURE__*/_jsxs("div", { - style: { - maxWidth: 155 - }, - children: [it.sell_unit === 'Combo' ? /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm py-0 px-1 fw-bold bg-warning-subtle text-dark border-warning", - style: { - maxWidth: 64, - fontSize: '0.72rem' - }, - value: it.sell_unit, - onChange: e => switchSellUnit(idx, e.target.value), - title: "Unit Type: Combo (Strips + Loose Tablets)", - children: [/*#__PURE__*/_jsx("option", { - value: "Tablet", - children: "Tab" - }), /*#__PURE__*/_jsx("option", { - value: "Strip", - children: "Strip" - }), /*#__PURE__*/_jsx("option", { - value: "Combo", - children: "Str+Tab" - })] - }), /*#__PURE__*/_jsx("input", { - type: "number", - id: `cart-qty-strip-${idx}`, - className: "form-control form-control-sm text-center fw-bold px-1", - min: "0", - placeholder: "Str", - title: "Whole Strips", - value: it.strip_qty ?? 1, - onChange: e => updateCartItem(idx, 'strip_qty', Number(e.target.value)), - onKeyDown: e => { - if (e.key === 'Enter') { - e.preventDefault(); - focusMedicineSearch(); - } else if (e.key === 'Delete' && e.shiftKey) { - e.preventDefault(); - removeCartItem(idx); - focusMedicineSearch(); - } - } - }), /*#__PURE__*/_jsx("input", { - type: "number", - id: `cart-qty-loose-${idx}`, - className: "form-control form-control-sm text-center fw-bold text-success border-success px-1", - min: "0", - placeholder: "Tab", - title: "Loose Tablets", - value: it.loose_qty ?? 0, - onChange: e => updateCartItem(idx, 'loose_qty', Number(e.target.value)), - onKeyDown: e => { - if (e.key === 'Enter') { - e.preventDefault(); - focusMedicineSearch(); - } else if (e.key === 'Delete' && e.shiftKey) { - e.preventDefault(); - removeCartItem(idx); - focusMedicineSearch(); - } - } - })] - }) : /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsxs("select", { - className: `form-select form-select-sm py-0 px-1 fw-bold ${it.sell_unit === 'Strip' ? 'bg-primary-subtle text-primary border-primary' : 'bg-success-subtle text-success border-success'}`, - style: { - maxWidth: 65, - fontSize: '0.72rem' - }, - value: it.sell_unit || 'Tablet', - onChange: e => switchSellUnit(idx, e.target.value), - title: "Select Unit Type before quantity", - children: [/*#__PURE__*/_jsx("option", { - value: "Tablet", - children: "Tab" - }), /*#__PURE__*/_jsx("option", { - value: "Strip", - children: "Strip" - }), /*#__PURE__*/_jsx("option", { - value: "Combo", - children: "Str+Tab" - })] - }), /*#__PURE__*/_jsx("input", { - type: "number", - id: it.sell_unit === 'Strip' ? `cart-qty-strip-${idx}` : `cart-qty-loose-${idx}`, - className: `form-control form-control-sm text-center fw-bold ${it.sell_unit === 'Strip' ? 'text-primary' : 'text-success border-success'}`, - min: "1", - max: it.current_qty, - value: it.sell_unit === 'Strip' ? it.strip_qty ?? it.qty ?? 1 : it.loose_qty ?? it.qty ?? 1, - onChange: e => { - const val = Number(e.target.value); - const updated = [...cart]; - if (it.sell_unit === 'Strip') { - updated[idx].strip_qty = val; - } else { - updated[idx].loose_qty = val; - } - updated[idx].qty = val; - setCart(updated); - }, - onKeyDown: e => { - if (e.key === 'Enter') { - e.preventDefault(); - focusMedicineSearch(); - } else if (e.altKey && (e.key === 's' || e.key === 'S')) { - e.preventDefault(); - switchSellUnit(idx, 'Strip'); - } else if (e.altKey && (e.key === 't' || e.key === 'T')) { - e.preventDefault(); - switchSellUnit(idx, 'Tablet'); - } else if (e.altKey && (e.key === 'c' || e.key === 'C')) { - e.preventDefault(); - switchSellUnit(idx, 'Combo'); - } else if (e.key === 'Delete' && e.shiftKey) { - e.preventDefault(); - removeCartItem(idx); - focusMedicineSearch(); - } - } - })] - }), /*#__PURE__*/_jsx("div", { - className: "text-muted text-center mt-0.5", - style: { - fontSize: '0.64rem' - }, - children: it.sell_unit === 'Tablet' ? `= ${info.totalUnits} Tab (₹${info.perUnitMrp}/tab)` : it.sell_unit === 'Combo' ? `= ${info.totalUnits} Tab total` : `= ${info.totalUnits} Tab (${upp}/str)` - })] - }) : /*#__PURE__*/_jsxs("div", { - style: { - maxWidth: 120 - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-light text-muted px-1.5 py-0 fw-semibold", - style: { - fontSize: '0.68rem', - maxWidth: 50 - }, - children: it.unit_pack || 'Unit' - }), /*#__PURE__*/_jsx("input", { - type: "number", - id: `cart-qty-strip-${idx}`, - className: "form-control form-control-sm text-center fw-bold", - min: "1", - max: it.current_qty, - value: it.qty, - onChange: e => updateCartItem(idx, 'qty', Number(e.target.value)), - onKeyDown: e => { - if (e.key === 'Enter') { - e.preventDefault(); - focusMedicineSearch(); - } else if (e.key === 'Delete' && e.shiftKey) { - e.preventDefault(); - removeCartItem(idx); - focusMedicineSearch(); - } - } - })] - }), /*#__PURE__*/_jsxs("div", { - className: "text-muted text-center mt-0.5", - style: { - fontSize: '0.64rem' - }, - children: ["₹", it.unit_mrp, " each"] - })] - }) - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-semibold", - children: it.sell_unit === 'Tablet' ? /*#__PURE__*/_jsxs("span", { - children: ["₹", info.perUnitMrp, " ", /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "/tab" - })] - }) : it.sell_unit === 'Combo' ? /*#__PURE__*/_jsxs("span", { - children: ["₹", it.unit_mrp, " ", /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "/str" - })] - }) : /*#__PURE__*/_jsxs("span", { - children: ["₹", it.unit_mrp, " ", upp > 1 ? /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "/strip" - }) : ''] - }) - }), upp > 1 && /*#__PURE__*/_jsx("small", { - className: "text-muted d-block", - style: { - fontSize: '0.68rem' - }, - children: it.sell_unit === 'Tablet' ? `Strip: ₹${it.unit_mrp}` : `Tab: ₹${info.perUnitMrp}` - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - style: { - width: 115 - }, - children: [/*#__PURE__*/_jsx("input", { - type: "number", - id: `cart-disc-${idx}`, - className: "form-control form-control-sm text-center px-1 fw-semibold", - min: "0", - max: it.discount_type === 'pct' ? 100 : lineGross, - step: it.discount_type === 'pct' ? '0.5' : '1', - value: it.discount_val ?? '', - placeholder: "0", - onChange: e => updateCartItem(idx, 'discount_val', e.target.value), - onKeyDown: e => { - if (e.key === 'Enter') { - e.preventDefault(); - focusMedicineSearch(); - } - } - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: `btn btn-sm ${it.discount_type === 'pct' ? 'btn-primary' : 'btn-warning text-dark'} px-2 py-0 fw-bold`, - title: `Click to switch between % and ₹ (Currently: ${it.discount_type === 'pct' ? 'Percentage' : 'Value in Rupees'})`, - onClick: () => toggleItemDiscType(idx), - children: it.discount_type === 'pct' ? '%' : '₹' - })] - }), lineDisc > 0 && /*#__PURE__*/_jsx("div", { - className: "text-muted text-center mt-0.5", - style: { - fontSize: '0.68rem' - }, - children: it.discount_type === 'pct' ? `-₹${lineDisc.toFixed(2)}` : `${lineGross > 0 ? (lineDisc / lineGross * 100).toFixed(1) : 0}% off` - })] - }), /*#__PURE__*/_jsxs("td", { - children: [it.gst_rate, "%"] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-bold text-dark", - children: ["₹", lineNet] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("button", { - className: "btn btn-sm btn-outline-danger py-0 px-1", - onClick: () => removeCartItem(idx), - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-trash" - }) - }) - })] - }, `sale-${idx}`); - }).concat(returnCart.map((rc, rIdx) => /*#__PURE__*/_jsxs("tr", { - style: { - backgroundColor: 'rgba(244, 63, 94, 0.05)' - }, - children: [/*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: "badge bg-danger text-white", - children: "RET" - }) - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsxs("div", { - className: "fw-bold text-danger", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-return-left me-1" - }), rc.item_name] - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: ["Bill: ", /*#__PURE__*/_jsx("code", { - children: rc.ref_invoice_no - }), " • ", rc.reason ? rc.reason.replace(/_/g, ' ') : 'Return'] - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-light text-dark border", - children: rc.batch_no - }), /*#__PURE__*/_jsxs("div", { - className: "text-muted", - style: { - fontSize: '0.7rem' - }, - children: ["Exp: ", rc.expiry_date ? rc.expiry_date.substring(0, 7) : ''] - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-danger-subtle text-danger border border-danger fw-bold", - children: ["- ", rc.return_qty, " ", rc.return_unit] - }), /*#__PURE__*/_jsxs("div", { - className: "text-muted mt-0.5", - style: { - fontSize: '0.64rem' - }, - children: ["(", rc.return_total_units, " Tabs • ", rc.condition === 'GOOD' ? 'Restocking' : 'Discard', ")"] - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsxs("div", { - className: "fw-semibold text-danger", - children: ["₹", rc.unit_price, " ", /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "/tab" - })] - }), rc.units_per_pack > 1 && /*#__PURE__*/_jsxs("small", { - className: "text-muted d-block", - style: { - fontSize: '0.68rem' - }, - children: ["MRP: ₹", rc.unit_mrp] - })] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary-subtle text-secondary", - style: { - fontSize: '0.7rem' - }, - children: rc.condition === 'GOOD' ? 'Restock' : 'Scrap' - }) - }), /*#__PURE__*/_jsxs("td", { - children: [rc.gst_rate || 12, "%"] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-bold text-danger", - children: ["-₹", Number(rc.line_total).toFixed(2)] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("button", { - className: "btn btn-sm btn-outline-danger py-0 px-1", - onClick: () => setReturnCart(returnCart.filter((_, i) => i !== rIdx)), - title: "Remove from returns", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-trash" - }) - }) - })] - }, `ret-${rIdx}`))) - })] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "p-3 bg-light border-top d-flex flex-wrap justify-content-between align-items-center gap-3", - children: [/*#__PURE__*/_jsx("div", { - className: "d-flex flex-wrap align-items-center gap-3", - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-secondary-subtle text-secondary border px-2.5 py-1.5 fw-semibold", - style: { - fontSize: '0.8rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cart-check me-1" - }), " ", cart.length + returnCart.length, " Line Items"] - }), /*#__PURE__*/_jsxs("span", { - className: "text-muted small", - children: ["Gross: ", /*#__PURE__*/_jsxs("strong", { - className: "text-dark", - children: ["₹", grossTotal.toFixed(2)] - })] - }), itemDiscountTotal > 0 && /*#__PURE__*/_jsxs("span", { - className: "text-muted small", - children: ["Item Disc: ", /*#__PURE__*/_jsxs("strong", { - className: "text-danger", - children: ["-₹", itemDiscountTotal.toFixed(2)] - })] - }), wholeDiscountAmt > 0 && /*#__PURE__*/_jsxs("span", { - className: "text-muted small", - children: ["Bill Disc: ", /*#__PURE__*/_jsxs("strong", { - className: "text-danger", - children: ["-₹", wholeDiscountAmt.toFixed(2)] - })] - }), returnTotal > 0 && /*#__PURE__*/_jsxs("span", { - className: "text-muted small", - children: ["Return Credit: ", /*#__PURE__*/_jsxs("strong", { - className: "text-danger", - children: ["-₹", returnTotal.toFixed(2)] - })] - })] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "text-end", - children: [/*#__PURE__*/_jsx("div", { - className: "text-muted small text-uppercase fw-semibold", - style: { - fontSize: '0.68rem', - letterSpacing: '0.5px' - }, - children: refundPayable > 0 ? 'Customer Refund' : 'Net Amount' - }), /*#__PURE__*/_jsxs("div", { - className: `fs-4 fw-bolder ${refundPayable > 0 ? 'text-danger' : 'text-success'}`, - style: { - lineHeight: 1.1 - }, - children: ["₹", refundPayable > 0 ? refundPayable.toFixed(2) : netPayable.toFixed(2)] - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - id: "btn-pos-checkout-trigger", - className: "btn btn-success btn-lg px-4 py-2.5 fw-bold shadow d-flex align-items-center gap-2", - disabled: cart.length === 0 && returnCart.length === 0, - onClick: () => setIsCheckoutOpen(true), - style: { - background: 'linear-gradient(135deg, #10b981 0%, #059669 100%)', - border: 'none', - borderRadius: '10px', - fontSize: '1rem', - letterSpacing: '0.3px', - transition: 'transform 0.15s ease, box-shadow 0.15s ease' - }, - title: "Open Checkout Desk to review totals, select payment method and complete sale (F8 / F9)", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-wallet2 fs-5" - }), /*#__PURE__*/_jsx("span", { - children: "Checkout" - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-white text-success ms-1 px-2 py-0.5", - style: { - fontSize: '0.72rem', - fontWeight: 800 - }, - children: "F8 / F9" - }), /*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-right fs-5" - })] - })] - })] - })] - })] - }), selectedPatient && showHistoryPanel && /*#__PURE__*/_jsx("div", { - className: "col-12 col-lg-4 col-xl-4", - children: /*#__PURE__*/_jsxs("div", { - className: "patient-history-sidebar position-sticky shadow-sm", - style: { - top: '15px', - maxHeight: 'calc(100vh - 100px)', - display: 'flex', - flexDirection: 'column' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "patient-history-header", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-1.5", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clock-history text-info fs-5" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "mb-0 fw-bold text-white", - style: { - fontSize: '0.9rem' - }, - children: "Patient Pharmacy History" - }), /*#__PURE__*/_jsxs("small", { - className: "text-secondary", - style: { - fontSize: '0.72rem' - }, - children: ["UHID: ", /*#__PURE__*/_jsx("span", { - className: "text-warning fw-bold", - children: selectedPatient.uhid - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-1", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-xs btn-outline-light py-0.5 px-2", - onClick: () => fetchPatientHistory(selectedPatient.patient_id, selectedPatient.uhid, selectedPatient.mobile), - disabled: isLoadingHistory, - title: "Refresh Patient History", - style: { - fontSize: '0.7rem' - }, - children: /*#__PURE__*/_jsx("i", { - className: `bi bi-arrow-clockwise ${isLoadingHistory ? 'spin' : ''}` - }) - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-xs btn-outline-light py-0.5 px-2", - onClick: () => setShowHistoryPanel(false), - title: "Hide sidebar (Click 'Old Records' in patient bar to re-open)", - style: { - fontSize: '0.7rem' - }, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-chevron-bar-right" - }) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap align-items-center justify-content-between gap-1 pt-1.5 border-top border-secondary", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsxs("span", { - className: "text-light", - children: [/*#__PURE__*/_jsx("strong", { - children: selectedPatient.full_name - }), " • ", selectedPatient.gender, ", ", selectedPatient.age] - }), patientHistory && /*#__PURE__*/_jsxs("span", { - className: "badge bg-primary-subtle text-primary border border-primary px-1.5 py-0.5", - children: [patientHistory.total_sales || 0, " Bills • ₹", patientHistory.total_spend || 0] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "patient-history-tabs", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: `patient-history-tab-btn ${historyActiveTab === 'last_given' ? 'active' : ''}`, - onClick: () => setHistoryActiveTab('last_given'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-capsule text-success" - }), /*#__PURE__*/_jsx("span", { - children: "Last Given" - }), patientHistory?.last_dispensed_items?.length > 0 && /*#__PURE__*/_jsx("span", { - className: "badge bg-success text-white rounded-pill px-1", - style: { - fontSize: '0.62rem' - }, - children: patientHistory.last_dispensed_items.length - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: `patient-history-tab-btn ${historyActiveTab === 'all_bills' ? 'active' : ''}`, - onClick: () => setHistoryActiveTab('all_bills'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-receipt text-primary" - }), /*#__PURE__*/_jsx("span", { - children: "Past Bills" - }), patientHistory?.invoices?.length > 0 && /*#__PURE__*/_jsx("span", { - className: "badge bg-primary text-white rounded-pill px-1", - style: { - fontSize: '0.62rem' - }, - children: patientHistory.invoices.length - })] - }), patientHistory?.doctor_prescriptions?.length > 0 && /*#__PURE__*/_jsxs("button", { - type: "button", - className: `patient-history-tab-btn ${historyActiveTab === 'prescriptions' ? 'active' : ''}`, - onClick: () => setHistoryActiveTab('prescriptions'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-stethoscope text-danger" - }), /*#__PURE__*/_jsx("span", { - children: "Doctor Rx" - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-danger text-white rounded-pill px-1", - style: { - fontSize: '0.62rem' - }, - children: patientHistory.doctor_prescriptions.length - })] - }), patientHistory?.unique_medicines?.length > 0 && /*#__PURE__*/_jsxs("button", { - type: "button", - className: `patient-history-tab-btn ${historyActiveTab === 'summary' ? 'active' : ''}`, - onClick: () => setHistoryActiveTab('summary'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-journal-medical text-warning" - }), /*#__PURE__*/_jsx("span", { - children: "All Meds" - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary text-white rounded-pill px-1", - style: { - fontSize: '0.62rem' - }, - children: patientHistory.unique_medicines.length - })] - })] - }), /*#__PURE__*/_jsx("div", { - className: "patient-history-body", - children: isLoadingHistory ? /*#__PURE__*/_jsxs("div", { - className: "text-center py-5 text-muted", - children: [/*#__PURE__*/_jsx("div", { - className: "spinner-border spinner-border-sm text-primary me-2" - }), "Loading patient records..."] - }) : !patientHistory || patientHistory.total_sales === 0 && (!patientHistory.doctor_prescriptions || patientHistory.doctor_prescriptions.length === 0) ? /*#__PURE__*/_jsxs("div", { - className: "text-center py-4 px-2 text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-folder-x fs-1 text-secondary opacity-50 d-block mb-2" - }), /*#__PURE__*/_jsx("h6", { - className: "fw-semibold text-dark", - children: "No Previous Pharmacy Records" - }), /*#__PURE__*/_jsx("small", { - children: "This patient has no recorded medicine dispenses or bills in the pharmacy database yet." - })] - }) : /*#__PURE__*/_jsxs(_Fragment, { - children: [historyActiveTab === 'last_given' && /*#__PURE__*/_jsx("div", { - children: patientHistory.last_sale ? /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsxs("div", { - className: "p-2.5 mb-2 rounded-3 border", - style: { - background: '#f0fdf4', - borderColor: '#bbf7d0' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-1", - children: [/*#__PURE__*/_jsxs("span", { - className: "fw-bold text-success", - style: { - fontSize: '0.78rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle-fill me-1" - }), " Last Dispensed Visit"] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-dark text-white", - style: { - fontSize: '0.68rem' - }, - children: patientHistory.last_sale.invoice_no - })] - }), /*#__PURE__*/_jsxs("div", { - className: "text-muted", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-calendar-event me-1" - }), " ", patientHistory.last_sale.sale_date ? patientHistory.last_sale.sale_date.substring(0, 16) : 'N/A'] - }), patientHistory.last_sale.doctor_name && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-badge me-1" - }), " Prescribed by: ", /*#__PURE__*/_jsx("strong", { - children: patientHistory.last_sale.doctor_name - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mt-1.5 pt-1 border-top border-success-subtle", - children: [/*#__PURE__*/_jsxs("span", { - children: ["Paid: ", /*#__PURE__*/_jsxs("strong", { - children: ["₹", patientHistory.last_sale.net_amount] - }), " (", patientHistory.last_sale.payment_mode, ")"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-outline-success py-0 px-2 fw-bold", - onClick: () => viewPastBill(patientHistory.last_sale.sale_id), - style: { - fontSize: '0.68rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer me-1" - }), " View Bill"] - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "fw-bold text-dark mb-1.5 d-flex justify-content-between align-items-center", - style: { - fontSize: '0.75rem' - }, - children: [/*#__PURE__*/_jsxs("span", { - children: ["Medicines Given (", patientHistory.last_dispensed_items.length, "):"] - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: ["Click ", /*#__PURE__*/_jsx("strong", { - children: "+" - }), " to re-dispense"] - })] - }), patientHistory.last_dispensed_items.map((it, mIdx) => /*#__PURE__*/_jsxs("div", { - className: "history-med-card last-given", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-start mb-1", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-dark", - style: { - fontSize: '0.82rem' - }, - children: it.item_name - }), /*#__PURE__*/_jsx("small", { - className: "text-muted d-block", - style: { - fontSize: '0.68rem' - }, - children: it.generic_name - })] - }), /*#__PURE__*/_jsxs("div", { - className: "text-end", - children: [/*#__PURE__*/_jsxs("span", { - className: "fw-bold text-dark", - style: { - fontSize: '0.82rem' - }, - children: ["₹", it.total_amount] - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted d-block", - style: { - fontSize: '0.68rem' - }, - children: ["₹", it.unit_mrp, "/", it.sell_unit] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap align-items-center gap-1 mb-2", - style: { - fontSize: '0.68rem' - }, - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-light text-dark border", - children: ["Batch: ", it.batch_no] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-light text-secondary border", - children: ["Exp: ", it.expiry_date] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-primary text-white", - children: ["Qty: ", it.qty, " ", it.sell_unit] - }), it.remaining_units > 0 ? /*#__PURE__*/_jsxs("span", { - className: "badge bg-success-subtle text-success border border-success", - children: ["Returnable: ", it.remaining_strips > 0 ? `${it.remaining_strips} Str ` : '', it.remaining_loose > 0 ? `${it.remaining_loose} Tab` : ''] - }) : /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary-subtle text-muted border", - children: "Fully Returned" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-1.5 pt-1.5 border-top", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-success py-1 px-2 fw-semibold d-inline-flex align-items-center gap-1 shadow-xs flex-fill justify-content-center", - onClick: () => reDispenseMedicine(it, it.qty), - style: { - fontSize: '0.72rem', - background: '#059669', - borderColor: '#047857' - }, - title: "Add this medicine to active dispensing cart with current FEFO batch", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-plus-circle-fill" - }), /*#__PURE__*/_jsx("span", { - children: "Dispense Again" - })] - }), it.remaining_units > 0 && /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-outline-danger py-1 px-2 fw-semibold d-inline-flex align-items-center gap-1 shadow-xs", - onClick: () => initiateReturnFromHistory(patientHistory.last_sale, it), - style: { - fontSize: '0.72rem' - }, - title: "Return or exchange this dispensed item into current bill", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-return-left" - }), /*#__PURE__*/_jsx("span", { - children: "Return" - })] - })] - })] - }, `last-med-${mIdx}`))] - }) : /*#__PURE__*/_jsxs("div", { - className: "text-center py-4 text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-basket text-secondary fs-3 d-block mb-1" - }), "No pharmacy sales recorded yet for this patient."] - }) - }), historyActiveTab === 'all_bills' && /*#__PURE__*/_jsx("div", { - children: patientHistory.invoices?.map((inv, invIdx) => { - const s = inv.sale; - const isExp = expandedBillId === s.sale_id; - return /*#__PURE__*/_jsxs("div", { - className: "card mb-2 border shadow-xs", - style: { - borderRadius: '8px' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header py-2 px-2.5 bg-white d-flex justify-content-between align-items-center", - style: { - cursor: 'pointer', - borderBottom: isExp ? '1px solid #e2e8f0' : 'none' - }, - onClick: () => setExpandedBillId(isExp ? null : s.sale_id), - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "fw-bold text-dark d-flex align-items-center gap-1.5", - style: { - fontSize: '0.78rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: `bi bi-chevron-${isExp ? 'down' : 'right'} text-primary`, - style: { - fontSize: '0.7rem' - } - }), /*#__PURE__*/_jsx("span", { - children: s.invoice_no - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-light text-secondary border", - style: { - fontSize: '0.65rem' - }, - children: [inv.items.length, " items"] - })] - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted", - style: { - fontSize: '0.68rem' - }, - children: [s.sale_date ? s.sale_date.substring(0, 10) : '', " • Dr. ", s.doctor_name || 'Consultant'] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "text-end", - children: [/*#__PURE__*/_jsxs("span", { - className: "fw-bold text-success d-block", - style: { - fontSize: '0.82rem' - }, - children: ["₹", s.net_amount] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary-subtle text-secondary", - style: { - fontSize: '0.62rem' - }, - children: s.payment_mode - })] - })] - }), isExp && /*#__PURE__*/_jsxs("div", { - className: "card-body p-2 bg-light", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-1.5", - children: [/*#__PURE__*/_jsx("span", { - className: "text-muted fw-semibold", - style: { - fontSize: '0.7rem' - }, - children: "Items Dispensed:" - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-1", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-outline-dark py-0 px-1.5", - onClick: e => { - e.stopPropagation(); - viewPastBill(s.sale_id); - }, - style: { - fontSize: '0.65rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer me-1" - }), " Reprint"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-outline-danger py-0 px-1.5", - onClick: e => { - e.stopPropagation(); - selectReturnInvoice(inv); - openReturnModal(); - }, - style: { - fontSize: '0.65rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-return-left me-1" - }), " Return All"] - })] - })] - }), inv.items.map((it, itIdx) => /*#__PURE__*/_jsxs("div", { - className: "p-1.5 mb-1 bg-white rounded border d-flex justify-content-between align-items-center", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-dark", - children: it.item_name - }), /*#__PURE__*/_jsxs("div", { - className: "text-muted", - style: { - fontSize: '0.65rem' - }, - children: ["Batch: ", it.batch_no, " • ", it.qty, " ", it.sell_unit, " @ ₹", it.unit_mrp] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-1", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-xs btn-outline-success py-0 px-1", - onClick: () => reDispenseMedicine(it, it.qty), - title: "Dispense again", - style: { - fontSize: '0.68rem' - }, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-plus" - }) - }), it.remaining_units > 0 && /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-xs btn-outline-danger py-0 px-1", - onClick: () => initiateReturnFromHistory(s, it), - title: "Return this item", - style: { - fontSize: '0.68rem' - }, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-return-left" - }) - })] - })] - }, `inv-item-${itIdx}`))] - })] - }, `inv-${s.sale_id}`); - }) - }), historyActiveTab === 'prescriptions' && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "text-muted mb-2 fw-semibold", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-stethoscope text-primary me-1" - }), " Doctor Prescriptions from OPD Visits:"] - }), patientHistory.doctor_prescriptions?.map((dp, dpIdx) => /*#__PURE__*/_jsxs("div", { - className: "history-med-card mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-start mb-1", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-dark", - style: { - fontSize: '0.82rem' - }, - children: dp.med_name - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary-subtle text-secondary border", - style: { - fontSize: '0.65rem' - }, - children: dp.med_type || 'Medicine' - })] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - style: { - fontSize: '0.68rem' - }, - children: dp.date_opd_visit - })] - }), /*#__PURE__*/_jsxs("div", { - className: "text-muted mb-1.5", - style: { - fontSize: '0.7rem' - }, - children: [dp.doc_name && /*#__PURE__*/_jsxs("div", { - children: ["Doc: ", /*#__PURE__*/_jsxs("strong", { - children: ["Dr. ", dp.doc_name] - })] - }), /*#__PURE__*/_jsxs("div", { - children: ["Dose: ", dp.dosage_freq_str || dp.dosage || '1 Tab', " • Duration: ", dp.no_of_days || '5 Days'] - }), dp.remark && /*#__PURE__*/_jsxs("div", { - children: ["Note: ", dp.remark] - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-primary w-100 py-1 fw-semibold d-flex align-items-center justify-content-center gap-1 shadow-xs", - onClick: () => reDispenseMedicine({ - item_name: dp.med_name, - qty: 10 - }), - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-plus-circle" - }), " Dispense Prescribed Medicine"] - })] - }, `doc-rx-${dpIdx}`))] - }), historyActiveTab === 'summary' && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "text-muted mb-2 fw-semibold", - style: { - fontSize: '0.72rem' - }, - children: "Distinct Medicines Dispensed to Patient:" - }), patientHistory.unique_medicines?.map((um, uIdx) => /*#__PURE__*/_jsxs("div", { - className: "history-med-card mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-start mb-1", - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-dark", - style: { - fontSize: '0.8rem' - }, - children: um.item_name - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-primary-subtle text-primary border", - style: { - fontSize: '0.65rem' - }, - children: [um.times_dispensed, "x dispensed"] - })] - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted d-block mb-1.5", - style: { - fontSize: '0.68rem' - }, - children: ["Last on ", um.last_dispensed ? um.last_dispensed.substring(0, 10) : '', " (Batch: ", um.last_batch_no, ")"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-outline-success w-100 py-0.5 fw-semibold d-flex align-items-center justify-content-center gap-1", - onClick: () => reDispenseMedicine(um, um.last_qty || 1), - style: { - fontSize: '0.7rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-plus-circle" - }), " Dispense Again"] - })] - }, `uniq-med-${uIdx}`))] - })] - }) - })] - }) - })] - }), /*#__PURE__*/_jsx("div", { - className: `checkout-drawer-overlay ${isCheckoutOpen ? 'open' : ''}`, - onClick: () => setIsCheckoutOpen(false) - }), /*#__PURE__*/_jsxs("div", { - className: `checkout-drawer ${isCheckoutOpen ? 'open' : ''}`, - id: "pos-checkout-drawer", - children: [/*#__PURE__*/_jsxs("div", { - className: "checkout-drawer-header", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cash-coin text-warning fs-5" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "mb-0 fw-bold text-white", - children: "Checkout Desk" - }), /*#__PURE__*/_jsxs("small", { - className: "text-secondary", - style: { - fontSize: '0.72rem' - }, - children: ["Counter: ", /*#__PURE__*/_jsx("span", { - className: "text-info fw-bold", - children: store?.store_code || '' - }), " • ", store?.store_name] - })] - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-light rounded-pill px-3 py-1 d-flex align-items-center gap-1.5", - onClick: () => setIsCheckoutOpen(false), - title: "Close Checkout Drawer (Esc)", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-x-lg" - }), /*#__PURE__*/_jsx("span", { - children: "Close" - }), /*#__PURE__*/_jsx("kbd", { - className: "ms-1", - style: { - background: '#334155', - color: '#f8fafc', - fontSize: '0.65rem', - padding: '1px 4px', - borderRadius: '3px' - }, - children: "Esc" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "checkout-drawer-body", - children: [/*#__PURE__*/_jsxs("h5", { - className: "fw-bold text-white mb-3 d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsx("span", { - children: "Checkout Desk" - }), /*#__PURE__*/_jsx("span", { - className: "fs-6 text-primary", - children: store?.store_code || '' - })] - }), /*#__PURE__*/_jsxs("div", { - className: "p-2.5 rounded-3 mb-3", - style: { - background: 'rgba(255, 255, 255, 0.08)', - border: '1px solid rgba(255, 255, 255, 0.15)' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-1.5", - children: [/*#__PURE__*/_jsxs("label", { - className: "text-white small fw-bold mb-0 d-flex align-items-center gap-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-tag-fill text-warning" - }), " Whole Bill Discount"] - }), /*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: `btn btn-xs py-0.5 px-2 ${wholeDiscountType === 'pct' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light text-white'}`, - style: { - fontSize: '0.72rem' - }, - onClick: () => setWholeDiscountType('pct'), - children: "% Percent" - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: `btn btn-xs py-0.5 px-2 ${wholeDiscountType === 'val' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light text-white'}`, - style: { - fontSize: '0.72rem' - }, - onClick: () => setWholeDiscountType('val'), - children: "₹ Fixed Value" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm mb-2", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-dark border-secondary text-warning fw-bold", - children: wholeDiscountType === 'pct' ? '%' : '₹' - }), /*#__PURE__*/_jsx("input", { - type: "number", - id: "whole-discount-input", - ref: wholeDiscountRef, - className: "form-control form-control-sm bg-dark text-white border-secondary fw-bold", - min: "0", - max: wholeDiscountType === 'pct' ? 100 : balanceAfterItemDisc, - step: wholeDiscountType === 'pct' ? '0.5' : '1', - placeholder: wholeDiscountType === 'pct' ? 'Enter % (F7)' : 'Enter ₹ (F7)', - value: wholeDiscountVal || '', - onChange: e => setWholeDiscountVal(e.target.value), - onKeyDown: e => { - if (e.key === 'Enter') { - e.preventDefault(); - if (!isProcessing && cart.length > 0) { - processSale(); - } - } - } - }), Number(wholeDiscountVal) > 0 && /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-danger", - title: "Reset Whole Bill Discount", - onClick: () => setWholeDiscountVal(0), - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-x-lg" - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap gap-1 align-items-center", - children: [/*#__PURE__*/_jsx("small", { - className: "text-slate-400 me-1", - style: { - fontSize: '0.7rem', - color: '#94a3b8' - }, - children: "Presets:" - }), wholeDiscountType === 'pct' ? [5, 10, 15, 20].map(p => /*#__PURE__*/_jsxs("button", { - type: "button", - className: `badge border ${Number(wholeDiscountVal) === p ? 'bg-warning text-dark border-warning' : 'bg-transparent text-white border-secondary'}`, - style: { - cursor: 'pointer', - padding: '4px 8px', - fontSize: '0.7rem' - }, - onClick: () => setWholeDiscountVal(p), - children: [p, "%"] - }, p)) : [20, 50, 100, 200].map(v => /*#__PURE__*/_jsxs("button", { - type: "button", - className: `badge border ${Number(wholeDiscountVal) === v ? 'bg-warning text-dark border-warning' : 'bg-transparent text-white border-secondary'}`, - style: { - cursor: 'pointer', - padding: '4px 8px', - fontSize: '0.7rem' - }, - onClick: () => setWholeDiscountVal(v), - children: ["₹", v] - }, v)), Number(wholeDiscountVal) > 0 && /*#__PURE__*/_jsx("button", { - type: "button", - className: "badge bg-danger-subtle text-danger border border-danger ms-auto", - style: { - cursor: 'pointer', - padding: '4px 6px', - fontSize: '0.7rem' - }, - onClick: () => setWholeDiscountVal(0), - children: "Clear" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-1.5 text-slate-300", - style: { - color: '#cbd5e1' - }, - children: [/*#__PURE__*/_jsx("span", { - children: "Gross Items Total:" - }), /*#__PURE__*/_jsxs("span", { - className: "fw-bold", - children: ["₹", grossTotal.toFixed(2)] - })] - }), itemDiscountTotal > 0 && /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-1 text-slate-300", - style: { - fontSize: '0.84rem', - color: '#94a3b8' - }, - children: [/*#__PURE__*/_jsx("span", { - children: "Item-Level Discounts:" - }), /*#__PURE__*/_jsxs("span", { - className: "text-danger", - children: ["-₹", itemDiscountTotal.toFixed(2)] - })] - }), wholeDiscountAmt > 0 && /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-1 text-slate-300", - style: { - fontSize: '0.84rem', - color: '#94a3b8' - }, - children: [/*#__PURE__*/_jsxs("span", { - children: ["Whole Bill Discount (", wholeDiscountType === 'pct' ? `${wholeDiscountVal}%` : `₹${wholeDiscountVal}`, "):"] - }), /*#__PURE__*/_jsxs("span", { - className: "text-danger", - children: ["-₹", wholeDiscountAmt.toFixed(2)] - })] - }), discountTotal > 0 && /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-2 text-slate-300", - style: { - color: '#cbd5e1' - }, - children: [/*#__PURE__*/_jsx("span", { - children: "Total Discounts:" - }), /*#__PURE__*/_jsxs("span", { - className: "text-danger fw-bold", - children: ["-₹", discountTotal.toFixed(2)] - })] - }), returnTotal > 0 && /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-2 text-danger fw-bold py-1 px-2 rounded", - style: { - background: 'rgba(244, 63, 94, 0.15)', - border: '1px solid rgba(244, 63, 94, 0.3)' - }, - children: [/*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-return-left me-1" - }), " Less Return Credit:"] - }), /*#__PURE__*/_jsxs("span", { - children: ["-₹", returnTotal.toFixed(2)] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-2 text-slate-300", - style: { - color: '#cbd5e1' - }, - children: [/*#__PURE__*/_jsx("span", { - children: "Round Off:" - }), /*#__PURE__*/_jsxs("span", { - children: ["₹", roundOff] - })] - }), /*#__PURE__*/_jsx("hr", { - style: { - borderColor: 'rgba(255,255,255,0.15)' - } - }), refundPayable > 0 ? /*#__PURE__*/_jsxs("div", { - className: "p-3 rounded-3 mb-3 border border-warning", - style: { - background: 'rgba(245, 158, 11, 0.15)' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("span", { - className: "fs-6 fw-bold text-white", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-wallet2 text-warning me-1" - }), " REFUND TO PATIENT:"] - }), /*#__PURE__*/_jsxs("span", { - className: "fs-3 fw-bolder text-warning", - children: ["₹", refundPayable.toLocaleString('en-IN')] - })] - }), /*#__PURE__*/_jsx("small", { - className: "text-white-50 d-block mt-1", - style: { - fontSize: '0.72rem' - }, - children: "Return credit exceeds new items. Refund this net difference from counter cash drawer or UPI." - }), /*#__PURE__*/_jsxs("div", { - className: "mt-2.5", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-white small fw-bold mb-1", - children: "Refund Outflow Method" - }), /*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm w-100 mb-2", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn ${refundMode === 'Cash' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light'}`, - onClick: () => setRefundMode('Cash'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cash-stack me-1" - }), " Cash Refund"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn ${refundMode === 'UPI' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light'}`, - onClick: () => setRefundMode('UPI'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-qr-code me-1" - }), " UPI / Bank Refund"] - })] - }), refundMode === 'UPI' && /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-dark text-white border-warning", - placeholder: "Patient UPI VPA or Bank Reference #", - value: refundRefNo, - onChange: e => setRefundRefNo(e.target.value) - })] - })] - }) : /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-4", - children: [/*#__PURE__*/_jsx("span", { - className: "fs-5 fw-bold text-white", - children: "Net Payable:" - }), /*#__PURE__*/_jsxs("span", { - className: "fs-3 fw-bolder text-warning", - children: ["₹", netPayable.toLocaleString('en-IN')] - })] - }), refundPayable <= 0 && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-2", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-white fw-bold mb-0", - children: "Payment Method" - }), paymentMode === 'Mixed' && /*#__PURE__*/_jsxs("span", { - className: "badge bg-warning text-dark", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-pie-chart me-1" - }), " Partial / Split Mode"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "col-4", - children: /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm w-100 ${paymentMode === 'Cash' ? 'btn-primary-custom' : 'btn-outline-light'}`, - onClick: () => setPaymentMode('Cash'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cash-stack me-1" - }), " Cash"] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-4", - children: /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm w-100 ${paymentMode === 'UPI' ? 'btn-primary-custom' : 'btn-outline-light'}`, - onClick: () => setPaymentMode('UPI'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-qr-code-scan me-1" - }), " UPI / QR"] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-4", - children: /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm w-100 ${paymentMode === 'Mixed' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light'}`, - onClick: () => { - setPaymentMode('Mixed'); - if (!splitCash && !splitUpi) { - setSplitCash(''); - setSplitUpi(''); - } - }, - title: "Partial payment by Cash and UPI/Bank", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-pie-chart-fill me-1" - }), " Split / Mixed"] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-6", - children: /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm w-100 ${paymentMode === 'Card' ? 'btn-primary-custom' : 'btn-outline-light'}`, - onClick: () => setPaymentMode('Card'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-credit-card me-1" - }), " Card Swipe"] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-6", - children: /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm w-100 ${paymentMode === 'IPD_Credit' ? 'btn-danger' : 'btn-outline-light'}`, - onClick: () => setPaymentMode('IPD_Credit'), - title: "Charge to IPD Patient Bill", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hospital me-1" - }), " IPD Bill Post"] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-12 mt-1", - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn btn-sm w-100 ${paymentMode === 'Staff_Credit' ? 'btn-info text-dark fw-bold' : 'btn-outline-info'}`, - onClick: () => setPaymentMode('Staff_Credit'), - title: "Charge to Staff / Doctor / Customer Credit Ledger", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-lines-fill me-1" - }), " Staff / Doctor / Customer Credit A/c"] - }) - })] - }), paymentMode === 'Staff_Credit' && /*#__PURE__*/_jsxs("div", { - className: "card bg-dark border-info mb-3 p-2.5 rounded-3 text-white", - style: { - fontSize: '0.82rem' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-2 pb-1 border-bottom border-secondary", - children: [/*#__PURE__*/_jsxs("span", { - className: "fw-bold text-info", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-lines-fill me-1" - }), " Staff / Customer Credit Account"] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-info text-dark", - children: "Ledger Debit" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-2", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label text-white-50 small mb-1", - children: ["Select Credit Account ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: selectedCreditAccount ? selectedCreditAccount.account_id : '', - onChange: e => { - const acc = creditAccounts.find(a => String(a.account_id) === e.target.value); - setSelectedCreditAccount(acc || null); - }, - children: [/*#__PURE__*/_jsx("option", { - value: "", - children: "-- Choose Account --" - }), creditAccounts.filter(a => a.is_active == 1).map(a => /*#__PURE__*/_jsxs("option", { - value: a.account_id, - children: [a.account_name, " (", a.account_type.toUpperCase(), ") - Dues: ₹", Number(a.current_balance || 0).toFixed(2)] - }, a.account_id))] - })] - }), selectedCreditAccount && /*#__PURE__*/_jsxs("div", { - className: "p-2 bg-secondary bg-opacity-25 rounded border border-secondary mb-1", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between", - children: [/*#__PURE__*/_jsx("span", { - className: "text-white-50", - children: "Dept / ID:" - }), /*#__PURE__*/_jsx("span", { - className: "fw-bold", - children: selectedCreditAccount.department || selectedCreditAccount.staff_id || 'N/A' - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between", - children: [/*#__PURE__*/_jsx("span", { - className: "text-white-50", - children: "Current Outstanding:" - }), /*#__PURE__*/_jsxs("span", { - className: `fw-bold ${Number(selectedCreditAccount.current_balance) > 0 ? 'text-warning' : 'text-success'}`, - children: ["₹", Number(selectedCreditAccount.current_balance || 0).toFixed(2)] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between", - children: [/*#__PURE__*/_jsx("span", { - className: "text-white-50", - children: "Credit Limit:" - }), /*#__PURE__*/_jsxs("span", { - className: "fw-bold", - children: ["₹", Number(selectedCreditAccount.credit_limit || 0).toFixed(2)] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between border-top border-secondary pt-1 mt-1", - children: [/*#__PURE__*/_jsx("span", { - className: "text-white-50", - children: "Balance after this bill:" - }), /*#__PURE__*/_jsxs("span", { - className: "fw-bold text-info", - children: ["₹", (Number(selectedCreditAccount.current_balance || 0) + netPayable).toFixed(2)] - })] - })] - })] - }), paymentMode === 'IPD_Credit' && /*#__PURE__*/_jsxs("div", { - className: "alert alert-warning py-2 mb-3", - style: { - fontSize: '0.78rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-info-circle me-1" - }), "Medicines will be charged directly to the patient's IPD Hospital Account and settled at discharge."] - }), paymentMode === 'Mixed' && /*#__PURE__*/_jsxs("div", { - className: "card bg-dark border-warning mb-3 p-2.5 rounded-3 text-white", - style: { - fontSize: '0.82rem' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-2 pb-1 border-bottom border-secondary", - children: [/*#__PURE__*/_jsxs("span", { - className: "fw-bold text-warning", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-receipt-cutoff me-1" - }), " Split Payment Allocation"] - }), /*#__PURE__*/_jsxs("span", { - className: "fw-bold", - children: ["Total: ₹", netPayable] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-white-50 mb-1", - style: { - fontSize: '0.75rem' - }, - children: "Cash Amount (₹)" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-secondary border-0 text-white", - children: "₹" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm bg-dark text-white border-secondary", - placeholder: "e.g. 35", - value: splitCash, - onChange: e => setSplitCash(e.target.value), - step: "any" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-white-50 mb-1", - style: { - fontSize: '0.75rem' - }, - children: "UPI / Bank (₹)" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-secondary border-0 text-white", - children: "₹" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm bg-dark text-white border-secondary", - placeholder: "e.g. 100", - value: splitUpi, - onChange: e => setSplitUpi(e.target.value), - step: "any" - })] - })] - })] - }), Number(splitUpi) > 0 && /*#__PURE__*/_jsx("div", { - className: "p-2 rounded bg-black bg-opacity-25 border border-secondary mb-2", - children: /*#__PURE__*/_jsxs("div", { - className: "row g-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-7", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label text-warning mb-0", - style: { - fontSize: '0.72rem' - }, - children: ["UPI UTR / Trans. Ref # ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-dark text-white border-warning", - placeholder: "e.g. 425109876543 (12-digit)", - value: upiRefNo, - onChange: e => setUpiRefNo(e.target.value) - }), /*#__PURE__*/_jsx("span", { - style: { - fontSize: '0.65rem' - }, - className: "text-white-50", - children: "Used by Accountant for statement audit" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-5", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-white-50 mb-0", - style: { - fontSize: '0.72rem' - }, - children: "Bank / QR" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-dark text-white border-secondary", - placeholder: "e.g. SBI, HDFC", - list: "commonBankList", - value: bankName, - onChange: e => setBankName(e.target.value) - }), /*#__PURE__*/_jsxs("datalist", { - id: "commonBankList", - children: [/*#__PURE__*/_jsx("option", { - value: "SBI" - }), /*#__PURE__*/_jsx("option", { - value: "HDFC Bank" - }), /*#__PURE__*/_jsx("option", { - value: "ICICI Bank" - }), /*#__PURE__*/_jsx("option", { - value: "Axis Bank" - }), /*#__PURE__*/_jsx("option", { - value: "Punjab National Bank" - }), /*#__PURE__*/_jsx("option", { - value: "Bank of Baroda" - }), /*#__PURE__*/_jsx("option", { - value: "Google Pay / PhonePe" - }), /*#__PURE__*/_jsx("option", { - value: "Paytm" - })] - })] - })] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsx("span", { - style: { - fontSize: '0.75rem' - }, - className: "text-white-50", - children: "Card Swiped (if any):" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - style: { - width: 140 - }, - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-secondary border-0 text-white", - style: { - fontSize: '0.7rem' - }, - children: "₹" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm bg-dark text-white border-secondary", - placeholder: "0", - value: splitCard, - onChange: e => setSplitCard(e.target.value), - step: "any" - })] - })] - }), Number(splitCard) > 0 && /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-dark text-white border-secondary mt-1", - placeholder: "Card Slip Auth / Ref No", - value: cardRefNo, - onChange: e => setCardRefNo(e.target.value) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "p-2 rounded bg-black bg-opacity-40 border border-secondary", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-1", - style: { - fontSize: '0.75rem' - }, - children: [/*#__PURE__*/_jsxs("span", { - children: ["Allocated: ", /*#__PURE__*/_jsxs("strong", { - children: ["₹", totalSplitAllocated.toFixed(2)] - })] - }), /*#__PURE__*/_jsxs("span", { - children: ["Bill Net: ", /*#__PURE__*/_jsxs("strong", { - children: ["₹", netPayable] - })] - })] - }), Math.abs(splitRemaining) <= 0.01 ? /*#__PURE__*/_jsxs("div", { - className: "text-success fw-bold d-flex align-items-center gap-1", - style: { - fontSize: '0.78rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle-fill" - }), " Balanced! Ready to print bill."] - }) : splitRemaining > 0 ? /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "text-warning fw-bold mb-1.5", - style: { - fontSize: '0.78rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-exclamation-circle me-1" - }), " Balance Remaining: ₹", splitRemaining.toFixed(2)] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-1", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-outline-warning py-0", - style: { - fontSize: '0.7rem' - }, - onClick: () => setSplitUpi(String(((Number(splitUpi) || 0) + splitRemaining).toFixed(2))), - children: ["+ ₹", splitRemaining.toFixed(2), " to UPI"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-outline-info py-0", - style: { - fontSize: '0.7rem' - }, - onClick: () => setSplitCash(String(((Number(splitCash) || 0) + splitRemaining).toFixed(2))), - children: ["+ ₹", splitRemaining.toFixed(2), " to Cash"] - })] - })] - }) : /*#__PURE__*/_jsxs("div", { - className: "text-danger fw-bold", - style: { - fontSize: '0.78rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-x-circle-fill me-1" - }), " Overallocated by ₹", Math.abs(splitRemaining).toFixed(2)] - })] - })] - }), paymentMode === 'UPI' && /*#__PURE__*/_jsxs("div", { - className: "bg-dark p-2.5 rounded-3 mb-3 border border-secondary", - children: [store?.upi_id && /*#__PURE__*/_jsx("div", { - className: "text-center mb-2", - children: /*#__PURE__*/_jsxs("small", { - className: "text-muted d-block", - style: { - fontSize: '0.75rem' - }, - children: ["Store UPI VPA: ", /*#__PURE__*/_jsx("span", { - className: "text-warning fw-bold", - children: store?.upi_id - })] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-7", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label text-white-50 mb-1", - style: { - fontSize: '0.72rem' - }, - children: ["UPI UTR / Ref No ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-dark text-white border-warning", - placeholder: "12-digit UTR No", - value: upiRefNo, - onChange: e => setUpiRefNo(e.target.value) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-5", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-white-50 mb-1", - style: { - fontSize: '0.72rem' - }, - children: "Bank Name" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-dark text-white border-secondary", - placeholder: "e.g. SBI, HDFC", - value: bankName, - onChange: e => setBankName(e.target.value) - })] - })] - }), /*#__PURE__*/_jsxs("small", { - className: "text-white-50 d-block mt-1", - style: { - fontSize: '0.68rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-check me-1 text-success" - }), " Accountant will match this UTR against the hospital bank statement."] - })] - }), paymentMode === 'Card' && /*#__PURE__*/_jsx("div", { - className: "bg-dark p-2.5 rounded-3 mb-3 border border-secondary", - children: /*#__PURE__*/_jsxs("div", { - className: "row g-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-7", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-white-50 mb-1", - style: { - fontSize: '0.72rem' - }, - children: "Card Slip / Auth Ref No" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-dark text-white border-secondary", - placeholder: "POS Machine Auth Code", - value: cardRefNo, - onChange: e => setCardRefNo(e.target.value) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-5", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-white-50 mb-1", - style: { - fontSize: '0.72rem' - }, - children: "Bank / Terminal" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-dark text-white border-secondary", - placeholder: "e.g. HDFC EDC", - value: bankName, - onChange: e => setBankName(e.target.value) - })] - })] - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-white small fw-bold mb-1", - children: "Invoice Print Format" - }), /*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm w-100", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn ${printFormat === 'thermal' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light'}`, - onClick: () => setPrintFormat('thermal'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-receipt me-1" - }), " Thermal (Text)"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn ${printFormat === 'a5' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light'}`, - onClick: () => setPrintFormat('a5'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-pdf me-1" - }), " A5 Landscape (PDF)"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn ${printFormat === 'a4' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light'}`, - onClick: () => setPrintFormat('a4'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-pdf me-1" - }), " A4 (PDF)"] - })] - })] - }), /*#__PURE__*/_jsx("button", { - className: `btn ${refundPayable > 0 ? 'btn-warning text-dark fw-bold' : 'btn-success-custom'} w-100 py-2.5 fs-6`, - onClick: processSale, - disabled: isProcessing || cart.length === 0 && returnCart.length === 0 || refundPayable === 0 && paymentMode === 'Mixed' && Math.abs(splitRemaining) > 0.01, - children: isProcessing ? /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hourglass-split me-2" - }), " Generating Bill & Credit Note..."] - }) : refundPayable === 0 && paymentMode === 'Mixed' && Math.abs(splitRemaining) > 0.01 ? /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-exclamation-triangle me-2" - }), " Allocate Balance (₹", splitRemaining > 0 ? splitRemaining.toFixed(2) + ' left' : Math.abs(splitRemaining).toFixed(2) + ' over', ")"] - }) : refundPayable > 0 ? /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-return-left me-2" - }), " Process Return & Refund ₹", refundPayable] - }) : returnCart.length > 0 ? /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-left-right me-2" - }), " Complete Exchange Bill & Print (", printFormat === 'a5' ? 'A5 LANDSCAPE' : printFormat.toUpperCase(), ")"] - }) : /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer me-2" - }), " Complete Sale & Print (", printFormat === 'a5' ? 'A5 LANDSCAPE' : printFormat.toUpperCase(), ")"] - }) - })] - })] - }), /*#__PURE__*/_jsx("div", { - className: `print-drawer-overlay ${isPrintOpen ? 'open' : ''}`, - onClick: () => setIsPrintOpen(false) - }), /*#__PURE__*/_jsx("div", { - className: `print-drawer ${isPrintOpen ? 'open' : ''}`, - id: "pos-print-drawer", - children: lastInvoice && /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsxs("div", { - className: "print-drawer-header", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-receipt text-warning fs-5" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "mb-0 fw-bold text-white", - children: "Invoice & Print Desk" - }), /*#__PURE__*/_jsxs("small", { - className: "text-secondary", - style: { - fontSize: '0.72rem' - }, - children: ["Bill: ", /*#__PURE__*/_jsx("span", { - className: "text-info fw-bold", - children: lastInvoice.sale.invoice_no - }), lastInvoice.sale.abdm_care_context_ref && /*#__PURE__*/_jsxs("span", { - className: "ms-2 text-success", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-fill-check me-0.5" - }), " ABDM Linked"] - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-1.5 flex-wrap", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-xs btn-outline-success text-white py-1 px-2", - onClick: () => viewAbdmBundle(lastInvoice.sale.sale_id), - title: "View official ABDM FHIR R4 MedicationDispense JSON Document Bundle", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-filetype-json me-1" - }), " FHIR R4"] - }), /*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm", - children: [/*#__PURE__*/_jsxs("button", { - className: `btn btn-xs py-1 px-2 ${printFormat === 'thermal' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light text-white'}`, - style: { - fontSize: '0.72rem' - }, - onClick: () => setPrintFormat('thermal'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-receipt me-1" - }), " Thermal (Text)"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-xs py-1 px-2 ${printFormat === 'a5' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light text-white'}`, - style: { - fontSize: '0.72rem' - }, - onClick: () => setPrintFormat('a5'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-pdf me-1" - }), " A5 Landscape (PDF)"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-xs py-1 px-2 ${printFormat === 'a4' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light text-white'}`, - style: { - fontSize: '0.72rem' - }, - onClick: () => setPrintFormat('a4'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-pdf me-1" - }), " A4 (PDF)"] - })] - }), printFormat === 'thermal' ? /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-warning text-dark fw-bold py-1 px-2.5 ms-0.5", - onClick: printThermalReceipt, - title: "Print on 80mm Thermal Receipt Printer", - style: { - fontSize: '0.75rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer-fill me-1" - }), " Print Thermal"] - }) : /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-light py-1 px-2 text-white", - onClick: () => downloadPdf(printFormat), - title: `Download ${printFormat === 'a5' ? 'A5 Landscape' : printFormat.toUpperCase()} PDF Document`, - style: { - fontSize: '0.75rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-download me-1 text-info" - }), " PDF"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-primary py-1 px-2.5 ms-0.5 fw-bold", - onClick: () => printPdf(printFormat), - title: `Print Vector-Clean ${printFormat === 'a5' ? 'A5 Landscape' : printFormat.toUpperCase()} PDF`, - style: { - fontSize: '0.75rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer me-1" - }), " Print PDF (", printFormat === 'a5' ? 'A5 LANDSCAPE' : printFormat.toUpperCase(), ")"] - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-light rounded-pill px-2.5 py-1 ms-1 d-flex align-items-center gap-1", - onClick: () => setIsPrintOpen(false), - title: "Close Print Drawer (Esc)", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-x-lg" - }), /*#__PURE__*/_jsx("kbd", { - style: { - background: '#334155', - color: '#f8fafc', - fontSize: '0.62rem', - padding: '1px 3px', - borderRadius: '3px' - }, - children: "Esc" - })] - })] - })] - }), /*#__PURE__*/_jsx("div", { - className: "print-drawer-body", - children: /*#__PURE__*/_jsx("div", { - className: "print-paper-card", - children: /*#__PURE__*/_jsxs("div", { - id: "printable-container", - children: [printFormat === 'thermal' && /*#__PURE__*/_jsxs("div", { - className: "p-2 text-center", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-2 mx-auto", - style: { - maxWidth: '360px' - }, - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-dark text-warning border border-secondary", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-receipt me-1" - }), " 80mm Thermal Receipt (Plain Text)"] - }), /*#__PURE__*/_jsx("div", { - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-warning text-dark fw-bold py-0.5 px-2.5", - onClick: printThermalReceipt, - title: "Print Thermal 80mm Receipt", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer-fill me-1" - }), " Print Thermal"] - }) - })] - }), /*#__PURE__*/_jsx("pre", { - id: "thermal-receipt-preview", - style: { - fontFamily: "'Courier New', Courier, monospace", - fontSize: '11px', - lineHeight: '1.28', - backgroundColor: '#ffffff', - color: '#000000', - padding: '16px', - border: '1px solid #cbd5e1', - borderRadius: '6px', - boxShadow: '0 4px 15px rgba(0,0,0,0.06)', - width: '360px', - maxWidth: '100%', - margin: '0 auto', - textAlign: 'left', - whiteSpace: 'pre-wrap', - wordBreak: 'break-all' - }, - children: generateThermalReceiptText(lastInvoice) - })] - }), printFormat === 'a5' && /*#__PURE__*/_jsxs("div", { - className: "print-a5-invoice", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center bg-primary-subtle border border-primary-subtle rounded px-2.5 py-1.5 mb-2.5 no-print", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-pdf-fill text-danger fs-5" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-dark", - style: { - fontSize: '0.78rem' - }, - children: "A5 Landscape Tax Invoice (PDF Ready)" - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - style: { - fontSize: '0.68rem' - }, - children: "Direct server vector PDF (Landscape: 210 × 148 mm) • Zero clipped columns" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-1.5", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-xs btn-outline-primary py-1 px-2", - onClick: () => downloadPdf('a5'), - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-download me-1" - }), " Download PDF"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-xs btn-primary py-1 px-2.5 fw-bold", - onClick: () => printPdf('a5'), - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer me-1" - }), " Print PDF (A5 Landscape)"] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-start border-bottom pb-2 mb-2", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "fw-bold mb-0 text-primary", - children: lastInvoice.sale.store_name - }), /*#__PURE__*/_jsxs("div", { - style: { - fontSize: '10px' - }, - children: [lastInvoice.sale.building_name, ", ", lastInvoice.sale.floor_no, ", ", lastInvoice.sale.store_address] - }), /*#__PURE__*/_jsxs("div", { - style: { - fontSize: '10px' - }, - children: [/*#__PURE__*/_jsx("strong", { - children: "DL 20B:" - }), " ", lastInvoice.sale.drug_license_no_20b, " | ", /*#__PURE__*/_jsx("strong", { - children: "DL 21B:" - }), " ", lastInvoice.sale.drug_license_no_21b, lastInvoice.sale.abdm_hfr_id && /*#__PURE__*/_jsxs("span", { - children: [" | ", /*#__PURE__*/_jsx("strong", { - children: "HFR ID:" - }), " ", lastInvoice.sale.abdm_hfr_id] - })] - }), /*#__PURE__*/_jsxs("div", { - style: { - fontSize: '10px' - }, - children: [/*#__PURE__*/_jsx("strong", { - children: "GSTIN:" - }), " ", lastInvoice.sale.gstin, " | ", /*#__PURE__*/_jsx("strong", { - children: "Phone:" - }), " ", lastInvoice.sale.contact_phone] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "text-end", - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-dark text-white mb-1", - children: "RETAIL TAX INVOICE" - }), /*#__PURE__*/_jsx("div", { - className: "fw-bold", - style: { - fontSize: '12px' - }, - children: lastInvoice.sale.invoice_no - }), /*#__PURE__*/_jsx("div", { - className: "text-muted", - style: { - fontSize: '10px' - }, - children: lastInvoice.sale.sale_date - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-1 mb-2 p-1.5 bg-light rounded", - style: { - fontSize: '10px' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("strong", { - children: "Patient:" - }), " ", lastInvoice.sale.patient_name, " ", lastInvoice.sale.uhid ? `(${lastInvoice.sale.uhid})` : ''] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("strong", { - children: "Prescribed By:" - }), " ", lastInvoice.sale.doctor_name] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("strong", { - children: "Age/Gender:" - }), " ", lastInvoice.sale.age || 'N/A', " / ", lastInvoice.sale.gender || 'N/A'] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("strong", { - children: "Payment Mode:" - }), " ", lastInvoice.sale.payment_mode] - }), (lastInvoice.sale.abha_id || lastInvoice.sale.abha_address) && /*#__PURE__*/_jsxs("div", { - className: "col-12 text-success fw-bold", - children: [/*#__PURE__*/_jsx("strong", { - children: "ABHA:" - }), " ", lastInvoice.sale.abha_id || 'N/A', " (", lastInvoice.sale.abha_address || 'N/A', ")", lastInvoice.sale.abdm_care_context_ref && /*#__PURE__*/_jsxs("span", { - children: [" | ", /*#__PURE__*/_jsx("strong", { - children: "Care Context:" - }), " ", lastInvoice.sale.abdm_care_context_ref] - })] - })] - }), /*#__PURE__*/_jsxs("table", { - className: "table table-bordered table-sm mb-2", - style: { - fontSize: '10px' - }, - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "#" - }), /*#__PURE__*/_jsx("th", { - children: "Medicine Name" - }), /*#__PURE__*/_jsx("th", { - children: "HSN" - }), /*#__PURE__*/_jsx("th", { - children: "Batch" - }), /*#__PURE__*/_jsx("th", { - children: "Exp" - }), /*#__PURE__*/_jsx("th", { - children: "Qty & Unit" - }), /*#__PURE__*/_jsx("th", { - children: "Unit MRP (₹)" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Amount (₹)" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: lastInvoice.items.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsx("td", { - colSpan: 8, - className: "text-center text-muted py-2", - children: "No medicines dispensed on this bill (Return / Refund Only)" - }) - }) : lastInvoice.items.map((it, i) => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - children: i + 1 - }), /*#__PURE__*/_jsxs("td", { - className: "fw-bold", - children: [it.item_name, it.snomed_ct_code && /*#__PURE__*/_jsxs("div", { - className: "text-muted", - style: { - fontSize: '8px' - }, - children: ["SNOMED: ", it.snomed_ct_code] - }), Number(it.units_per_pack) > 1 && /*#__PURE__*/_jsxs("div", { - className: "text-muted fw-normal", - style: { - fontSize: '8px' - }, - children: ["Pack: 1 Strip = ", it.units_per_pack, " Tabs"] - })] - }), /*#__PURE__*/_jsx("td", { - children: it.hsn_code - }), /*#__PURE__*/_jsx("td", { - children: it.batch_no - }), /*#__PURE__*/_jsx("td", { - children: it.expiry_date.substring(0, 7) - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("span", { - className: "fw-bold", - children: it.sell_unit === 'Tablet' ? `${it.total_units} Tab` : it.sell_unit === 'Combo' ? `${it.qty} Str + ${it.loose_qty} Tab` : Number(it.units_per_pack) > 1 ? `${it.qty} Strip` : `${it.qty} ${it.unit_pack || 'Unit'}` - }), Number(it.units_per_pack) > 1 && it.sell_unit !== 'Tablet' && /*#__PURE__*/_jsxs("div", { - className: "text-muted", - style: { - fontSize: '8px' - }, - children: ["(", it.total_units, " Tabs)"] - })] - }), /*#__PURE__*/_jsx("td", { - children: it.sell_unit === 'Tablet' ? /*#__PURE__*/_jsxs("span", { - children: ["₹", it.unit_price, " ", /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "/tab" - })] - }) : /*#__PURE__*/_jsxs("span", { - children: ["₹", it.unit_mrp, " ", Number(it.units_per_pack) > 1 ? /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "/strip" - }) : ''] - }) - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-bold", - children: ["₹", it.total_amount] - })] - }, i)) - })] - }), lastInvoice.return_items && lastInvoice.return_items.length > 0 && /*#__PURE__*/_jsxs("div", { - className: "mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center bg-danger-subtle px-2 py-1 rounded-top border border-bottom-0 border-danger-subtle text-danger", - style: { - fontSize: '10px' - }, - children: [/*#__PURE__*/_jsxs("span", { - className: "fw-bold", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-return-left me-1" - }), " RETURNED / EXCHANGED MEDICINES"] - }), lastInvoice.credit_note && /*#__PURE__*/_jsxs("span", { - className: "badge bg-danger", - children: ["Credit Note: ", lastInvoice.credit_note.credit_note_no] - })] - }), /*#__PURE__*/_jsxs("table", { - className: "table table-bordered table-sm mb-0 text-danger border-danger-subtle", - style: { - fontSize: '9px' - }, - children: [/*#__PURE__*/_jsx("thead", { - className: "table-danger", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "#" - }), /*#__PURE__*/_jsx("th", { - children: "Medicine Name" - }), /*#__PURE__*/_jsx("th", { - children: "Batch" - }), /*#__PURE__*/_jsx("th", { - children: "Original Bill" - }), /*#__PURE__*/_jsx("th", { - children: "Condition" - }), /*#__PURE__*/_jsx("th", { - children: "Returned Qty" - }), /*#__PURE__*/_jsx("th", { - children: "Credit Rate (₹)" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Credit Total (₹)" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: lastInvoice.return_items.map((it, i) => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - children: i + 1 - }), /*#__PURE__*/_jsx("td", { - className: "fw-bold text-decoration-line-through", - children: it.item_name - }), /*#__PURE__*/_jsx("td", { - children: it.batch_no - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("code", { - children: it.ref_invoice_no || 'N/A' - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary", - children: it.return_condition - }) - }), /*#__PURE__*/_jsxs("td", { - className: "fw-bold", - children: ["-", it.sell_unit === 'Tablet' ? `${it.total_units} Tab` : `${it.qty} ${it.unit_pack || 'Unit'}`] - }), /*#__PURE__*/_jsxs("td", { - children: ["₹", it.unit_price] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-bold", - children: ["-₹", Math.abs(Number(it.total_amount)).toFixed(2)] - })] - }, `a5-ret-${i}`)) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center border-top pt-2", - children: [/*#__PURE__*/_jsxs("div", { - style: { - fontSize: '9px' - }, - children: ["R.Ph: ", lastInvoice.sale.registered_pharmacist_name || 'Pharmacist', " (", lastInvoice.sale.pharmacist_reg_no, ")", lastInvoice.sale.pharmacist_hpr_id && /*#__PURE__*/_jsxs("span", { - children: [" | HPR ID: ", lastInvoice.sale.pharmacist_hpr_id] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "text-end", - children: [/*#__PURE__*/_jsxs("div", { - style: { - fontSize: '10px' - }, - className: "text-muted", - children: ["Gross: ₹", lastInvoice.sale.gross_amount, Number(lastInvoice.sale.discount_amount) > 0 && /*#__PURE__*/_jsxs("span", { - className: "text-danger ms-2", - children: ["Disc: -₹", lastInvoice.sale.discount_amount] - }), Number(lastInvoice.sale.return_amount) > 0 && /*#__PURE__*/_jsxs("span", { - className: "text-danger fw-bold ms-2", - children: ["Return Credit: -₹", lastInvoice.sale.return_amount] - })] - }), /*#__PURE__*/_jsx("span", { - className: "fs-6 fw-bold text-primary", - children: Number(lastInvoice.sale.refund_amount) > 0 ? `NET REFUND: ₹${lastInvoice.sale.refund_amount}` : `TOTAL: ₹${lastInvoice.sale.net_amount}` - }), Number(lastInvoice.sale.refund_amount) > 0 && /*#__PURE__*/_jsxs("div", { - className: "text-danger fw-bold small", - children: ["Refund Paid via ", lastInvoice.sale.refund_mode, " ", lastInvoice.sale.refund_ref_no ? `[Ref: ${lastInvoice.sale.refund_ref_no}]` : ''] - }), /*#__PURE__*/_jsxs("div", { - style: { - fontSize: '9px' - }, - className: "text-muted mt-0.5", - children: [/*#__PURE__*/_jsxs("span", { - children: ["Settlement: ", /*#__PURE__*/_jsx("strong", { - children: lastInvoice.sale.payment_mode - })] - }), Number(lastInvoice.sale.cash_paid) > 0 && /*#__PURE__*/_jsxs("span", { - className: "ms-1.5", - children: ["Cash: ₹", lastInvoice.sale.cash_paid] - }), Number(lastInvoice.sale.upi_paid) > 0 && /*#__PURE__*/_jsxs("span", { - className: "ms-1.5", - children: ["UPI: ₹", lastInvoice.sale.upi_paid, " ", lastInvoice.sale.upi_ref_no ? `(UTR: ${lastInvoice.sale.upi_ref_no})` : ''] - }), Number(lastInvoice.sale.card_paid) > 0 && /*#__PURE__*/_jsxs("span", { - className: "ms-1.5", - children: ["Card: ₹", lastInvoice.sale.card_paid] - }), lastInvoice.sale.is_bank_reconciled == 1 && /*#__PURE__*/_jsx("span", { - className: "ms-1.5 text-success fw-bold", - children: "✓ Audited" - })] - })] - })] - })] - }), printFormat === 'a4' && /*#__PURE__*/_jsxs("div", { - className: "print-a4-invoice", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center bg-primary-subtle border border-primary-subtle rounded px-3 py-1.5 mb-3 no-print", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-pdf-fill text-danger fs-5" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-dark", - style: { - fontSize: '0.8rem' - }, - children: "A4 Hospital GST Tax Invoice (PDF Ready)" - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - style: { - fontSize: '0.68rem' - }, - children: "Server-rendered vector PDF • Zero clipped columns" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-1.5", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-xs btn-outline-primary py-1 px-2.5", - onClick: () => downloadPdf('a4'), - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-download me-1" - }), " Download PDF"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-xs btn-primary py-1 px-2.5 fw-bold", - onClick: () => printPdf('a4'), - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer me-1" - }), " Print PDF"] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center border-bottom pb-3 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h4", { - className: "fw-bold text-primary mb-1", - children: lastInvoice.sale.store_name - }), /*#__PURE__*/_jsxs("div", { - className: "text-muted", - children: [lastInvoice.sale.building_name, ", ", lastInvoice.sale.floor_no, ", ", lastInvoice.sale.store_address] - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("strong", { - children: "Drug License 20-B:" - }), " ", lastInvoice.sale.drug_license_no_20b, " | ", /*#__PURE__*/_jsx("strong", { - children: "21-B:" - }), " ", lastInvoice.sale.drug_license_no_21b, " | ", /*#__PURE__*/_jsx("strong", { - children: "FSSAI:" - }), " ", lastInvoice.sale.fssai_no || 'N/A'] - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("strong", { - children: "GSTIN:" - }), " ", lastInvoice.sale.gstin, " | ", /*#__PURE__*/_jsx("strong", { - children: "State:" - }), " ", lastInvoice.sale.state_name, " (Code: ", lastInvoice.sale.state_code, ")", lastInvoice.sale.abdm_hfr_id && /*#__PURE__*/_jsxs("span", { - children: [" | ", /*#__PURE__*/_jsx("strong", { - children: "ABDM HFR Facility ID:" - }), " ", lastInvoice.sale.abdm_hfr_id] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "text-end", - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-primary fs-6 px-3 py-1.5 mb-1", - children: "HOSPITAL GST TAX INVOICE" - }), /*#__PURE__*/_jsx("h5", { - className: "fw-bold mb-0 text-dark", - children: lastInvoice.sale.invoice_no - }), /*#__PURE__*/_jsxs("div", { - className: "text-muted small", - children: ["Date & Time: ", lastInvoice.sale.sale_date] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-3 p-2 bg-light rounded border", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-4", - children: [/*#__PURE__*/_jsx("strong", { - children: "Patient Name:" - }), " ", lastInvoice.sale.patient_name] - }), /*#__PURE__*/_jsxs("div", { - className: "col-4", - children: [/*#__PURE__*/_jsx("strong", { - children: "UHID No:" - }), " ", /*#__PURE__*/_jsx("code", { - className: "text-primary fw-bold", - children: lastInvoice.sale.uhid || 'Walk-in' - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-4", - children: [/*#__PURE__*/_jsx("strong", { - children: "Phone:" - }), " ", lastInvoice.sale.patient_mobile || 'N/A'] - }), /*#__PURE__*/_jsxs("div", { - className: "col-4", - children: [/*#__PURE__*/_jsx("strong", { - children: "Age / Gender:" - }), " ", lastInvoice.sale.age || 'N/A', " / ", lastInvoice.sale.gender || 'N/A'] - }), /*#__PURE__*/_jsxs("div", { - className: "col-4", - children: [/*#__PURE__*/_jsx("strong", { - children: "Consultant Doctor:" - }), " ", lastInvoice.sale.doctor_name] - }), /*#__PURE__*/_jsxs("div", { - className: "col-4", - children: [/*#__PURE__*/_jsx("strong", { - children: "Doctor Reg No:" - }), " ", lastInvoice.sale.doctor_reg_no || 'N/A'] - }), (lastInvoice.sale.abha_id || lastInvoice.sale.abha_address) && /*#__PURE__*/_jsxs("div", { - className: "col-12 bg-success-subtle p-1.5 rounded text-success fw-bold border border-success mt-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-fill-check me-1" - }), " ABDM Linked: ABHA Number: ", lastInvoice.sale.abha_id || 'N/A', " | ABHA Address: ", lastInvoice.sale.abha_address || 'N/A', " | Care Context: ", lastInvoice.sale.abdm_care_context_ref || 'N/A'] - }), lastInvoice.sale.ipd_id && /*#__PURE__*/_jsxs("div", { - className: "col-12 text-danger fw-bold border-top pt-1 mt-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hospital me-1" - }), " IPD Admission #", lastInvoice.sale.ipd_id, " • Ward: ", lastInvoice.sale.ward_name || 'General', " • Bed: ", lastInvoice.sale.bed_no || 'Bed', " (Charged to IPD Running Bill)"] - })] - }), /*#__PURE__*/_jsxs("table", { - className: "table table-bordered mb-3", - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - style: { - width: 40 - }, - children: "#" - }), /*#__PURE__*/_jsx("th", { - children: "Medicine & Formulation" - }), /*#__PURE__*/_jsx("th", { - children: "HSN" - }), /*#__PURE__*/_jsx("th", { - children: "Batch No" - }), /*#__PURE__*/_jsx("th", { - children: "Exp Date" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 105 - }, - children: "Qty & Unit" - }), /*#__PURE__*/_jsx("th", { - children: "Rate (₹)" - }), /*#__PURE__*/_jsx("th", { - children: "Taxable (₹)" - }), /*#__PURE__*/_jsx("th", { - children: "CGST (₹)" - }), /*#__PURE__*/_jsx("th", { - children: "SGST (₹)" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Total (₹)" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: lastInvoice.items.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsx("td", { - colSpan: 11, - className: "text-center text-muted py-3", - children: "No medicines dispensed on this bill (Pure Sales Return & Customer Refund)" - }) - }) : lastInvoice.items.map((it, i) => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - children: i + 1 - }), /*#__PURE__*/_jsxs("td", { - className: "fw-bold", - children: [it.item_name, it.snomed_ct_code && /*#__PURE__*/_jsxs("div", { - className: "text-muted fw-normal", - style: { - fontSize: '9px' - }, - children: ["SNOMED-CT: ", /*#__PURE__*/_jsx("code", { - children: it.snomed_ct_code - }), " (", it.snomed_display || '', ")"] - }), Number(it.units_per_pack) > 1 && /*#__PURE__*/_jsxs("div", { - className: "text-muted fw-normal", - style: { - fontSize: '9px' - }, - children: ["Packing: 1 Strip of ", it.units_per_pack, " Tablets"] - })] - }), /*#__PURE__*/_jsx("td", { - children: it.hsn_code - }), /*#__PURE__*/_jsx("td", { - children: it.batch_no - }), /*#__PURE__*/_jsx("td", { - children: it.expiry_date - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("span", { - className: "fw-bold", - children: it.sell_unit === 'Tablet' ? `${it.total_units} Tab` : it.sell_unit === 'Combo' ? `${it.qty} Str + ${it.loose_qty} Tab` : Number(it.units_per_pack) > 1 ? `${it.qty} Strip` : `${it.qty} ${it.unit_pack || 'Unit'}` - }), Number(it.units_per_pack) > 1 && it.sell_unit !== 'Tablet' && /*#__PURE__*/_jsxs("div", { - className: "text-muted", - style: { - fontSize: '9px' - }, - children: ["(", it.total_units, " Tablets)"] - })] - }), /*#__PURE__*/_jsx("td", { - children: it.sell_unit === 'Tablet' ? /*#__PURE__*/_jsxs("span", { - children: ["₹", it.unit_price, " ", /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "/tab" - })] - }) : /*#__PURE__*/_jsxs("span", { - children: ["₹", it.unit_mrp, " ", Number(it.units_per_pack) > 1 ? /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "/strip" - }) : ''] - }) - }), /*#__PURE__*/_jsxs("td", { - children: ["₹", it.taxable_value] - }), /*#__PURE__*/_jsxs("td", { - children: ["₹", it.cgst_amount] - }), /*#__PURE__*/_jsxs("td", { - children: ["₹", it.sgst_amount] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-bold", - children: ["₹", it.total_amount] - })] - }, i)) - })] - }), lastInvoice.return_items && lastInvoice.return_items.length > 0 && /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center bg-danger-subtle p-2 rounded-top border border-bottom-0 border-danger text-danger", - children: [/*#__PURE__*/_jsxs("span", { - className: "fw-bold", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-return-left me-1" - }), " GST CREDIT NOTE / RETURNED & EXCHANGED MEDICINES"] - }), lastInvoice.credit_note && /*#__PURE__*/_jsxs("span", { - className: "badge bg-danger fs-7", - children: ["Credit Note No: ", lastInvoice.credit_note.credit_note_no, " (", lastInvoice.credit_note.return_date, ")"] - })] - }), /*#__PURE__*/_jsxs("table", { - className: "table table-bordered mb-0 text-danger border-danger", - children: [/*#__PURE__*/_jsx("thead", { - className: "table-danger", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - style: { - width: 40 - }, - children: "#" - }), /*#__PURE__*/_jsx("th", { - children: "Returned Medicine & Formulation" - }), /*#__PURE__*/_jsx("th", { - children: "HSN" - }), /*#__PURE__*/_jsx("th", { - children: "Batch No" - }), /*#__PURE__*/_jsx("th", { - children: "Original Invoice" - }), /*#__PURE__*/_jsx("th", { - children: "Condition / Reason" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 105 - }, - children: "Qty Returned" - }), /*#__PURE__*/_jsx("th", { - children: "Credit Rate (₹)" - }), /*#__PURE__*/_jsx("th", { - children: "Taxable (₹)" - }), /*#__PURE__*/_jsx("th", { - children: "CGST (₹)" - }), /*#__PURE__*/_jsx("th", { - children: "SGST (₹)" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Credit Total (₹)" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: lastInvoice.return_items.map((it, i) => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - children: i + 1 - }), /*#__PURE__*/_jsx("td", { - className: "fw-bold text-decoration-line-through", - children: it.item_name - }), /*#__PURE__*/_jsx("td", { - children: it.hsn_code - }), /*#__PURE__*/_jsx("td", { - children: it.batch_no - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("code", { - children: it.ref_invoice_no || 'N/A' - }) - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-secondary me-1", - children: it.return_condition - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: it.return_reason - })] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("span", { - className: "fw-bold", - children: ["-", it.sell_unit === 'Tablet' ? `${it.total_units} Tab` : `${it.qty} ${it.unit_pack || 'Unit'}`] - }) - }), /*#__PURE__*/_jsxs("td", { - children: ["₹", it.unit_price] - }), /*#__PURE__*/_jsxs("td", { - children: ["-₹", Math.abs(Number(it.taxable_value)).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - children: ["-₹", Math.abs(Number(it.cgst_amount)).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - children: ["-₹", Math.abs(Number(it.sgst_amount)).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-bold", - children: ["-₹", Math.abs(Number(it.total_amount)).toFixed(2)] - })] - }, `a4-ret-${i}`)) - })] - })] - }), lastInvoice.hsn_summary && lastInvoice.hsn_summary.length > 0 && /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "GST Tax Breakdown" - }), /*#__PURE__*/_jsxs("table", { - className: "table table-sm table-bordered text-center", - style: { - fontSize: '10px' - }, - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "HSN Code" - }), /*#__PURE__*/_jsx("th", { - children: "GST Rate" - }), /*#__PURE__*/_jsx("th", { - children: "Taxable Value (₹)" - }), /*#__PURE__*/_jsx("th", { - children: "CGST (₹)" - }), /*#__PURE__*/_jsx("th", { - children: "SGST (₹)" - }), /*#__PURE__*/_jsx("th", { - children: "Total Tax (₹)" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: lastInvoice.hsn_summary.map((h, idx) => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - children: h.hsn_code - }), /*#__PURE__*/_jsxs("td", { - children: [h.gst_rate, "%"] - }), /*#__PURE__*/_jsxs("td", { - children: ["₹", h.taxable_value.toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - children: ["₹", h.cgst_amount.toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - children: ["₹", h.sgst_amount.toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - className: "fw-bold", - children: ["₹", h.total_tax.toFixed(2)] - })] - }, idx)) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-3 border-top pt-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-7", - children: [/*#__PURE__*/_jsxs("small", { - className: "text-muted d-block", - children: [/*#__PURE__*/_jsx("strong", { - children: "Registered Pharmacist:" - }), " ", lastInvoice.sale.registered_pharmacist_name || 'Pharmacist', " (Reg No: ", lastInvoice.sale.pharmacist_reg_no || 'N/A', ")", lastInvoice.sale.pharmacist_hpr_id && /*#__PURE__*/_jsxs("span", { - children: [" | ", /*#__PURE__*/_jsx("strong", { - children: "HPR ID:" - }), " ", lastInvoice.sale.pharmacist_hpr_id] - })] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted d-block mt-1", - children: lastInvoice.sale.terms_conditions || '1. Goods once sold are returnable only as per Drug Rules.\n2. Store medicines below 25°C.' - }), /*#__PURE__*/_jsxs("div", { - className: "mt-2 p-2 bg-light rounded border", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "fw-bold text-dark mb-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-wallet2 me-1" - }), " Payment Settlement:"] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap gap-2 align-items-center mb-1", - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-secondary", - children: lastInvoice.sale.payment_mode - }), Number(lastInvoice.sale.cash_paid) > 0 && /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("strong", { - children: "Cash:" - }), " ₹", lastInvoice.sale.cash_paid] - }), Number(lastInvoice.sale.upi_paid) > 0 && /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("strong", { - children: "UPI / Bank:" - }), " ₹", lastInvoice.sale.upi_paid, lastInvoice.sale.upi_ref_no && /*#__PURE__*/_jsxs("code", { - className: "text-primary ms-1", - children: ["[UTR: ", lastInvoice.sale.upi_ref_no, "]"] - }), lastInvoice.sale.bank_name && /*#__PURE__*/_jsxs("span", { - className: "text-muted ms-1", - children: ["(", lastInvoice.sale.bank_name, ")"] - })] - }), Number(lastInvoice.sale.card_paid) > 0 && /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("strong", { - children: "Card:" - }), " ₹", lastInvoice.sale.card_paid, " ", lastInvoice.sale.card_ref_no ? `[Ref: ${lastInvoice.sale.card_ref_no}]` : ''] - }), Number(lastInvoice.sale.credit_amount) > 0 && /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("strong", { - children: "Hospital Credit:" - }), " ₹", lastInvoice.sale.credit_amount] - })] - }), Number(lastInvoice.sale.refund_amount) > 0 && /*#__PURE__*/_jsx("div", { - className: "mb-1", - children: /*#__PURE__*/_jsxs("span", { - className: "badge bg-danger-subtle text-danger border border-danger", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cash-stack me-1" - }), " Refund Issued: ₹", lastInvoice.sale.refund_amount, " via ", lastInvoice.sale.refund_mode, " ", lastInvoice.sale.refund_ref_no ? `[Ref: ${lastInvoice.sale.refund_ref_no}]` : ''] - }) - }), /*#__PURE__*/_jsx("div", { - children: lastInvoice.sale.is_bank_reconciled == 1 ? /*#__PURE__*/_jsxs("span", { - className: "badge bg-success-subtle text-success border border-success", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-patch-check-fill me-1" - }), " Bank Statement Reconciled & Audited"] - }) : /*#__PURE__*/_jsxs("span", { - className: "badge bg-warning-subtle text-dark border border-warning", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clock-history me-1" - }), " Bank Statement: Pending Audit"] - }) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-5", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-1", - children: [/*#__PURE__*/_jsx("span", { - children: "Gross Items Total:" - }), /*#__PURE__*/_jsxs("span", { - children: ["₹", lastInvoice.sale.gross_amount] - })] - }), Number(lastInvoice.sale.discount_amount) > 0 && /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-1 text-danger", - children: [/*#__PURE__*/_jsx("span", { - children: "Total Discounts Allowed:" - }), /*#__PURE__*/_jsxs("span", { - children: ["-₹", lastInvoice.sale.discount_amount] - })] - }), Number(lastInvoice.sale.return_amount) > 0 && /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-1 text-danger fw-bold", - children: [/*#__PURE__*/_jsx("span", { - children: "Less Return / Exchange Credit:" - }), /*#__PURE__*/_jsxs("span", { - children: ["-₹", lastInvoice.sale.return_amount] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-1", - children: [/*#__PURE__*/_jsx("span", { - children: "Taxable Amount:" - }), /*#__PURE__*/_jsxs("span", { - children: ["₹", lastInvoice.sale.taxable_amount] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-1", - children: [/*#__PURE__*/_jsx("span", { - children: "CGST Amount:" - }), /*#__PURE__*/_jsxs("span", { - children: ["₹", lastInvoice.sale.cgst_amount] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-1", - children: [/*#__PURE__*/_jsx("span", { - children: "SGST Amount:" - }), /*#__PURE__*/_jsxs("span", { - children: ["₹", lastInvoice.sale.sgst_amount] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-1", - children: [/*#__PURE__*/_jsx("span", { - children: "Round Off:" - }), /*#__PURE__*/_jsxs("span", { - children: ["₹", lastInvoice.sale.round_off] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between fs-5 fw-bolder border-top pt-2 text-primary", - children: [/*#__PURE__*/_jsx("span", { - children: "GRAND TOTAL / NET PAYABLE:" - }), /*#__PURE__*/_jsxs("span", { - children: ["₹", lastInvoice.sale.net_amount] - })] - }), Number(lastInvoice.sale.refund_amount) > 0 && /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between fs-6 fw-bold text-danger border-top border-bottom py-1 mt-2", - children: [/*#__PURE__*/_jsx("span", { - children: "REFUND PAID TO CUSTOMER:" - }), /*#__PURE__*/_jsxs("span", { - children: ["₹", lastInvoice.sale.refund_amount, " (", lastInvoice.sale.refund_mode, lastInvoice.sale.refund_ref_no ? ` - ${lastInvoice.sale.refund_ref_no}` : '', ")"] - })] - })] - })] - })] - })] - }) - }) - }), /*#__PURE__*/_jsxs("div", { - className: "p-2.5 bg-white border-top d-flex justify-content-between align-items-center flex-shrink-0 px-3", - children: [/*#__PURE__*/_jsxs("span", { - className: "text-muted small", - children: ["Format: ", /*#__PURE__*/_jsx("strong", { - className: "text-dark text-uppercase", - children: printFormat - }), " • Bill No: ", /*#__PURE__*/_jsx("strong", { - children: lastInvoice.sale.invoice_no - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2 flex-wrap align-items-center", - children: [/*#__PURE__*/_jsx("button", { - className: "btn btn-sm btn-outline-secondary px-3", - onClick: () => setIsPrintOpen(false), - children: "Done / Close (Esc)" - }), printFormat === 'thermal' ? /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-warning text-dark px-3 fw-bold", - onClick: printThermalReceipt, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer-fill me-1" - }), " Print Thermal Receipt"] - }) : /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-primary px-3", - onClick: () => downloadPdf(printFormat), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-download me-1" - }), " Download PDF"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-primary px-3 fw-bold", - onClick: () => printPdf(printFormat), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer me-1" - }), " Print PDF (", printFormat === 'a5' ? 'A5 LANDSCAPE' : printFormat.toUpperCase(), ")"] - })] - })] - })] - })] - }) - }), showFhirModal && /*#__PURE__*/_jsx("div", { - className: "modal fade show d-block", - style: { - backgroundColor: 'rgba(15, 23, 42, 0.75)' + return /*#__PURE__*/React.createElement("div", { + className: "pos-counter-wrapper position-relative" + }, /*#__PURE__*/React.createElement("div", { + className: "row g-3" + }, /*#__PURE__*/React.createElement("div", { + className: selectedPatient && showHistoryPanel ? "col-12 col-lg-8 col-xl-8" : "col-12" + }, isRestoredBannerVisible && /*#__PURE__*/React.createElement("div", { + className: "alert alert-info py-2 px-3 d-flex flex-wrap justify-content-between align-items-center mb-2 shadow-sm border-info rounded-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-clockwise text-info fs-5" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", { + className: "text-dark" + }, "Draft Auto-Restored:"), /*#__PURE__*/React.createElement("span", { + className: "text-secondary ms-1" + }, "Recovered ", /*#__PURE__*/React.createElement("strong", null, cart.length, " medicine(s)"), " ", selectedPatient ? /*#__PURE__*/React.createElement(React.Fragment, null, "for ", /*#__PURE__*/React.createElement("strong", null, selectedPatient.name || selectedPatient.patient_name)) : '', " from your previous session ", draftSavedAt ? `(${draftSavedAt.toLocaleTimeString()})` : '', "."))), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2 mt-1 mt-md-0" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-primary py-0.5 px-2.5", + onClick: () => setIsRestoredBannerVisible(false) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-lg me-1" + }), " Continue Working"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-danger py-0.5 px-2.5", + onClick: clearDraftAndReset + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-trash me-1" + }), " Discard Draft"))), editingInvoiceBanner && /*#__PURE__*/React.createElement("div", { + className: "alert alert-warning py-2 px-3 d-flex flex-wrap justify-content-between align-items-center mb-2 shadow-sm border-warning rounded-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-pencil-square text-warning-emphasis fs-5" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", { + className: "text-dark" + }, "Editing Invoice #", editingInvoiceBanner, ":"), /*#__PURE__*/React.createElement("span", { + className: "text-secondary ms-1" + }, "Patient and medicines loaded into POS Counter. You can adjust items, quantities, or re-dispense."))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-dark py-0.5 px-2.5 mt-1 mt-md-0", + onClick: clearDraftAndReset + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x-circle me-1" + }), " Cancel Edit & New Bill")), /*#__PURE__*/React.createElement("div", { + className: "counter-card position-relative" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap align-items-center justify-content-between gap-2 mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-dark fs-6" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-fill text-primary me-1" + }), " Patient & Prescription"), /*#__PURE__*/React.createElement("span", { + className: `badge ${patientType === 'IPD' ? 'bg-danger' : patientType === 'OPD' ? 'bg-primary' : 'bg-secondary'}` + }, patientType), draftStatus === 'saved' && /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success border border-success-subtle px-2 py-0.5 d-inline-flex align-items-center gap-1 shadow-sm", + style: { + fontSize: '0.72rem' + }, + title: draftSavedAt ? `Auto-saved at ${draftSavedAt.toLocaleTimeString()}` : 'Auto-saved in local draft' + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cloud-check-fill" + }), " Draft Auto-Saved (", cart.length, " items)")), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-1.5 flex-wrap" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn btn-sm ${draftBillsList.length > 0 ? 'btn-warning text-dark fw-bold' : 'btn-outline-secondary'} py-0.5 px-2.5 d-inline-flex align-items-center gap-1 shadow-sm`, + onClick: () => { + loadDraftBills(); + setShowDraftModal(true); + }, + title: "Draft bills collected from racks via Mobile App", + style: { + fontSize: "0.75rem" + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-phone" + }), /*#__PURE__*/React.createElement("span", null, "Mobile Drafts"), draftBillsList.length > 0 && /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger text-white rounded-pill ms-1", + style: { + fontSize: '0.65rem' + } + }, draftBillsList.length)), (cart.length > 0 || selectedPatient) && /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-secondary py-0.5 px-2 d-inline-flex align-items-center gap-1 shadow-sm", + onClick: clearDraftAndReset, + title: "Discard draft and start new blank bill", + style: { + fontSize: "0.75rem" + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-plus-circle" + }), " New Bill"), lastInvoice && /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-success py-0.5 px-2.5 fw-semibold d-inline-flex align-items-center gap-1 shadow-sm", + onClick: () => setIsPrintOpen(true), + title: "View & Print Last Bill", + style: { + fontSize: "0.75rem" + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer" + }), " Last Bill: ", /*#__PURE__*/React.createElement("strong", null, lastInvoice.sale.invoice_no))), selectedPatient && /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1.5 flex-wrap" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn btn-sm ${showHistoryPanel ? 'btn-primary text-white' : 'btn-outline-primary'} py-1 px-2.5 d-inline-flex align-items-center gap-1 shadow-sm`, + onClick: () => setShowHistoryPanel(!showHistoryPanel), + title: "Toggle Patient Old Records & Past Dispensed Medicines (Right-Side)", + style: { + fontSize: "0.75rem" + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clock-history" + }), /*#__PURE__*/React.createElement("span", null, "Old Records"), patientHistory && patientHistory.total_sales > 0 && /*#__PURE__*/React.createElement("span", { + className: `badge ${showHistoryPanel ? 'bg-white text-primary' : 'bg-primary text-white'} ms-1`, + style: { + fontSize: "0.65rem" + } + }, patientHistory.total_sales)), (selectedPatient.has_active_opd || selectedPatient.has_active_ipd) && /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-success py-1 px-2.5", + onClick: loadDoctorPrescription + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-medical me-1" + }), " 1-Click Load Doctor Rx"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-secondary py-1 px-2", + onClick: resetPatient + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x-circle me-1" + }), " Clear"))), /*#__PURE__*/React.createElement("div", { + className: "row g-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-7 position-relative" + }, /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light text-primary fw-bold", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("kbd", { + className: "me-1", + style: { + background: '#0f172a', + color: '#38bdf8', + fontWeight: 800, + padding: '1px 5px', + borderRadius: '3px' + } + }, "F4"), /*#__PURE__*/React.createElement("i", { + className: "bi bi-search" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + id: "patient-search-input", + ref: patientSearchRef, + className: "form-control", + placeholder: "Search by UHID, Mobile, Name, OPD No, IPD No... (F4)", + value: patientQuery, + onChange: e => searchPatients(e.target.value), + onKeyDown: handlePatientSearchKeyDown, + autoComplete: "off" + })), patientResults.length > 0 && /*#__PURE__*/React.createElement("div", { + className: "search-results-dropdown" + }, patientResults.map((p, pIdx) => { + const isHighlighted = pIdx === selectedPatientIndex; + return /*#__PURE__*/React.createElement("div", { + key: p.patient_id, + className: `search-item-row d-flex justify-content-between align-items-center ${isHighlighted ? 'bg-primary-subtle border-primary' : ''}`, + onClick: () => { + selectPatient(p); + setTimeout(() => focusMedicineSearch(), 50); }, - tabIndex: "-1", - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-lg modal-dialog-scrollable", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content border-0 shadow-lg", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2 px-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-fill-check text-success fs-5" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "modal-title mb-0 fw-bold", - children: "ABDM NRCES FHIR R4 MedicationDispense Document" - }), /*#__PURE__*/_jsx("small", { - className: "text-secondary", - style: { - fontSize: '0.75rem' - }, - children: "Profile: MedicationDispenseDocument | LOINC: 60590-7" - })] - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setShowFhirModal(false) - })] - }), /*#__PURE__*/_jsx("div", { - className: "modal-body p-3 bg-light", - children: isLoadingFhir ? /*#__PURE__*/_jsxs("div", { - className: "text-center py-5", - children: [/*#__PURE__*/_jsx("div", { - className: "spinner-border text-primary mb-2", - role: "status" - }), /*#__PURE__*/_jsx("div", { - className: "text-muted", - children: "Retrieving & Validating ABDM FHIR R4 Bundle..." - })] - }) : fhirBundleData ? /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "col-md-4", - children: /*#__PURE__*/_jsxs("div", { - className: "bg-white p-2 rounded border", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted d-block", - children: "Care Context Reference" - }), /*#__PURE__*/_jsx("code", { - className: "text-primary fw-bold", - children: fhirBundleData.care_context_ref - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-4", - children: /*#__PURE__*/_jsxs("div", { - className: "bg-white p-2 rounded border", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted d-block", - children: "ABHA Number / Address" - }), /*#__PURE__*/_jsx("strong", { - className: "text-success", - children: fhirBundleData.abha_id || fhirBundleData.abha_address || 'Not ABHA Linked' - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-4", - children: /*#__PURE__*/_jsxs("div", { - className: "bg-white p-2 rounded border", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted d-block", - children: "Gateway Sync Status" - }), /*#__PURE__*/_jsx("span", { - className: `badge ${fhirBundleData.sync_status === 'SYNCED' ? 'bg-success' : 'bg-warning text-dark'}`, - children: fhirBundleData.sync_status || 'QUEUED_FOR_BRIDGE' - })] - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-1", - children: [/*#__PURE__*/_jsx("span", { - className: "small fw-bold text-dark", - children: "NRCES FHIR R4 Document Bundle (JSON):" - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-secondary py-0 px-2", - onClick: copyFhirToClipboard, - children: [/*#__PURE__*/_jsx("i", { - className: `bi ${copiedFhir ? 'bi-check-lg text-success' : 'bi-clipboard'} me-1` - }), copiedFhir ? 'Copied!' : 'Copy JSON'] - })] - }), /*#__PURE__*/_jsx("pre", { - className: "bg-dark text-light p-3 rounded-2", - style: { - maxHeight: 360, - fontSize: '0.75rem', - overflow: 'auto' - }, - children: JSON.stringify(fhirBundleData.bundle, null, 2) - })] - }) : /*#__PURE__*/_jsx("div", { - className: "alert alert-warning mb-0", - children: "No FHIR bundle data found." - }) - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer py-1 px-3 bg-white", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted me-auto", - style: { - fontSize: '0.75rem' - }, - children: "Includes SNOMED-CT clinical codes, HFR Facility ID, and Practitioner HPR ID." - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-secondary", - onClick: () => setShowFhirModal(false), - children: "Close" - })] - })] - }) - }) - }), showReturnModal && /*#__PURE__*/_jsx("div", { - className: "modal fade show d-block", style: { - backgroundColor: 'rgba(15, 23, 42, 0.75)' - }, - tabIndex: "-1", - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-xl modal-dialog-scrollable", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content border-0 shadow-lg", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2 px-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-left-right text-warning fs-5" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "modal-title mb-0 fw-bold", - children: "Sales Return & Same-Invoice Exchange Desk" - }), /*#__PURE__*/_jsx("small", { - className: "text-secondary", - style: { - fontSize: '0.75rem' - }, - children: "B2C Retail Returns • Stock Replenishment • GST Credit Note • Fast POS Standard (F6 / Alt+R)" - })] - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setShowReturnModal(false) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-3 bg-light", - children: [/*#__PURE__*/_jsx("div", { - className: "card shadow-sm border-0 mb-3", - children: /*#__PURE__*/_jsxs("div", { - className: "card-body p-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "Lookup Original Tax Invoice / Patient UHID / Phone:" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-white", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-search" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - ref: returnSearchInputRef, - className: "form-control", - placeholder: "Enter Invoice No (e.g. MAIN/26-27/08176), UHID, Patient Name, or Mobile...", - value: returnSearchQuery, - onChange: e => setReturnSearchQuery(e.target.value), - onKeyDown: e => { - if (e.key === 'Enter') { - e.preventDefault(); - searchReturnInvoices(); - } - } - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-primary px-3", - type: "button", - disabled: isSearchingReturn, - onClick: () => searchReturnInvoices(), - children: isSearchingReturn ? /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm me-1" - }), "Searching..."] - }) : /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-repeat me-1" - }), " Search Bill"] - }) - })] - })] - }) - }), !selectedReturnInvoice && returnSearchResults.length > 1 && /*#__PURE__*/_jsxs("div", { - className: "card shadow-sm border-0 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header bg-white py-2 fw-bold text-dark small", - children: ["Matching Invoices (", returnSearchResults.length, " found) - Select an invoice to process returns:"] - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive", - style: { - maxHeight: '220px' - }, - children: /*#__PURE__*/_jsxs("table", { - className: "table table-hover table-sm align-middle mb-0", - style: { - fontSize: '0.85rem' - }, - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "Bill No" - }), /*#__PURE__*/_jsx("th", { - children: "Date" - }), /*#__PURE__*/_jsx("th", { - children: "Patient" - }), /*#__PURE__*/_jsx("th", { - children: "Doctor" - }), /*#__PURE__*/_jsx("th", { - children: "Original Net" - }), /*#__PURE__*/_jsx("th", { - children: "Returnable Items" - }), /*#__PURE__*/_jsx("th", { - children: "Action" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: returnSearchResults.map(resObj => { - const returnableCount = (resObj.items || []).filter(it => it.remaining_units > 0).length; - return /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - className: "fw-bold text-primary", - children: resObj.sale.invoice_no - }), /*#__PURE__*/_jsx("td", { - className: "text-muted", - children: resObj.sale.sale_date - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("strong", { - children: resObj.sale.patient_name - }), resObj.sale.uhid && /*#__PURE__*/_jsxs("span", { - className: "text-muted ms-1", - children: ["(", resObj.sale.uhid, ")"] - })] - }), /*#__PURE__*/_jsx("td", { - children: resObj.sale.doctor_name || 'N/A' - }), /*#__PURE__*/_jsxs("td", { - className: "fw-bold", - children: ["₹", resObj.sale.net_amount] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("span", { - className: `badge ${returnableCount > 0 ? 'bg-success-subtle text-success' : 'bg-secondary'}`, - children: [returnableCount, " items eligible"] - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-primary py-0 px-2", - onClick: () => selectReturnInvoice(resObj), - children: ["Select Bill ", /*#__PURE__*/_jsx("i", { - className: "bi bi-chevron-right ms-1" - })] - }) - })] - }, resObj.sale.sale_id); - }) - })] - }) - })] - }), selectedReturnInvoice && /*#__PURE__*/_jsxs("div", { - className: "card shadow-sm border-0 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header bg-white py-2 d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-primary fs-7", - children: selectedReturnInvoice.sale.invoice_no - }), /*#__PURE__*/_jsxs("span", { - className: "text-muted small", - children: ["Date: ", selectedReturnInvoice.sale.sale_date] - }), selectedReturnInvoice.sale.uhid && /*#__PURE__*/_jsxs("span", { - className: "badge bg-light text-dark border", - children: ["UHID: ", selectedReturnInvoice.sale.uhid] - })] - }), returnSearchResults.length > 1 && /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-secondary py-0", - onClick: () => setSelectedReturnInvoice(null), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-left me-1" - }), " Change Bill"] - })] - }), /*#__PURE__*/_jsx("div", { - className: "card-body p-2 bg-light-subtle", - children: /*#__PURE__*/_jsxs("div", { - className: "row g-2 small", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-3", - children: [/*#__PURE__*/_jsx("strong", { - children: "Patient:" - }), " ", selectedReturnInvoice.sale.patient_name] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-3", - children: [/*#__PURE__*/_jsx("strong", { - children: "Phone:" - }), " ", selectedReturnInvoice.sale.patient_mobile || 'N/A'] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-3", - children: [/*#__PURE__*/_jsx("strong", { - children: "Doctor:" - }), " ", selectedReturnInvoice.sale.doctor_name || 'N/A'] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-3", - children: [/*#__PURE__*/_jsx("strong", { - children: "Original Net Paid:" - }), " ₹", selectedReturnInvoice.sale.net_amount] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-bordered table-sm align-middle mb-0", - style: { - fontSize: '0.85rem' - }, - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "#" - }), /*#__PURE__*/_jsx("th", { - children: "Medicine Name" - }), /*#__PURE__*/_jsx("th", { - children: "Batch / Exp" - }), /*#__PURE__*/_jsx("th", { - children: "Sold / Returned" - }), /*#__PURE__*/_jsx("th", { - children: "Eligible Units" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 150 - }, - children: "Return Qty & Unit" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 140 - }, - children: "Condition" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 150 - }, - children: "Reason" - }), /*#__PURE__*/_jsx("th", { - children: "Credit Rate" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - style: { - width: 110 - }, - children: "Line Credit" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: selectedReturnInvoice.items.map((it, idx) => { - const draft = returnDraftItems[it.sale_item_id] || { - return_qty: 0, - return_unit: it.units_per_pack > 1 && it.remaining_strips > 0 ? 'Strip' : 'Tab', - condition: 'GOOD', - reason: 'EXCESS_UNUSED' - }; - const isEligible = it.remaining_units > 0; - const qty = Number(draft.return_qty) || 0; - const upp = Number(it.units_per_pack) || 1; - const totalReturnUnits = draft.return_unit === 'Strip' ? qty * upp : qty; - const lineCredit = Number((totalReturnUnits * it.effective_unit_price).toFixed(2)); - const isOverLimit = totalReturnUnits > it.remaining_units; - return /*#__PURE__*/_jsxs("tr", { - className: !isEligible ? 'opacity-50 table-light' : qty > 0 ? 'table-warning' : '', - children: [/*#__PURE__*/_jsx("td", { - children: idx + 1 - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("strong", { - className: "text-dark", - children: it.item_name - }), it.generic_name && /*#__PURE__*/_jsx("div", { - className: "text-muted", - style: { - fontSize: '0.75rem' - }, - children: it.generic_name - }), upp > 1 && /*#__PURE__*/_jsxs("div", { - className: "text-muted", - style: { - fontSize: '0.72rem' - }, - children: ["1 Strip = ", upp, " Tabs"] - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-secondary-subtle text-dark border", - children: it.batch_no - }), /*#__PURE__*/_jsxs("div", { - className: "text-muted", - style: { - fontSize: '0.72rem' - }, - children: ["Exp: ", it.expiry_date ? it.expiry_date.substring(0, 7) : 'N/A'] - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsxs("div", { - children: ["Sold: ", it.total_units, " tab"] - }), Number(it.already_returned_units) > 0 && /*#__PURE__*/_jsxs("div", { - className: "text-danger", - style: { - fontSize: '0.75rem' - }, - children: ["Returned: ", it.already_returned_units, " tab"] - })] - }), /*#__PURE__*/_jsx("td", { - children: isEligible ? /*#__PURE__*/_jsxs("span", { - className: "badge bg-success-subtle text-success border border-success", - children: [it.remaining_units, " Tabs ", upp > 1 ? `(${it.remaining_strips} Str + ${it.remaining_loose} Tab)` : ''] - }) : /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary", - children: "Fully Returned" - }) - }), /*#__PURE__*/_jsxs("td", { - children: [isEligible ? /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "number", - min: "0", - max: draft.return_unit === 'Strip' ? it.remaining_strips : it.remaining_units, - className: `form-control ${isOverLimit ? 'is-invalid' : ''}`, - value: draft.return_qty, - onChange: e => updateReturnDraft(it.sale_item_id, 'return_qty', e.target.value) - }), upp > 1 && /*#__PURE__*/_jsxs("select", { - className: "form-select", - style: { - maxWidth: 80 - }, - value: draft.return_unit, - onChange: e => updateReturnDraft(it.sale_item_id, 'return_unit', e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "Tab", - children: "Tab" - }), /*#__PURE__*/_jsx("option", { - value: "Strip", - children: "Strip" - })] - })] - }) : /*#__PURE__*/_jsx("span", { - className: "text-muted small", - children: "-" - }), isOverLimit && /*#__PURE__*/_jsxs("small", { - className: "text-danger d-block", - children: ["Max ", it.remaining_units, " tabs"] - })] - }), /*#__PURE__*/_jsx("td", { - children: isEligible && qty > 0 ? /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: draft.condition, - onChange: e => updateReturnDraft(it.sale_item_id, 'condition', e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "GOOD", - children: "Good (Restock)" - }), /*#__PURE__*/_jsx("option", { - value: "DAMAGED", - children: "Damaged / Broken" - }), /*#__PURE__*/_jsx("option", { - value: "EXPIRED", - children: "Expired / Defective" - })] - }) : /*#__PURE__*/_jsx("span", { - className: "text-muted small", - children: "-" - }) - }), /*#__PURE__*/_jsx("td", { - children: isEligible && qty > 0 ? /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: draft.reason, - onChange: e => updateReturnDraft(it.sale_item_id, 'reason', e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "EXCESS_UNUSED", - children: "Excess / Unused" - }), /*#__PURE__*/_jsx("option", { - value: "DOCTOR_CHANGED_RX", - children: "Doctor Changed Rx" - }), /*#__PURE__*/_jsx("option", { - value: "PATIENT_DISCHARGED", - children: "Patient Discharged" - }), /*#__PURE__*/_jsx("option", { - value: "WRONG_MEDICINE", - children: "Wrong Dispense" - })] - }) : /*#__PURE__*/_jsx("span", { - className: "text-muted small", - children: "-" - }) - }), /*#__PURE__*/_jsxs("td", { - children: ["₹", it.effective_unit_price, " ", /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "/tab" - }), upp > 1 && /*#__PURE__*/_jsxs("div", { - className: "text-muted", - style: { - fontSize: '0.72rem' - }, - children: ["₹", (it.effective_unit_price * upp).toFixed(2), "/str"] - })] - }), /*#__PURE__*/_jsx("td", { - className: "text-end fw-bold", - children: qty > 0 ? /*#__PURE__*/_jsxs("span", { - className: "text-danger", - children: ["-₹", lineCredit.toFixed(2)] - }) : /*#__PURE__*/_jsx("span", { - className: "text-muted", - children: "₹0.00" - }) - })] - }, it.sale_item_id); - }) - })] - }) - })] - }), !selectedReturnInvoice && returnSearchResults.length === 0 && /*#__PURE__*/_jsxs("div", { - className: "text-center py-5 text-muted bg-white rounded border", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-receipt-cutoff fs-1 text-secondary mb-2 d-block" - }), /*#__PURE__*/_jsx("div", { - className: "fw-bold", - children: "No Invoice Selected" - }), /*#__PURE__*/_jsx("div", { - className: "small", - children: "Search by Bill Number, Patient UHID, Name, or Mobile to load returnable items." - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer py-2 px-3 bg-white d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsx("div", { - children: selectedReturnInvoice && /*#__PURE__*/_jsx("div", { - className: "d-flex align-items-center gap-3", - children: (() => { - let totalCredit = 0; - let totalItemsCount = 0; - selectedReturnInvoice.items.forEach(it => { - const draft = returnDraftItems[it.sale_item_id]; - if (draft && Number(draft.return_qty) > 0) { - const qty = Number(draft.return_qty); - const upp = Number(it.units_per_pack) || 1; - const tu = draft.return_unit === 'Strip' ? qty * upp : qty; - totalCredit += tu * it.effective_unit_price; - totalItemsCount++; - } - }); - return /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("span", { - className: "text-muted small me-2", - children: ["Selected Items: ", /*#__PURE__*/_jsx("strong", { - children: totalItemsCount - })] - }), /*#__PURE__*/_jsxs("span", { - className: "text-danger fw-bold fs-6", - children: ["Total Return Credit: -₹", totalCredit.toFixed(2)] - })] - }); - })() - }) - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-secondary btn-sm", - onClick: () => setShowReturnModal(false), - children: "Cancel" - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-danger btn-sm px-3 fw-bold", - disabled: !selectedReturnInvoice, - onClick: addSelectedReturnsToBill, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cart-plus me-1" - }), " Add to Current Bill (Exchange / Net-Off)"] - })] - })] - })] - }) - }) - }), showDraftModal && /*#__PURE__*/_jsx("div", { - className: "modal show d-block", - tabIndex: "-1", + cursor: 'pointer' + } + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark" + }, p.full_name, " ", /*#__PURE__*/React.createElement("small", { + className: "text-primary" + }, "(", p.uhid, ")"), isHighlighted && /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary text-white ms-2", style: { - backgroundColor: 'rgba(15, 23, 42, 0.75)' + fontSize: '0.65rem' + } + }, "↵ Enter"), (p.abha_id || p.abha_address) && /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success border border-success ms-2", + style: { + fontSize: '0.65rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-fill-check me-1" + }), "ABHA: ", p.abha_id || p.abha_address)), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-telephone me-1" + }), p.mobile || 'No Mobile', " • ", p.gender, " • ", p.age)), /*#__PURE__*/React.createElement("div", { + className: "text-end" + }, p.has_active_ipd && /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger d-block mb-1" + }, "IPD Admitted: ", p.active_ipd.bed_info?.bed_no || 'Bed'), p.has_active_opd && /*#__PURE__*/React.createElement("span", { + className: "badge bg-info d-block" + }, "OPD Visit Today"))); + }))), /*#__PURE__*/React.createElement("div", { + className: "col-md-5" + }, /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "Consultant Doctor Name", + value: doctorName, + onChange: e => setDoctorName(e.target.value) + }))), /*#__PURE__*/React.createElement("div", { + className: "row g-2 mt-1" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light text-success fw-bold", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-check me-1" + }), " ABHA No"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "14-Digit ABHA (e.g. 12-3456-7890-1234)", + value: walkinAbhaId, + onChange: e => setWalkinAbhaId(e.target.value) + }))), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light text-success fw-bold", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-at me-1" + }), " ABHA Address"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "username@abdm", + value: walkinAbhaAddress, + onChange: e => setWalkinAbhaAddress(e.target.value) + })))), selectedPatient && /*#__PURE__*/React.createElement("div", { + className: "mt-2 p-2 bg-light rounded-2 d-flex flex-wrap gap-3 align-items-center", + style: { + fontSize: '0.8rem' + } + }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("strong", null, "Name:"), " ", selectedPatient.full_name), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("strong", null, "UHID:"), " ", /*#__PURE__*/React.createElement("code", { + className: "text-primary" + }, selectedPatient.uhid)), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("strong", null, "Gender/Age:"), " ", selectedPatient.gender, ", ", selectedPatient.age), (selectedPatient.abha_id || selectedPatient.abha_address) && /*#__PURE__*/React.createElement("span", { + className: "badge bg-success text-white py-1 px-2", + style: { + fontSize: '0.75rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-fill-check me-1" + }), " ABDM Linked: ", selectedPatient.abha_id || '', " ", selectedPatient.abha_address ? `(${selectedPatient.abha_address})` : ''), selectedPatient.has_active_ipd && /*#__PURE__*/React.createElement("span", { + className: "text-danger fw-bold" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hospital me-1" + }), selectedPatient.active_ipd.bed_info?.ward_name || 'Ward', " / ", selectedPatient.active_ipd.bed_info?.bed_no || 'Bed', " (Dr. ", selectedPatient.active_ipd.doctor_name, ")"), selectedPatient.has_active_opd && !selectedPatient.has_active_ipd && /*#__PURE__*/React.createElement("span", { + className: "text-primary fw-bold" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-stethoscope me-1" + }), "OPD Dr. ", selectedPatient.active_opd.doctor_name)), !selectedPatient && (walkinMobile || walkinUhid) && /*#__PURE__*/React.createElement("div", { + className: "mt-2 p-2 bg-light rounded-2 d-flex flex-wrap gap-3 align-items-center", + style: { + fontSize: '0.8rem' + } + }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("strong", null, "Customer:"), " ", patientQuery || 'Walk-in'), walkinMobile && /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("strong", null, "Mobile:"), " ", /*#__PURE__*/React.createElement("i", { + className: "bi bi-telephone me-1 text-primary" + }), walkinMobile), walkinUhid && /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("strong", null, "UHID:"), " ", /*#__PURE__*/React.createElement("code", { + className: "text-primary" + }, walkinUhid))), loadedDraft && /*#__PURE__*/React.createElement("div", { + className: "mt-2 p-2 rounded-2 d-flex flex-wrap justify-content-between align-items-center gap-2", + style: { + background: '#fef3c7', + border: '1px solid #f59e0b', + fontSize: '0.8rem' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap align-items-center gap-2" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-warning text-dark fw-bold" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-phone me-1" + }), " Draft: ", loadedDraft.draft_code), /*#__PURE__*/React.createElement("span", { + className: "text-dark" + }, "Collector: ", /*#__PURE__*/React.createElement("strong", null, loadedDraft.collected_by_name || 'Staff'), loadedDraft.ward_name ? ` • Ward: ${loadedDraft.ward_name} (${loadedDraft.bed_no || ''})` : ''), /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-secondary border", + style: { + fontSize: '0.7rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-right-circle me-1 text-success" + }), "Auto-converts to invoice on checkout")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-dark py-0 px-2", + onClick: () => { + setLoadedDraft(null); + notify(`Draft [${loadedDraft.draft_code}] unlinked. Cart items kept.`, 'info'); + }, + title: "Unlink this draft without clearing the cart", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-link-45deg me-1" + }), " Unlink Draft"))), /*#__PURE__*/React.createElement("div", { + className: "counter-card position-relative" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap align-items-center gap-1.5 mb-2.5 py-1.5 px-2.5 rounded-3 shadow-sm", + style: { + background: '#f8fafc', + border: '1px solid #cbd5e1' + } + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold d-flex align-items-center me-1", + style: { + color: '#0f172a', + fontSize: '0.74rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-keyboard-fill text-primary me-1 fs-6" + }), /*#__PURE__*/React.createElement("span", null, "Keys:")), /*#__PURE__*/React.createElement("span", { + className: "d-inline-flex align-items-center gap-1 px-2 py-0.5 bg-white rounded border shadow-xs", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("kbd", { + style: { + background: '#0f172a', + color: '#38bdf8', + fontWeight: 800, + padding: '1px 5px', + borderRadius: '3px', + fontSize: '0.68rem' + } + }, "F2"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold", + style: { + color: '#0f172a' + } + }, "Search")), /*#__PURE__*/React.createElement("span", { + className: "d-inline-flex align-items-center gap-1 px-2 py-0.5 bg-white rounded border shadow-xs", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("kbd", { + style: { + background: '#0f172a', + color: '#38bdf8', + fontWeight: 800, + padding: '1px 5px', + borderRadius: '3px', + fontSize: '0.68rem' + } + }, "↑ / ↓"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold", + style: { + color: '#0f172a' + } + }, "Select")), /*#__PURE__*/React.createElement("span", { + className: "d-inline-flex align-items-center gap-1 px-2 py-0.5 bg-white rounded border shadow-xs", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("kbd", { + style: { + background: '#0f172a', + color: '#38bdf8', + fontWeight: 800, + padding: '1px 5px', + borderRadius: '3px', + fontSize: '0.68rem' + } + }, "↵ Enter"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold", + style: { + color: '#0f172a' + } + }, "Batch")), /*#__PURE__*/React.createElement("span", { + className: "d-inline-flex align-items-center gap-1 px-2 py-0.5 bg-white rounded border border-primary shadow-xs", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("kbd", { + style: { + background: '#0891b2', + color: '#ffffff', + fontWeight: 800, + padding: '1px 5px', + borderRadius: '3px', + fontSize: '0.68rem' + } + }, "↵ on Qty"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-primary" + }, "Next Item")), /*#__PURE__*/React.createElement("span", { + className: "d-inline-flex align-items-center gap-1 px-2 py-0.5 bg-white rounded border shadow-xs", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("kbd", { + style: { + background: '#0f172a', + color: '#10b981', + fontWeight: 800, + padding: '1px 5px', + borderRadius: '3px', + fontSize: '0.68rem' + } + }, "Alt+T"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold", + style: { + color: '#0f172a' + } + }, "Loose")), /*#__PURE__*/React.createElement("span", { + className: "d-inline-flex align-items-center gap-1 px-2 py-0.5 bg-white rounded border shadow-xs", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("kbd", { + style: { + background: '#0f172a', + color: '#38bdf8', + fontWeight: 800, + padding: '1px 5px', + borderRadius: '3px', + fontSize: '0.68rem' + } + }, "Alt+S"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold", + style: { + color: '#0f172a' + } + }, "Strip")), /*#__PURE__*/React.createElement("span", { + className: "d-inline-flex align-items-center gap-1 px-2 py-0.5 bg-white rounded border shadow-xs", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("kbd", { + style: { + background: '#0f172a', + color: '#f59e0b', + fontWeight: 800, + padding: '1px 5px', + borderRadius: '3px', + fontSize: '0.68rem' + } + }, "F4"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold", + style: { + color: '#0f172a' + } + }, "Patient")), /*#__PURE__*/React.createElement("span", { + className: "d-inline-flex align-items-center gap-1 px-2 py-0.5 bg-white rounded border shadow-xs", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("kbd", { + style: { + background: '#0f172a', + color: '#a855f7', + fontWeight: 800, + padding: '1px 5px', + borderRadius: '3px', + fontSize: '0.68rem' + } + }, "F8"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold", + style: { + color: '#0f172a' + } + }, "Payment")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs py-0.5 px-2 bg-white rounded border border-danger shadow-xs d-inline-flex align-items-center gap-1", + onClick: openReturnModal, + style: { + fontSize: '0.72rem' + }, + title: "Accept patient returns or exchange on current bill (Alt+R / F6)" + }, /*#__PURE__*/React.createElement("kbd", { + style: { + background: '#e11d48', + color: '#ffffff', + fontWeight: 800, + padding: '1px 5px', + borderRadius: '3px', + fontSize: '0.68rem' + } + }, "Alt+R / F6"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-danger" + }, "Return / Exch")), /*#__PURE__*/React.createElement("span", { + className: "d-inline-flex align-items-center gap-1 px-2.5 py-0.5 rounded text-white shadow-sm", + style: { + background: '#059669', + fontSize: '0.72rem', + border: '1px solid #047857' + } + }, /*#__PURE__*/React.createElement("kbd", { + style: { + background: '#ffffff', + color: '#065f46', + fontWeight: 800, + padding: '1px 5px', + borderRadius: '3px', + fontSize: '0.68rem' + } + }, "F9 / Ctrl+↵"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold" + }, "Bill & Print"))), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2 mb-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-upc-scan text-primary fs-5" + }), /*#__PURE__*/React.createElement("span", { + className: "fw-bold fs-6" + }, "Medicine Lookup & Barcode Dispenser")), /*#__PURE__*/React.createElement("div", { + className: "input-group" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light text-primary fw-bold", + style: { + fontSize: '0.75rem' + } + }, /*#__PURE__*/React.createElement("kbd", { + className: "me-1", + style: { + background: '#0f172a', + color: '#38bdf8', + fontWeight: 800, + padding: '1px 5px', + borderRadius: '3px' + } + }, "F2"), /*#__PURE__*/React.createElement("i", { + className: "bi bi-capsule" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + id: "item-search-input", + ref: medicineSearchRef, + className: "form-control fw-semibold", + placeholder: "Type Medicine Name, Generic Molecule, or Scan Box Barcode... (Press F2 anytime)", + value: itemQuery, + onChange: e => searchItems(e.target.value), + onKeyDown: handleMedicineSearchKeyDown, + autoComplete: "off" + }), isSearchingItems && /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hourglass-split" + }))), itemResults.length > 0 && /*#__PURE__*/React.createElement("div", { + className: "search-results-dropdown" + }, itemResults.map(it => /*#__PURE__*/React.createElement("div", { + key: it.item_id, + className: "search-item-row" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-1" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-dark fs-6" + }, it.item_name), /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary ms-2", + style: { + fontSize: '0.65rem' + } + }, it.unit_pack), it.drug_schedule && it.drug_schedule !== 'OTC' && /*#__PURE__*/React.createElement("span", { + className: "badge bg-warning-subtle text-warning border border-warning ms-1", + style: { + fontSize: '0.65rem' + } + }, it.drug_schedule)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", { + className: "text-muted me-2", + style: { + fontSize: '0.75rem' + } + }, "Total Stock: ", it.total_stock))), /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block mb-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-diagram-3 me-1" + }), it.generic_name, " • HSN: ", it.hsn_code), it.batches && it.batches.length > 0 ? /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap gap-2 mt-1" + }, it.batches.map(b => { + const isHighlighted = selectableBatches[selectedBatchIndex] && selectableBatches[selectedBatchIndex].batch.batch_id === b.batch_id && selectableBatches[selectedBatchIndex].item.item_id === it.item_id; + return /*#__PURE__*/React.createElement("button", { + key: b.batch_id, + className: `btn btn-sm ${isHighlighted ? 'btn-warning text-dark border-2 shadow-sm fw-bold' : b.is_expired ? 'btn-outline-danger disabled' : 'btn-outline-dark'} d-flex align-items-center gap-1 py-0.5 px-2`, + style: { + fontSize: '0.75rem', + transform: isHighlighted ? 'scale(1.04)' : 'scale(1)', + transition: 'transform 0.1s' }, - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered modal-lg", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content shadow-lg border-0", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2.5 px-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-phone-vibrate text-warning fs-5" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "modal-title fw-bold mb-0", - children: "Mobile App Rack Drafts Queue" - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "Draft bills collected from pharmacy shelves via smartphone" - })] - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setShowDraftModal(false) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-between mb-3 pb-2 border-bottom", - children: [/*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn btn-sm ${draftModalTab === 'DRAFT' ? 'btn-warning text-dark fw-bold' : 'btn-outline-secondary'}`, - onClick: () => { - setDraftModalTab('DRAFT'); - loadDraftBills('DRAFT'); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hourglass-split me-1" - }), " Pending Queue"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn btn-sm ${draftModalTab === 'CONVERTED' ? 'btn-success text-white fw-bold' : 'btn-outline-secondary'}`, - onClick: () => { - setDraftModalTab('CONVERTED'); - loadDraftBills('CONVERTED'); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check2-all me-1" - }), " Billed / Converted"] - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-primary py-0.5 px-2", - onClick: () => loadDraftBills(draftModalTab), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-clockwise me-1" - }), " Refresh"] - })] - }), draftBillsList.length === 0 ? /*#__PURE__*/_jsxs("div", { - className: "text-center py-5 text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-basket3 fs-1 d-block mb-2 text-secondary" - }), /*#__PURE__*/_jsx("h5", { - children: draftModalTab === 'CONVERTED' ? 'No Converted Draft Bills' : 'No Pending Draft Bills' - }), /*#__PURE__*/_jsx("p", { - className: "small mb-0", - children: draftModalTab === 'CONVERTED' ? 'Draft bills will appear here once converted into pharmacy sales invoices.' : 'Medicines added by rack collectors from the mobile app will automatically show up here.' - })] - }) : /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-pos table-hover mb-0", - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "Draft Code" - }), /*#__PURE__*/_jsx("th", { - children: "Patient / Ward" - }), /*#__PURE__*/_jsx("th", { - children: "Items" - }), /*#__PURE__*/_jsx("th", { - children: "Est. Amount" - }), /*#__PURE__*/_jsx("th", { - children: "Collector" - }), /*#__PURE__*/_jsx("th", { - children: "Time" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Action" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: draftBillsList.map(d => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: `badge ${d.status === 'CONVERTED' ? 'bg-secondary' : 'bg-warning text-dark'} fw-bold`, - children: d.draft_code - }) - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold", - children: d.patient_name || 'Walk-in' - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: d.ward_name ? `${d.ward_name} / Bed ${d.bed_no}` : d.patient_mobile || 'No bed info' - })] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("span", { - className: "badge bg-primary rounded-pill", - children: [d.total_items, " items"] - }) - }), /*#__PURE__*/_jsxs("td", { - className: "fw-bold text-success", - children: ["₹", Number(d.estimated_amount || 0).toFixed(2)] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("small", { - className: "text-secondary", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person me-1" - }), d.collected_by_name || 'Staff'] - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: d.created_at?.split(' ')[1] || d.created_at - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-end", - children: d.status === 'CONVERTED' ? /*#__PURE__*/_jsxs("span", { - className: "badge bg-success-subtle text-success border border-success fw-bold px-2 py-1", - style: { - fontSize: '0.75rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle-fill me-1" - }), " Billed: ", d.converted_invoice_no || 'INV'] - }) : /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-success fw-bold px-2.5 py-1 me-1 shadow-sm", - onClick: () => handleLoadDraftBillIntoCart(d), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cart-plus me-1" - }), " Load Bill"] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-danger py-1 px-1.5", - onClick: () => handleCancelDraft(d.draft_id), - title: "Discard draft", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-trash" - }) - })] - }) - })] - }, d.draft_id)) - })] - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer py-2 px-3 bg-light d-flex justify-content-between", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted", - children: draftModalTab === 'DRAFT' ? `${draftBillsList.length} draft bill(s) pending` : `${draftBillsList.length} converted draft bill(s)` - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-secondary", - onClick: () => setShowDraftModal(false), - children: "Close" - })] - })] - }) - }) - })] - }); + onClick: () => addItemToCart(it, b, 1), + disabled: b.is_expired, + title: isHighlighted ? 'Press Enter to select this batch' : `Select batch ${b.batch_no}` + }, /*#__PURE__*/React.createElement("strong", null, b.batch_no), /*#__PURE__*/React.createElement("span", null, "(Exp: ", b.expiry_display, ")"), /*#__PURE__*/React.createElement("span", { + className: "text-success fw-bold" + }, "₹", b.mrp), /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary text-white" + }, b.current_qty, " left"), it.fefo_batch && it.fefo_batch.batch_id === b.batch_id && /*#__PURE__*/React.createElement("span", { + className: "badge-fefo ms-1" + }, "FEFO"), b.is_near_expiry && /*#__PURE__*/React.createElement("span", { + className: "badge-near-expiry ms-1" + }, "Near Exp"), b.is_expired && /*#__PURE__*/React.createElement("span", { + className: "badge-expired ms-1" + }, "EXPIRED"), isHighlighted && /*#__PURE__*/React.createElement("span", { + className: "badge bg-dark text-warning ms-1", + style: { + fontSize: '0.62rem' + } + }, "↵ Enter")); + })) : /*#__PURE__*/React.createElement("span", { + className: "text-danger fw-bold", + style: { + fontSize: '0.75rem' + } + }, "Out of Stock in this Counter"))))), /*#__PURE__*/React.createElement("div", { + className: "counter-card p-0 overflow-hidden" + }, /*#__PURE__*/React.createElement("div", { + className: "p-3 pb-2 d-flex flex-wrap justify-content-between align-items-center gap-2 border-bottom" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("h6", { + className: "mb-0 fw-bold" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cart-check-fill text-success me-1" + }), " Dispensing Cart (", cart.length, " new)"), returnCart.length > 0 && /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger-subtle text-danger border border-danger" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-return-left me-1" + }), returnCart.length, " return/exchange")), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2 align-items-center" + }, (cart.length > 0 || returnCart.length > 0) && /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-success py-0.5 px-2.5 fw-bold d-inline-flex align-items-center gap-1.5 shadow-sm", + onClick: () => setIsCheckoutOpen(true), + style: { + fontSize: '0.75rem', + background: '#10b981', + borderColor: '#059669' + }, + title: "Open Checkout Desk to finalize bill (F8 / F9)" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-wallet2" + }), " Checkout ", refundPayable > 0 ? `(Refund ₹${refundPayable})` : `(₹${netPayable})`, " ", /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-right" + })), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-danger py-0.5 px-2.5 fw-semibold d-inline-flex align-items-center gap-1", + onClick: openReturnModal, + style: { + fontSize: '0.75rem' + }, + title: "Add patient return or item exchange (Alt+R / F6)" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-return-left" + }), " Add Return / Exch"), (cart.length > 0 || returnCart.length > 0) && /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-link text-muted text-decoration-none p-0", + onClick: () => { + setCart([]); + setReturnCart([]); + } + }, "Clear All"))), /*#__PURE__*/React.createElement("div", { + className: "table-responsive", + style: { + maxHeight: 380 + } + }, /*#__PURE__*/React.createElement("table", { + className: "table table-pos mb-0" + }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "#"), /*#__PURE__*/React.createElement("th", null, "Medicine Name"), /*#__PURE__*/React.createElement("th", null, "Batch / Exp"), /*#__PURE__*/React.createElement("th", { + style: { + width: 155 + } + }, "Qty & Unit"), /*#__PURE__*/React.createElement("th", null, "Rate (₹)"), /*#__PURE__*/React.createElement("th", { + style: { + width: 125 + } + }, "Disc (% / ₹)"), /*#__PURE__*/React.createElement("th", null, "GST%"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Total (₹)"), /*#__PURE__*/React.createElement("th", { + style: { + width: 40 + } + }))), /*#__PURE__*/React.createElement("tbody", null, cart.length === 0 && returnCart.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "9", + className: "text-center py-4 text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-basket3 fs-3 d-block mb-1" + }), "Scan barcode or search medicine to add items, or click ", /*#__PURE__*/React.createElement("strong", { + className: "text-danger" + }, "Add Return / Exch"), " (Alt+R / F6).")) : cart.map((it, idx) => { + const info = getItemLineInfo(it); + const lineGross = info.lineGross; + const lineDisc = getItemDiscount(it); + const lineNet = Math.max(0, lineGross - lineDisc).toFixed(2); + const upp = info.upp; + return /*#__PURE__*/React.createElement("tr", { + key: `sale-${idx}` + }, /*#__PURE__*/React.createElement("td", null, idx + 1), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold" + }, it.item_name), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, it.generic_name, " • HSN: ", it.hsn_code), upp > 1 && /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-secondary border ms-1", + style: { + fontSize: '0.62rem' + } + }, "Pack: ", it.unit_pack || `${upp} Tabs`)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border" + }, it.batch_no), /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '0.7rem' + } + }, "Exp: ", it.expiry_display)), /*#__PURE__*/React.createElement("td", null, upp > 1 ? /*#__PURE__*/React.createElement("div", { + style: { + maxWidth: 155 + } + }, it.sell_unit === 'Combo' ? /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm py-0 px-1 fw-bold bg-warning-subtle text-dark border-warning", + style: { + maxWidth: 64, + fontSize: '0.72rem' + }, + value: it.sell_unit, + onChange: e => switchSellUnit(idx, e.target.value), + title: "Unit Type: Combo (Strips + Loose Tablets)" + }, /*#__PURE__*/React.createElement("option", { + value: "Tablet" + }, "Tab"), /*#__PURE__*/React.createElement("option", { + value: "Strip" + }, "Strip"), /*#__PURE__*/React.createElement("option", { + value: "Combo" + }, "Str+Tab")), /*#__PURE__*/React.createElement("input", { + type: "number", + id: `cart-qty-strip-${idx}`, + className: "form-control form-control-sm text-center fw-bold px-1", + min: "0", + placeholder: "Str", + title: "Whole Strips", + value: it.strip_qty ?? 1, + onChange: e => updateCartItem(idx, 'strip_qty', Number(e.target.value)), + onKeyDown: e => { + if (e.key === 'Enter') { + e.preventDefault(); + focusMedicineSearch(); + } else if (e.key === 'Delete' && e.shiftKey) { + e.preventDefault(); + removeCartItem(idx); + focusMedicineSearch(); + } + } + }), /*#__PURE__*/React.createElement("input", { + type: "number", + id: `cart-qty-loose-${idx}`, + className: "form-control form-control-sm text-center fw-bold text-success border-success px-1", + min: "0", + placeholder: "Tab", + title: "Loose Tablets", + value: it.loose_qty ?? 0, + onChange: e => updateCartItem(idx, 'loose_qty', Number(e.target.value)), + onKeyDown: e => { + if (e.key === 'Enter') { + e.preventDefault(); + focusMedicineSearch(); + } else if (e.key === 'Delete' && e.shiftKey) { + e.preventDefault(); + removeCartItem(idx); + focusMedicineSearch(); + } + } + })) : /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("select", { + className: `form-select form-select-sm py-0 px-1 fw-bold ${it.sell_unit === 'Strip' ? 'bg-primary-subtle text-primary border-primary' : 'bg-success-subtle text-success border-success'}`, + style: { + maxWidth: 65, + fontSize: '0.72rem' + }, + value: it.sell_unit || 'Tablet', + onChange: e => switchSellUnit(idx, e.target.value), + title: "Select Unit Type before quantity" + }, /*#__PURE__*/React.createElement("option", { + value: "Tablet" + }, "Tab"), /*#__PURE__*/React.createElement("option", { + value: "Strip" + }, "Strip"), /*#__PURE__*/React.createElement("option", { + value: "Combo" + }, "Str+Tab")), /*#__PURE__*/React.createElement("input", { + type: "number", + id: it.sell_unit === 'Strip' ? `cart-qty-strip-${idx}` : `cart-qty-loose-${idx}`, + className: `form-control form-control-sm text-center fw-bold ${it.sell_unit === 'Strip' ? 'text-primary' : 'text-success border-success'}`, + min: "1", + max: it.current_qty, + value: it.sell_unit === 'Strip' ? it.strip_qty ?? it.qty ?? 1 : it.loose_qty ?? it.qty ?? 1, + onChange: e => { + const val = Number(e.target.value); + const updated = [...cart]; + if (it.sell_unit === 'Strip') { + updated[idx].strip_qty = val; + } else { + updated[idx].loose_qty = val; + } + updated[idx].qty = val; + setCart(updated); + }, + onKeyDown: e => { + if (e.key === 'Enter') { + e.preventDefault(); + focusMedicineSearch(); + } else if (e.altKey && (e.key === 's' || e.key === 'S')) { + e.preventDefault(); + switchSellUnit(idx, 'Strip'); + } else if (e.altKey && (e.key === 't' || e.key === 'T')) { + e.preventDefault(); + switchSellUnit(idx, 'Tablet'); + } else if (e.altKey && (e.key === 'c' || e.key === 'C')) { + e.preventDefault(); + switchSellUnit(idx, 'Combo'); + } else if (e.key === 'Delete' && e.shiftKey) { + e.preventDefault(); + removeCartItem(idx); + focusMedicineSearch(); + } + } + })), /*#__PURE__*/React.createElement("div", { + className: "text-muted text-center mt-0.5", + style: { + fontSize: '0.64rem' + } + }, it.sell_unit === 'Tablet' ? `= ${info.totalUnits} Tab (₹${info.perUnitMrp}/tab)` : it.sell_unit === 'Combo' ? `= ${info.totalUnits} Tab total` : `= ${info.totalUnits} Tab (${upp}/str)`)) : /*#__PURE__*/React.createElement("div", { + style: { + maxWidth: 120 + } + }, /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light text-muted px-1.5 py-0 fw-semibold", + style: { + fontSize: '0.68rem', + maxWidth: 50 + } + }, it.unit_pack || 'Unit'), /*#__PURE__*/React.createElement("input", { + type: "number", + id: `cart-qty-strip-${idx}`, + className: "form-control form-control-sm text-center fw-bold", + min: "1", + max: it.current_qty, + value: it.qty, + onChange: e => updateCartItem(idx, 'qty', Number(e.target.value)), + onKeyDown: e => { + if (e.key === 'Enter') { + e.preventDefault(); + focusMedicineSearch(); + } else if (e.key === 'Delete' && e.shiftKey) { + e.preventDefault(); + removeCartItem(idx); + focusMedicineSearch(); + } + } + })), /*#__PURE__*/React.createElement("div", { + className: "text-muted text-center mt-0.5", + style: { + fontSize: '0.64rem' + } + }, "₹", it.unit_mrp, " each"))), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-semibold" + }, it.sell_unit === 'Tablet' ? /*#__PURE__*/React.createElement("span", null, "₹", info.perUnitMrp, " ", /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "/tab")) : it.sell_unit === 'Combo' ? /*#__PURE__*/React.createElement("span", null, "₹", it.unit_mrp, " ", /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "/str")) : /*#__PURE__*/React.createElement("span", null, "₹", it.unit_mrp, " ", upp > 1 ? /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "/strip") : '')), upp > 1 && /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block", + style: { + fontSize: '0.68rem' + } + }, it.sell_unit === 'Tablet' ? `Strip: ₹${it.unit_mrp}` : `Tab: ₹${info.perUnitMrp}`)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm", + style: { + width: 115 + } + }, /*#__PURE__*/React.createElement("input", { + type: "number", + id: `cart-disc-${idx}`, + className: "form-control form-control-sm text-center px-1 fw-semibold", + min: "0", + max: it.discount_type === 'pct' ? 100 : lineGross, + step: it.discount_type === 'pct' ? '0.5' : '1', + value: it.discount_val ?? '', + placeholder: "0", + onChange: e => updateCartItem(idx, 'discount_val', e.target.value), + onKeyDown: e => { + if (e.key === 'Enter') { + e.preventDefault(); + focusMedicineSearch(); + } + } + }), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn btn-sm ${it.discount_type === 'pct' ? 'btn-primary' : 'btn-warning text-dark'} px-2 py-0 fw-bold`, + title: `Click to switch between % and ₹ (Currently: ${it.discount_type === 'pct' ? 'Percentage' : 'Value in Rupees'})`, + onClick: () => toggleItemDiscType(idx) + }, it.discount_type === 'pct' ? '%' : '₹')), lineDisc > 0 && /*#__PURE__*/React.createElement("div", { + className: "text-muted text-center mt-0.5", + style: { + fontSize: '0.68rem' + } + }, it.discount_type === 'pct' ? `-₹${lineDisc.toFixed(2)}` : `${lineGross > 0 ? (lineDisc / lineGross * 100).toFixed(1) : 0}% off`)), /*#__PURE__*/React.createElement("td", null, it.gst_rate, "%"), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold text-dark" + }, "₹", lineNet), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-danger py-0 px-1", + onClick: () => removeCartItem(idx) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-trash" + })))); + }).concat(returnCart.map((rc, rIdx) => /*#__PURE__*/React.createElement("tr", { + key: `ret-${rIdx}`, + style: { + backgroundColor: 'rgba(244, 63, 94, 0.05)' + } + }, /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger text-white" + }, "RET")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-danger" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-return-left me-1" + }), rc.item_name), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "Bill: ", /*#__PURE__*/React.createElement("code", null, rc.ref_invoice_no), " • ", rc.reason ? rc.reason.replace(/_/g, ' ') : 'Return')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border" + }, rc.batch_no), /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '0.7rem' + } + }, "Exp: ", rc.expiry_date ? rc.expiry_date.substring(0, 7) : '')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger-subtle text-danger border border-danger fw-bold" + }, "- ", rc.return_qty, " ", rc.return_unit), /*#__PURE__*/React.createElement("div", { + className: "text-muted mt-0.5", + style: { + fontSize: '0.64rem' + } + }, "(", rc.return_total_units, " Tabs • ", rc.condition === 'GOOD' ? 'Restocking' : 'Discard', ")")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-semibold text-danger" + }, "₹", rc.unit_price, " ", /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "/tab")), rc.units_per_pack > 1 && /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block", + style: { + fontSize: '0.68rem' + } + }, "MRP: ₹", rc.unit_mrp)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-secondary", + style: { + fontSize: '0.7rem' + } + }, rc.condition === 'GOOD' ? 'Restock' : 'Scrap')), /*#__PURE__*/React.createElement("td", null, rc.gst_rate || 12, "%"), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold text-danger" + }, "-₹", Number(rc.line_total).toFixed(2)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-danger py-0 px-1", + onClick: () => setReturnCart(returnCart.filter((_, i) => i !== rIdx)), + title: "Remove from returns" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-trash" + }))))))))), /*#__PURE__*/React.createElement("div", { + className: "p-3 bg-light border-top d-flex flex-wrap justify-content-between align-items-center gap-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap align-items-center gap-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-secondary border px-2.5 py-1.5 fw-semibold", + style: { + fontSize: '0.8rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cart-check me-1" + }), " ", cart.length + returnCart.length, " Line Items"), /*#__PURE__*/React.createElement("span", { + className: "text-muted small" + }, "Gross: ", /*#__PURE__*/React.createElement("strong", { + className: "text-dark" + }, "₹", grossTotal.toFixed(2))), itemDiscountTotal > 0 && /*#__PURE__*/React.createElement("span", { + className: "text-muted small" + }, "Item Disc: ", /*#__PURE__*/React.createElement("strong", { + className: "text-danger" + }, "-₹", itemDiscountTotal.toFixed(2))), wholeDiscountAmt > 0 && /*#__PURE__*/React.createElement("span", { + className: "text-muted small" + }, "Bill Disc: ", /*#__PURE__*/React.createElement("strong", { + className: "text-danger" + }, "-₹", wholeDiscountAmt.toFixed(2))), returnTotal > 0 && /*#__PURE__*/React.createElement("span", { + className: "text-muted small" + }, "Return Credit: ", /*#__PURE__*/React.createElement("strong", { + className: "text-danger" + }, "-₹", returnTotal.toFixed(2))))), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-3" + }, /*#__PURE__*/React.createElement("div", { + className: "text-end" + }, /*#__PURE__*/React.createElement("div", { + className: "text-muted small text-uppercase fw-semibold", + style: { + fontSize: '0.68rem', + letterSpacing: '0.5px' + } + }, refundPayable > 0 ? 'Customer Refund' : 'Net Amount'), /*#__PURE__*/React.createElement("div", { + className: `fs-4 fw-bolder ${refundPayable > 0 ? 'text-danger' : 'text-success'}`, + style: { + lineHeight: 1.1 + } + }, "₹", refundPayable > 0 ? refundPayable.toFixed(2) : netPayable.toFixed(2))), /*#__PURE__*/React.createElement("button", { + type: "button", + id: "btn-pos-checkout-trigger", + className: "btn btn-success btn-lg px-4 py-2.5 fw-bold shadow d-flex align-items-center gap-2", + disabled: cart.length === 0 && returnCart.length === 0, + onClick: () => setIsCheckoutOpen(true), + style: { + background: 'linear-gradient(135deg, #10b981 0%, #059669 100%)', + border: 'none', + borderRadius: '10px', + fontSize: '1rem', + letterSpacing: '0.3px', + transition: 'transform 0.15s ease, box-shadow 0.15s ease' + }, + title: "Open Checkout Desk to review totals, select payment method and complete sale (F8 / F9)" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-wallet2 fs-5" + }), /*#__PURE__*/React.createElement("span", null, "Checkout"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-white text-success ms-1 px-2 py-0.5", + style: { + fontSize: '0.72rem', + fontWeight: 800 + } + }, "F8 / F9"), /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-right fs-5" + })))))), selectedPatient && showHistoryPanel && /*#__PURE__*/React.createElement("div", { + className: "col-12 col-lg-4 col-xl-4" + }, /*#__PURE__*/React.createElement("div", { + className: "patient-history-sidebar position-sticky shadow-sm", + style: { + top: '15px', + maxHeight: 'calc(100vh - 100px)', + display: 'flex', + flexDirection: 'column' + } + }, /*#__PURE__*/React.createElement("div", { + className: "patient-history-header" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-1.5" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clock-history text-info fs-5" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "mb-0 fw-bold text-white", + style: { + fontSize: '0.9rem' + } + }, "Patient Pharmacy History"), /*#__PURE__*/React.createElement("small", { + className: "text-secondary", + style: { + fontSize: '0.72rem' + } + }, "UHID: ", /*#__PURE__*/React.createElement("span", { + className: "text-warning fw-bold" + }, selectedPatient.uhid)))), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-1" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-light py-0.5 px-2", + onClick: () => fetchPatientHistory(selectedPatient.patient_id, selectedPatient.uhid, selectedPatient.mobile), + disabled: isLoadingHistory, + title: "Refresh Patient History", + style: { + fontSize: '0.7rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: `bi bi-arrow-clockwise ${isLoadingHistory ? 'spin' : ''}` + })), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-light py-0.5 px-2", + onClick: () => setShowHistoryPanel(false), + title: "Hide sidebar (Click 'Old Records' in patient bar to re-open)", + style: { + fontSize: '0.7rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-chevron-bar-right" + })))), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap align-items-center justify-content-between gap-1 pt-1.5 border-top border-secondary", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("span", { + className: "text-light" + }, /*#__PURE__*/React.createElement("strong", null, selectedPatient.full_name), " • ", selectedPatient.gender, ", ", selectedPatient.age), patientHistory && /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary border border-primary px-1.5 py-0.5" + }, patientHistory.total_sales || 0, " Bills • ₹", patientHistory.total_spend || 0))), /*#__PURE__*/React.createElement("div", { + className: "patient-history-tabs" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: `patient-history-tab-btn ${historyActiveTab === 'last_given' ? 'active' : ''}`, + onClick: () => setHistoryActiveTab('last_given') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-capsule text-success" + }), /*#__PURE__*/React.createElement("span", null, "Last Given"), patientHistory?.last_dispensed_items?.length > 0 && /*#__PURE__*/React.createElement("span", { + className: "badge bg-success text-white rounded-pill px-1", + style: { + fontSize: '0.62rem' + } + }, patientHistory.last_dispensed_items.length)), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `patient-history-tab-btn ${historyActiveTab === 'all_bills' ? 'active' : ''}`, + onClick: () => setHistoryActiveTab('all_bills') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-receipt text-primary" + }), /*#__PURE__*/React.createElement("span", null, "Past Bills"), patientHistory?.invoices?.length > 0 && /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary text-white rounded-pill px-1", + style: { + fontSize: '0.62rem' + } + }, patientHistory.invoices.length)), patientHistory?.doctor_prescriptions?.length > 0 && /*#__PURE__*/React.createElement("button", { + type: "button", + className: `patient-history-tab-btn ${historyActiveTab === 'prescriptions' ? 'active' : ''}`, + onClick: () => setHistoryActiveTab('prescriptions') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-stethoscope text-danger" + }), /*#__PURE__*/React.createElement("span", null, "Doctor Rx"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger text-white rounded-pill px-1", + style: { + fontSize: '0.62rem' + } + }, patientHistory.doctor_prescriptions.length)), patientHistory?.unique_medicines?.length > 0 && /*#__PURE__*/React.createElement("button", { + type: "button", + className: `patient-history-tab-btn ${historyActiveTab === 'summary' ? 'active' : ''}`, + onClick: () => setHistoryActiveTab('summary') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-journal-medical text-warning" + }), /*#__PURE__*/React.createElement("span", null, "All Meds"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary text-white rounded-pill px-1", + style: { + fontSize: '0.62rem' + } + }, patientHistory.unique_medicines.length))), /*#__PURE__*/React.createElement("div", { + className: "patient-history-body" + }, isLoadingHistory ? /*#__PURE__*/React.createElement("div", { + className: "text-center py-5 text-muted" + }, /*#__PURE__*/React.createElement("div", { + className: "spinner-border spinner-border-sm text-primary me-2" + }), "Loading patient records...") : !patientHistory || patientHistory.total_sales === 0 && (!patientHistory.doctor_prescriptions || patientHistory.doctor_prescriptions.length === 0) ? /*#__PURE__*/React.createElement("div", { + className: "text-center py-4 px-2 text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-folder-x fs-1 text-secondary opacity-50 d-block mb-2" + }), /*#__PURE__*/React.createElement("h6", { + className: "fw-semibold text-dark" + }, "No Previous Pharmacy Records"), /*#__PURE__*/React.createElement("small", null, "This patient has no recorded medicine dispenses or bills in the pharmacy database yet.")) : /*#__PURE__*/React.createElement(React.Fragment, null, historyActiveTab === 'last_given' && /*#__PURE__*/React.createElement("div", null, patientHistory.last_sale ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", { + className: "p-2.5 mb-2 rounded-3 border", + style: { + background: '#f0fdf4', + borderColor: '#bbf7d0' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-1" + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-success", + style: { + fontSize: '0.78rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle-fill me-1" + }), " Last Dispensed Visit"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-dark text-white", + style: { + fontSize: '0.68rem' + } + }, patientHistory.last_sale.invoice_no)), /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-calendar-event me-1" + }), " ", patientHistory.last_sale.sale_date ? patientHistory.last_sale.sale_date.substring(0, 16) : 'N/A'), patientHistory.last_sale.doctor_name && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-badge me-1" + }), " Prescribed by: ", /*#__PURE__*/React.createElement("strong", null, patientHistory.last_sale.doctor_name)), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mt-1.5 pt-1 border-top border-success-subtle" + }, /*#__PURE__*/React.createElement("span", null, "Paid: ", /*#__PURE__*/React.createElement("strong", null, "₹", patientHistory.last_sale.net_amount), " (", patientHistory.last_sale.payment_mode, ")"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-success py-0 px-2 fw-bold", + onClick: () => viewPastBill(patientHistory.last_sale.sale_id), + style: { + fontSize: '0.68rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer me-1" + }), " View Bill")))), /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark mb-1.5 d-flex justify-content-between align-items-center", + style: { + fontSize: '0.75rem' + } + }, /*#__PURE__*/React.createElement("span", null, "Medicines Given (", patientHistory.last_dispensed_items.length, "):"), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "Click ", /*#__PURE__*/React.createElement("strong", null, "+"), " to re-dispense")), patientHistory.last_dispensed_items.map((it, mIdx) => /*#__PURE__*/React.createElement("div", { + key: `last-med-${mIdx}`, + className: "history-med-card last-given" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-start mb-1" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark", + style: { + fontSize: '0.82rem' + } + }, it.item_name), /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block", + style: { + fontSize: '0.68rem' + } + }, it.generic_name)), /*#__PURE__*/React.createElement("div", { + className: "text-end" + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-dark", + style: { + fontSize: '0.82rem' + } + }, "₹", it.total_amount), /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block", + style: { + fontSize: '0.68rem' + } + }, "₹", it.unit_mrp, "/", it.sell_unit))), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap align-items-center gap-1 mb-2", + style: { + fontSize: '0.68rem' + } + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border" + }, "Batch: ", it.batch_no), /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-secondary border" + }, "Exp: ", it.expiry_date), /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary text-white" + }, "Qty: ", it.qty, " ", it.sell_unit), it.remaining_units > 0 ? /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success border border-success" + }, "Returnable: ", it.remaining_strips > 0 ? `${it.remaining_strips} Str ` : '', it.remaining_loose > 0 ? `${it.remaining_loose} Tab` : '') : /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-muted border" + }, "Fully Returned")), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1.5 pt-1.5 border-top" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-success py-1 px-2 fw-semibold d-inline-flex align-items-center gap-1 shadow-xs flex-fill justify-content-center", + onClick: () => reDispenseMedicine(it, it.qty), + style: { + fontSize: '0.72rem', + background: '#059669', + borderColor: '#047857' + }, + title: "Add this medicine to active dispensing cart with current FEFO batch" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-plus-circle-fill" + }), /*#__PURE__*/React.createElement("span", null, "Dispense Again")), it.remaining_units > 0 && /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-danger py-1 px-2 fw-semibold d-inline-flex align-items-center gap-1 shadow-xs", + onClick: () => initiateReturnFromHistory(patientHistory.last_sale, it), + style: { + fontSize: '0.72rem' + }, + title: "Return or exchange this dispensed item into current bill" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-return-left" + }), /*#__PURE__*/React.createElement("span", null, "Return")))))) : /*#__PURE__*/React.createElement("div", { + className: "text-center py-4 text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-basket text-secondary fs-3 d-block mb-1" + }), "No pharmacy sales recorded yet for this patient.")), historyActiveTab === 'all_bills' && /*#__PURE__*/React.createElement("div", null, patientHistory.invoices?.map((inv, invIdx) => { + const s = inv.sale; + const isExp = expandedBillId === s.sale_id; + return /*#__PURE__*/React.createElement("div", { + key: `inv-${s.sale_id}`, + className: "card mb-2 border shadow-xs", + style: { + borderRadius: '8px' + } + }, /*#__PURE__*/React.createElement("div", { + className: "card-header py-2 px-2.5 bg-white d-flex justify-content-between align-items-center", + style: { + cursor: 'pointer', + borderBottom: isExp ? '1px solid #e2e8f0' : 'none' + }, + onClick: () => setExpandedBillId(isExp ? null : s.sale_id) + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark d-flex align-items-center gap-1.5", + style: { + fontSize: '0.78rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: `bi bi-chevron-${isExp ? 'down' : 'right'} text-primary`, + style: { + fontSize: '0.7rem' + } + }), /*#__PURE__*/React.createElement("span", null, s.invoice_no), /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-secondary border", + style: { + fontSize: '0.65rem' + } + }, inv.items.length, " items")), /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '0.68rem' + } + }, s.sale_date ? s.sale_date.substring(0, 10) : '', " • Dr. ", s.doctor_name || 'Consultant')), /*#__PURE__*/React.createElement("div", { + className: "text-end" + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-success d-block", + style: { + fontSize: '0.82rem' + } + }, "₹", s.net_amount), /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-secondary", + style: { + fontSize: '0.62rem' + } + }, s.payment_mode))), isExp && /*#__PURE__*/React.createElement("div", { + className: "card-body p-2 bg-light" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-1.5" + }, /*#__PURE__*/React.createElement("span", { + className: "text-muted fw-semibold", + style: { + fontSize: '0.7rem' + } + }, "Items Dispensed:"), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-dark py-0 px-1.5", + onClick: e => { + e.stopPropagation(); + viewPastBill(s.sale_id); + }, + style: { + fontSize: '0.65rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer me-1" + }), " Reprint"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-danger py-0 px-1.5", + onClick: e => { + e.stopPropagation(); + selectReturnInvoice(inv); + openReturnModal(); + }, + style: { + fontSize: '0.65rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-return-left me-1" + }), " Return All"))), inv.items.map((it, itIdx) => /*#__PURE__*/React.createElement("div", { + key: `inv-item-${itIdx}`, + className: "p-1.5 mb-1 bg-white rounded border d-flex justify-content-between align-items-center", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark" + }, it.item_name), /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '0.65rem' + } + }, "Batch: ", it.batch_no, " • ", it.qty, " ", it.sell_unit, " @ ₹", it.unit_mrp)), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-1" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-success py-0 px-1", + onClick: () => reDispenseMedicine(it, it.qty), + title: "Dispense again", + style: { + fontSize: '0.68rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-plus" + })), it.remaining_units > 0 && /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-danger py-0 px-1", + onClick: () => initiateReturnFromHistory(s, it), + title: "Return this item", + style: { + fontSize: '0.68rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-return-left" + }))))))); + })), historyActiveTab === 'prescriptions' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "text-muted mb-2 fw-semibold", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-stethoscope text-primary me-1" + }), " Doctor Prescriptions from OPD Visits:"), patientHistory.doctor_prescriptions?.map((dp, dpIdx) => /*#__PURE__*/React.createElement("div", { + key: `doc-rx-${dpIdx}`, + className: "history-med-card mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-start mb-1" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark", + style: { + fontSize: '0.82rem' + } + }, dp.med_name), /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-secondary border", + style: { + fontSize: '0.65rem' + } + }, dp.med_type || 'Medicine')), /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '0.68rem' + } + }, dp.date_opd_visit)), /*#__PURE__*/React.createElement("div", { + className: "text-muted mb-1.5", + style: { + fontSize: '0.7rem' + } + }, dp.doc_name && /*#__PURE__*/React.createElement("div", null, "Doc: ", /*#__PURE__*/React.createElement("strong", null, "Dr. ", dp.doc_name)), /*#__PURE__*/React.createElement("div", null, "Dose: ", dp.dosage_freq_str || dp.dosage || '1 Tab', " • Duration: ", dp.no_of_days || '5 Days'), dp.remark && /*#__PURE__*/React.createElement("div", null, "Note: ", dp.remark)), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-primary w-100 py-1 fw-semibold d-flex align-items-center justify-content-center gap-1 shadow-xs", + onClick: () => reDispenseMedicine({ + item_name: dp.med_name, + qty: 10 + }), + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-plus-circle" + }), " Dispense Prescribed Medicine")))), historyActiveTab === 'summary' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "text-muted mb-2 fw-semibold", + style: { + fontSize: '0.72rem' + } + }, "Distinct Medicines Dispensed to Patient:"), patientHistory.unique_medicines?.map((um, uIdx) => /*#__PURE__*/React.createElement("div", { + key: `uniq-med-${uIdx}`, + className: "history-med-card mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-start mb-1" + }, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark", + style: { + fontSize: '0.8rem' + } + }, um.item_name), /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary border", + style: { + fontSize: '0.65rem' + } + }, um.times_dispensed, "x dispensed")), /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block mb-1.5", + style: { + fontSize: '0.68rem' + } + }, "Last on ", um.last_dispensed ? um.last_dispensed.substring(0, 10) : '', " (Batch: ", um.last_batch_no, ")"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-success w-100 py-0.5 fw-semibold d-flex align-items-center justify-content-center gap-1", + onClick: () => reDispenseMedicine(um, um.last_qty || 1), + style: { + fontSize: '0.7rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-plus-circle" + }), " Dispense Again"))))))))), /*#__PURE__*/React.createElement("div", { + className: `checkout-drawer-overlay ${isCheckoutOpen ? 'open' : ''}`, + onClick: () => setIsCheckoutOpen(false) + }), /*#__PURE__*/React.createElement("div", { + className: `checkout-drawer ${isCheckoutOpen ? 'open' : ''}`, + id: "pos-checkout-drawer" + }, /*#__PURE__*/React.createElement("div", { + className: "checkout-drawer-header" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cash-coin text-warning fs-5" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "mb-0 fw-bold text-white" + }, "Checkout Desk"), /*#__PURE__*/React.createElement("small", { + className: "text-secondary", + style: { + fontSize: '0.72rem' + } + }, "Counter: ", /*#__PURE__*/React.createElement("span", { + className: "text-info fw-bold" + }, store?.store_code || ''), " • ", store?.store_name))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-light rounded-pill px-3 py-1 d-flex align-items-center gap-1.5", + onClick: () => setIsCheckoutOpen(false), + title: "Close Checkout Drawer (Esc)" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x-lg" + }), /*#__PURE__*/React.createElement("span", null, "Close"), /*#__PURE__*/React.createElement("kbd", { + className: "ms-1", + style: { + background: '#334155', + color: '#f8fafc', + fontSize: '0.65rem', + padding: '1px 4px', + borderRadius: '3px' + } + }, "Esc"))), /*#__PURE__*/React.createElement("div", { + className: "checkout-drawer-body" + }, /*#__PURE__*/React.createElement("h5", { + className: "fw-bold text-white mb-3 d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("span", null, "Checkout Desk"), /*#__PURE__*/React.createElement("span", { + className: "fs-6 text-primary" + }, store?.store_code || '')), /*#__PURE__*/React.createElement("div", { + className: "p-2.5 rounded-3 mb-3", + style: { + background: 'rgba(255, 255, 255, 0.08)', + border: '1px solid rgba(255, 255, 255, 0.15)' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-1.5" + }, /*#__PURE__*/React.createElement("label", { + className: "text-white small fw-bold mb-0 d-flex align-items-center gap-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-tag-fill text-warning" + }), " Whole Bill Discount"), /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn btn-xs py-0.5 px-2 ${wholeDiscountType === 'pct' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light text-white'}`, + style: { + fontSize: '0.72rem' + }, + onClick: () => setWholeDiscountType('pct') + }, "% Percent"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn btn-xs py-0.5 px-2 ${wholeDiscountType === 'val' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light text-white'}`, + style: { + fontSize: '0.72rem' + }, + onClick: () => setWholeDiscountType('val') + }, "₹ Fixed Value"))), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm mb-2" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-dark border-secondary text-warning fw-bold" + }, wholeDiscountType === 'pct' ? '%' : '₹'), /*#__PURE__*/React.createElement("input", { + type: "number", + id: "whole-discount-input", + ref: wholeDiscountRef, + className: "form-control form-control-sm bg-dark text-white border-secondary fw-bold", + min: "0", + max: wholeDiscountType === 'pct' ? 100 : balanceAfterItemDisc, + step: wholeDiscountType === 'pct' ? '0.5' : '1', + placeholder: wholeDiscountType === 'pct' ? 'Enter % (F7)' : 'Enter ₹ (F7)', + value: wholeDiscountVal || '', + onChange: e => setWholeDiscountVal(e.target.value), + onKeyDown: e => { + if (e.key === 'Enter') { + e.preventDefault(); + if (!isProcessing && cart.length > 0) { + processSale(); + } + } + } + }), Number(wholeDiscountVal) > 0 && /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-danger", + title: "Reset Whole Bill Discount", + onClick: () => setWholeDiscountVal(0) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x-lg" + }))), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap gap-1 align-items-center" + }, /*#__PURE__*/React.createElement("small", { + className: "text-slate-400 me-1", + style: { + fontSize: '0.7rem', + color: '#94a3b8' + } + }, "Presets:"), wholeDiscountType === 'pct' ? [5, 10, 15, 20].map(p => /*#__PURE__*/React.createElement("button", { + key: p, + type: "button", + className: `badge border ${Number(wholeDiscountVal) === p ? 'bg-warning text-dark border-warning' : 'bg-transparent text-white border-secondary'}`, + style: { + cursor: 'pointer', + padding: '4px 8px', + fontSize: '0.7rem' + }, + onClick: () => setWholeDiscountVal(p) + }, p, "%")) : [20, 50, 100, 200].map(v => /*#__PURE__*/React.createElement("button", { + key: v, + type: "button", + className: `badge border ${Number(wholeDiscountVal) === v ? 'bg-warning text-dark border-warning' : 'bg-transparent text-white border-secondary'}`, + style: { + cursor: 'pointer', + padding: '4px 8px', + fontSize: '0.7rem' + }, + onClick: () => setWholeDiscountVal(v) + }, "₹", v)), Number(wholeDiscountVal) > 0 && /*#__PURE__*/React.createElement("button", { + type: "button", + className: "badge bg-danger-subtle text-danger border border-danger ms-auto", + style: { + cursor: 'pointer', + padding: '4px 6px', + fontSize: '0.7rem' + }, + onClick: () => setWholeDiscountVal(0) + }, "Clear"))), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-1.5 text-slate-300", + style: { + color: '#cbd5e1' + } + }, /*#__PURE__*/React.createElement("span", null, "Gross Items Total:"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold" + }, "₹", grossTotal.toFixed(2))), itemDiscountTotal > 0 && /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-1 text-slate-300", + style: { + fontSize: '0.84rem', + color: '#94a3b8' + } + }, /*#__PURE__*/React.createElement("span", null, "Item-Level Discounts:"), /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "-₹", itemDiscountTotal.toFixed(2))), wholeDiscountAmt > 0 && /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-1 text-slate-300", + style: { + fontSize: '0.84rem', + color: '#94a3b8' + } + }, /*#__PURE__*/React.createElement("span", null, "Whole Bill Discount (", wholeDiscountType === 'pct' ? `${wholeDiscountVal}%` : `₹${wholeDiscountVal}`, "):"), /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "-₹", wholeDiscountAmt.toFixed(2))), discountTotal > 0 && /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-2 text-slate-300", + style: { + color: '#cbd5e1' + } + }, /*#__PURE__*/React.createElement("span", null, "Total Discounts:"), /*#__PURE__*/React.createElement("span", { + className: "text-danger fw-bold" + }, "-₹", discountTotal.toFixed(2))), returnTotal > 0 && /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-2 text-danger fw-bold py-1 px-2 rounded", + style: { + background: 'rgba(244, 63, 94, 0.15)', + border: '1px solid rgba(244, 63, 94, 0.3)' + } + }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-return-left me-1" + }), " Less Return Credit:"), /*#__PURE__*/React.createElement("span", null, "-₹", returnTotal.toFixed(2))), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-2 text-slate-300", + style: { + color: '#cbd5e1' + } + }, /*#__PURE__*/React.createElement("span", null, "Round Off:"), /*#__PURE__*/React.createElement("span", null, "₹", roundOff)), /*#__PURE__*/React.createElement("hr", { + style: { + borderColor: 'rgba(255,255,255,0.15)' + } + }), refundPayable > 0 ? /*#__PURE__*/React.createElement("div", { + className: "p-3 rounded-3 mb-3 border border-warning", + style: { + background: 'rgba(245, 158, 11, 0.15)' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("span", { + className: "fs-6 fw-bold text-white" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-wallet2 text-warning me-1" + }), " REFUND TO PATIENT:"), /*#__PURE__*/React.createElement("span", { + className: "fs-3 fw-bolder text-warning" + }, "₹", refundPayable.toLocaleString('en-IN'))), /*#__PURE__*/React.createElement("small", { + className: "text-white-50 d-block mt-1", + style: { + fontSize: '0.72rem' + } + }, "Return credit exceeds new items. Refund this net difference from counter cash drawer or UPI."), /*#__PURE__*/React.createElement("div", { + className: "mt-2.5" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-white small fw-bold mb-1" + }, "Refund Outflow Method"), /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm w-100 mb-2" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn ${refundMode === 'Cash' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light'}`, + onClick: () => setRefundMode('Cash') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cash-stack me-1" + }), " Cash Refund"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn ${refundMode === 'UPI' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light'}`, + onClick: () => setRefundMode('UPI') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-qr-code me-1" + }), " UPI / Bank Refund")), refundMode === 'UPI' && /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-dark text-white border-warning", + placeholder: "Patient UPI VPA or Bank Reference #", + value: refundRefNo, + onChange: e => setRefundRefNo(e.target.value) + }))) : /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-4" + }, /*#__PURE__*/React.createElement("span", { + className: "fs-5 fw-bold text-white" + }, "Net Payable:"), /*#__PURE__*/React.createElement("span", { + className: "fs-3 fw-bolder text-warning" + }, "₹", netPayable.toLocaleString('en-IN'))), refundPayable <= 0 && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-white fw-bold mb-0" + }, "Payment Method"), paymentMode === 'Mixed' && /*#__PURE__*/React.createElement("span", { + className: "badge bg-warning text-dark" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-pie-chart me-1" + }), " Partial / Split Mode")), /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm w-100 ${paymentMode === 'Cash' ? 'btn-primary-custom' : 'btn-outline-light'}`, + onClick: () => setPaymentMode('Cash') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cash-stack me-1" + }), " Cash")), /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm w-100 ${paymentMode === 'UPI' ? 'btn-primary-custom' : 'btn-outline-light'}`, + onClick: () => setPaymentMode('UPI') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-qr-code-scan me-1" + }), " UPI / QR")), /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm w-100 ${paymentMode === 'Mixed' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light'}`, + onClick: () => { + setPaymentMode('Mixed'); + if (!splitCash && !splitUpi) { + setSplitCash(''); + setSplitUpi(''); + } + }, + title: "Partial payment by Cash and UPI/Bank" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-pie-chart-fill me-1" + }), " Split / Mixed")), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm w-100 ${paymentMode === 'Card' ? 'btn-primary-custom' : 'btn-outline-light'}`, + onClick: () => setPaymentMode('Card') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-credit-card me-1" + }), " Card Swipe")), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm w-100 ${paymentMode === 'IPD_Credit' ? 'btn-danger' : 'btn-outline-light'}`, + onClick: () => setPaymentMode('IPD_Credit'), + title: "Charge to IPD Patient Bill" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hospital me-1" + }), " IPD Bill Post")), /*#__PURE__*/React.createElement("div", { + className: "col-12 mt-1" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn btn-sm w-100 ${paymentMode === 'Staff_Credit' ? 'btn-info text-dark fw-bold' : 'btn-outline-info'}`, + onClick: () => setPaymentMode('Staff_Credit'), + title: "Charge to Staff / Doctor / Customer Credit Ledger" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-lines-fill me-1" + }), " Staff / Doctor / Customer Credit A/c"))), paymentMode === 'Staff_Credit' && /*#__PURE__*/React.createElement("div", { + className: "card bg-dark border-info mb-3 p-2.5 rounded-3 text-white", + style: { + fontSize: '0.82rem' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-2 pb-1 border-bottom border-secondary" + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-info" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-lines-fill me-1" + }), " Staff / Customer Credit Account"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-info text-dark" + }, "Ledger Debit")), /*#__PURE__*/React.createElement("div", { + className: "mb-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-white-50 small mb-1" + }, "Select Credit Account ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: selectedCreditAccount ? selectedCreditAccount.account_id : '', + onChange: e => { + const acc = creditAccounts.find(a => String(a.account_id) === e.target.value); + setSelectedCreditAccount(acc || null); + } + }, /*#__PURE__*/React.createElement("option", { + value: "" + }, "-- Choose Account --"), creditAccounts.filter(a => a.is_active == 1).map(a => /*#__PURE__*/React.createElement("option", { + key: a.account_id, + value: a.account_id + }, a.account_name, " (", a.account_type.toUpperCase(), ") - Dues: ₹", Number(a.current_balance || 0).toFixed(2))))), selectedCreditAccount && /*#__PURE__*/React.createElement("div", { + className: "p-2 bg-secondary bg-opacity-25 rounded border border-secondary mb-1" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between" + }, /*#__PURE__*/React.createElement("span", { + className: "text-white-50" + }, "Dept / ID:"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold" + }, selectedCreditAccount.department || selectedCreditAccount.staff_id || 'N/A')), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between" + }, /*#__PURE__*/React.createElement("span", { + className: "text-white-50" + }, "Current Outstanding:"), /*#__PURE__*/React.createElement("span", { + className: `fw-bold ${Number(selectedCreditAccount.current_balance) > 0 ? 'text-warning' : 'text-success'}` + }, "₹", Number(selectedCreditAccount.current_balance || 0).toFixed(2))), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between" + }, /*#__PURE__*/React.createElement("span", { + className: "text-white-50" + }, "Credit Limit:"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold" + }, "₹", Number(selectedCreditAccount.credit_limit || 0).toFixed(2))), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between border-top border-secondary pt-1 mt-1" + }, /*#__PURE__*/React.createElement("span", { + className: "text-white-50" + }, "Balance after this bill:"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-info" + }, "₹", (Number(selectedCreditAccount.current_balance || 0) + netPayable).toFixed(2))))), paymentMode === 'IPD_Credit' && /*#__PURE__*/React.createElement("div", { + className: "alert alert-warning py-2 mb-3", + style: { + fontSize: '0.78rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-info-circle me-1" + }), "Medicines will be charged directly to the patient's IPD Hospital Account and settled at discharge."), paymentMode === 'Mixed' && /*#__PURE__*/React.createElement("div", { + className: "card bg-dark border-warning mb-3 p-2.5 rounded-3 text-white", + style: { + fontSize: '0.82rem' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-2 pb-1 border-bottom border-secondary" + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-warning" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-receipt-cutoff me-1" + }), " Split Payment Allocation"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold" + }, "Total: ₹", netPayable)), /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-white-50 mb-1", + style: { + fontSize: '0.75rem' + } + }, "Cash Amount (₹)"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-secondary border-0 text-white" + }, "₹"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm bg-dark text-white border-secondary", + placeholder: "e.g. 35", + value: splitCash, + onChange: e => setSplitCash(e.target.value), + step: "any" + }))), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-white-50 mb-1", + style: { + fontSize: '0.75rem' + } + }, "UPI / Bank (₹)"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-secondary border-0 text-white" + }, "₹"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm bg-dark text-white border-secondary", + placeholder: "e.g. 100", + value: splitUpi, + onChange: e => setSplitUpi(e.target.value), + step: "any" + })))), Number(splitUpi) > 0 && /*#__PURE__*/React.createElement("div", { + className: "p-2 rounded bg-black bg-opacity-25 border border-secondary mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "row g-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-7" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-warning mb-0", + style: { + fontSize: '0.72rem' + } + }, "UPI UTR / Trans. Ref # ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-dark text-white border-warning", + placeholder: "e.g. 425109876543 (12-digit)", + value: upiRefNo, + onChange: e => setUpiRefNo(e.target.value) + }), /*#__PURE__*/React.createElement("span", { + style: { + fontSize: '0.65rem' + }, + className: "text-white-50" + }, "Used by Accountant for statement audit")), /*#__PURE__*/React.createElement("div", { + className: "col-5" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-white-50 mb-0", + style: { + fontSize: '0.72rem' + } + }, "Bank / QR"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-dark text-white border-secondary", + placeholder: "e.g. SBI, HDFC", + list: "commonBankList", + value: bankName, + onChange: e => setBankName(e.target.value) + }), /*#__PURE__*/React.createElement("datalist", { + id: "commonBankList" + }, /*#__PURE__*/React.createElement("option", { + value: "SBI" + }), /*#__PURE__*/React.createElement("option", { + value: "HDFC Bank" + }), /*#__PURE__*/React.createElement("option", { + value: "ICICI Bank" + }), /*#__PURE__*/React.createElement("option", { + value: "Axis Bank" + }), /*#__PURE__*/React.createElement("option", { + value: "Punjab National Bank" + }), /*#__PURE__*/React.createElement("option", { + value: "Bank of Baroda" + }), /*#__PURE__*/React.createElement("option", { + value: "Google Pay / PhonePe" + }), /*#__PURE__*/React.createElement("option", { + value: "Paytm" + }))))), /*#__PURE__*/React.createElement("div", { + className: "mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("span", { + style: { + fontSize: '0.75rem' + }, + className: "text-white-50" + }, "Card Swiped (if any):"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm", + style: { + width: 140 + } + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-secondary border-0 text-white", + style: { + fontSize: '0.7rem' + } + }, "₹"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm bg-dark text-white border-secondary", + placeholder: "0", + value: splitCard, + onChange: e => setSplitCard(e.target.value), + step: "any" + }))), Number(splitCard) > 0 && /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-dark text-white border-secondary mt-1", + placeholder: "Card Slip Auth / Ref No", + value: cardRefNo, + onChange: e => setCardRefNo(e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "p-2 rounded bg-black bg-opacity-40 border border-secondary" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-1", + style: { + fontSize: '0.75rem' + } + }, /*#__PURE__*/React.createElement("span", null, "Allocated: ", /*#__PURE__*/React.createElement("strong", null, "₹", totalSplitAllocated.toFixed(2))), /*#__PURE__*/React.createElement("span", null, "Bill Net: ", /*#__PURE__*/React.createElement("strong", null, "₹", netPayable))), Math.abs(splitRemaining) <= 0.01 ? /*#__PURE__*/React.createElement("div", { + className: "text-success fw-bold d-flex align-items-center gap-1", + style: { + fontSize: '0.78rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle-fill" + }), " Balanced! Ready to print bill.") : splitRemaining > 0 ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "text-warning fw-bold mb-1.5", + style: { + fontSize: '0.78rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-exclamation-circle me-1" + }), " Balance Remaining: ₹", splitRemaining.toFixed(2)), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-warning py-0", + style: { + fontSize: '0.7rem' + }, + onClick: () => setSplitUpi(String(((Number(splitUpi) || 0) + splitRemaining).toFixed(2))) + }, "+ ₹", splitRemaining.toFixed(2), " to UPI"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-info py-0", + style: { + fontSize: '0.7rem' + }, + onClick: () => setSplitCash(String(((Number(splitCash) || 0) + splitRemaining).toFixed(2))) + }, "+ ₹", splitRemaining.toFixed(2), " to Cash"))) : /*#__PURE__*/React.createElement("div", { + className: "text-danger fw-bold", + style: { + fontSize: '0.78rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x-circle-fill me-1" + }), " Overallocated by ₹", Math.abs(splitRemaining).toFixed(2)))), paymentMode === 'UPI' && /*#__PURE__*/React.createElement("div", { + className: "bg-dark p-2.5 rounded-3 mb-3 border border-secondary" + }, store?.upi_id && /*#__PURE__*/React.createElement("div", { + className: "text-center mb-2" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block", + style: { + fontSize: '0.75rem' + } + }, "Store UPI VPA: ", /*#__PURE__*/React.createElement("span", { + className: "text-warning fw-bold" + }, store?.upi_id))), /*#__PURE__*/React.createElement("div", { + className: "row g-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-7" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-white-50 mb-1", + style: { + fontSize: '0.72rem' + } + }, "UPI UTR / Ref No ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-dark text-white border-warning", + placeholder: "12-digit UTR No", + value: upiRefNo, + onChange: e => setUpiRefNo(e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "col-5" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-white-50 mb-1", + style: { + fontSize: '0.72rem' + } + }, "Bank Name"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-dark text-white border-secondary", + placeholder: "e.g. SBI, HDFC", + value: bankName, + onChange: e => setBankName(e.target.value) + }))), /*#__PURE__*/React.createElement("small", { + className: "text-white-50 d-block mt-1", + style: { + fontSize: '0.68rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-check me-1 text-success" + }), " Accountant will match this UTR against the hospital bank statement.")), paymentMode === 'Card' && /*#__PURE__*/React.createElement("div", { + className: "bg-dark p-2.5 rounded-3 mb-3 border border-secondary" + }, /*#__PURE__*/React.createElement("div", { + className: "row g-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-7" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-white-50 mb-1", + style: { + fontSize: '0.72rem' + } + }, "Card Slip / Auth Ref No"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-dark text-white border-secondary", + placeholder: "POS Machine Auth Code", + value: cardRefNo, + onChange: e => setCardRefNo(e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "col-5" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-white-50 mb-1", + style: { + fontSize: '0.72rem' + } + }, "Bank / Terminal"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-dark text-white border-secondary", + placeholder: "e.g. HDFC EDC", + value: bankName, + onChange: e => setBankName(e.target.value) + }))))), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-white small fw-bold mb-1" + }, "Invoice Print Format"), /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm w-100" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn ${printFormat === 'thermal' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light'}`, + onClick: () => setPrintFormat('thermal') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-receipt me-1" + }), " Thermal (Text)"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn ${printFormat === 'a5' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light'}`, + onClick: () => setPrintFormat('a5') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-pdf me-1" + }), " A5 Landscape (PDF)"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn ${printFormat === 'a4' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light'}`, + onClick: () => setPrintFormat('a4') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-pdf me-1" + }), " A4 (PDF)"))), /*#__PURE__*/React.createElement("button", { + className: `btn ${refundPayable > 0 ? 'btn-warning text-dark fw-bold' : 'btn-success-custom'} w-100 py-2.5 fs-6`, + onClick: processSale, + disabled: isProcessing || cart.length === 0 && returnCart.length === 0 || refundPayable === 0 && paymentMode === 'Mixed' && Math.abs(splitRemaining) > 0.01 + }, isProcessing ? /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hourglass-split me-2" + }), " Generating Bill & Credit Note...") : refundPayable === 0 && paymentMode === 'Mixed' && Math.abs(splitRemaining) > 0.01 ? /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-exclamation-triangle me-2" + }), " Allocate Balance (₹", splitRemaining > 0 ? splitRemaining.toFixed(2) + ' left' : Math.abs(splitRemaining).toFixed(2) + ' over', ")") : refundPayable > 0 ? /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-return-left me-2" + }), " Process Return & Refund ₹", refundPayable) : returnCart.length > 0 ? /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-left-right me-2" + }), " Complete Exchange Bill & Print (", printFormat === 'a5' ? 'A5 LANDSCAPE' : printFormat.toUpperCase(), ")") : /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer me-2" + }), " Complete Sale & Print (", printFormat === 'a5' ? 'A5 LANDSCAPE' : printFormat.toUpperCase(), ")")))), /*#__PURE__*/React.createElement("div", { + className: `print-drawer-overlay ${isPrintOpen ? 'open' : ''}`, + onClick: () => setIsPrintOpen(false) + }), /*#__PURE__*/React.createElement("div", { + className: `print-drawer ${isPrintOpen ? 'open' : ''}`, + id: "pos-print-drawer" + }, lastInvoice && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", { + className: "print-drawer-header" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-receipt text-warning fs-5" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "mb-0 fw-bold text-white" + }, "Invoice & Print Desk"), /*#__PURE__*/React.createElement("small", { + className: "text-secondary", + style: { + fontSize: '0.72rem' + } + }, "Bill: ", /*#__PURE__*/React.createElement("span", { + className: "text-info fw-bold" + }, lastInvoice.sale.invoice_no), lastInvoice.sale.abdm_care_context_ref && /*#__PURE__*/React.createElement("span", { + className: "ms-2 text-success" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-fill-check me-0.5" + }), " ABDM Linked")))), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-1.5 flex-wrap" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-xs btn-outline-success text-white py-1 px-2", + onClick: () => viewAbdmBundle(lastInvoice.sale.sale_id), + title: "View official ABDM FHIR R4 MedicationDispense JSON Document Bundle", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-filetype-json me-1" + }), " FHIR R4"), /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm" + }, /*#__PURE__*/React.createElement("button", { + className: `btn btn-xs py-1 px-2 ${printFormat === 'thermal' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light text-white'}`, + style: { + fontSize: '0.72rem' + }, + onClick: () => setPrintFormat('thermal') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-receipt me-1" + }), " Thermal (Text)"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-xs py-1 px-2 ${printFormat === 'a5' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light text-white'}`, + style: { + fontSize: '0.72rem' + }, + onClick: () => setPrintFormat('a5') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-pdf me-1" + }), " A5 Landscape (PDF)"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-xs py-1 px-2 ${printFormat === 'a4' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light text-white'}`, + style: { + fontSize: '0.72rem' + }, + onClick: () => setPrintFormat('a4') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-pdf me-1" + }), " A4 (PDF)")), printFormat === 'thermal' ? /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-warning text-dark fw-bold py-1 px-2.5 ms-0.5", + onClick: printThermalReceipt, + title: "Print on 80mm Thermal Receipt Printer", + style: { + fontSize: '0.75rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer-fill me-1" + }), " Print Thermal") : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-light py-1 px-2 text-white", + onClick: () => downloadPdf(printFormat), + title: `Download ${printFormat === 'a5' ? 'A5 Landscape' : printFormat.toUpperCase()} PDF Document`, + style: { + fontSize: '0.75rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-download me-1 text-info" + }), " PDF"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-primary py-1 px-2.5 ms-0.5 fw-bold", + onClick: () => printPdf(printFormat), + title: `Print Vector-Clean ${printFormat === 'a5' ? 'A5 Landscape' : printFormat.toUpperCase()} PDF`, + style: { + fontSize: '0.75rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer me-1" + }), " Print PDF (", printFormat === 'a5' ? 'A5 LANDSCAPE' : printFormat.toUpperCase(), ")")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-light rounded-pill px-2.5 py-1 ms-1 d-flex align-items-center gap-1", + onClick: () => setIsPrintOpen(false), + title: "Close Print Drawer (Esc)" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x-lg" + }), /*#__PURE__*/React.createElement("kbd", { + style: { + background: '#334155', + color: '#f8fafc', + fontSize: '0.62rem', + padding: '1px 3px', + borderRadius: '3px' + } + }, "Esc")))), /*#__PURE__*/React.createElement("div", { + className: "print-drawer-body" + }, /*#__PURE__*/React.createElement("div", { + className: "print-paper-card" + }, /*#__PURE__*/React.createElement("div", { + id: "printable-container" + }, printFormat === 'thermal' && /*#__PURE__*/React.createElement("div", { + className: "p-2 text-center" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-2 mx-auto", + style: { + maxWidth: '360px' + } + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-dark text-warning border border-secondary", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-receipt me-1" + }), " 80mm Thermal Receipt (Plain Text)"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-warning text-dark fw-bold py-0.5 px-2.5", + onClick: printThermalReceipt, + title: "Print Thermal 80mm Receipt", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer-fill me-1" + }), " Print Thermal"))), /*#__PURE__*/React.createElement("pre", { + id: "thermal-receipt-preview", + style: { + fontFamily: "'Courier New', Courier, monospace", + fontSize: '11px', + lineHeight: '1.28', + backgroundColor: '#ffffff', + color: '#000000', + padding: '16px', + border: '1px solid #cbd5e1', + borderRadius: '6px', + boxShadow: '0 4px 15px rgba(0,0,0,0.06)', + width: '360px', + maxWidth: '100%', + margin: '0 auto', + textAlign: 'left', + whiteSpace: 'pre-wrap', + wordBreak: 'break-all' + } + }, generateThermalReceiptText(lastInvoice))), printFormat === 'a5' && /*#__PURE__*/React.createElement("div", { + className: "print-a5-invoice" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center bg-primary-subtle border border-primary-subtle rounded px-2.5 py-1.5 mb-2.5 no-print" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-pdf-fill text-danger fs-5" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark", + style: { + fontSize: '0.78rem' + } + }, "A5 Landscape Tax Invoice (PDF Ready)"), /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '0.68rem' + } + }, "Direct server vector PDF (Landscape: 210 × 148 mm) • Zero clipped columns"))), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1.5" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-xs btn-outline-primary py-1 px-2", + onClick: () => downloadPdf('a5'), + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-download me-1" + }), " Download PDF"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-xs btn-primary py-1 px-2.5 fw-bold", + onClick: () => printPdf('a5'), + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer me-1" + }), " Print PDF (A5 Landscape)"))), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-start border-bottom pb-2 mb-2" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold mb-0 text-primary" + }, lastInvoice.sale.store_name), /*#__PURE__*/React.createElement("div", { + style: { + fontSize: '10px' + } + }, lastInvoice.sale.building_name, ", ", lastInvoice.sale.floor_no, ", ", lastInvoice.sale.store_address), /*#__PURE__*/React.createElement("div", { + style: { + fontSize: '10px' + } + }, /*#__PURE__*/React.createElement("strong", null, "DL 20B:"), " ", lastInvoice.sale.drug_license_no_20b, " | ", /*#__PURE__*/React.createElement("strong", null, "DL 21B:"), " ", lastInvoice.sale.drug_license_no_21b, lastInvoice.sale.abdm_hfr_id && /*#__PURE__*/React.createElement("span", null, " | ", /*#__PURE__*/React.createElement("strong", null, "HFR ID:"), " ", lastInvoice.sale.abdm_hfr_id)), /*#__PURE__*/React.createElement("div", { + style: { + fontSize: '10px' + } + }, /*#__PURE__*/React.createElement("strong", null, "GSTIN:"), " ", lastInvoice.sale.gstin, " | ", /*#__PURE__*/React.createElement("strong", null, "Phone:"), " ", lastInvoice.sale.contact_phone)), /*#__PURE__*/React.createElement("div", { + className: "text-end" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-dark text-white mb-1" + }, "RETAIL TAX INVOICE"), /*#__PURE__*/React.createElement("div", { + className: "fw-bold", + style: { + fontSize: '12px' + } + }, lastInvoice.sale.invoice_no), /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '10px' + } + }, lastInvoice.sale.sale_date))), /*#__PURE__*/React.createElement("div", { + className: "row g-1 mb-2 p-1.5 bg-light rounded", + style: { + fontSize: '10px' + } + }, /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("strong", null, "Patient:"), " ", lastInvoice.sale.patient_name, " ", lastInvoice.sale.uhid ? `(${lastInvoice.sale.uhid})` : ''), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("strong", null, "Prescribed By:"), " ", lastInvoice.sale.doctor_name), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("strong", null, "Age/Gender:"), " ", lastInvoice.sale.age || 'N/A', " / ", lastInvoice.sale.gender || 'N/A'), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("strong", null, "Payment Mode:"), " ", lastInvoice.sale.payment_mode), (lastInvoice.sale.abha_id || lastInvoice.sale.abha_address) && /*#__PURE__*/React.createElement("div", { + className: "col-12 text-success fw-bold" + }, /*#__PURE__*/React.createElement("strong", null, "ABHA:"), " ", lastInvoice.sale.abha_id || 'N/A', " (", lastInvoice.sale.abha_address || 'N/A', ")", lastInvoice.sale.abdm_care_context_ref && /*#__PURE__*/React.createElement("span", null, " | ", /*#__PURE__*/React.createElement("strong", null, "Care Context:"), " ", lastInvoice.sale.abdm_care_context_ref))), /*#__PURE__*/React.createElement("table", { + className: "table table-bordered table-sm mb-2", + style: { + fontSize: '10px' + } + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "#"), /*#__PURE__*/React.createElement("th", null, "Medicine Name"), /*#__PURE__*/React.createElement("th", null, "HSN"), /*#__PURE__*/React.createElement("th", null, "Batch"), /*#__PURE__*/React.createElement("th", null, "Exp"), /*#__PURE__*/React.createElement("th", null, "Qty & Unit"), /*#__PURE__*/React.createElement("th", null, "Unit MRP (₹)"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Amount (₹)"))), /*#__PURE__*/React.createElement("tbody", null, lastInvoice.items.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: 8, + className: "text-center text-muted py-2" + }, "No medicines dispensed on this bill (Return / Refund Only)")) : lastInvoice.items.map((it, i) => /*#__PURE__*/React.createElement("tr", { + key: i + }, /*#__PURE__*/React.createElement("td", null, i + 1), /*#__PURE__*/React.createElement("td", { + className: "fw-bold" + }, it.item_name, it.snomed_ct_code && /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '8px' + } + }, "SNOMED: ", it.snomed_ct_code), Number(it.units_per_pack) > 1 && /*#__PURE__*/React.createElement("div", { + className: "text-muted fw-normal", + style: { + fontSize: '8px' + } + }, "Pack: 1 Strip = ", it.units_per_pack, " Tabs")), /*#__PURE__*/React.createElement("td", null, it.hsn_code), /*#__PURE__*/React.createElement("td", null, it.batch_no), /*#__PURE__*/React.createElement("td", null, it.expiry_date.substring(0, 7)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "fw-bold" + }, it.sell_unit === 'Tablet' ? `${it.total_units} Tab` : it.sell_unit === 'Combo' ? `${it.qty} Str + ${it.loose_qty} Tab` : Number(it.units_per_pack) > 1 ? `${it.qty} Strip` : `${it.qty} ${it.unit_pack || 'Unit'}`), Number(it.units_per_pack) > 1 && it.sell_unit !== 'Tablet' && /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '8px' + } + }, "(", it.total_units, " Tabs)")), /*#__PURE__*/React.createElement("td", null, it.sell_unit === 'Tablet' ? /*#__PURE__*/React.createElement("span", null, "₹", it.unit_price, " ", /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "/tab")) : /*#__PURE__*/React.createElement("span", null, "₹", it.unit_mrp, " ", Number(it.units_per_pack) > 1 ? /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "/strip") : '')), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold" + }, "₹", it.total_amount))))), lastInvoice.return_items && lastInvoice.return_items.length > 0 && /*#__PURE__*/React.createElement("div", { + className: "mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center bg-danger-subtle px-2 py-1 rounded-top border border-bottom-0 border-danger-subtle text-danger", + style: { + fontSize: '10px' + } + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-return-left me-1" + }), " RETURNED / EXCHANGED MEDICINES"), lastInvoice.credit_note && /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger" + }, "Credit Note: ", lastInvoice.credit_note.credit_note_no)), /*#__PURE__*/React.createElement("table", { + className: "table table-bordered table-sm mb-0 text-danger border-danger-subtle", + style: { + fontSize: '9px' + } + }, /*#__PURE__*/React.createElement("thead", { + className: "table-danger" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "#"), /*#__PURE__*/React.createElement("th", null, "Medicine Name"), /*#__PURE__*/React.createElement("th", null, "Batch"), /*#__PURE__*/React.createElement("th", null, "Original Bill"), /*#__PURE__*/React.createElement("th", null, "Condition"), /*#__PURE__*/React.createElement("th", null, "Returned Qty"), /*#__PURE__*/React.createElement("th", null, "Credit Rate (₹)"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Credit Total (₹)"))), /*#__PURE__*/React.createElement("tbody", null, lastInvoice.return_items.map((it, i) => /*#__PURE__*/React.createElement("tr", { + key: `a5-ret-${i}` + }, /*#__PURE__*/React.createElement("td", null, i + 1), /*#__PURE__*/React.createElement("td", { + className: "fw-bold text-decoration-line-through" + }, it.item_name), /*#__PURE__*/React.createElement("td", null, it.batch_no), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("code", null, it.ref_invoice_no || 'N/A')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary" + }, it.return_condition)), /*#__PURE__*/React.createElement("td", { + className: "fw-bold" + }, "-", it.sell_unit === 'Tablet' ? `${it.total_units} Tab` : `${it.qty} ${it.unit_pack || 'Unit'}`), /*#__PURE__*/React.createElement("td", null, "₹", it.unit_price), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold" + }, "-₹", Math.abs(Number(it.total_amount)).toFixed(2))))))), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center border-top pt-2" + }, /*#__PURE__*/React.createElement("div", { + style: { + fontSize: '9px' + } + }, "R.Ph: ", lastInvoice.sale.registered_pharmacist_name || 'Pharmacist', " (", lastInvoice.sale.pharmacist_reg_no, ")", lastInvoice.sale.pharmacist_hpr_id && /*#__PURE__*/React.createElement("span", null, " | HPR ID: ", lastInvoice.sale.pharmacist_hpr_id)), /*#__PURE__*/React.createElement("div", { + className: "text-end" + }, /*#__PURE__*/React.createElement("div", { + style: { + fontSize: '10px' + }, + className: "text-muted" + }, "Gross: ₹", lastInvoice.sale.gross_amount, Number(lastInvoice.sale.discount_amount) > 0 && /*#__PURE__*/React.createElement("span", { + className: "text-danger ms-2" + }, "Disc: -₹", lastInvoice.sale.discount_amount), Number(lastInvoice.sale.return_amount) > 0 && /*#__PURE__*/React.createElement("span", { + className: "text-danger fw-bold ms-2" + }, "Return Credit: -₹", lastInvoice.sale.return_amount)), /*#__PURE__*/React.createElement("span", { + className: "fs-6 fw-bold text-primary" + }, Number(lastInvoice.sale.refund_amount) > 0 ? `NET REFUND: ₹${lastInvoice.sale.refund_amount}` : `TOTAL: ₹${lastInvoice.sale.net_amount}`), Number(lastInvoice.sale.refund_amount) > 0 && /*#__PURE__*/React.createElement("div", { + className: "text-danger fw-bold small" + }, "Refund Paid via ", lastInvoice.sale.refund_mode, " ", lastInvoice.sale.refund_ref_no ? `[Ref: ${lastInvoice.sale.refund_ref_no}]` : ''), /*#__PURE__*/React.createElement("div", { + style: { + fontSize: '9px' + }, + className: "text-muted mt-0.5" + }, /*#__PURE__*/React.createElement("span", null, "Settlement: ", /*#__PURE__*/React.createElement("strong", null, lastInvoice.sale.payment_mode)), Number(lastInvoice.sale.cash_paid) > 0 && /*#__PURE__*/React.createElement("span", { + className: "ms-1.5" + }, "Cash: ₹", lastInvoice.sale.cash_paid), Number(lastInvoice.sale.upi_paid) > 0 && /*#__PURE__*/React.createElement("span", { + className: "ms-1.5" + }, "UPI: ₹", lastInvoice.sale.upi_paid, " ", lastInvoice.sale.upi_ref_no ? `(UTR: ${lastInvoice.sale.upi_ref_no})` : ''), Number(lastInvoice.sale.card_paid) > 0 && /*#__PURE__*/React.createElement("span", { + className: "ms-1.5" + }, "Card: ₹", lastInvoice.sale.card_paid), lastInvoice.sale.is_bank_reconciled == 1 && /*#__PURE__*/React.createElement("span", { + className: "ms-1.5 text-success fw-bold" + }, "✓ Audited"))))), printFormat === 'a4' && /*#__PURE__*/React.createElement("div", { + className: "print-a4-invoice" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center bg-primary-subtle border border-primary-subtle rounded px-3 py-1.5 mb-3 no-print" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-pdf-fill text-danger fs-5" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark", + style: { + fontSize: '0.8rem' + } + }, "A4 Hospital GST Tax Invoice (PDF Ready)"), /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '0.68rem' + } + }, "Server-rendered vector PDF • Zero clipped columns"))), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1.5" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-xs btn-outline-primary py-1 px-2.5", + onClick: () => downloadPdf('a4'), + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-download me-1" + }), " Download PDF"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-xs btn-primary py-1 px-2.5 fw-bold", + onClick: () => printPdf('a4'), + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer me-1" + }), " Print PDF"))), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center border-bottom pb-3 mb-3" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h4", { + className: "fw-bold text-primary mb-1" + }, lastInvoice.sale.store_name), /*#__PURE__*/React.createElement("div", { + className: "text-muted" + }, lastInvoice.sale.building_name, ", ", lastInvoice.sale.floor_no, ", ", lastInvoice.sale.store_address), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", null, "Drug License 20-B:"), " ", lastInvoice.sale.drug_license_no_20b, " | ", /*#__PURE__*/React.createElement("strong", null, "21-B:"), " ", lastInvoice.sale.drug_license_no_21b, " | ", /*#__PURE__*/React.createElement("strong", null, "FSSAI:"), " ", lastInvoice.sale.fssai_no || 'N/A'), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", null, "GSTIN:"), " ", lastInvoice.sale.gstin, " | ", /*#__PURE__*/React.createElement("strong", null, "State:"), " ", lastInvoice.sale.state_name, " (Code: ", lastInvoice.sale.state_code, ")", lastInvoice.sale.abdm_hfr_id && /*#__PURE__*/React.createElement("span", null, " | ", /*#__PURE__*/React.createElement("strong", null, "ABDM HFR Facility ID:"), " ", lastInvoice.sale.abdm_hfr_id))), /*#__PURE__*/React.createElement("div", { + className: "text-end" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary fs-6 px-3 py-1.5 mb-1" + }, "HOSPITAL GST TAX INVOICE"), /*#__PURE__*/React.createElement("h5", { + className: "fw-bold mb-0 text-dark" + }, lastInvoice.sale.invoice_no), /*#__PURE__*/React.createElement("div", { + className: "text-muted small" + }, "Date & Time: ", lastInvoice.sale.sale_date))), /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-3 p-2 bg-light rounded border" + }, /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("strong", null, "Patient Name:"), " ", lastInvoice.sale.patient_name), /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("strong", null, "UHID No:"), " ", /*#__PURE__*/React.createElement("code", { + className: "text-primary fw-bold" + }, lastInvoice.sale.uhid || 'Walk-in')), /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("strong", null, "Phone:"), " ", lastInvoice.sale.patient_mobile || 'N/A'), /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("strong", null, "Age / Gender:"), " ", lastInvoice.sale.age || 'N/A', " / ", lastInvoice.sale.gender || 'N/A'), /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("strong", null, "Consultant Doctor:"), " ", lastInvoice.sale.doctor_name), /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("strong", null, "Doctor Reg No:"), " ", lastInvoice.sale.doctor_reg_no || 'N/A'), (lastInvoice.sale.abha_id || lastInvoice.sale.abha_address) && /*#__PURE__*/React.createElement("div", { + className: "col-12 bg-success-subtle p-1.5 rounded text-success fw-bold border border-success mt-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-fill-check me-1" + }), " ABDM Linked: ABHA Number: ", lastInvoice.sale.abha_id || 'N/A', " | ABHA Address: ", lastInvoice.sale.abha_address || 'N/A', " | Care Context: ", lastInvoice.sale.abdm_care_context_ref || 'N/A'), lastInvoice.sale.ipd_id && /*#__PURE__*/React.createElement("div", { + className: "col-12 text-danger fw-bold border-top pt-1 mt-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hospital me-1" + }), " IPD Admission #", lastInvoice.sale.ipd_id, " • Ward: ", lastInvoice.sale.ward_name || 'General', " • Bed: ", lastInvoice.sale.bed_no || 'Bed', " (Charged to IPD Running Bill)")), /*#__PURE__*/React.createElement("table", { + className: "table table-bordered mb-3" + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", { + style: { + width: 40 + } + }, "#"), /*#__PURE__*/React.createElement("th", null, "Medicine & Formulation"), /*#__PURE__*/React.createElement("th", null, "HSN"), /*#__PURE__*/React.createElement("th", null, "Batch No"), /*#__PURE__*/React.createElement("th", null, "Exp Date"), /*#__PURE__*/React.createElement("th", { + style: { + width: 105 + } + }, "Qty & Unit"), /*#__PURE__*/React.createElement("th", null, "Rate (₹)"), /*#__PURE__*/React.createElement("th", null, "Taxable (₹)"), /*#__PURE__*/React.createElement("th", null, "CGST (₹)"), /*#__PURE__*/React.createElement("th", null, "SGST (₹)"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Total (₹)"))), /*#__PURE__*/React.createElement("tbody", null, lastInvoice.items.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: 11, + className: "text-center text-muted py-3" + }, "No medicines dispensed on this bill (Pure Sales Return & Customer Refund)")) : lastInvoice.items.map((it, i) => /*#__PURE__*/React.createElement("tr", { + key: i + }, /*#__PURE__*/React.createElement("td", null, i + 1), /*#__PURE__*/React.createElement("td", { + className: "fw-bold" + }, it.item_name, it.snomed_ct_code && /*#__PURE__*/React.createElement("div", { + className: "text-muted fw-normal", + style: { + fontSize: '9px' + } + }, "SNOMED-CT: ", /*#__PURE__*/React.createElement("code", null, it.snomed_ct_code), " (", it.snomed_display || '', ")"), Number(it.units_per_pack) > 1 && /*#__PURE__*/React.createElement("div", { + className: "text-muted fw-normal", + style: { + fontSize: '9px' + } + }, "Packing: 1 Strip of ", it.units_per_pack, " Tablets")), /*#__PURE__*/React.createElement("td", null, it.hsn_code), /*#__PURE__*/React.createElement("td", null, it.batch_no), /*#__PURE__*/React.createElement("td", null, it.expiry_date), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "fw-bold" + }, it.sell_unit === 'Tablet' ? `${it.total_units} Tab` : it.sell_unit === 'Combo' ? `${it.qty} Str + ${it.loose_qty} Tab` : Number(it.units_per_pack) > 1 ? `${it.qty} Strip` : `${it.qty} ${it.unit_pack || 'Unit'}`), Number(it.units_per_pack) > 1 && it.sell_unit !== 'Tablet' && /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '9px' + } + }, "(", it.total_units, " Tablets)")), /*#__PURE__*/React.createElement("td", null, it.sell_unit === 'Tablet' ? /*#__PURE__*/React.createElement("span", null, "₹", it.unit_price, " ", /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "/tab")) : /*#__PURE__*/React.createElement("span", null, "₹", it.unit_mrp, " ", Number(it.units_per_pack) > 1 ? /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "/strip") : '')), /*#__PURE__*/React.createElement("td", null, "₹", it.taxable_value), /*#__PURE__*/React.createElement("td", null, "₹", it.cgst_amount), /*#__PURE__*/React.createElement("td", null, "₹", it.sgst_amount), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold" + }, "₹", it.total_amount))))), lastInvoice.return_items && lastInvoice.return_items.length > 0 && /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center bg-danger-subtle p-2 rounded-top border border-bottom-0 border-danger text-danger" + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-return-left me-1" + }), " GST CREDIT NOTE / RETURNED & EXCHANGED MEDICINES"), lastInvoice.credit_note && /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger fs-7" + }, "Credit Note No: ", lastInvoice.credit_note.credit_note_no, " (", lastInvoice.credit_note.return_date, ")")), /*#__PURE__*/React.createElement("table", { + className: "table table-bordered mb-0 text-danger border-danger" + }, /*#__PURE__*/React.createElement("thead", { + className: "table-danger" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", { + style: { + width: 40 + } + }, "#"), /*#__PURE__*/React.createElement("th", null, "Returned Medicine & Formulation"), /*#__PURE__*/React.createElement("th", null, "HSN"), /*#__PURE__*/React.createElement("th", null, "Batch No"), /*#__PURE__*/React.createElement("th", null, "Original Invoice"), /*#__PURE__*/React.createElement("th", null, "Condition / Reason"), /*#__PURE__*/React.createElement("th", { + style: { + width: 105 + } + }, "Qty Returned"), /*#__PURE__*/React.createElement("th", null, "Credit Rate (₹)"), /*#__PURE__*/React.createElement("th", null, "Taxable (₹)"), /*#__PURE__*/React.createElement("th", null, "CGST (₹)"), /*#__PURE__*/React.createElement("th", null, "SGST (₹)"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Credit Total (₹)"))), /*#__PURE__*/React.createElement("tbody", null, lastInvoice.return_items.map((it, i) => /*#__PURE__*/React.createElement("tr", { + key: `a4-ret-${i}` + }, /*#__PURE__*/React.createElement("td", null, i + 1), /*#__PURE__*/React.createElement("td", { + className: "fw-bold text-decoration-line-through" + }, it.item_name), /*#__PURE__*/React.createElement("td", null, it.hsn_code), /*#__PURE__*/React.createElement("td", null, it.batch_no), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("code", null, it.ref_invoice_no || 'N/A')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary me-1" + }, it.return_condition), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, it.return_reason)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "fw-bold" + }, "-", it.sell_unit === 'Tablet' ? `${it.total_units} Tab` : `${it.qty} ${it.unit_pack || 'Unit'}`)), /*#__PURE__*/React.createElement("td", null, "₹", it.unit_price), /*#__PURE__*/React.createElement("td", null, "-₹", Math.abs(Number(it.taxable_value)).toFixed(2)), /*#__PURE__*/React.createElement("td", null, "-₹", Math.abs(Number(it.cgst_amount)).toFixed(2)), /*#__PURE__*/React.createElement("td", null, "-₹", Math.abs(Number(it.sgst_amount)).toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold" + }, "-₹", Math.abs(Number(it.total_amount)).toFixed(2))))))), lastInvoice.hsn_summary && lastInvoice.hsn_summary.length > 0 && /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "GST Tax Breakdown"), /*#__PURE__*/React.createElement("table", { + className: "table table-sm table-bordered text-center", + style: { + fontSize: '10px' + } + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "HSN Code"), /*#__PURE__*/React.createElement("th", null, "GST Rate"), /*#__PURE__*/React.createElement("th", null, "Taxable Value (₹)"), /*#__PURE__*/React.createElement("th", null, "CGST (₹)"), /*#__PURE__*/React.createElement("th", null, "SGST (₹)"), /*#__PURE__*/React.createElement("th", null, "Total Tax (₹)"))), /*#__PURE__*/React.createElement("tbody", null, lastInvoice.hsn_summary.map((h, idx) => /*#__PURE__*/React.createElement("tr", { + key: idx + }, /*#__PURE__*/React.createElement("td", null, h.hsn_code), /*#__PURE__*/React.createElement("td", null, h.gst_rate, "%"), /*#__PURE__*/React.createElement("td", null, "₹", h.taxable_value.toFixed(2)), /*#__PURE__*/React.createElement("td", null, "₹", h.cgst_amount.toFixed(2)), /*#__PURE__*/React.createElement("td", null, "₹", h.sgst_amount.toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: "fw-bold" + }, "₹", h.total_tax.toFixed(2))))))), /*#__PURE__*/React.createElement("div", { + className: "row g-3 border-top pt-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-7" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block" + }, /*#__PURE__*/React.createElement("strong", null, "Registered Pharmacist:"), " ", lastInvoice.sale.registered_pharmacist_name || 'Pharmacist', " (Reg No: ", lastInvoice.sale.pharmacist_reg_no || 'N/A', ")", lastInvoice.sale.pharmacist_hpr_id && /*#__PURE__*/React.createElement("span", null, " | ", /*#__PURE__*/React.createElement("strong", null, "HPR ID:"), " ", lastInvoice.sale.pharmacist_hpr_id)), /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block mt-1" + }, lastInvoice.sale.terms_conditions || '1. Goods once sold are returnable only as per Drug Rules.\n2. Store medicines below 25°C.'), /*#__PURE__*/React.createElement("div", { + className: "mt-2 p-2 bg-light rounded border", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark mb-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-wallet2 me-1" + }), " Payment Settlement:"), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap gap-2 align-items-center mb-1" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary" + }, lastInvoice.sale.payment_mode), Number(lastInvoice.sale.cash_paid) > 0 && /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("strong", null, "Cash:"), " ₹", lastInvoice.sale.cash_paid), Number(lastInvoice.sale.upi_paid) > 0 && /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("strong", null, "UPI / Bank:"), " ₹", lastInvoice.sale.upi_paid, lastInvoice.sale.upi_ref_no && /*#__PURE__*/React.createElement("code", { + className: "text-primary ms-1" + }, "[UTR: ", lastInvoice.sale.upi_ref_no, "]"), lastInvoice.sale.bank_name && /*#__PURE__*/React.createElement("span", { + className: "text-muted ms-1" + }, "(", lastInvoice.sale.bank_name, ")")), Number(lastInvoice.sale.card_paid) > 0 && /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("strong", null, "Card:"), " ₹", lastInvoice.sale.card_paid, " ", lastInvoice.sale.card_ref_no ? `[Ref: ${lastInvoice.sale.card_ref_no}]` : ''), Number(lastInvoice.sale.credit_amount) > 0 && /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("strong", null, "Hospital Credit:"), " ₹", lastInvoice.sale.credit_amount)), Number(lastInvoice.sale.refund_amount) > 0 && /*#__PURE__*/React.createElement("div", { + className: "mb-1" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger-subtle text-danger border border-danger" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cash-stack me-1" + }), " Refund Issued: ₹", lastInvoice.sale.refund_amount, " via ", lastInvoice.sale.refund_mode, " ", lastInvoice.sale.refund_ref_no ? `[Ref: ${lastInvoice.sale.refund_ref_no}]` : '')), /*#__PURE__*/React.createElement("div", null, lastInvoice.sale.is_bank_reconciled == 1 ? /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success border border-success" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-patch-check-fill me-1" + }), " Bank Statement Reconciled & Audited") : /*#__PURE__*/React.createElement("span", { + className: "badge bg-warning-subtle text-dark border border-warning" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clock-history me-1" + }), " Bank Statement: Pending Audit")))), /*#__PURE__*/React.createElement("div", { + className: "col-5" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-1" + }, /*#__PURE__*/React.createElement("span", null, "Gross Items Total:"), /*#__PURE__*/React.createElement("span", null, "₹", lastInvoice.sale.gross_amount)), Number(lastInvoice.sale.discount_amount) > 0 && /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-1 text-danger" + }, /*#__PURE__*/React.createElement("span", null, "Total Discounts Allowed:"), /*#__PURE__*/React.createElement("span", null, "-₹", lastInvoice.sale.discount_amount)), Number(lastInvoice.sale.return_amount) > 0 && /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-1 text-danger fw-bold" + }, /*#__PURE__*/React.createElement("span", null, "Less Return / Exchange Credit:"), /*#__PURE__*/React.createElement("span", null, "-₹", lastInvoice.sale.return_amount)), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-1" + }, /*#__PURE__*/React.createElement("span", null, "Taxable Amount:"), /*#__PURE__*/React.createElement("span", null, "₹", lastInvoice.sale.taxable_amount)), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-1" + }, /*#__PURE__*/React.createElement("span", null, "CGST Amount:"), /*#__PURE__*/React.createElement("span", null, "₹", lastInvoice.sale.cgst_amount)), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-1" + }, /*#__PURE__*/React.createElement("span", null, "SGST Amount:"), /*#__PURE__*/React.createElement("span", null, "₹", lastInvoice.sale.sgst_amount)), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-1" + }, /*#__PURE__*/React.createElement("span", null, "Round Off:"), /*#__PURE__*/React.createElement("span", null, "₹", lastInvoice.sale.round_off)), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between fs-5 fw-bolder border-top pt-2 text-primary" + }, /*#__PURE__*/React.createElement("span", null, "GRAND TOTAL / NET PAYABLE:"), /*#__PURE__*/React.createElement("span", null, "₹", lastInvoice.sale.net_amount)), Number(lastInvoice.sale.refund_amount) > 0 && /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between fs-6 fw-bold text-danger border-top border-bottom py-1 mt-2" + }, /*#__PURE__*/React.createElement("span", null, "REFUND PAID TO CUSTOMER:"), /*#__PURE__*/React.createElement("span", null, "₹", lastInvoice.sale.refund_amount, " (", lastInvoice.sale.refund_mode, lastInvoice.sale.refund_ref_no ? ` - ${lastInvoice.sale.refund_ref_no}` : '', ")")))))))), /*#__PURE__*/React.createElement("div", { + className: "p-2.5 bg-white border-top d-flex justify-content-between align-items-center flex-shrink-0 px-3" + }, /*#__PURE__*/React.createElement("span", { + className: "text-muted small" + }, "Format: ", /*#__PURE__*/React.createElement("strong", { + className: "text-dark text-uppercase" + }, printFormat), " • Bill No: ", /*#__PURE__*/React.createElement("strong", null, lastInvoice.sale.invoice_no)), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2 flex-wrap align-items-center" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-secondary px-3", + onClick: () => setIsPrintOpen(false) + }, "Done / Close (Esc)"), printFormat === 'thermal' ? /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-warning text-dark px-3 fw-bold", + onClick: printThermalReceipt + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer-fill me-1" + }), " Print Thermal Receipt") : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-primary px-3", + onClick: () => downloadPdf(printFormat) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-download me-1" + }), " Download PDF"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-primary px-3 fw-bold", + onClick: () => printPdf(printFormat) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer me-1" + }), " Print PDF (", printFormat === 'a5' ? 'A5 LANDSCAPE' : printFormat.toUpperCase(), ")")))))), showFhirModal && /*#__PURE__*/React.createElement("div", { + className: "modal fade show d-block", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.75)' + }, + tabIndex: "-1" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-lg modal-dialog-scrollable" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content border-0 shadow-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2 px-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-fill-check text-success fs-5" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "modal-title mb-0 fw-bold" + }, "ABDM NRCES FHIR R4 MedicationDispense Document"), /*#__PURE__*/React.createElement("small", { + className: "text-secondary", + style: { + fontSize: '0.75rem' + } + }, "Profile: MedicationDispenseDocument | LOINC: 60590-7"))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setShowFhirModal(false) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3 bg-light" + }, isLoadingFhir ? /*#__PURE__*/React.createElement("div", { + className: "text-center py-5" + }, /*#__PURE__*/React.createElement("div", { + className: "spinner-border text-primary mb-2", + role: "status" + }), /*#__PURE__*/React.createElement("div", { + className: "text-muted" + }, "Retrieving & Validating ABDM FHIR R4 Bundle...")) : fhirBundleData ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("div", { + className: "bg-white p-2 rounded border" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block" + }, "Care Context Reference"), /*#__PURE__*/React.createElement("code", { + className: "text-primary fw-bold" + }, fhirBundleData.care_context_ref))), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("div", { + className: "bg-white p-2 rounded border" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block" + }, "ABHA Number / Address"), /*#__PURE__*/React.createElement("strong", { + className: "text-success" + }, fhirBundleData.abha_id || fhirBundleData.abha_address || 'Not ABHA Linked'))), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("div", { + className: "bg-white p-2 rounded border" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block" + }, "Gateway Sync Status"), /*#__PURE__*/React.createElement("span", { + className: `badge ${fhirBundleData.sync_status === 'SYNCED' ? 'bg-success' : 'bg-warning text-dark'}` + }, fhirBundleData.sync_status || 'QUEUED_FOR_BRIDGE')))), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-1" + }, /*#__PURE__*/React.createElement("span", { + className: "small fw-bold text-dark" + }, "NRCES FHIR R4 Document Bundle (JSON):"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-secondary py-0 px-2", + onClick: copyFhirToClipboard + }, /*#__PURE__*/React.createElement("i", { + className: `bi ${copiedFhir ? 'bi-check-lg text-success' : 'bi-clipboard'} me-1` + }), copiedFhir ? 'Copied!' : 'Copy JSON')), /*#__PURE__*/React.createElement("pre", { + className: "bg-dark text-light p-3 rounded-2", + style: { + maxHeight: 360, + fontSize: '0.75rem', + overflow: 'auto' + } + }, JSON.stringify(fhirBundleData.bundle, null, 2))) : /*#__PURE__*/React.createElement("div", { + className: "alert alert-warning mb-0" + }, "No FHIR bundle data found.")), /*#__PURE__*/React.createElement("div", { + className: "modal-footer py-1 px-3 bg-white" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted me-auto", + style: { + fontSize: '0.75rem' + } + }, "Includes SNOMED-CT clinical codes, HFR Facility ID, and Practitioner HPR ID."), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-secondary", + onClick: () => setShowFhirModal(false) + }, "Close"))))), showReturnModal && /*#__PURE__*/React.createElement("div", { + className: "modal fade show d-block", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.75)' + }, + tabIndex: "-1" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-xl modal-dialog-scrollable" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content border-0 shadow-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2 px-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-left-right text-warning fs-5" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "modal-title mb-0 fw-bold" + }, "Sales Return & Same-Invoice Exchange Desk"), /*#__PURE__*/React.createElement("small", { + className: "text-secondary", + style: { + fontSize: '0.75rem' + } + }, "B2C Retail Returns • Stock Replenishment • GST Credit Note • Fast POS Standard (F6 / Alt+R)"))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setShowReturnModal(false) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3 bg-light" + }, /*#__PURE__*/React.createElement("div", { + className: "card shadow-sm border-0 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "card-body p-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "Lookup Original Tax Invoice / Patient UHID / Phone:"), /*#__PURE__*/React.createElement("div", { + className: "input-group" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-white" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + ref: returnSearchInputRef, + className: "form-control", + placeholder: "Enter Invoice No (e.g. MAIN/26-27/08176), UHID, Patient Name, or Mobile...", + value: returnSearchQuery, + onChange: e => setReturnSearchQuery(e.target.value), + onKeyDown: e => { + if (e.key === 'Enter') { + e.preventDefault(); + searchReturnInvoices(); + } + } + }), /*#__PURE__*/React.createElement("button", { + className: "btn btn-primary px-3", + type: "button", + disabled: isSearchingReturn, + onClick: () => searchReturnInvoices() + }, isSearchingReturn ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm me-1" + }), "Searching...") : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-repeat me-1" + }), " Search Bill"))))), !selectedReturnInvoice && returnSearchResults.length > 1 && /*#__PURE__*/React.createElement("div", { + className: "card shadow-sm border-0 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "card-header bg-white py-2 fw-bold text-dark small" + }, "Matching Invoices (", returnSearchResults.length, " found) - Select an invoice to process returns:"), /*#__PURE__*/React.createElement("div", { + className: "table-responsive", + style: { + maxHeight: '220px' + } + }, /*#__PURE__*/React.createElement("table", { + className: "table table-hover table-sm align-middle mb-0", + style: { + fontSize: '0.85rem' + } + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "Bill No"), /*#__PURE__*/React.createElement("th", null, "Date"), /*#__PURE__*/React.createElement("th", null, "Patient"), /*#__PURE__*/React.createElement("th", null, "Doctor"), /*#__PURE__*/React.createElement("th", null, "Original Net"), /*#__PURE__*/React.createElement("th", null, "Returnable Items"), /*#__PURE__*/React.createElement("th", null, "Action"))), /*#__PURE__*/React.createElement("tbody", null, returnSearchResults.map(resObj => { + const returnableCount = (resObj.items || []).filter(it => it.remaining_units > 0).length; + return /*#__PURE__*/React.createElement("tr", { + key: resObj.sale.sale_id + }, /*#__PURE__*/React.createElement("td", { + className: "fw-bold text-primary" + }, resObj.sale.invoice_no), /*#__PURE__*/React.createElement("td", { + className: "text-muted" + }, resObj.sale.sale_date), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("strong", null, resObj.sale.patient_name), resObj.sale.uhid && /*#__PURE__*/React.createElement("span", { + className: "text-muted ms-1" + }, "(", resObj.sale.uhid, ")")), /*#__PURE__*/React.createElement("td", null, resObj.sale.doctor_name || 'N/A'), /*#__PURE__*/React.createElement("td", { + className: "fw-bold" + }, "₹", resObj.sale.net_amount), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: `badge ${returnableCount > 0 ? 'bg-success-subtle text-success' : 'bg-secondary'}` + }, returnableCount, " items eligible")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-primary py-0 px-2", + onClick: () => selectReturnInvoice(resObj) + }, "Select Bill ", /*#__PURE__*/React.createElement("i", { + className: "bi bi-chevron-right ms-1" + })))); + }))))), selectedReturnInvoice && /*#__PURE__*/React.createElement("div", { + className: "card shadow-sm border-0 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "card-header bg-white py-2 d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary fs-7" + }, selectedReturnInvoice.sale.invoice_no), /*#__PURE__*/React.createElement("span", { + className: "text-muted small" + }, "Date: ", selectedReturnInvoice.sale.sale_date), selectedReturnInvoice.sale.uhid && /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border" + }, "UHID: ", selectedReturnInvoice.sale.uhid)), returnSearchResults.length > 1 && /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-secondary py-0", + onClick: () => setSelectedReturnInvoice(null) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-left me-1" + }), " Change Bill")), /*#__PURE__*/React.createElement("div", { + className: "card-body p-2 bg-light-subtle" + }, /*#__PURE__*/React.createElement("div", { + className: "row g-2 small" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("strong", null, "Patient:"), " ", selectedReturnInvoice.sale.patient_name), /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("strong", null, "Phone:"), " ", selectedReturnInvoice.sale.patient_mobile || 'N/A'), /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("strong", null, "Doctor:"), " ", selectedReturnInvoice.sale.doctor_name || 'N/A'), /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("strong", null, "Original Net Paid:"), " ₹", selectedReturnInvoice.sale.net_amount))), /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-bordered table-sm align-middle mb-0", + style: { + fontSize: '0.85rem' + } + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "#"), /*#__PURE__*/React.createElement("th", null, "Medicine Name"), /*#__PURE__*/React.createElement("th", null, "Batch / Exp"), /*#__PURE__*/React.createElement("th", null, "Sold / Returned"), /*#__PURE__*/React.createElement("th", null, "Eligible Units"), /*#__PURE__*/React.createElement("th", { + style: { + width: 150 + } + }, "Return Qty & Unit"), /*#__PURE__*/React.createElement("th", { + style: { + width: 140 + } + }, "Condition"), /*#__PURE__*/React.createElement("th", { + style: { + width: 150 + } + }, "Reason"), /*#__PURE__*/React.createElement("th", null, "Credit Rate"), /*#__PURE__*/React.createElement("th", { + className: "text-end", + style: { + width: 110 + } + }, "Line Credit"))), /*#__PURE__*/React.createElement("tbody", null, selectedReturnInvoice.items.map((it, idx) => { + const draft = returnDraftItems[it.sale_item_id] || { + return_qty: 0, + return_unit: it.units_per_pack > 1 && it.remaining_strips > 0 ? 'Strip' : 'Tab', + condition: 'GOOD', + reason: 'EXCESS_UNUSED' + }; + const isEligible = it.remaining_units > 0; + const qty = Number(draft.return_qty) || 0; + const upp = Number(it.units_per_pack) || 1; + const totalReturnUnits = draft.return_unit === 'Strip' ? qty * upp : qty; + const lineCredit = Number((totalReturnUnits * it.effective_unit_price).toFixed(2)); + const isOverLimit = totalReturnUnits > it.remaining_units; + return /*#__PURE__*/React.createElement("tr", { + key: it.sale_item_id, + className: !isEligible ? 'opacity-50 table-light' : qty > 0 ? 'table-warning' : '' + }, /*#__PURE__*/React.createElement("td", null, idx + 1), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("strong", { + className: "text-dark" + }, it.item_name), it.generic_name && /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '0.75rem' + } + }, it.generic_name), upp > 1 && /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '0.72rem' + } + }, "1 Strip = ", upp, " Tabs")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-dark border" + }, it.batch_no), /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '0.72rem' + } + }, "Exp: ", it.expiry_date ? it.expiry_date.substring(0, 7) : 'N/A')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", null, "Sold: ", it.total_units, " tab"), Number(it.already_returned_units) > 0 && /*#__PURE__*/React.createElement("div", { + className: "text-danger", + style: { + fontSize: '0.75rem' + } + }, "Returned: ", it.already_returned_units, " tab")), /*#__PURE__*/React.createElement("td", null, isEligible ? /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success border border-success" + }, it.remaining_units, " Tabs ", upp > 1 ? `(${it.remaining_strips} Str + ${it.remaining_loose} Tab)` : '') : /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary" + }, "Fully Returned")), /*#__PURE__*/React.createElement("td", null, isEligible ? /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + min: "0", + max: draft.return_unit === 'Strip' ? it.remaining_strips : it.remaining_units, + className: `form-control ${isOverLimit ? 'is-invalid' : ''}`, + value: draft.return_qty, + onChange: e => updateReturnDraft(it.sale_item_id, 'return_qty', e.target.value) + }), upp > 1 && /*#__PURE__*/React.createElement("select", { + className: "form-select", + style: { + maxWidth: 80 + }, + value: draft.return_unit, + onChange: e => updateReturnDraft(it.sale_item_id, 'return_unit', e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "Tab" + }, "Tab"), /*#__PURE__*/React.createElement("option", { + value: "Strip" + }, "Strip"))) : /*#__PURE__*/React.createElement("span", { + className: "text-muted small" + }, "-"), isOverLimit && /*#__PURE__*/React.createElement("small", { + className: "text-danger d-block" + }, "Max ", it.remaining_units, " tabs")), /*#__PURE__*/React.createElement("td", null, isEligible && qty > 0 ? /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: draft.condition, + onChange: e => updateReturnDraft(it.sale_item_id, 'condition', e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "GOOD" + }, "Good (Restock)"), /*#__PURE__*/React.createElement("option", { + value: "DAMAGED" + }, "Damaged / Broken"), /*#__PURE__*/React.createElement("option", { + value: "EXPIRED" + }, "Expired / Defective")) : /*#__PURE__*/React.createElement("span", { + className: "text-muted small" + }, "-")), /*#__PURE__*/React.createElement("td", null, isEligible && qty > 0 ? /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: draft.reason, + onChange: e => updateReturnDraft(it.sale_item_id, 'reason', e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "EXCESS_UNUSED" + }, "Excess / Unused"), /*#__PURE__*/React.createElement("option", { + value: "DOCTOR_CHANGED_RX" + }, "Doctor Changed Rx"), /*#__PURE__*/React.createElement("option", { + value: "PATIENT_DISCHARGED" + }, "Patient Discharged"), /*#__PURE__*/React.createElement("option", { + value: "WRONG_MEDICINE" + }, "Wrong Dispense")) : /*#__PURE__*/React.createElement("span", { + className: "text-muted small" + }, "-")), /*#__PURE__*/React.createElement("td", null, "₹", it.effective_unit_price, " ", /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "/tab"), upp > 1 && /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '0.72rem' + } + }, "₹", (it.effective_unit_price * upp).toFixed(2), "/str")), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold" + }, qty > 0 ? /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "-₹", lineCredit.toFixed(2)) : /*#__PURE__*/React.createElement("span", { + className: "text-muted" + }, "₹0.00"))); + }))))), !selectedReturnInvoice && returnSearchResults.length === 0 && /*#__PURE__*/React.createElement("div", { + className: "text-center py-5 text-muted bg-white rounded border" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-receipt-cutoff fs-1 text-secondary mb-2 d-block" + }), /*#__PURE__*/React.createElement("div", { + className: "fw-bold" + }, "No Invoice Selected"), /*#__PURE__*/React.createElement("div", { + className: "small" + }, "Search by Bill Number, Patient UHID, Name, or Mobile to load returnable items."))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer py-2 px-3 bg-white d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("div", null, selectedReturnInvoice && /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-3" + }, (() => { + let totalCredit = 0; + let totalItemsCount = 0; + selectedReturnInvoice.items.forEach(it => { + const draft = returnDraftItems[it.sale_item_id]; + if (draft && Number(draft.return_qty) > 0) { + const qty = Number(draft.return_qty); + const upp = Number(it.units_per_pack) || 1; + const tu = draft.return_unit === 'Strip' ? qty * upp : qty; + totalCredit += tu * it.effective_unit_price; + totalItemsCount++; + } + }); + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", { + className: "text-muted small me-2" + }, "Selected Items: ", /*#__PURE__*/React.createElement("strong", null, totalItemsCount)), /*#__PURE__*/React.createElement("span", { + className: "text-danger fw-bold fs-6" + }, "Total Return Credit: -₹", totalCredit.toFixed(2))); + })())), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-secondary btn-sm", + onClick: () => setShowReturnModal(false) + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-danger btn-sm px-3 fw-bold", + disabled: !selectedReturnInvoice, + onClick: addSelectedReturnsToBill + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cart-plus me-1" + }), " Add to Current Bill (Exchange / Net-Off)")))))), showDraftModal && /*#__PURE__*/React.createElement("div", { + className: "modal show d-block", + tabIndex: "-1", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.75)' + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered modal-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content shadow-lg border-0" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2.5 px-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-phone-vibrate text-warning fs-5" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold mb-0" + }, "Mobile App Rack Drafts Queue"), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "Draft bills collected from pharmacy shelves via smartphone"))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setShowDraftModal(false) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-between mb-3 pb-2 border-bottom" + }, /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn btn-sm ${draftModalTab === 'DRAFT' ? 'btn-warning text-dark fw-bold' : 'btn-outline-secondary'}`, + onClick: () => { + setDraftModalTab('DRAFT'); + loadDraftBills('DRAFT'); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hourglass-split me-1" + }), " Pending Queue"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn btn-sm ${draftModalTab === 'CONVERTED' ? 'btn-success text-white fw-bold' : 'btn-outline-secondary'}`, + onClick: () => { + setDraftModalTab('CONVERTED'); + loadDraftBills('CONVERTED'); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check2-all me-1" + }), " Billed / Converted")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-primary py-0.5 px-2", + onClick: () => loadDraftBills(draftModalTab) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-clockwise me-1" + }), " Refresh")), draftBillsList.length === 0 ? /*#__PURE__*/React.createElement("div", { + className: "text-center py-5 text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-basket3 fs-1 d-block mb-2 text-secondary" + }), /*#__PURE__*/React.createElement("h5", null, draftModalTab === 'CONVERTED' ? 'No Converted Draft Bills' : 'No Pending Draft Bills'), /*#__PURE__*/React.createElement("p", { + className: "small mb-0" + }, draftModalTab === 'CONVERTED' ? 'Draft bills will appear here once converted into pharmacy sales invoices.' : 'Medicines added by rack collectors from the mobile app will automatically show up here.')) : /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-pos table-hover mb-0" + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "Draft Code"), /*#__PURE__*/React.createElement("th", null, "Patient / Ward"), /*#__PURE__*/React.createElement("th", null, "Items"), /*#__PURE__*/React.createElement("th", null, "Est. Amount"), /*#__PURE__*/React.createElement("th", null, "Collector"), /*#__PURE__*/React.createElement("th", null, "Time"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Action"))), /*#__PURE__*/React.createElement("tbody", null, draftBillsList.map(d => /*#__PURE__*/React.createElement("tr", { + key: d.draft_id + }, /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: `badge ${d.status === 'CONVERTED' ? 'bg-secondary' : 'bg-warning text-dark'} fw-bold` + }, d.draft_code)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold" + }, d.patient_name || 'Walk-in'), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, d.ward_name ? `${d.ward_name} / Bed ${d.bed_no}` : d.patient_mobile || 'No bed info')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary rounded-pill" + }, d.total_items, " items")), /*#__PURE__*/React.createElement("td", { + className: "fw-bold text-success" + }, "₹", Number(d.estimated_amount || 0).toFixed(2)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("small", { + className: "text-secondary" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person me-1" + }), d.collected_by_name || 'Staff')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, d.created_at?.split(' ')[1] || d.created_at)), /*#__PURE__*/React.createElement("td", { + className: "text-end" + }, d.status === 'CONVERTED' ? /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success border border-success fw-bold px-2 py-1", + style: { + fontSize: '0.75rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle-fill me-1" + }), " Billed: ", d.converted_invoice_no || 'INV') : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-success fw-bold px-2.5 py-1 me-1 shadow-sm", + onClick: () => handleLoadDraftBillIntoCart(d) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cart-plus me-1" + }), " Load Bill"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-danger py-1 px-1.5", + onClick: () => handleCancelDraft(d.draft_id), + title: "Discard draft" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-trash" + })))))))))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer py-2 px-3 bg-light d-flex justify-content-between" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, draftModalTab === 'DRAFT' ? `${draftBillsList.length} draft bill(s) pending` : `${draftBillsList.length} converted draft bill(s)`), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-secondary", + onClick: () => setShowDraftModal(false) + }, "Close")))))); } // ========================================================================= @@ -7430,12 +5846,11 @@ function InvoicesView({ onEditInPos }) { if (!store) { - return /*#__PURE__*/_jsxs("div", { - className: "text-center py-5 text-muted", - children: [/*#__PURE__*/_jsx("div", { - className: "spinner-border spinner-border-sm text-primary me-2" - }), "Loading invoices register..."] - }); + return /*#__PURE__*/React.createElement("div", { + className: "text-center py-5 text-muted" + }, /*#__PURE__*/React.createElement("div", { + className: "spinner-border spinner-border-sm text-primary me-2" + }), "Loading invoices register..."); } const [invoices, setInvoices] = useState([]); const [stats, setStats] = useState({ @@ -7755,1089 +6170,831 @@ function InvoicesView({ lines.push(center('Medicines cannot be returned without original bill.')); return lines.join('n'); }; - return /*#__PURE__*/_jsxs("div", { - className: "invoices-view-wrapper", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap align-items-center justify-content-between gap-3 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("h5", { - className: "mb-0 fw-bold text-dark d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-receipt-cutoff text-primary fs-4" - }), "Invoices & Sales Register", /*#__PURE__*/_jsxs("span", { - className: "badge bg-primary-subtle text-primary border border-primary-subtle fs-6 rounded-pill px-2.5 py-0.5", - children: [pagination.total_records || 0, " Bills"] - })] - }), /*#__PURE__*/_jsxs("small", { - className: "text-secondary", - children: ["Showing all sales across pharmacy desk ordered ", /*#__PURE__*/_jsx("strong", { - children: "Latest to Oldest" - }), ". Search by bill #, patient, mobile, or doctor."] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-primary d-inline-flex align-items-center gap-1.5", - onClick: () => loadInvoices(page), - disabled: isLoading, - children: [/*#__PURE__*/_jsx("i", { - className: `bi bi-arrow-clockwise {isLoading ? 'spin' : ''}` - }), "Refresh"] - }), onEditInPos && /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-primary-custom d-inline-flex align-items-center gap-1.5", - onClick: () => onEditInPos(null), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cart-plus-fill" - }), "New POS Counter Bill"] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap align-items-center gap-2 mb-3 bg-light p-2.5 rounded-3 border", - children: [/*#__PURE__*/_jsxs("span", { - className: "text-muted small fw-bold me-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-calendar3 me-1" - }), " Quick Filter:"] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: `invoices-date-pill {datePreset === 'today' ? 'active' : ''}`, - onClick: () => handleDatePreset('today'), - children: "Today" - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: `invoices-date-pill {datePreset === 'yesterday' ? 'active' : ''}`, - onClick: () => handleDatePreset('yesterday'), - children: "Yesterday" - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: `invoices-date-pill {datePreset === 'last7' ? 'active' : ''}`, - onClick: () => handleDatePreset('last7'), - children: "Last 7 Days" - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: `invoices-date-pill {datePreset === 'month' ? 'active' : ''}`, - onClick: () => handleDatePreset('month'), - children: "This Month" - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: `invoices-date-pill {datePreset === 'all' ? 'active' : ''}`, - onClick: () => handleDatePreset('all'), - children: "All Records" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-3 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "col-6 col-md-3", - children: /*#__PURE__*/_jsxs("div", { - className: "invoices-stats-card border-start border-primary border-4", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-1", - children: [/*#__PURE__*/_jsx("span", { - className: "text-secondary small fw-bold text-uppercase", - children: "Today's Bills" - }), /*#__PURE__*/_jsx("i", { - className: "bi bi-calendar-check text-primary fs-5" - })] - }), /*#__PURE__*/_jsx("h4", { - className: "fw-bold text-dark mb-0", - children: stats.today_count || 0 - }), /*#__PURE__*/_jsxs("small", { - className: "text-primary fw-semibold", - children: ["₹", Number(stats.today_amount || 0).toLocaleString('en-IN', { - minimumFractionDigits: 2 - })] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-6 col-md-3", - children: /*#__PURE__*/_jsxs("div", { - className: "invoices-stats-card border-start border-success border-4", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-1", - children: [/*#__PURE__*/_jsx("span", { - className: "text-secondary small fw-bold text-uppercase", - children: "Total Invoices" - }), /*#__PURE__*/_jsx("i", { - className: "bi bi-receipt text-success fs-5" - })] - }), /*#__PURE__*/_jsx("h4", { - className: "fw-bold text-dark mb-0", - children: stats.total_count || 0 - }), /*#__PURE__*/_jsxs("small", { - className: "text-success fw-semibold", - children: ["₹", Number(stats.total_amount || 0).toLocaleString('en-IN', { - minimumFractionDigits: 2 - })] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-6 col-md-3", - children: /*#__PURE__*/_jsxs("div", { - className: "invoices-stats-card border-start border-warning border-4", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-1", - children: [/*#__PURE__*/_jsx("span", { - className: "text-secondary small fw-bold text-uppercase", - children: "Returns / Refunds" - }), /*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-return-left text-warning fs-5" - })] - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bold text-dark mb-0", - children: ["₹", Number(stats.total_returns || 0).toLocaleString('en-IN', { - minimumFractionDigits: 2 - })] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "Total customer returns" - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-6 col-md-3", - children: /*#__PURE__*/_jsxs("div", { - className: "invoices-stats-card border-start border-info border-4", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-1", - children: [/*#__PURE__*/_jsx("span", { - className: "text-secondary small fw-bold text-uppercase", - children: "Net Realized" - }), /*#__PURE__*/_jsx("i", { - className: "bi bi-cash-stack text-info fs-5" - })] - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bold text-dark mb-0", - children: ["₹", Number((stats.total_amount || 0) - (stats.total_returns || 0)).toLocaleString('en-IN', { - minimumFractionDigits: 2 - })] - }), /*#__PURE__*/_jsx("small", { - className: "text-info fw-semibold", - children: "Net pharmacy collection" - })] - }) - })] - }), /*#__PURE__*/_jsx("div", { - className: "card border shadow-sm mb-3", - children: /*#__PURE__*/_jsx("div", { - className: "card-body p-3", - children: /*#__PURE__*/_jsxs("form", { - onSubmit: handleSearchSubmit, - className: "row g-2 align-items-center", - children: [/*#__PURE__*/_jsx("div", { - className: "col-12 col-md-4", - children: /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-white text-muted", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-search" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control", - placeholder: "Search Bill #, Patient, Mobile, Doctor...", - value: searchQuery, - onChange: e => setSearchQuery(e.target.value) - }), searchQuery && /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-outline-secondary", - onClick: clearSearch, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-x" - }) - }), /*#__PURE__*/_jsx("button", { - type: "submit", - className: "btn btn-primary px-3", - children: "Search" - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-6 col-md-2", - children: /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-light text-muted", - style: { - fontSize: '0.72rem' - }, - children: "From" - }), /*#__PURE__*/_jsx("input", { - type: "date", - className: "form-control", - value: fromDate, - onChange: e => { - setFromDate(e.target.value); - setDatePreset('custom'); - } - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-6 col-md-2", - children: /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-light text-muted", - style: { - fontSize: '0.72rem' - }, - children: "To" - }), /*#__PURE__*/_jsx("input", { - type: "date", - className: "form-control", - value: toDate, - onChange: e => { - setToDate(e.target.value); - setDatePreset('custom'); - } - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-6 col-md-2", - children: /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: paymentMode, - onChange: e => setPaymentMode(e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "ALL", - children: "All Payments" - }), /*#__PURE__*/_jsx("option", { - value: "Cash", - children: "Cash" - }), /*#__PURE__*/_jsx("option", { - value: "UPI", - children: "UPI / QR" - }), /*#__PURE__*/_jsx("option", { - value: "Card", - children: "Card" - }), /*#__PURE__*/_jsx("option", { - value: "Mixed", - children: "Split / Mixed" - }), /*#__PURE__*/_jsx("option", { - value: "IPD_Credit", - children: "IPD Credit" - })] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-2 d-flex justify-content-end align-items-center gap-2", - children: [/*#__PURE__*/_jsx("label", { - className: "text-muted small mb-0", - children: "Show:" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - style: { - width: 80 - }, - value: limit, - onChange: e => setLimit(Number(e.target.value)), - children: [/*#__PURE__*/_jsx("option", { - value: "15", - children: "15" - }), /*#__PURE__*/_jsx("option", { - value: "25", - children: "25" - }), /*#__PURE__*/_jsx("option", { - value: "50", - children: "50" - }), /*#__PURE__*/_jsx("option", { - value: "100", - children: "100" - })] - })] - })] - }) - }) - }), /*#__PURE__*/_jsxs("div", { - className: "card border shadow-sm mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-hover align-middle mb-0 invoices-table", - children: [/*#__PURE__*/_jsx("thead", { - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - style: { - width: 140 - }, - children: "Invoice No" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 130 - }, - children: "Date & Time" - }), /*#__PURE__*/_jsx("th", { - children: "Patient Details" - }), /*#__PURE__*/_jsx("th", { - children: "Doctor" - }), /*#__PURE__*/_jsx("th", { - children: "Items Dispensed" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 100 - }, - children: "Payment" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - style: { - width: 110 - }, - children: "Net Total" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - style: { - width: 90 - }, - children: "Status" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - style: { - width: 220 - }, - children: "Actions" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: isLoading ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "9", - className: "text-center py-5 text-muted", - children: [/*#__PURE__*/_jsx("div", { - className: "spinner-border spinner-border-sm text-primary me-2" - }), "Loading invoices..."] - }) - }) : invoices.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "9", - className: "text-center py-5 text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-inbox fs-2 d-block mb-2 text-secondary" - }), /*#__PURE__*/_jsx("h6", { - children: "No invoices found" - }), /*#__PURE__*/_jsx("p", { - className: "small mb-0", - children: "Try changing your search query or date range filters." - })] - }) - }) : invoices.map(inv => { - const hasReturns = Number(inv.return_amount) > 0; - return /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-dark-subtle text-dark border font-monospace px-2 py-1 fs-6 cursor-pointer", - onClick: () => openPrintDrawer(inv.sale_id), - title: "Click to View / Print Invoice", - style: { - cursor: 'pointer' - }, - children: inv.invoice_no - }), inv.abdm_care_context_ref && /*#__PURE__*/_jsxs("span", { - className: "d-block mt-1 text-success", - style: { - fontSize: '0.68rem' - }, - title: "ABDM Linked", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-fill-check me-0.5" - }), " ABDM"] - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-semibold text-dark", - style: { - fontSize: '0.82rem' - }, - children: String(inv.sale_date).slice(0, 10) - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - style: { - fontSize: '0.72rem' - }, - children: String(inv.sale_date).slice(11, 16) - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-dark", - children: inv.patient_name || 'Walk-in Customer' - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-1 flex-wrap mt-0.5", - children: [inv.uhid && /*#__PURE__*/_jsx("span", { - className: "badge bg-light text-primary border", - style: { - fontSize: '0.68rem' - }, - children: inv.uhid - }), inv.patient_mobile && /*#__PURE__*/_jsxs("span", { - className: "text-muted", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-telephone me-0.5" - }), " ", inv.patient_mobile] - }), /*#__PURE__*/_jsx("span", { - className: `badge {inv.patient_type === 'IPD' ? 'bg-danger-subtle text-danger' : (inv.patient_type === 'OPD' ? 'bg-primary-subtle text-primary' : 'bg-secondary-subtle text-secondary')}`, - style: { - fontSize: '0.65rem' - }, - children: inv.patient_type || 'Walk-in' - })] - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "text-dark fw-medium", - style: { - fontSize: '0.82rem' - }, - children: inv.doctor_name || 'Self / Walk-in' - }), inv.doctor_reg_no && /*#__PURE__*/_jsxs("small", { - className: "text-muted", - style: { - fontSize: '0.7rem' - }, - children: ["Reg: ", inv.doctor_reg_no] - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "d-flex align-items-center gap-1 mb-0.5", - children: /*#__PURE__*/_jsxs("span", { - className: "badge bg-info-subtle text-info border border-info-subtle", - style: { - fontSize: '0.7rem' - }, - children: [inv.items_count || 0, " items"] - }) - }), /*#__PURE__*/_jsx("div", { - className: "text-secondary text-truncate", - style: { - maxWidth: 220, - fontSize: '0.75rem' - }, - title: inv.items_summary, - children: inv.items_summary || 'N/A' - })] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: `badge {inv.payment_mode === 'Cash' ? 'bg-success-subtle text-success border border-success-subtle' : (inv.payment_mode === 'UPI' ? 'bg-info-subtle text-info border border-info-subtle' : (inv.payment_mode === 'Card' ? 'bg-primary-subtle text-primary border border-primary-subtle' : 'bg-warning-subtle text-warning-emphasis border border-warning-subtle'))}`, - children: inv.payment_mode || 'Cash' - }) - }), /*#__PURE__*/_jsxs("td", { - className: "text-end", - children: [/*#__PURE__*/_jsxs("div", { - className: "fw-bold text-dark fs-6", - children: ["₹", Number(inv.net_amount).toFixed(2)] - }), Number(inv.discount_amount) > 0 && /*#__PURE__*/_jsxs("small", { - className: "text-danger d-block", - style: { - fontSize: '0.7rem' - }, - children: ["Disc: -₹", Number(inv.discount_amount).toFixed(2)] - }), hasReturns && /*#__PURE__*/_jsxs("small", { - className: "text-warning-emphasis d-block", - style: { - fontSize: '0.7rem' - }, - children: ["Ret: -₹", Number(inv.return_amount).toFixed(2)] - })] - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: hasReturns ? /*#__PURE__*/_jsx("span", { - className: "badge bg-warning text-dark", - style: { - fontSize: '0.7rem' - }, - children: "Exchange" - }) : /*#__PURE__*/_jsx("span", { - className: "badge bg-success-subtle text-success border border-success-subtle", - style: { - fontSize: '0.7rem' - }, - children: "Paid" - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-center gap-1", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-outline-primary py-1 px-2 d-inline-flex align-items-center gap-1", - onClick: () => openPrintDrawer(inv.sale_id), - title: "View & Print Invoice (Thermal, A5 Landscape, A4)", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer" - }), /*#__PURE__*/_jsx("span", { - children: "View" - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-outline-secondary py-1 px-2 d-inline-flex align-items-center gap-1", - onClick: () => openEditModal(inv), - title: "Quick Edit Patient Name, Mobile, Doctor, Payment Mode", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-pencil" - }), /*#__PURE__*/_jsx("span", { - children: "Edit" - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-success py-1 px-2 d-inline-flex align-items-center gap-1", - onClick: () => handleEditInPos(inv.sale_id), - title: "Open in POS Counter Desk to edit medicines, quantities, or re-bill", - style: { - fontSize: '0.72rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cart3" - }), /*#__PURE__*/_jsx("span", { - children: "Edit in POS" - })] - })] - }) - })] - }, inv.sale_id); - }) - })] - }) - }), pagination.total_pages > 1 && /*#__PURE__*/_jsxs("div", { - className: "card-footer bg-white d-flex flex-wrap justify-content-between align-items-center py-2 px-3", - children: [/*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: ["Showing page ", /*#__PURE__*/_jsx("strong", { - children: pagination.current_page - }), " of ", /*#__PURE__*/_jsx("strong", { - children: pagination.total_pages - }), " (", pagination.total_records, " total invoices)"] - }), /*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-outline-secondary", - disabled: pagination.current_page <= 1 || isLoading, - onClick: () => loadInvoices(pagination.current_page - 1), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-chevron-left" - }), " Prev"] - }), /*#__PURE__*/_jsxs("span", { - className: "btn btn-outline-secondary disabled fw-bold text-dark px-3", - children: [pagination.current_page, " / ", pagination.total_pages] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-outline-secondary", - disabled: pagination.current_page >= pagination.total_pages || isLoading, - onClick: () => loadInvoices(pagination.current_page + 1), - children: ["Next ", /*#__PURE__*/_jsx("i", { - className: "bi bi-chevron-right" - })] - })] - })] - })] - }), editModalSale && /*#__PURE__*/_jsx("div", { - className: "modal fade show d-block", + return /*#__PURE__*/React.createElement("div", { + className: "invoices-view-wrapper" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap align-items-center justify-content-between gap-3 mb-3" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h5", { + className: "mb-0 fw-bold text-dark d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-receipt-cutoff text-primary fs-4" + }), "Invoices & Sales Register", /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary border border-primary-subtle fs-6 rounded-pill px-2.5 py-0.5" + }, pagination.total_records || 0, " Bills")), /*#__PURE__*/React.createElement("small", { + className: "text-secondary" + }, "Showing all sales across pharmacy desk ordered ", /*#__PURE__*/React.createElement("strong", null, "Latest to Oldest"), ". Search by bill #, patient, mobile, or doctor.")), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-primary d-inline-flex align-items-center gap-1.5", + onClick: () => loadInvoices(page), + disabled: isLoading + }, /*#__PURE__*/React.createElement("i", { + className: `bi bi-arrow-clockwise {isLoading ? 'spin' : ''}` + }), "Refresh"), onEditInPos && /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-primary-custom d-inline-flex align-items-center gap-1.5", + onClick: () => onEditInPos(null) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cart-plus-fill" + }), "New POS Counter Bill"))), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap align-items-center gap-2 mb-3 bg-light p-2.5 rounded-3 border" + }, /*#__PURE__*/React.createElement("span", { + className: "text-muted small fw-bold me-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-calendar3 me-1" + }), " Quick Filter:"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `invoices-date-pill {datePreset === 'today' ? 'active' : ''}`, + onClick: () => handleDatePreset('today') + }, "Today"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `invoices-date-pill {datePreset === 'yesterday' ? 'active' : ''}`, + onClick: () => handleDatePreset('yesterday') + }, "Yesterday"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `invoices-date-pill {datePreset === 'last7' ? 'active' : ''}`, + onClick: () => handleDatePreset('last7') + }, "Last 7 Days"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `invoices-date-pill {datePreset === 'month' ? 'active' : ''}`, + onClick: () => handleDatePreset('month') + }, "This Month"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `invoices-date-pill {datePreset === 'all' ? 'active' : ''}`, + onClick: () => handleDatePreset('all') + }, "All Records")), /*#__PURE__*/React.createElement("div", { + className: "row g-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("div", { + className: "invoices-stats-card border-start border-primary border-4" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-1" + }, /*#__PURE__*/React.createElement("span", { + className: "text-secondary small fw-bold text-uppercase" + }, "Today's Bills"), /*#__PURE__*/React.createElement("i", { + className: "bi bi-calendar-check text-primary fs-5" + })), /*#__PURE__*/React.createElement("h4", { + className: "fw-bold text-dark mb-0" + }, stats.today_count || 0), /*#__PURE__*/React.createElement("small", { + className: "text-primary fw-semibold" + }, "₹", Number(stats.today_amount || 0).toLocaleString('en-IN', { + minimumFractionDigits: 2 + })))), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("div", { + className: "invoices-stats-card border-start border-success border-4" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-1" + }, /*#__PURE__*/React.createElement("span", { + className: "text-secondary small fw-bold text-uppercase" + }, "Total Invoices"), /*#__PURE__*/React.createElement("i", { + className: "bi bi-receipt text-success fs-5" + })), /*#__PURE__*/React.createElement("h4", { + className: "fw-bold text-dark mb-0" + }, stats.total_count || 0), /*#__PURE__*/React.createElement("small", { + className: "text-success fw-semibold" + }, "₹", Number(stats.total_amount || 0).toLocaleString('en-IN', { + minimumFractionDigits: 2 + })))), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("div", { + className: "invoices-stats-card border-start border-warning border-4" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-1" + }, /*#__PURE__*/React.createElement("span", { + className: "text-secondary small fw-bold text-uppercase" + }, "Returns / Refunds"), /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-return-left text-warning fs-5" + })), /*#__PURE__*/React.createElement("h4", { + className: "fw-bold text-dark mb-0" + }, "₹", Number(stats.total_returns || 0).toLocaleString('en-IN', { + minimumFractionDigits: 2 + })), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "Total customer returns"))), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("div", { + className: "invoices-stats-card border-start border-info border-4" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-1" + }, /*#__PURE__*/React.createElement("span", { + className: "text-secondary small fw-bold text-uppercase" + }, "Net Realized"), /*#__PURE__*/React.createElement("i", { + className: "bi bi-cash-stack text-info fs-5" + })), /*#__PURE__*/React.createElement("h4", { + className: "fw-bold text-dark mb-0" + }, "₹", Number((stats.total_amount || 0) - (stats.total_returns || 0)).toLocaleString('en-IN', { + minimumFractionDigits: 2 + })), /*#__PURE__*/React.createElement("small", { + className: "text-info fw-semibold" + }, "Net pharmacy collection")))), /*#__PURE__*/React.createElement("div", { + className: "card border shadow-sm mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "card-body p-3" + }, /*#__PURE__*/React.createElement("form", { + onSubmit: handleSearchSubmit, + className: "row g-2 align-items-center" + }, /*#__PURE__*/React.createElement("div", { + className: "col-12 col-md-4" + }, /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-white text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control", + placeholder: "Search Bill #, Patient, Mobile, Doctor...", + value: searchQuery, + onChange: e => setSearchQuery(e.target.value) + }), searchQuery && /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-outline-secondary", + onClick: clearSearch + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x" + })), /*#__PURE__*/React.createElement("button", { + type: "submit", + className: "btn btn-primary px-3" + }, "Search"))), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-2" + }, /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light text-muted", + style: { + fontSize: '0.72rem' + } + }, "From"), /*#__PURE__*/React.createElement("input", { + type: "date", + className: "form-control", + value: fromDate, + onChange: e => { + setFromDate(e.target.value); + setDatePreset('custom'); + } + }))), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-2" + }, /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light text-muted", + style: { + fontSize: '0.72rem' + } + }, "To"), /*#__PURE__*/React.createElement("input", { + type: "date", + className: "form-control", + value: toDate, + onChange: e => { + setToDate(e.target.value); + setDatePreset('custom'); + } + }))), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-2" + }, /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: paymentMode, + onChange: e => setPaymentMode(e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "ALL" + }, "All Payments"), /*#__PURE__*/React.createElement("option", { + value: "Cash" + }, "Cash"), /*#__PURE__*/React.createElement("option", { + value: "UPI" + }, "UPI / QR"), /*#__PURE__*/React.createElement("option", { + value: "Card" + }, "Card"), /*#__PURE__*/React.createElement("option", { + value: "Mixed" + }, "Split / Mixed"), /*#__PURE__*/React.createElement("option", { + value: "IPD_Credit" + }, "IPD Credit"))), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-2 d-flex justify-content-end align-items-center gap-2" + }, /*#__PURE__*/React.createElement("label", { + className: "text-muted small mb-0" + }, "Show:"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + style: { + width: 80 + }, + value: limit, + onChange: e => setLimit(Number(e.target.value)) + }, /*#__PURE__*/React.createElement("option", { + value: "15" + }, "15"), /*#__PURE__*/React.createElement("option", { + value: "25" + }, "25"), /*#__PURE__*/React.createElement("option", { + value: "50" + }, "50"), /*#__PURE__*/React.createElement("option", { + value: "100" + }, "100")))))), /*#__PURE__*/React.createElement("div", { + className: "card border shadow-sm mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-hover align-middle mb-0 invoices-table" + }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", { + style: { + width: 140 + } + }, "Invoice No"), /*#__PURE__*/React.createElement("th", { + style: { + width: 130 + } + }, "Date & Time"), /*#__PURE__*/React.createElement("th", null, "Patient Details"), /*#__PURE__*/React.createElement("th", null, "Doctor"), /*#__PURE__*/React.createElement("th", null, "Items Dispensed"), /*#__PURE__*/React.createElement("th", { + style: { + width: 100 + } + }, "Payment"), /*#__PURE__*/React.createElement("th", { + className: "text-end", + style: { + width: 110 + } + }, "Net Total"), /*#__PURE__*/React.createElement("th", { + className: "text-center", + style: { + width: 90 + } + }, "Status"), /*#__PURE__*/React.createElement("th", { + className: "text-center", + style: { + width: 220 + } + }, "Actions"))), /*#__PURE__*/React.createElement("tbody", null, isLoading ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "9", + className: "text-center py-5 text-muted" + }, /*#__PURE__*/React.createElement("div", { + className: "spinner-border spinner-border-sm text-primary me-2" + }), "Loading invoices...")) : invoices.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "9", + className: "text-center py-5 text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-inbox fs-2 d-block mb-2 text-secondary" + }), /*#__PURE__*/React.createElement("h6", null, "No invoices found"), /*#__PURE__*/React.createElement("p", { + className: "small mb-0" + }, "Try changing your search query or date range filters."))) : invoices.map(inv => { + const hasReturns = Number(inv.return_amount) > 0; + return /*#__PURE__*/React.createElement("tr", { + key: inv.sale_id + }, /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-dark-subtle text-dark border font-monospace px-2 py-1 fs-6 cursor-pointer", + onClick: () => openPrintDrawer(inv.sale_id), + title: "Click to View / Print Invoice", style: { - backgroundColor: 'rgba(15, 23, 42, 0.65)', - backdropFilter: 'blur(3px)', - zIndex: 1060 + cursor: 'pointer' + } + }, inv.invoice_no), inv.abdm_care_context_ref && /*#__PURE__*/React.createElement("span", { + className: "d-block mt-1 text-success", + style: { + fontSize: '0.68rem' }, - tabIndex: "-1", - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered modal-lg", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content border-0 shadow-lg rounded-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2.5 px-3", - children: [/*#__PURE__*/_jsxs("h6", { - className: "modal-title mb-0 fw-bold d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-pencil-square text-warning" - }), "Edit Invoice Details: ", /*#__PURE__*/_jsx("span", { - className: "text-info", - children: editModalSale.invoice_no - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setEditModalSale(null) - })] - }), /*#__PURE__*/_jsxs("form", { - onSubmit: handleSaveEdit, - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-body p-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "alert alert-info py-1.5 px-2.5 mb-3", - style: { - fontSize: '0.78rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-info-circle me-1" - }), "Use this to correct patient information, doctor name, or payment mode on this completed bill. To modify medicine quantities or items, click ", /*#__PURE__*/_jsx("strong", { - children: "\"Edit in POS\"" - }), " in the main table."] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "Patient Name" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: editForm.patient_name, - onChange: e => setEditForm({ - ...editForm, - patient_name: e.target.value - }), - required: true - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "Mobile Number" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: editForm.patient_mobile, - onChange: e => setEditForm({ - ...editForm, - patient_mobile: e.target.value - }), - placeholder: "10-digit mobile" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "Age" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: editForm.age, - onChange: e => setEditForm({ - ...editForm, - age: e.target.value - }), - placeholder: "e.g. 45 Y" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "Gender" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: editForm.gender, - onChange: e => setEditForm({ - ...editForm, - gender: e.target.value - }), - children: [/*#__PURE__*/_jsx("option", { - value: "", - children: "Select Gender" - }), /*#__PURE__*/_jsx("option", { - value: "Male", - children: "Male" - }), /*#__PURE__*/_jsx("option", { - value: "Female", - children: "Female" - }), /*#__PURE__*/_jsx("option", { - value: "Other", - children: "Other" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "Payment Mode" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: editForm.payment_mode, - onChange: e => setEditForm({ - ...editForm, - payment_mode: e.target.value - }), - children: [/*#__PURE__*/_jsx("option", { - value: "Cash", - children: "Cash" - }), /*#__PURE__*/_jsx("option", { - value: "UPI", - children: "UPI / QR" - }), /*#__PURE__*/_jsx("option", { - value: "Card", - children: "Card" - }), /*#__PURE__*/_jsx("option", { - value: "Mixed", - children: "Mixed / Split" - }), /*#__PURE__*/_jsx("option", { - value: "IPD_Credit", - children: "IPD Credit" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "Doctor Name" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: editForm.doctor_name, - onChange: e => setEditForm({ - ...editForm, - doctor_name: e.target.value - }), - placeholder: "Prescribing doctor" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "Doctor Reg No" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: editForm.doctor_reg_no, - onChange: e => setEditForm({ - ...editForm, - doctor_reg_no: e.target.value - }), - placeholder: "MCI / State Medical Council Reg No" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "Patient Address" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: editForm.patient_address, - onChange: e => setEditForm({ - ...editForm, - patient_address: e.target.value - }), - placeholder: "Address / City" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "Payment Ref / UPI UTR / Bank" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: editForm.payment_reference || editForm.upi_ref_no || editForm.card_ref_no, - onChange: e => setEditForm({ - ...editForm, - payment_reference: e.target.value, - upi_ref_no: e.target.value - }), - placeholder: "Transaction reference ID" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-12", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "Audit Notes / Remarks" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: editForm.remarks, - onChange: e => setEditForm({ - ...editForm, - remarks: e.target.value - }), - placeholder: "Reason for correction or cashier notes" - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer bg-light py-2 px-3 d-flex justify-content-between", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-secondary", - onClick: () => setEditModalSale(null), - children: "Cancel" - }), /*#__PURE__*/_jsx("button", { - type: "submit", - className: "btn btn-sm btn-primary px-3 fw-bold", - disabled: isUpdating, - children: isUpdating ? /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hourglass-split me-1" - }), " Saving..."] - }) : /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle me-1" - }), " Save Changes"] - }) - })] - })] - })] - }) - }) - }), /*#__PURE__*/_jsx("div", { - className: `print-drawer-overlay {isPrintOpen ? 'open' : ''}`, - onClick: () => setIsPrintOpen(false) - }), /*#__PURE__*/_jsx("div", { - className: `print-drawer {isPrintOpen ? 'open' : ''}`, - id: "invoices-print-drawer", - children: viewInvoice && /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsxs("div", { - className: "print-drawer-header", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-receipt text-warning fs-5" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "mb-0 fw-bold text-white", - children: "Invoice & Print Desk" - }), /*#__PURE__*/_jsxs("small", { - className: "text-secondary", - style: { - fontSize: '0.72rem' - }, - children: ["Bill: ", /*#__PURE__*/_jsx("span", { - className: "text-info fw-bold", - children: viewInvoice.sale.invoice_no - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-1.5 flex-wrap", - children: [/*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm", - children: [/*#__PURE__*/_jsxs("button", { - className: `btn btn-xs py-1 px-2 {printFormat === 'thermal' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light text-white'}`, - style: { - fontSize: '0.72rem' - }, - onClick: () => setPrintFormat('thermal'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-receipt me-1" - }), " Thermal (Text)"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-xs py-1 px-2 {printFormat === 'a5' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light text-white'}`, - style: { - fontSize: '0.72rem' - }, - onClick: () => setPrintFormat('a5'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-pdf me-1" - }), " A5 Landscape (PDF)"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-xs py-1 px-2 {printFormat === 'a4' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light text-white'}`, - style: { - fontSize: '0.72rem' - }, - onClick: () => setPrintFormat('a4'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-pdf me-1" - }), " A4 (PDF)"] - })] - }), printFormat === 'thermal' ? /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-warning text-dark fw-bold py-1 px-2.5 ms-0.5", - onClick: printThermalReceipt, - title: "Print on 80mm Thermal Receipt Printer", - style: { - fontSize: '0.75rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer-fill me-1" - }), " Print Thermal"] - }) : /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-light py-1 px-2 text-white", - onClick: () => downloadPdf(printFormat), - title: "Download PDF Document", - style: { - fontSize: '0.75rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-download me-1 text-info" - }), " PDF"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-primary py-1 px-2.5 ms-0.5 fw-bold", - onClick: () => printPdf(printFormat), - title: "Print Clean Vector PDF", - style: { - fontSize: '0.75rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer me-1" - }), " Print PDF (", printFormat === 'a5' ? 'A5 LANDSCAPE' : printFormat.toUpperCase(), ")"] - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-light rounded-pill px-2.5 py-1 ms-1 d-flex align-items-center gap-1", - onClick: () => setIsPrintOpen(false), - title: "Close Print Drawer (Esc)", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-x-lg" - }), /*#__PURE__*/_jsx("kbd", { - style: { - background: '#334155', - color: '#f8fafc', - fontSize: '0.62rem', - padding: '1px 3px', - borderRadius: '3px' - }, - children: "Esc" - })] - })] - })] - }), /*#__PURE__*/_jsx("div", { - className: "print-drawer-body", - children: /*#__PURE__*/_jsx("div", { - className: "print-paper-card", - children: /*#__PURE__*/_jsxs("div", { - id: "printable-container", - children: [printFormat === 'thermal' && /*#__PURE__*/_jsxs("div", { - className: "p-2 text-center", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-2 px-2 pb-2 border-bottom", - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-secondary", - children: "Thermal 80mm ESC/POS Text" - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-xs btn-warning text-dark fw-bold", - onClick: printThermalReceipt, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer-fill me-1" - }), " Print Thermal Receipt"] - })] - }), /*#__PURE__*/_jsx("pre", { - style: { - fontFamily: '"Courier New", Courier, monospace', - fontSize: '12px', - lineHeight: '1.2', - color: '#000000', - backgroundColor: '#ffffff', - padding: '12px', - margin: '0 auto', - maxWidth: '380px', - textAlign: 'left', - whiteSpace: 'pre-wrap', - wordBreak: 'break-word', - border: '1px dashed #cbd5e1', - borderRadius: '6px' - }, - children: generateThermalReceiptText(viewInvoice) - })] - }), printFormat === 'a5' && /*#__PURE__*/_jsxs("div", { - className: "p-3 text-center print-a5-invoice", - style: { - maxWidth: '820px', - margin: '0 auto' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "alert alert-info py-1.5 px-3 mb-3 d-flex justify-content-between align-items-center shadow-sm", - style: { - fontSize: '0.78rem' - }, - children: [/*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-pdf-fill me-1" - }), /*#__PURE__*/_jsx("strong", { - children: "A5 Landscape PDF (210mm × 148mm):" - }), " Native vector document rendered by mPDF."] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-1.5", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-xs btn-outline-primary py-1 px-2", - onClick: () => downloadPdf('a5'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-download me-1" - }), " Download"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-xs btn-primary py-1 px-2.5 fw-bold", - onClick: () => printPdf('a5'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer me-1" - }), " Print PDF (A5 Landscape)"] - })] - })] - }), /*#__PURE__*/_jsx("div", { - className: "border rounded shadow-sm overflow-hidden", - style: { - background: '#525659', - padding: '12px' - }, - children: /*#__PURE__*/_jsx("iframe", { - src: `{API_BASE}sales/invoice-pdf/{viewInvoice.sale.sale_id}?format=a5&view=1`, - title: "A5 Landscape PDF Preview", - style: { - width: '100%', - height: '540px', - border: 'none', - borderRadius: '4px', - background: '#ffffff' - } - }) - })] - }), printFormat === 'a4' && /*#__PURE__*/_jsxs("div", { - className: "p-3 text-center print-a4-invoice", - style: { - maxWidth: '780px', - margin: '0 auto' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "alert alert-info py-1.5 px-3 mb-3 d-flex justify-content-between align-items-center shadow-sm", - style: { - fontSize: '0.78rem' - }, - children: [/*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-pdf-fill me-1" - }), /*#__PURE__*/_jsx("strong", { - children: "A4 Vector PDF (210mm × 297mm):" - }), " Native vector document rendered by mPDF."] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-1.5", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-xs btn-outline-primary py-1 px-2", - onClick: () => downloadPdf('a4'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-download me-1" - }), " Download"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-xs btn-primary py-1 px-2.5 fw-bold", - onClick: () => printPdf('a4'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer me-1" - }), " Print PDF (A4)"] - })] - })] - }), /*#__PURE__*/_jsx("div", { - className: "border rounded shadow-sm overflow-hidden", - style: { - background: '#525659', - padding: '12px' - }, - children: /*#__PURE__*/_jsx("iframe", { - src: `{API_BASE}sales/invoice-pdf/{viewInvoice.sale.sale_id}?format=a4&view=1`, - title: "A4 PDF Preview", - style: { - width: '100%', - height: '620px', - border: 'none', - borderRadius: '4px', - background: '#ffffff' - } - }) - })] - })] - }) - }) - })] - }) - })] - }); + title: "ABDM Linked" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-fill-check me-0.5" + }), " ABDM")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-semibold text-dark", + style: { + fontSize: '0.82rem' + } + }, String(inv.sale_date).slice(0, 10)), /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '0.72rem' + } + }, String(inv.sale_date).slice(11, 16))), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark" + }, inv.patient_name || 'Walk-in Customer'), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-1 flex-wrap mt-0.5" + }, inv.uhid && /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-primary border", + style: { + fontSize: '0.68rem' + } + }, inv.uhid), inv.patient_mobile && /*#__PURE__*/React.createElement("span", { + className: "text-muted", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-telephone me-0.5" + }), " ", inv.patient_mobile), /*#__PURE__*/React.createElement("span", { + className: `badge {inv.patient_type === 'IPD' ? 'bg-danger-subtle text-danger' : (inv.patient_type === 'OPD' ? 'bg-primary-subtle text-primary' : 'bg-secondary-subtle text-secondary')}`, + style: { + fontSize: '0.65rem' + } + }, inv.patient_type || 'Walk-in'))), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "text-dark fw-medium", + style: { + fontSize: '0.82rem' + } + }, inv.doctor_name || 'Self / Walk-in'), inv.doctor_reg_no && /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '0.7rem' + } + }, "Reg: ", inv.doctor_reg_no)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-1 mb-0.5" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-info-subtle text-info border border-info-subtle", + style: { + fontSize: '0.7rem' + } + }, inv.items_count || 0, " items")), /*#__PURE__*/React.createElement("div", { + className: "text-secondary text-truncate", + style: { + maxWidth: 220, + fontSize: '0.75rem' + }, + title: inv.items_summary + }, inv.items_summary || 'N/A')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: `badge {inv.payment_mode === 'Cash' ? 'bg-success-subtle text-success border border-success-subtle' : (inv.payment_mode === 'UPI' ? 'bg-info-subtle text-info border border-info-subtle' : (inv.payment_mode === 'Card' ? 'bg-primary-subtle text-primary border border-primary-subtle' : 'bg-warning-subtle text-warning-emphasis border border-warning-subtle'))}` + }, inv.payment_mode || 'Cash')), /*#__PURE__*/React.createElement("td", { + className: "text-end" + }, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark fs-6" + }, "₹", Number(inv.net_amount).toFixed(2)), Number(inv.discount_amount) > 0 && /*#__PURE__*/React.createElement("small", { + className: "text-danger d-block", + style: { + fontSize: '0.7rem' + } + }, "Disc: -₹", Number(inv.discount_amount).toFixed(2)), hasReturns && /*#__PURE__*/React.createElement("small", { + className: "text-warning-emphasis d-block", + style: { + fontSize: '0.7rem' + } + }, "Ret: -₹", Number(inv.return_amount).toFixed(2))), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, hasReturns ? /*#__PURE__*/React.createElement("span", { + className: "badge bg-warning text-dark", + style: { + fontSize: '0.7rem' + } + }, "Exchange") : /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success border border-success-subtle", + style: { + fontSize: '0.7rem' + } + }, "Paid")), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-center gap-1" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-primary py-1 px-2 d-inline-flex align-items-center gap-1", + onClick: () => openPrintDrawer(inv.sale_id), + title: "View & Print Invoice (Thermal, A5 Landscape, A4)", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer" + }), /*#__PURE__*/React.createElement("span", null, "View")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-secondary py-1 px-2 d-inline-flex align-items-center gap-1", + onClick: () => openEditModal(inv), + title: "Quick Edit Patient Name, Mobile, Doctor, Payment Mode", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-pencil" + }), /*#__PURE__*/React.createElement("span", null, "Edit")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-success py-1 px-2 d-inline-flex align-items-center gap-1", + onClick: () => handleEditInPos(inv.sale_id), + title: "Open in POS Counter Desk to edit medicines, quantities, or re-bill", + style: { + fontSize: '0.72rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cart3" + }), /*#__PURE__*/React.createElement("span", null, "Edit in POS"))))); + })))), pagination.total_pages > 1 && /*#__PURE__*/React.createElement("div", { + className: "card-footer bg-white d-flex flex-wrap justify-content-between align-items-center py-2 px-3" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "Showing page ", /*#__PURE__*/React.createElement("strong", null, pagination.current_page), " of ", /*#__PURE__*/React.createElement("strong", null, pagination.total_pages), " (", pagination.total_records, " total invoices)"), /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-secondary", + disabled: pagination.current_page <= 1 || isLoading, + onClick: () => loadInvoices(pagination.current_page - 1) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-chevron-left" + }), " Prev"), /*#__PURE__*/React.createElement("span", { + className: "btn btn-outline-secondary disabled fw-bold text-dark px-3" + }, pagination.current_page, " / ", pagination.total_pages), /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-secondary", + disabled: pagination.current_page >= pagination.total_pages || isLoading, + onClick: () => loadInvoices(pagination.current_page + 1) + }, "Next ", /*#__PURE__*/React.createElement("i", { + className: "bi bi-chevron-right" + }))))), editModalSale && /*#__PURE__*/React.createElement("div", { + className: "modal fade show d-block", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.65)', + backdropFilter: 'blur(3px)', + zIndex: 1060 + }, + tabIndex: "-1" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered modal-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content border-0 shadow-lg rounded-3" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2.5 px-3" + }, /*#__PURE__*/React.createElement("h6", { + className: "modal-title mb-0 fw-bold d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-pencil-square text-warning" + }), "Edit Invoice Details: ", /*#__PURE__*/React.createElement("span", { + className: "text-info" + }, editModalSale.invoice_no)), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setEditModalSale(null) + })), /*#__PURE__*/React.createElement("form", { + onSubmit: handleSaveEdit + }, /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3" + }, /*#__PURE__*/React.createElement("div", { + className: "alert alert-info py-1.5 px-2.5 mb-3", + style: { + fontSize: '0.78rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-info-circle me-1" + }), "Use this to correct patient information, doctor name, or payment mode on this completed bill. To modify medicine quantities or items, click ", /*#__PURE__*/React.createElement("strong", null, "\"Edit in POS\""), " in the main table."), /*#__PURE__*/React.createElement("div", { + className: "row g-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "Patient Name"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: editForm.patient_name, + onChange: e => setEditForm({ + ...editForm, + patient_name: e.target.value + }), + required: true + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "Mobile Number"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: editForm.patient_mobile, + onChange: e => setEditForm({ + ...editForm, + patient_mobile: e.target.value + }), + placeholder: "10-digit mobile" + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "Age"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: editForm.age, + onChange: e => setEditForm({ + ...editForm, + age: e.target.value + }), + placeholder: "e.g. 45 Y" + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "Gender"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: editForm.gender, + onChange: e => setEditForm({ + ...editForm, + gender: e.target.value + }) + }, /*#__PURE__*/React.createElement("option", { + value: "" + }, "Select Gender"), /*#__PURE__*/React.createElement("option", { + value: "Male" + }, "Male"), /*#__PURE__*/React.createElement("option", { + value: "Female" + }, "Female"), /*#__PURE__*/React.createElement("option", { + value: "Other" + }, "Other"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "Payment Mode"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: editForm.payment_mode, + onChange: e => setEditForm({ + ...editForm, + payment_mode: e.target.value + }) + }, /*#__PURE__*/React.createElement("option", { + value: "Cash" + }, "Cash"), /*#__PURE__*/React.createElement("option", { + value: "UPI" + }, "UPI / QR"), /*#__PURE__*/React.createElement("option", { + value: "Card" + }, "Card"), /*#__PURE__*/React.createElement("option", { + value: "Mixed" + }, "Mixed / Split"), /*#__PURE__*/React.createElement("option", { + value: "IPD_Credit" + }, "IPD Credit"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "Doctor Name"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: editForm.doctor_name, + onChange: e => setEditForm({ + ...editForm, + doctor_name: e.target.value + }), + placeholder: "Prescribing doctor" + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "Doctor Reg No"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: editForm.doctor_reg_no, + onChange: e => setEditForm({ + ...editForm, + doctor_reg_no: e.target.value + }), + placeholder: "MCI / State Medical Council Reg No" + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "Patient Address"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: editForm.patient_address, + onChange: e => setEditForm({ + ...editForm, + patient_address: e.target.value + }), + placeholder: "Address / City" + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "Payment Ref / UPI UTR / Bank"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: editForm.payment_reference || editForm.upi_ref_no || editForm.card_ref_no, + onChange: e => setEditForm({ + ...editForm, + payment_reference: e.target.value, + upi_ref_no: e.target.value + }), + placeholder: "Transaction reference ID" + })), /*#__PURE__*/React.createElement("div", { + className: "col-12" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "Audit Notes / Remarks"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: editForm.remarks, + onChange: e => setEditForm({ + ...editForm, + remarks: e.target.value + }), + placeholder: "Reason for correction or cashier notes" + })))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer bg-light py-2 px-3 d-flex justify-content-between" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-secondary", + onClick: () => setEditModalSale(null) + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + type: "submit", + className: "btn btn-sm btn-primary px-3 fw-bold", + disabled: isUpdating + }, isUpdating ? /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hourglass-split me-1" + }), " Saving...") : /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle me-1" + }), " Save Changes"))))))), /*#__PURE__*/React.createElement("div", { + className: `print-drawer-overlay {isPrintOpen ? 'open' : ''}`, + onClick: () => setIsPrintOpen(false) + }), /*#__PURE__*/React.createElement("div", { + className: `print-drawer {isPrintOpen ? 'open' : ''}`, + id: "invoices-print-drawer" + }, viewInvoice && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", { + className: "print-drawer-header" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-receipt text-warning fs-5" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "mb-0 fw-bold text-white" + }, "Invoice & Print Desk"), /*#__PURE__*/React.createElement("small", { + className: "text-secondary", + style: { + fontSize: '0.72rem' + } + }, "Bill: ", /*#__PURE__*/React.createElement("span", { + className: "text-info fw-bold" + }, viewInvoice.sale.invoice_no)))), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-1.5 flex-wrap" + }, /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm" + }, /*#__PURE__*/React.createElement("button", { + className: `btn btn-xs py-1 px-2 {printFormat === 'thermal' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light text-white'}`, + style: { + fontSize: '0.72rem' + }, + onClick: () => setPrintFormat('thermal') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-receipt me-1" + }), " Thermal (Text)"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-xs py-1 px-2 {printFormat === 'a5' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light text-white'}`, + style: { + fontSize: '0.72rem' + }, + onClick: () => setPrintFormat('a5') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-pdf me-1" + }), " A5 Landscape (PDF)"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-xs py-1 px-2 {printFormat === 'a4' ? 'btn-warning text-dark fw-bold' : 'btn-outline-light text-white'}`, + style: { + fontSize: '0.72rem' + }, + onClick: () => setPrintFormat('a4') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-pdf me-1" + }), " A4 (PDF)")), printFormat === 'thermal' ? /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-warning text-dark fw-bold py-1 px-2.5 ms-0.5", + onClick: printThermalReceipt, + title: "Print on 80mm Thermal Receipt Printer", + style: { + fontSize: '0.75rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer-fill me-1" + }), " Print Thermal") : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-light py-1 px-2 text-white", + onClick: () => downloadPdf(printFormat), + title: "Download PDF Document", + style: { + fontSize: '0.75rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-download me-1 text-info" + }), " PDF"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-primary py-1 px-2.5 ms-0.5 fw-bold", + onClick: () => printPdf(printFormat), + title: "Print Clean Vector PDF", + style: { + fontSize: '0.75rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer me-1" + }), " Print PDF (", printFormat === 'a5' ? 'A5 LANDSCAPE' : printFormat.toUpperCase(), ")")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-light rounded-pill px-2.5 py-1 ms-1 d-flex align-items-center gap-1", + onClick: () => setIsPrintOpen(false), + title: "Close Print Drawer (Esc)" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x-lg" + }), /*#__PURE__*/React.createElement("kbd", { + style: { + background: '#334155', + color: '#f8fafc', + fontSize: '0.62rem', + padding: '1px 3px', + borderRadius: '3px' + } + }, "Esc")))), /*#__PURE__*/React.createElement("div", { + className: "print-drawer-body" + }, /*#__PURE__*/React.createElement("div", { + className: "print-paper-card" + }, /*#__PURE__*/React.createElement("div", { + id: "printable-container" + }, printFormat === 'thermal' && /*#__PURE__*/React.createElement("div", { + className: "p-2 text-center" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-2 px-2 pb-2 border-bottom" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary" + }, "Thermal 80mm ESC/POS Text"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-xs btn-warning text-dark fw-bold", + onClick: printThermalReceipt + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer-fill me-1" + }), " Print Thermal Receipt")), /*#__PURE__*/React.createElement("pre", { + style: { + fontFamily: '"Courier New", Courier, monospace', + fontSize: '12px', + lineHeight: '1.2', + color: '#000000', + backgroundColor: '#ffffff', + padding: '12px', + margin: '0 auto', + maxWidth: '380px', + textAlign: 'left', + whiteSpace: 'pre-wrap', + wordBreak: 'break-word', + border: '1px dashed #cbd5e1', + borderRadius: '6px' + } + }, generateThermalReceiptText(viewInvoice))), printFormat === 'a5' && /*#__PURE__*/React.createElement("div", { + className: "p-3 text-center print-a5-invoice", + style: { + maxWidth: '820px', + margin: '0 auto' + } + }, /*#__PURE__*/React.createElement("div", { + className: "alert alert-info py-1.5 px-3 mb-3 d-flex justify-content-between align-items-center shadow-sm", + style: { + fontSize: '0.78rem' + } + }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-pdf-fill me-1" + }), /*#__PURE__*/React.createElement("strong", null, "A5 Landscape PDF (210mm × 148mm):"), " Native vector document rendered by mPDF."), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1.5" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-xs btn-outline-primary py-1 px-2", + onClick: () => downloadPdf('a5') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-download me-1" + }), " Download"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-xs btn-primary py-1 px-2.5 fw-bold", + onClick: () => printPdf('a5') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer me-1" + }), " Print PDF (A5 Landscape)"))), /*#__PURE__*/React.createElement("div", { + className: "border rounded shadow-sm overflow-hidden", + style: { + background: '#525659', + padding: '12px' + } + }, /*#__PURE__*/React.createElement("iframe", { + src: `{API_BASE}sales/invoice-pdf/{viewInvoice.sale.sale_id}?format=a5&view=1`, + title: "A5 Landscape PDF Preview", + style: { + width: '100%', + height: '540px', + border: 'none', + borderRadius: '4px', + background: '#ffffff' + } + }))), printFormat === 'a4' && /*#__PURE__*/React.createElement("div", { + className: "p-3 text-center print-a4-invoice", + style: { + maxWidth: '780px', + margin: '0 auto' + } + }, /*#__PURE__*/React.createElement("div", { + className: "alert alert-info py-1.5 px-3 mb-3 d-flex justify-content-between align-items-center shadow-sm", + style: { + fontSize: '0.78rem' + } + }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-pdf-fill me-1" + }), /*#__PURE__*/React.createElement("strong", null, "A4 Vector PDF (210mm × 297mm):"), " Native vector document rendered by mPDF."), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1.5" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-xs btn-outline-primary py-1 px-2", + onClick: () => downloadPdf('a4') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-download me-1" + }), " Download"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-xs btn-primary py-1 px-2.5 fw-bold", + onClick: () => printPdf('a4') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer me-1" + }), " Print PDF (A4)"))), /*#__PURE__*/React.createElement("div", { + className: "border rounded shadow-sm overflow-hidden", + style: { + background: '#525659', + padding: '12px' + } + }, /*#__PURE__*/React.createElement("iframe", { + src: `{API_BASE}sales/invoice-pdf/{viewInvoice.sale.sale_id}?format=a4&view=1`, + title: "A4 PDF Preview", + style: { + width: '100%', + height: '620px', + border: 'none', + borderRadius: '4px', + background: '#ffffff' + } + }))))))))); } // ========================================================================= @@ -9085,1111 +7242,754 @@ function InventoryView({ } } } - return /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap align-items-center justify-content-between gap-2 mb-3 pb-2 border-bottom", - children: [/*#__PURE__*/_jsxs("div", { - className: "btn-group shadow-sm", - children: [/*#__PURE__*/_jsxs("button", { - className: `btn btn-sm fw-bold d-flex align-items-center gap-1.5 ${invSubTab === 'live' ? 'btn-primary' : 'btn-outline-secondary'}`, - onClick: () => setInvSubTab('live'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-boxes" - }), " Live Stock & Batches"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm fw-bold d-flex align-items-center gap-1.5 ${invSubTab === 'physical_audit' ? 'btn-primary' : 'btn-outline-secondary'}`, - onClick: () => setInvSubTab('physical_audit'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clipboard-check-fill" - }), " Physical Stock Take & Cycle Audit"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm fw-bold d-flex align-items-center gap-1.5 ${invSubTab === 'audit_logs' ? 'btn-primary' : 'btn-outline-secondary'}`, - onClick: () => { - setInvSubTab('audit_logs'); - loadAuditLogs(); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-journal-check" - }), " Stock Discrepancy Audit Log"] - })] - }), /*#__PURE__*/_jsx("div", { - className: "d-flex align-items-center gap-2", - children: /*#__PURE__*/_jsxs("span", { - className: "badge bg-light text-dark border px-2.5 py-1.5 rounded-pill shadow-xs d-flex align-items-center gap-1.5", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-badge-fill text-primary" - }), /*#__PURE__*/_jsxs("span", { - children: ["Auditor: ", /*#__PURE__*/_jsx("strong", { - className: "text-dark", - children: activeOperator ? activeOperator.full_name : 'Store Staff' - })] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-primary-subtle text-primary", - style: { - fontSize: '0.65rem' - }, - children: activeOperator ? activeOperator.user_role.toUpperCase() : 'COUNTER' - })] - }) - })] - }), invSubTab === 'live' && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "row g-3 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "col-md-3 col-sm-6", - children: /*#__PURE__*/_jsxs("div", { - className: "counter-card p-3 border-start border-4 border-primary", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted fw-bold text-uppercase", - children: "Total Batches in Store" - }), /*#__PURE__*/_jsx("h4", { - className: "fw-bolder text-dark mt-1 mb-0", - children: summary.total_rows || 0 - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-3 col-sm-6", - children: /*#__PURE__*/_jsxs("div", { - className: "counter-card p-3 border-start border-4 border-success", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted fw-bold text-uppercase", - children: "Stock Cost Valuation (PTR)" - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bolder text-success mt-1 mb-0", - children: ["₹", (summary.total_cost_valuation || 0).toLocaleString('en-IN')] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-3 col-sm-6", - children: /*#__PURE__*/_jsxs("div", { - className: "counter-card p-3 border-start border-4 border-warning", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted fw-bold text-uppercase", - children: "Stock Retail Valuation (MRP)" - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bolder text-dark mt-1 mb-0", - children: ["₹", (summary.total_mrp_valuation || 0).toLocaleString('en-IN')] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-3 col-sm-6", - children: /*#__PURE__*/_jsxs("div", { - className: "counter-card p-3 border-start border-4 border-info", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted fw-bold text-uppercase", - children: "Counter / URL" - }), /*#__PURE__*/_jsxs("h6", { - className: "fw-bolder text-primary mt-1 mb-0 text-truncate", - children: ["MedicalStore/", store.store_slug] - })] - }) - })] - }), /*#__PURE__*/_jsx("div", { - className: "counter-card p-3 mb-3", - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap justify-content-between align-items-center gap-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm", - children: [/*#__PURE__*/_jsx("button", { - className: `btn ${filter === 'all' ? 'btn-primary' : 'btn-outline-secondary'}`, - onClick: () => setFilter('all'), - children: "All Stock" - }), /*#__PURE__*/_jsxs("button", { - className: `btn ${filter === 'low' ? 'btn-primary' : 'btn-outline-secondary'}`, - onClick: () => setFilter('low'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-down-circle me-1" - }), " Low Stock"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn ${filter === 'near_expiry' ? 'btn-warning' : 'btn-outline-secondary'}`, - onClick: () => setFilter('near_expiry'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clock-history me-1" - }), " Near Expiry (<90 Days)"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn ${filter === 'expired' ? 'btn-danger' : 'btn-outline-secondary'}`, - onClick: () => setFilter('expired'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-x me-1" - }), " Expired Stock"] - })] - }), /*#__PURE__*/_jsx("div", { - style: { - maxWidth: 320 - }, - className: "w-100", - children: /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-light", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-search" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control", - placeholder: "Search item, molecule, batch...", - value: searchTerm, - onChange: e => setSearchTerm(e.target.value) - })] - }) - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "counter-card p-0 overflow-hidden shadow-sm", - children: /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-pos table-hover align-middle mb-0", - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "#" - }), /*#__PURE__*/_jsx("th", { - children: "Item & Generic Molecule" - }), /*#__PURE__*/_jsx("th", { - children: "Category" - }), /*#__PURE__*/_jsx("th", { - children: "Batch No" - }), /*#__PURE__*/_jsx("th", { - children: "Location" - }), /*#__PURE__*/_jsx("th", { - children: "Expiry" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "System Qty" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "PTR (₹)" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "MRP (₹)" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Valuation (₹)" - }), /*#__PURE__*/_jsx("th", { - children: "Status" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - children: "Action" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: loading ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "12", - className: "text-center py-5 text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hourglass-split fs-3 d-block mb-2 text-primary" - }), " Loading inventory batches..."] - }) - }) : filteredStock.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "12", - className: "text-center py-5 text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-inboxes fs-3 d-block mb-1 text-secondary" - }), "No stock records found matching filters."] - }) - }) : filteredStock.map((s, idx) => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - children: idx + 1 - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-dark", - children: s.item_name - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [s.generic_name || 'Allopathic', " • HSN: ", s.hsn_code || '3004'] - })] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary-subtle text-secondary", - children: s.category || 'Medicine' - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: "badge bg-light text-dark border fw-bold", - children: s.batch_no - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [s.shelf_no ? `Sh: ${s.shelf_no}` : '', " ", s.rack_no ? `• Rk: ${s.rack_no}` : s.shelf_no ? '' : '-'] - }) - }), /*#__PURE__*/_jsx("td", { - children: s.expiry_display || s.expiry_date - }), /*#__PURE__*/_jsxs("td", { - className: "text-end", - children: [/*#__PURE__*/_jsx("span", { - className: `fw-bolder fs-6 ${s.current_qty <= (s.min_reorder_level || 5) ? 'text-danger' : 'text-success'}`, - children: s.current_qty - }), /*#__PURE__*/_jsx("small", { - className: "text-muted d-block", - style: { - fontSize: '0.7rem' - }, - children: "Units" - })] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end", - children: ["₹", s.ptr] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-semibold", - children: ["₹", s.mrp] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-bold", - children: ["₹", s.cost_valuation] - }), /*#__PURE__*/_jsx("td", { - children: s.is_expired ? /*#__PURE__*/_jsx("span", { - className: "badge-expired", - children: "EXPIRED" - }) : s.is_near_expiry ? /*#__PURE__*/_jsx("span", { - className: "badge-near-expiry", - children: "Near Expiry" - }) : /*#__PURE__*/_jsx("span", { - className: "badge-fefo", - children: "Good Stock" - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-outline-primary py-1 px-2.5 rounded-pill shadow-xs d-inline-flex align-items-center gap-1", - title: "Check physical stock against system record & adjust", - onClick: () => openReconcileModal(s), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-sliders2" - }), " Reconcile"] - }) - })] - }, s.stock_id)) - })] - }) - }) - })] - }), invSubTab === 'physical_audit' && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "counter-card p-3 mb-3 border-start border-4 border-info", - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap justify-content-between align-items-center gap-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap align-items-center gap-2", - children: [/*#__PURE__*/_jsxs("div", { - style: { - minWidth: 180 - }, - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "Filter by Shelf / Rack" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: cycleRackFilter, - onChange: e => setCycleRackFilter(e.target.value), - children: [/*#__PURE__*/_jsxs("option", { - value: "all", - children: ["All Racks & Shelves (", stock.length, " batches)"] - }), uniqueRacks.map(r => /*#__PURE__*/_jsxs("option", { - value: r, - children: ["Rack: ", r] - }, r))] - })] - }), /*#__PURE__*/_jsxs("div", { - style: { - minWidth: 220 - }, - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "Search Medicine / Batch" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "Type item or batch...", - value: cycleSearch, - onChange: e => setCycleSearch(e.target.value) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "text-end", - children: [/*#__PURE__*/_jsx("div", { - className: "small text-muted fw-bold text-uppercase", - children: "Discrepancies Found" - }), /*#__PURE__*/_jsxs("div", { - className: "fw-bolder fs-5 text-dark", - children: [/*#__PURE__*/_jsxs("span", { - className: cycleDiscrepancyCount > 0 ? 'text-danger' : 'text-success', - children: [cycleDiscrepancyCount, " items"] - }), cycleDiscrepancyCount > 0 && /*#__PURE__*/_jsxs("span", { - className: "small text-muted ms-1", - children: ["(₹", cycleDiscrepancyValue.toFixed(2), ")"] - })] - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-primary btn-sm px-3 py-2 fw-bold shadow-sm d-flex align-items-center gap-1.5", - onClick: handleCommitCycleAudit, - disabled: isCommittingCycle || cycleDiscrepancyCount === 0, - children: isCommittingCycle ? /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm" - }), " Committing..."] - }) : /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cloud-arrow-up-fill" - }), " Commit Cycle Count (", cycleDiscrepancyCount, ")"] - }) - })] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "counter-card p-0 overflow-hidden shadow-sm", - children: /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-pos table-hover align-middle mb-0", - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "#" - }), /*#__PURE__*/_jsx("th", { - children: "Medicine Item" - }), /*#__PURE__*/_jsx("th", { - children: "Batch No" - }), /*#__PURE__*/_jsx("th", { - children: "Location" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - style: { - width: 110 - }, - children: "System Qty" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - style: { - width: 140 - }, - children: "Physical Count" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - style: { - width: 110 - }, - children: "Variance" - }), /*#__PURE__*/_jsx("th", { - style: { - minWidth: 170 - }, - children: "Audit Reason" - }), /*#__PURE__*/_jsx("th", { - style: { - minWidth: 180 - }, - children: "Remarks / Notes" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - children: "Action" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: cycleFilteredStock.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsx("td", { - colSpan: "10", - className: "text-center py-5 text-muted", - children: "No items found in this shelf/rack." - }) - }) : cycleFilteredStock.map((item, idx) => { - const countData = cycleCounts[item.batch_id] || {}; - const hasInput = countData.physical_qty !== undefined && countData.physical_qty !== ''; - const pVal = hasInput ? Number(countData.physical_qty) : null; - const sVal = Number(item.current_qty); - const diff = pVal !== null ? pVal - sVal : 0; - const rate = Number(item.ptr || item.mrp || 0); - return /*#__PURE__*/_jsxs("tr", { - className: diff !== 0 && hasInput ? diff < 0 ? 'table-danger-subtle' : 'table-info-subtle' : '', - children: [/*#__PURE__*/_jsx("td", { - children: idx + 1 - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-dark", - children: item.item_name - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [item.generic_name, " • Packing: ", item.unit_pack || 'Unit'] - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-light text-dark border fw-bold", - children: item.batch_no - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted d-block", - style: { - fontSize: '0.7rem' - }, - children: ["Exp: ", item.expiry_display || item.expiry_date] - })] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [item.shelf_no ? `Sh: ${item.shelf_no}` : '', " ", item.rack_no ? `• Rk: ${item.rack_no}` : item.shelf_no ? '' : 'Normal'] - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary-subtle text-secondary fs-6 px-2 py-1 fw-bolder", - children: sVal - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: /*#__PURE__*/_jsx("input", { - type: "number", - min: "0", - className: `form-control form-control-sm text-center fw-bolder ${hasInput ? diff === 0 ? 'is-valid' : 'is-invalid' : ''}`, - placeholder: sVal, - value: countData.physical_qty !== undefined ? countData.physical_qty : '', - onChange: e => handleCycleCountChange(item.batch_id, e.target.value) - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: hasInput ? diff === 0 ? /*#__PURE__*/_jsx("span", { - className: "badge bg-success-subtle text-success fw-bold px-2 py-1", - children: "✓ Match (0)" - }) : diff < 0 ? /*#__PURE__*/_jsxs("span", { - className: "badge bg-danger text-white fw-bold px-2 py-1", - title: `Shortage: ₹${(Math.abs(diff) * rate).toFixed(2)}`, - children: [diff, " Units"] - }) : /*#__PURE__*/_jsxs("span", { - className: "badge bg-info text-dark fw-bold px-2 py-1", - title: `Surplus: ₹${(diff * rate).toFixed(2)}`, - children: ["+", diff, " Units"] - }) : /*#__PURE__*/_jsx("span", { - className: "text-muted small", - children: "-" - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - disabled: !hasInput || diff === 0, - value: countData.audit_type || 'PHYSICAL_VARIATION', - onChange: e => handleCycleReasonChange(item.batch_id, e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "PHYSICAL_VARIATION", - children: "Shelf Miscount" - }), /*#__PURE__*/_jsx("option", { - value: "DAMAGE", - children: "Damaged Packaging" - }), /*#__PURE__*/_jsx("option", { - value: "BREAKAGE", - children: "Bottle Broken / Spilt" - }), /*#__PURE__*/_jsx("option", { - value: "EXPIRY_DUMP", - children: "Expired On Shelf" - }), /*#__PURE__*/_jsx("option", { - value: "SURPLUS_FOUND", - children: "Surplus Found" - }), /*#__PURE__*/_jsx("option", { - value: "THEFT_LOSS", - children: "Unaccounted Shortage" - })] - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - disabled: !hasInput, - placeholder: "Note / Shelf position", - value: countData.remarks || '', - onChange: e => handleCycleRemarksChange(item.batch_id, e.target.value) - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: hasInput && /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-xs btn-outline-secondary py-0.5 px-1.5", - title: "Clear entered count", - onClick: () => handleCycleCountChange(item.batch_id, ''), - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-x" - }) - }) - })] - }, item.batch_id); - }) - })] - }) - }) - })] - }), invSubTab === 'audit_logs' && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "counter-card p-3 mb-3", - children: /*#__PURE__*/_jsxs("div", { - className: "row g-2 align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-3 col-sm-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "Audit Type / Reason" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: auditFilterType, - onChange: e => setAuditFilterType(e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "all", - children: "All Audit Events & Movements" - }), /*#__PURE__*/_jsx("option", { - value: "PHYSICAL_VARIATION", - children: "Physical Variation (Shelf vs System)" - }), /*#__PURE__*/_jsx("option", { - value: "DAMAGE", - children: "Damaged Packaging" - }), /*#__PURE__*/_jsx("option", { - value: "BREAKAGE", - children: "Breakage / Spillage" - }), /*#__PURE__*/_jsx("option", { - value: "EXPIRY_DUMP", - children: "Expired Stock Dump" - }), /*#__PURE__*/_jsx("option", { - value: "SURPLUS_FOUND", - children: "Surplus Stock Found" - }), /*#__PURE__*/_jsx("option", { - value: "THEFT_LOSS", - children: "Unaccounted Loss / Pilferage" - }), /*#__PURE__*/_jsx("option", { - value: "PURCHASE", - children: "Purchase Inward" - }), /*#__PURE__*/_jsx("option", { - value: "SALE", - children: "Sale Dispensation" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-3 col-sm-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "Search Medicine / Auditor" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control", - placeholder: "Item, batch, auditor...", - value: auditSearch, - onChange: e => setAuditSearch(e.target.value), - onKeyDown: e => { - if (e.key === 'Enter') loadAuditLogs(); - } - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-outline-secondary", - onClick: loadAuditLogs, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-search" - }) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-sm-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "From Date" - }), /*#__PURE__*/_jsx("input", { - type: "date", - className: "form-control form-control-sm", - value: auditFromDate, - onChange: e => setAuditFromDate(e.target.value) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-sm-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-muted mb-1", - children: "To Date" - }), /*#__PURE__*/_jsx("input", { - type: "date", - className: "form-control form-control-sm", - value: auditToDate, - onChange: e => setAuditToDate(e.target.value) - })] - }), /*#__PURE__*/_jsx("div", { - className: "col-md-2 col-sm-4 d-flex align-items-end", - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-primary w-100 d-flex align-items-center justify-content-center gap-1", - onClick: loadAuditLogs, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-clockwise" - }), " Refresh Logs"] - }) - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "counter-card p-0 overflow-hidden shadow-sm", - children: /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-pos table-hover align-middle mb-0", - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "# & Timestamp" - }), /*#__PURE__*/_jsx("th", { - children: "Medicine Item" - }), /*#__PURE__*/_jsx("th", { - children: "Batch No" - }), /*#__PURE__*/_jsx("th", { - children: "System Qty" - }), /*#__PURE__*/_jsx("th", { - children: "Physical Qty" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - children: "Variance Qty" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Valuation (₹)" - }), /*#__PURE__*/_jsx("th", { - children: "Audit Event / Reason" - }), /*#__PURE__*/_jsx("th", { - children: "Remarks" - }), /*#__PURE__*/_jsx("th", { - children: "Conducted By" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: loadingAuditLogs ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "10", - className: "text-center py-5 text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hourglass-split fs-3 d-block mb-2 text-primary" - }), " Loading audit trail..."] - }) - }) : auditLogs.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "10", - className: "text-center py-5 text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clipboard-check fs-3 d-block mb-1 text-secondary" - }), "No stock audit events recorded yet for this criteria."] - }) - }) : auditLogs.map(log => { - const vQty = Number(log.variation_qty || 0); - return /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsxs("div", { - className: "fw-bold text-dark", - children: ["#", log.audit_id] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - style: { - fontSize: '0.72rem' - }, - children: log.created_at - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-dark", - children: log.item_name || `Item #${log.item_id}` - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [log.generic_name, " • ", log.unit_pack || 'Unit'] - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-light text-dark border fw-bold", - children: log.batch_no || `Batch #${log.batch_id}` - }), log.expiry_date && /*#__PURE__*/_jsxs("small", { - className: "text-muted d-block", - style: { - fontSize: '0.7rem' - }, - children: ["Exp: ", log.expiry_date] - })] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: "fw-semibold text-secondary", - children: log.system_qty - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: "fw-bold text-dark", - children: log.physical_qty - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: vQty === 0 ? /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary-subtle text-secondary fw-semibold", - children: "0" - }) : vQty < 0 ? /*#__PURE__*/_jsxs("span", { - className: "badge bg-danger text-white fw-bold px-2 py-1", - children: [vQty, " Units"] - }) : /*#__PURE__*/_jsxs("span", { - className: "badge bg-success text-white fw-bold px-2 py-1", - children: ["+", vQty, " Units"] - }) - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-bold", - children: ["₹", Number(log.total_value || 0).toFixed(2)] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: `badge ${log.audit_type === 'PHYSICAL_VARIATION' ? 'bg-warning-subtle text-dark border border-warning' : log.audit_type === 'DAMAGE' || log.audit_type === 'BREAKAGE' ? 'bg-danger-subtle text-danger border border-danger' : log.audit_type === 'EXPIRY_DUMP' ? 'bg-dark text-white' : log.audit_type === 'SURPLUS_FOUND' ? 'bg-info-subtle text-info border border-info' : log.audit_type === 'PURCHASE' ? 'bg-success-subtle text-success border border-success' : 'bg-secondary-subtle text-secondary'}`, - children: log.audit_type ? log.audit_type.replace(/_/g, ' ') : 'AUDIT' - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("small", { - className: "text-muted text-break", - children: log.remarks || '-' - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("span", { - className: "badge bg-light text-dark border", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person me-1" - }), log.conducted_by_name || 'Staff'] - }) - })] - }, log.audit_id); - }) - })] - }) - }) - })] - }), reconcileModalItem && /*#__PURE__*/_jsx("div", { - className: "modal fade show d-block", + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap align-items-center justify-content-between gap-2 mb-3 pb-2 border-bottom" + }, /*#__PURE__*/React.createElement("div", { + className: "btn-group shadow-sm" + }, /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm fw-bold d-flex align-items-center gap-1.5 ${invSubTab === 'live' ? 'btn-primary' : 'btn-outline-secondary'}`, + onClick: () => setInvSubTab('live') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-boxes" + }), " Live Stock & Batches"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm fw-bold d-flex align-items-center gap-1.5 ${invSubTab === 'physical_audit' ? 'btn-primary' : 'btn-outline-secondary'}`, + onClick: () => setInvSubTab('physical_audit') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clipboard-check-fill" + }), " Physical Stock Take & Cycle Audit"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm fw-bold d-flex align-items-center gap-1.5 ${invSubTab === 'audit_logs' ? 'btn-primary' : 'btn-outline-secondary'}`, + onClick: () => { + setInvSubTab('audit_logs'); + loadAuditLogs(); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-journal-check" + }), " Stock Discrepancy Audit Log")), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border px-2.5 py-1.5 rounded-pill shadow-xs d-flex align-items-center gap-1.5" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-badge-fill text-primary" + }), /*#__PURE__*/React.createElement("span", null, "Auditor: ", /*#__PURE__*/React.createElement("strong", { + className: "text-dark" + }, activeOperator ? activeOperator.full_name : 'Store Staff')), /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary", + style: { + fontSize: '0.65rem' + } + }, activeOperator ? activeOperator.user_role.toUpperCase() : 'COUNTER')))), invSubTab === 'live' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "row g-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-3 col-sm-6" + }, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 border-start border-4 border-primary" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-bold text-uppercase" + }, "Total Batches in Store"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bolder text-dark mt-1 mb-0" + }, summary.total_rows || 0))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3 col-sm-6" + }, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 border-start border-4 border-success" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-bold text-uppercase" + }, "Stock Cost Valuation (PTR)"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bolder text-success mt-1 mb-0" + }, "₹", (summary.total_cost_valuation || 0).toLocaleString('en-IN')))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3 col-sm-6" + }, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 border-start border-4 border-warning" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-bold text-uppercase" + }, "Stock Retail Valuation (MRP)"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bolder text-dark mt-1 mb-0" + }, "₹", (summary.total_mrp_valuation || 0).toLocaleString('en-IN')))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3 col-sm-6" + }, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 border-start border-4 border-info" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-bold text-uppercase" + }, "Counter / URL"), /*#__PURE__*/React.createElement("h6", { + className: "fw-bolder text-primary mt-1 mb-0 text-truncate" + }, "MedicalStore/", store.store_slug)))), /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap justify-content-between align-items-center gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm" + }, /*#__PURE__*/React.createElement("button", { + className: `btn ${filter === 'all' ? 'btn-primary' : 'btn-outline-secondary'}`, + onClick: () => setFilter('all') + }, "All Stock"), /*#__PURE__*/React.createElement("button", { + className: `btn ${filter === 'low' ? 'btn-primary' : 'btn-outline-secondary'}`, + onClick: () => setFilter('low') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-down-circle me-1" + }), " Low Stock"), /*#__PURE__*/React.createElement("button", { + className: `btn ${filter === 'near_expiry' ? 'btn-warning' : 'btn-outline-secondary'}`, + onClick: () => setFilter('near_expiry') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clock-history me-1" + }), " Near Expiry (<90 Days)"), /*#__PURE__*/React.createElement("button", { + className: `btn ${filter === 'expired' ? 'btn-danger' : 'btn-outline-secondary'}`, + onClick: () => setFilter('expired') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-x me-1" + }), " Expired Stock")), /*#__PURE__*/React.createElement("div", { + style: { + maxWidth: 320 + }, + className: "w-100" + }, /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control", + placeholder: "Search item, molecule, batch...", + value: searchTerm, + onChange: e => setSearchTerm(e.target.value) + }))))), /*#__PURE__*/React.createElement("div", { + className: "counter-card p-0 overflow-hidden shadow-sm" + }, /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-pos table-hover align-middle mb-0" + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "#"), /*#__PURE__*/React.createElement("th", null, "Item & Generic Molecule"), /*#__PURE__*/React.createElement("th", null, "Category"), /*#__PURE__*/React.createElement("th", null, "Batch No"), /*#__PURE__*/React.createElement("th", null, "Location"), /*#__PURE__*/React.createElement("th", null, "Expiry"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "System Qty"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "PTR (₹)"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "MRP (₹)"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Valuation (₹)"), /*#__PURE__*/React.createElement("th", null, "Status"), /*#__PURE__*/React.createElement("th", { + className: "text-center" + }, "Action"))), /*#__PURE__*/React.createElement("tbody", null, loading ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "12", + className: "text-center py-5 text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hourglass-split fs-3 d-block mb-2 text-primary" + }), " Loading inventory batches...")) : filteredStock.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "12", + className: "text-center py-5 text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-inboxes fs-3 d-block mb-1 text-secondary" + }), "No stock records found matching filters.")) : filteredStock.map((s, idx) => /*#__PURE__*/React.createElement("tr", { + key: s.stock_id + }, /*#__PURE__*/React.createElement("td", null, idx + 1), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark" + }, s.item_name), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, s.generic_name || 'Allopathic', " • HSN: ", s.hsn_code || '3004')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-secondary" + }, s.category || 'Medicine')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border fw-bold" + }, s.batch_no)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, s.shelf_no ? `Sh: ${s.shelf_no}` : '', " ", s.rack_no ? `• Rk: ${s.rack_no}` : s.shelf_no ? '' : '-')), /*#__PURE__*/React.createElement("td", null, s.expiry_display || s.expiry_date), /*#__PURE__*/React.createElement("td", { + className: "text-end" + }, /*#__PURE__*/React.createElement("span", { + className: `fw-bolder fs-6 ${s.current_qty <= (s.min_reorder_level || 5) ? 'text-danger' : 'text-success'}` + }, s.current_qty), /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block", + style: { + fontSize: '0.7rem' + } + }, "Units")), /*#__PURE__*/React.createElement("td", { + className: "text-end" + }, "₹", s.ptr), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-semibold" + }, "₹", s.mrp), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold" + }, "₹", s.cost_valuation), /*#__PURE__*/React.createElement("td", null, s.is_expired ? /*#__PURE__*/React.createElement("span", { + className: "badge-expired" + }, "EXPIRED") : s.is_near_expiry ? /*#__PURE__*/React.createElement("span", { + className: "badge-near-expiry" + }, "Near Expiry") : /*#__PURE__*/React.createElement("span", { + className: "badge-fefo" + }, "Good Stock")), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-primary py-1 px-2.5 rounded-pill shadow-xs d-inline-flex align-items-center gap-1", + title: "Check physical stock against system record & adjust", + onClick: () => openReconcileModal(s) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-sliders2" + }), " Reconcile"))))))))), invSubTab === 'physical_audit' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 mb-3 border-start border-4 border-info" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap justify-content-between align-items-center gap-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap align-items-center gap-2" + }, /*#__PURE__*/React.createElement("div", { + style: { + minWidth: 180 + } + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "Filter by Shelf / Rack"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: cycleRackFilter, + onChange: e => setCycleRackFilter(e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "all" + }, "All Racks & Shelves (", stock.length, " batches)"), uniqueRacks.map(r => /*#__PURE__*/React.createElement("option", { + key: r, + value: r + }, "Rack: ", r)))), /*#__PURE__*/React.createElement("div", { + style: { + minWidth: 220 + } + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "Search Medicine / Batch"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "Type item or batch...", + value: cycleSearch, + onChange: e => setCycleSearch(e.target.value) + }))), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-3" + }, /*#__PURE__*/React.createElement("div", { + className: "text-end" + }, /*#__PURE__*/React.createElement("div", { + className: "small text-muted fw-bold text-uppercase" + }, "Discrepancies Found"), /*#__PURE__*/React.createElement("div", { + className: "fw-bolder fs-5 text-dark" + }, /*#__PURE__*/React.createElement("span", { + className: cycleDiscrepancyCount > 0 ? 'text-danger' : 'text-success' + }, cycleDiscrepancyCount, " items"), cycleDiscrepancyCount > 0 && /*#__PURE__*/React.createElement("span", { + className: "small text-muted ms-1" + }, "(₹", cycleDiscrepancyValue.toFixed(2), ")"))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-primary btn-sm px-3 py-2 fw-bold shadow-sm d-flex align-items-center gap-1.5", + onClick: handleCommitCycleAudit, + disabled: isCommittingCycle || cycleDiscrepancyCount === 0 + }, isCommittingCycle ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm" + }), " Committing...") : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cloud-arrow-up-fill" + }), " Commit Cycle Count (", cycleDiscrepancyCount, ")"))))), /*#__PURE__*/React.createElement("div", { + className: "counter-card p-0 overflow-hidden shadow-sm" + }, /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-pos table-hover align-middle mb-0" + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "#"), /*#__PURE__*/React.createElement("th", null, "Medicine Item"), /*#__PURE__*/React.createElement("th", null, "Batch No"), /*#__PURE__*/React.createElement("th", null, "Location"), /*#__PURE__*/React.createElement("th", { + className: "text-center", + style: { + width: 110 + } + }, "System Qty"), /*#__PURE__*/React.createElement("th", { + className: "text-center", + style: { + width: 140 + } + }, "Physical Count"), /*#__PURE__*/React.createElement("th", { + className: "text-center", + style: { + width: 110 + } + }, "Variance"), /*#__PURE__*/React.createElement("th", { + style: { + minWidth: 170 + } + }, "Audit Reason"), /*#__PURE__*/React.createElement("th", { + style: { + minWidth: 180 + } + }, "Remarks / Notes"), /*#__PURE__*/React.createElement("th", { + className: "text-center" + }, "Action"))), /*#__PURE__*/React.createElement("tbody", null, cycleFilteredStock.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "10", + className: "text-center py-5 text-muted" + }, "No items found in this shelf/rack.")) : cycleFilteredStock.map((item, idx) => { + const countData = cycleCounts[item.batch_id] || {}; + const hasInput = countData.physical_qty !== undefined && countData.physical_qty !== ''; + const pVal = hasInput ? Number(countData.physical_qty) : null; + const sVal = Number(item.current_qty); + const diff = pVal !== null ? pVal - sVal : 0; + const rate = Number(item.ptr || item.mrp || 0); + return /*#__PURE__*/React.createElement("tr", { + key: item.batch_id, + className: diff !== 0 && hasInput ? diff < 0 ? 'table-danger-subtle' : 'table-info-subtle' : '' + }, /*#__PURE__*/React.createElement("td", null, idx + 1), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark" + }, item.item_name), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, item.generic_name, " • Packing: ", item.unit_pack || 'Unit')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border fw-bold" + }, item.batch_no), /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block", style: { - backgroundColor: 'rgba(15, 23, 42, 0.75)', - zIndex: 10650 - }, - tabIndex: "-1", - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered", + fontSize: '0.7rem' + } + }, "Exp: ", item.expiry_display || item.expiry_date)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, item.shelf_no ? `Sh: ${item.shelf_no}` : '', " ", item.rack_no ? `• Rk: ${item.rack_no}` : item.shelf_no ? '' : 'Normal')), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-secondary fs-6 px-2 py-1 fw-bolder" + }, sVal)), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + min: "0", + className: `form-control form-control-sm text-center fw-bolder ${hasInput ? diff === 0 ? 'is-valid' : 'is-invalid' : ''}`, + placeholder: sVal, + value: countData.physical_qty !== undefined ? countData.physical_qty : '', + onChange: e => handleCycleCountChange(item.batch_id, e.target.value) + })), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, hasInput ? diff === 0 ? /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success fw-bold px-2 py-1" + }, "✓ Match (0)") : diff < 0 ? /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger text-white fw-bold px-2 py-1", + title: `Shortage: ₹${(Math.abs(diff) * rate).toFixed(2)}` + }, diff, " Units") : /*#__PURE__*/React.createElement("span", { + className: "badge bg-info text-dark fw-bold px-2 py-1", + title: `Surplus: ₹${(diff * rate).toFixed(2)}` + }, "+", diff, " Units") : /*#__PURE__*/React.createElement("span", { + className: "text-muted small" + }, "-")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + disabled: !hasInput || diff === 0, + value: countData.audit_type || 'PHYSICAL_VARIATION', + onChange: e => handleCycleReasonChange(item.batch_id, e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "PHYSICAL_VARIATION" + }, "Shelf Miscount"), /*#__PURE__*/React.createElement("option", { + value: "DAMAGE" + }, "Damaged Packaging"), /*#__PURE__*/React.createElement("option", { + value: "BREAKAGE" + }, "Bottle Broken / Spilt"), /*#__PURE__*/React.createElement("option", { + value: "EXPIRY_DUMP" + }, "Expired On Shelf"), /*#__PURE__*/React.createElement("option", { + value: "SURPLUS_FOUND" + }, "Surplus Found"), /*#__PURE__*/React.createElement("option", { + value: "THEFT_LOSS" + }, "Unaccounted Shortage"))), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + disabled: !hasInput, + placeholder: "Note / Shelf position", + value: countData.remarks || '', + onChange: e => handleCycleRemarksChange(item.batch_id, e.target.value) + })), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, hasInput && /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-secondary py-0.5 px-1.5", + title: "Clear entered count", + onClick: () => handleCycleCountChange(item.batch_id, '') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x" + })))); + })))))), invSubTab === 'audit_logs' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "row g-2 align-items-center" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-3 col-sm-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "Audit Type / Reason"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: auditFilterType, + onChange: e => setAuditFilterType(e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "all" + }, "All Audit Events & Movements"), /*#__PURE__*/React.createElement("option", { + value: "PHYSICAL_VARIATION" + }, "Physical Variation (Shelf vs System)"), /*#__PURE__*/React.createElement("option", { + value: "DAMAGE" + }, "Damaged Packaging"), /*#__PURE__*/React.createElement("option", { + value: "BREAKAGE" + }, "Breakage / Spillage"), /*#__PURE__*/React.createElement("option", { + value: "EXPIRY_DUMP" + }, "Expired Stock Dump"), /*#__PURE__*/React.createElement("option", { + value: "SURPLUS_FOUND" + }, "Surplus Stock Found"), /*#__PURE__*/React.createElement("option", { + value: "THEFT_LOSS" + }, "Unaccounted Loss / Pilferage"), /*#__PURE__*/React.createElement("option", { + value: "PURCHASE" + }, "Purchase Inward"), /*#__PURE__*/React.createElement("option", { + value: "SALE" + }, "Sale Dispensation"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3 col-sm-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "Search Medicine / Auditor"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control", + placeholder: "Item, batch, auditor...", + value: auditSearch, + onChange: e => setAuditSearch(e.target.value), + onKeyDown: e => { + if (e.key === 'Enter') loadAuditLogs(); + } + }), /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-secondary", + onClick: loadAuditLogs + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search" + })))), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-sm-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "From Date"), /*#__PURE__*/React.createElement("input", { + type: "date", + className: "form-control form-control-sm", + value: auditFromDate, + onChange: e => setAuditFromDate(e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-sm-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-muted mb-1" + }, "To Date"), /*#__PURE__*/React.createElement("input", { + type: "date", + className: "form-control form-control-sm", + value: auditToDate, + onChange: e => setAuditToDate(e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-sm-4 d-flex align-items-end" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-primary w-100 d-flex align-items-center justify-content-center gap-1", + onClick: loadAuditLogs + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-clockwise" + }), " Refresh Logs")))), /*#__PURE__*/React.createElement("div", { + className: "counter-card p-0 overflow-hidden shadow-sm" + }, /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-pos table-hover align-middle mb-0" + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "# & Timestamp"), /*#__PURE__*/React.createElement("th", null, "Medicine Item"), /*#__PURE__*/React.createElement("th", null, "Batch No"), /*#__PURE__*/React.createElement("th", null, "System Qty"), /*#__PURE__*/React.createElement("th", null, "Physical Qty"), /*#__PURE__*/React.createElement("th", { + className: "text-center" + }, "Variance Qty"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Valuation (₹)"), /*#__PURE__*/React.createElement("th", null, "Audit Event / Reason"), /*#__PURE__*/React.createElement("th", null, "Remarks"), /*#__PURE__*/React.createElement("th", null, "Conducted By"))), /*#__PURE__*/React.createElement("tbody", null, loadingAuditLogs ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "10", + className: "text-center py-5 text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hourglass-split fs-3 d-block mb-2 text-primary" + }), " Loading audit trail...")) : auditLogs.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "10", + className: "text-center py-5 text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clipboard-check fs-3 d-block mb-1 text-secondary" + }), "No stock audit events recorded yet for this criteria.")) : auditLogs.map(log => { + const vQty = Number(log.variation_qty || 0); + return /*#__PURE__*/React.createElement("tr", { + key: log.audit_id + }, /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark" + }, "#", log.audit_id), /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '0.72rem' + } + }, log.created_at)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark" + }, log.item_name || `Item #${log.item_id}`), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, log.generic_name, " • ", log.unit_pack || 'Unit')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border fw-bold" + }, log.batch_no || `Batch #${log.batch_id}`), log.expiry_date && /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block", + style: { + fontSize: '0.7rem' + } + }, "Exp: ", log.expiry_date)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "fw-semibold text-secondary" + }, log.system_qty)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-dark" + }, log.physical_qty)), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, vQty === 0 ? /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-secondary fw-semibold" + }, "0") : vQty < 0 ? /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger text-white fw-bold px-2 py-1" + }, vQty, " Units") : /*#__PURE__*/React.createElement("span", { + className: "badge bg-success text-white fw-bold px-2 py-1" + }, "+", vQty, " Units")), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold" + }, "₹", Number(log.total_value || 0).toFixed(2)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: `badge ${log.audit_type === 'PHYSICAL_VARIATION' ? 'bg-warning-subtle text-dark border border-warning' : log.audit_type === 'DAMAGE' || log.audit_type === 'BREAKAGE' ? 'bg-danger-subtle text-danger border border-danger' : log.audit_type === 'EXPIRY_DUMP' ? 'bg-dark text-white' : log.audit_type === 'SURPLUS_FOUND' ? 'bg-info-subtle text-info border border-info' : log.audit_type === 'PURCHASE' ? 'bg-success-subtle text-success border border-success' : 'bg-secondary-subtle text-secondary'}` + }, log.audit_type ? log.audit_type.replace(/_/g, ' ') : 'AUDIT')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("small", { + className: "text-muted text-break" + }, log.remarks || '-')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person me-1" + }), log.conducted_by_name || 'Staff'))); + })))))), reconcileModalItem && /*#__PURE__*/React.createElement("div", { + className: "modal fade show d-block", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.75)', + zIndex: 10650 + }, + tabIndex: "-1" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered", + style: { + maxWidth: 540 + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content border-0 shadow-2xl rounded-4 overflow-hidden", + style: { + background: '#0f172a', + color: '#f8fafc', + border: '1px solid #334155' + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header border-bottom border-secondary py-3 px-4", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "p-2 rounded-3 bg-primary bg-opacity-25 text-primary" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-sliders2 fs-5" + })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold text-white mb-0" + }, "Stock Reconciliation & Discrepancy Audit"), /*#__PURE__*/React.createElement("small", { + className: "text-slate-400", + style: { + color: '#94a3b8' + } + }, store.store_name, " • Physical vs System Shelf Count"))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setReconcileModalItem(null) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-4" + }, /*#__PURE__*/React.createElement("div", { + className: "p-3 rounded-3 mb-3 border border-secondary", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-white fs-6" + }, reconcileModalItem.item_name), /*#__PURE__*/React.createElement("div", { + className: "text-slate-400 small mb-2", + style: { + color: '#94a3b8' + } + }, reconcileModalItem.generic_name, " • Unit Pack: ", reconcileModalItem.unit_pack || 'Unit'), /*#__PURE__*/React.createElement("div", { + className: "row g-2 small" + }, /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("span", { + className: "text-slate-400", + style: { + color: '#94a3b8' + } + }, "Batch No:"), " ", /*#__PURE__*/React.createElement("strong", { + className: "text-cyan-300", + style: { + color: '#67e8f9' + } + }, reconcileModalItem.batch_no)), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("span", { + className: "text-slate-400", + style: { + color: '#94a3b8' + } + }, "Expiry:"), " ", /*#__PURE__*/React.createElement("strong", { + className: "text-white" + }, reconcileModalItem.expiry_display || reconcileModalItem.expiry_date)), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("span", { + className: "text-slate-400", + style: { + color: '#94a3b8' + } + }, "PTR / Cost:"), " ", /*#__PURE__*/React.createElement("strong", { + className: "text-white" + }, "₹", reconcileModalItem.ptr)), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("span", { + className: "text-slate-400", + style: { + color: '#94a3b8' + } + }, "MRP:"), " ", /*#__PURE__*/React.createElement("strong", { + className: "text-white" + }, "₹", reconcileModalItem.mrp)))), /*#__PURE__*/React.createElement("div", { + className: "row g-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("div", { + className: "p-3 rounded-3 border border-secondary text-center", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("small", { + className: "text-slate-400 text-uppercase fw-bold d-block", + style: { + color: '#94a3b8' + } + }, "System Stock"), /*#__PURE__*/React.createElement("span", { + className: "fs-3 fw-bolder text-white" + }, reconcileModalItem.current_qty), /*#__PURE__*/React.createElement("span", { + className: "small text-slate-400 ms-1", + style: { + color: '#94a3b8' + } + }, "Units"))), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("div", { + className: "p-3 rounded-3 border border-primary text-center", + style: { + background: 'rgba(14, 165, 233, 0.15)' + } + }, /*#__PURE__*/React.createElement("small", { + className: "text-cyan-300 text-uppercase fw-bold d-block", + style: { + color: '#38bdf8' + } + }, "Physical Shelf Count"), /*#__PURE__*/React.createElement("input", { + type: "number", + min: "0", + className: "form-control form-control-lg text-center fw-bolder text-cyan-300 border-primary mt-1 bg-dark", + value: reconcilePhysicalQty, + onChange: e => setReconcilePhysicalQty(e.target.value), + autoFocus: true + })))), (() => { + const sys = Number(reconcileModalItem.current_qty || 0); + const phy = Number(reconcilePhysicalQty !== '' ? reconcilePhysicalQty : sys); + const diff = phy - sys; + const rate = Number(reconcileModalItem.ptr || reconcileModalItem.mrp || 0); + const val = Math.abs(diff) * rate; + if (diff === 0) { + return /*#__PURE__*/React.createElement("div", { + className: "p-2.5 rounded-3 border border-success d-flex align-items-center gap-2 mb-3 small", style: { - maxWidth: 540 - }, - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content border-0 shadow-2xl rounded-4 overflow-hidden", - style: { - background: '#0f172a', - color: '#f8fafc', - border: '1px solid #334155' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header border-bottom border-secondary py-3 px-4", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("div", { - className: "p-2 rounded-3 bg-primary bg-opacity-25 text-primary", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-sliders2 fs-5" - }) - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "modal-title fw-bold text-white mb-0", - children: "Stock Reconciliation & Discrepancy Audit" - }), /*#__PURE__*/_jsxs("small", { - className: "text-slate-400", - style: { - color: '#94a3b8' - }, - children: [store.store_name, " • Physical vs System Shelf Count"] - })] - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setReconcileModalItem(null) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-4", - children: [/*#__PURE__*/_jsxs("div", { - className: "p-3 rounded-3 mb-3 border border-secondary", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-white fs-6", - children: reconcileModalItem.item_name - }), /*#__PURE__*/_jsxs("div", { - className: "text-slate-400 small mb-2", - style: { - color: '#94a3b8' - }, - children: [reconcileModalItem.generic_name, " • Unit Pack: ", reconcileModalItem.unit_pack || 'Unit'] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 small", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("span", { - className: "text-slate-400", - style: { - color: '#94a3b8' - }, - children: "Batch No:" - }), " ", /*#__PURE__*/_jsx("strong", { - className: "text-cyan-300", - style: { - color: '#67e8f9' - }, - children: reconcileModalItem.batch_no - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("span", { - className: "text-slate-400", - style: { - color: '#94a3b8' - }, - children: "Expiry:" - }), " ", /*#__PURE__*/_jsx("strong", { - className: "text-white", - children: reconcileModalItem.expiry_display || reconcileModalItem.expiry_date - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("span", { - className: "text-slate-400", - style: { - color: '#94a3b8' - }, - children: "PTR / Cost:" - }), " ", /*#__PURE__*/_jsxs("strong", { - className: "text-white", - children: ["₹", reconcileModalItem.ptr] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("span", { - className: "text-slate-400", - style: { - color: '#94a3b8' - }, - children: "MRP:" - }), " ", /*#__PURE__*/_jsxs("strong", { - className: "text-white", - children: ["₹", reconcileModalItem.mrp] - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-3 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "col-6", - children: /*#__PURE__*/_jsxs("div", { - className: "p-3 rounded-3 border border-secondary text-center", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsx("small", { - className: "text-slate-400 text-uppercase fw-bold d-block", - style: { - color: '#94a3b8' - }, - children: "System Stock" - }), /*#__PURE__*/_jsx("span", { - className: "fs-3 fw-bolder text-white", - children: reconcileModalItem.current_qty - }), /*#__PURE__*/_jsx("span", { - className: "small text-slate-400 ms-1", - style: { - color: '#94a3b8' - }, - children: "Units" - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-6", - children: /*#__PURE__*/_jsxs("div", { - className: "p-3 rounded-3 border border-primary text-center", - style: { - background: 'rgba(14, 165, 233, 0.15)' - }, - children: [/*#__PURE__*/_jsx("small", { - className: "text-cyan-300 text-uppercase fw-bold d-block", - style: { - color: '#38bdf8' - }, - children: "Physical Shelf Count" - }), /*#__PURE__*/_jsx("input", { - type: "number", - min: "0", - className: "form-control form-control-lg text-center fw-bolder text-cyan-300 border-primary mt-1 bg-dark", - value: reconcilePhysicalQty, - onChange: e => setReconcilePhysicalQty(e.target.value), - autoFocus: true - })] - }) - })] - }), (() => { - const sys = Number(reconcileModalItem.current_qty || 0); - const phy = Number(reconcilePhysicalQty !== '' ? reconcilePhysicalQty : sys); - const diff = phy - sys; - const rate = Number(reconcileModalItem.ptr || reconcileModalItem.mrp || 0); - const val = Math.abs(diff) * rate; - if (diff === 0) { - return /*#__PURE__*/_jsxs("div", { - className: "p-2.5 rounded-3 border border-success d-flex align-items-center gap-2 mb-3 small", - style: { - background: 'rgba(16, 185, 129, 0.15)', - color: '#34d399' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle-fill fs-5" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("strong", { - children: "Counts Match Perfectly." - }), " Physical shelf count equals system record (0 discrepancy)."] - })] - }); - } else if (diff < 0) { - return /*#__PURE__*/_jsxs("div", { - className: "p-2.5 rounded-3 border border-danger d-flex align-items-center gap-2 mb-3 small", - style: { - background: 'rgba(239, 68, 68, 0.15)', - color: '#f87171' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-exclamation-octagon-fill fs-5" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("strong", { - children: ["Shortage Detected: ", Math.abs(diff), " Units Short"] - }), /*#__PURE__*/_jsxs("div", { - className: "text-white-50", - children: ["Estimated Discrepancy Value: ", /*#__PURE__*/_jsxs("strong", { - children: ["₹", val.toFixed(2)] - }), " (System ", sys, " > Shelf ", phy, ")"] - })] - })] - }); - } else { - return /*#__PURE__*/_jsxs("div", { - className: "p-2.5 rounded-3 border border-info d-flex align-items-center gap-2 mb-3 small", - style: { - background: 'rgba(14, 165, 233, 0.15)', - color: '#38bdf8' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-plus-circle-fill fs-5" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("strong", { - children: ["Surplus Stock: +", diff, " Extra Units Found"] - }), /*#__PURE__*/_jsxs("div", { - className: "text-white-50", - children: ["Estimated Valuation: ", /*#__PURE__*/_jsxs("strong", { - children: ["₹", val.toFixed(2)] - }), " (Shelf ", phy, " > System ", sys, ")"] - })] - })] - }); - } - })(), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-slate-300 small fw-bold", - style: { - color: '#cbd5e1' - }, - children: "Audit Reason / Discrepancy Cause" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm bg-dark text-white border-secondary", - value: reconcileAuditType, - onChange: e => setReconcileAuditType(e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "PHYSICAL_VARIATION", - children: "Physical Count Variation (Shelf vs System Count)" - }), /*#__PURE__*/_jsx("option", { - value: "DAMAGE", - children: "Damaged Packaging / Foil Broken" - }), /*#__PURE__*/_jsx("option", { - value: "BREAKAGE", - children: "Breakage / Spillage / Bottle Leakage" - }), /*#__PURE__*/_jsx("option", { - value: "EXPIRY_DUMP", - children: "Expired Stock (Disposed from Shelf)" - }), /*#__PURE__*/_jsx("option", { - value: "SURPLUS_FOUND", - children: "Unrecorded Surplus Stock Found" - }), /*#__PURE__*/_jsx("option", { - value: "THEFT_LOSS", - children: "Unaccounted Discrepancy / Shrinkage" - }), /*#__PURE__*/_jsx("option", { - value: "AUDIT_CORRECTION", - children: "Manual Inventory Correction" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-slate-300 small fw-bold", - style: { - color: '#cbd5e1' - }, - children: "Audit Remarks & Shelf Notes" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-dark text-white border-secondary", - placeholder: "e.g., Verified on shelf during physical stock take", - value: reconcileRemarks, - onChange: e => setReconcileRemarks(e.target.value) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-between p-2.5 rounded-3 border border-secondary small", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsxs("span", { - className: "text-slate-400", - style: { - color: '#94a3b8' - }, - children: ["Audited By: ", /*#__PURE__*/_jsx("strong", { - className: "text-white", - children: activeOperator ? activeOperator.full_name : 'Store Staff' - }), " (", activeOperator?.user_role || 'auditor', ")"] - }), /*#__PURE__*/_jsxs("span", { - className: "text-slate-400", - style: { - color: '#94a3b8' - }, - children: ["Date: ", /*#__PURE__*/_jsx("strong", { - className: "text-white", - children: new Date().toLocaleDateString('en-IN') - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer border-top border-secondary py-2 px-4", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-secondary", - onClick: () => setReconcileModalItem(null), - children: "Cancel" - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-primary px-3 fw-bold d-flex align-items-center gap-1.5", - onClick: handleReconcileSubmit, - disabled: isSubmittingReconcile, - children: isSubmittingReconcile ? /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm" - }), " Reconciling..."] - }) : /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-lg" - }), " Commit Stock Adjustment"] - }) - })] - })] - }) - }) - })] - }); + background: 'rgba(16, 185, 129, 0.15)', + color: '#34d399' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle-fill fs-5" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", null, "Counts Match Perfectly."), " Physical shelf count equals system record (0 discrepancy).")); + } else if (diff < 0) { + return /*#__PURE__*/React.createElement("div", { + className: "p-2.5 rounded-3 border border-danger d-flex align-items-center gap-2 mb-3 small", + style: { + background: 'rgba(239, 68, 68, 0.15)', + color: '#f87171' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-exclamation-octagon-fill fs-5" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", null, "Shortage Detected: ", Math.abs(diff), " Units Short"), /*#__PURE__*/React.createElement("div", { + className: "text-white-50" + }, "Estimated Discrepancy Value: ", /*#__PURE__*/React.createElement("strong", null, "₹", val.toFixed(2)), " (System ", sys, " > Shelf ", phy, ")"))); + } else { + return /*#__PURE__*/React.createElement("div", { + className: "p-2.5 rounded-3 border border-info d-flex align-items-center gap-2 mb-3 small", + style: { + background: 'rgba(14, 165, 233, 0.15)', + color: '#38bdf8' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-plus-circle-fill fs-5" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", null, "Surplus Stock: +", diff, " Extra Units Found"), /*#__PURE__*/React.createElement("div", { + className: "text-white-50" + }, "Estimated Valuation: ", /*#__PURE__*/React.createElement("strong", null, "₹", val.toFixed(2)), " (Shelf ", phy, " > System ", sys, ")"))); + } + })(), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-slate-300 small fw-bold", + style: { + color: '#cbd5e1' + } + }, "Audit Reason / Discrepancy Cause"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm bg-dark text-white border-secondary", + value: reconcileAuditType, + onChange: e => setReconcileAuditType(e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "PHYSICAL_VARIATION" + }, "Physical Count Variation (Shelf vs System Count)"), /*#__PURE__*/React.createElement("option", { + value: "DAMAGE" + }, "Damaged Packaging / Foil Broken"), /*#__PURE__*/React.createElement("option", { + value: "BREAKAGE" + }, "Breakage / Spillage / Bottle Leakage"), /*#__PURE__*/React.createElement("option", { + value: "EXPIRY_DUMP" + }, "Expired Stock (Disposed from Shelf)"), /*#__PURE__*/React.createElement("option", { + value: "SURPLUS_FOUND" + }, "Unrecorded Surplus Stock Found"), /*#__PURE__*/React.createElement("option", { + value: "THEFT_LOSS" + }, "Unaccounted Discrepancy / Shrinkage"), /*#__PURE__*/React.createElement("option", { + value: "AUDIT_CORRECTION" + }, "Manual Inventory Correction"))), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-slate-300 small fw-bold", + style: { + color: '#cbd5e1' + } + }, "Audit Remarks & Shelf Notes"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-dark text-white border-secondary", + placeholder: "e.g., Verified on shelf during physical stock take", + value: reconcileRemarks, + onChange: e => setReconcileRemarks(e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-between p-2.5 rounded-3 border border-secondary small", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("span", { + className: "text-slate-400", + style: { + color: '#94a3b8' + } + }, "Audited By: ", /*#__PURE__*/React.createElement("strong", { + className: "text-white" + }, activeOperator ? activeOperator.full_name : 'Store Staff'), " (", activeOperator?.user_role || 'auditor', ")"), /*#__PURE__*/React.createElement("span", { + className: "text-slate-400", + style: { + color: '#94a3b8' + } + }, "Date: ", /*#__PURE__*/React.createElement("strong", { + className: "text-white" + }, new Date().toLocaleDateString('en-IN'))))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer border-top border-secondary py-2 px-4", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-secondary", + onClick: () => setReconcileModalItem(null) + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-primary px-3 fw-bold d-flex align-items-center gap-1.5", + onClick: handleReconcileSubmit, + disabled: isSubmittingReconcile + }, isSubmittingReconcile ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm" + }), " Reconciling...") : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-lg" + }), " Commit Stock Adjustment"))))))); } // ========================================================================= @@ -11469,4412 +9269,3296 @@ function PurchaseView({ notify('Purchase invoice error: ' + e.message, 'error'); } }; - return /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap gap-2 mb-3 align-items-center", - children: [/*#__PURE__*/_jsxs("button", { - className: `btn btn-sm ${subTab === 'inward' ? 'btn-primary shadow-sm' : 'btn-outline-secondary'}`, - onClick: () => setSubTab('inward'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-box-arrow-in-down me-1" - }), " Inward Purchase Bill"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm ${subTab === 'ledger' ? 'btn-primary shadow-sm' : 'btn-outline-secondary'}`, - onClick: () => { - setSubTab('ledger'); - fetchLedgerSummary(); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-journal-bookmark me-1" - }), " Supplier Ledger & Payments"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm ${subTab === 'short_items' ? 'btn-warning text-dark fw-bold shadow-sm' : 'btn-outline-secondary'}`, - onClick: () => { - setSubTab('short_items'); - fetchShortItems(); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-exclamation-triangle me-1" - }), " Short Items & PO Generator", shortItems.length > 0 && /*#__PURE__*/_jsx("span", { - className: "badge bg-danger ms-1", - children: shortItems.length - })] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm ${subTab === 'purchase_orders' ? 'btn-primary shadow-sm' : 'btn-outline-secondary'}`, - onClick: () => { - setSubTab('purchase_orders'); - fetchPurchaseOrders(); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-text me-1" - }), " Purchase Orders"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm ${subTab === 'suppliers' ? 'btn-primary shadow-sm' : 'btn-outline-secondary'}`, - onClick: () => setSubTab('suppliers'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-truck me-1" - }), " Supplier Directory (", suppliers.length, ")"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm ${subTab === 'excel' ? 'btn-success shadow-sm' : 'btn-outline-secondary'}`, - onClick: () => setSubTab('excel'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-spreadsheet me-1" - }), " Excel / CSV Import"] - })] - }), subTab === 'inward' && /*#__PURE__*/_jsxs("div", { - className: "counter-card", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap justify-content-between align-items-center mb-3 gap-2", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("h5", { - className: "fw-bold mb-0", - children: [/*#__PURE__*/_jsx("i", { - className: `bi ${isChallan ? 'bi-truck text-warning' : 'bi-receipt text-primary'} me-1.5` - }), editingPurchaseId ? `Edit Purchase Invoice #${invoiceNo}` : isChallan ? 'Distributor Delivery Challan (Stock Entry)' : 'Distributor Purchase Inward (Tax Invoice)'] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: editingPurchaseId ? `Modifying existing Bill #${invoiceNo} (Ref #${editingPurchaseId}) - adjustments reflect in stock & ledger` : isChallan ? 'Record inward stock under vendor delivery challan (can be converted to tax invoice later)' : 'Enter vendor tax invoice to replenish store inventory and post supplier ledger payable' - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-secondary", - onClick: () => { - fetchRecentPurchases(); - setShowPurchaseHistoryModal(true); - }, - title: "View recent inward bills and select one to edit", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clock-history me-1" - }), " Inward Bills History / Edit (", recentPurchases.length, ")"] - }), loadedPoNumber ? /*#__PURE__*/_jsxs("div", { - className: "badge bg-info-subtle text-info border border-info px-2 py-1.5 d-flex align-items-center gap-1.5", - style: { - fontSize: '12px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-link-45deg fs-6" - }), /*#__PURE__*/_jsxs("span", { - children: ["Linked PO: ", /*#__PURE__*/_jsx("strong", { - children: loadedPoNumber - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-dark ms-1", - style: { - fontSize: '9px' - }, - onClick: () => { - setLoadedPoId(null); - setLoadedPoNumber(''); - }, - title: "Unlink PO" - })] - }) : /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-primary", - onClick: () => { - fetchPurchaseOrders(); - setSubTab('purchase_orders'); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-box-arrow-in-down-right me-1" - }), " Load from Purchase Order"] - })] - })] - }), editingPurchaseId && /*#__PURE__*/_jsxs("div", { - className: "alert alert-warning border border-warning-subtle shadow-sm py-2 px-3 mb-3 d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-warning text-dark fs-6 px-2.5 py-1.5", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-pencil-square me-1" - }), "EDIT MODE"] - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("strong", { - className: "text-dark d-block", - children: ["Editing Purchase Invoice #", invoiceNo, " (Purchase ID: #", editingPurchaseId, ")"] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "Updating this invoice will recalculate batch stock in this store and adjust supplier ledger balances." - })] - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-outline-dark btn-sm fw-semibold", - onClick: cancelEditPurchase, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-x-circle me-1" - }), " Cancel Edit & New Inward"] - })] - }), /*#__PURE__*/_jsx("div", { - className: "card border-0 shadow-sm p-3 mb-3", - style: { - background: '#f8fafc', - borderRadius: '10px' - }, - children: /*#__PURE__*/_jsxs("div", { - className: "row g-2 align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-4", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-1", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-0", - children: ["Supplier / Distributor ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-link btn-sm p-0 text-decoration-none fw-semibold", - style: { - fontSize: '11px' - }, - onClick: openAddSupplier, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-plus-circle me-1" - }), "+ Add New"] - })] - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: selectedSupplierId, - onChange: e => { - const sId = e.target.value; - setSelectedSupplierId(sId); - fetchSupplierChallans(sId); - }, - children: [/*#__PURE__*/_jsx("option", { - value: "", - children: "-- Select Supplier --" - }), suppliers.map(s => /*#__PURE__*/_jsxs("option", { - value: s.supplier_id, - children: [s.supplier_name, " (GST: ", s.gstin || 'N/A', ")"] - }, s.supplier_id))] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Entry Type" - }), /*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm w-100", - role: "group", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn ${!isChallan ? 'btn-primary fw-bold' : 'btn-outline-secondary'}`, - onClick: () => setIsChallan(false), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-receipt me-1" - }), " Tax Invoice"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn ${isChallan ? 'btn-warning text-dark fw-bold' : 'btn-outline-secondary'}`, - onClick: () => setIsChallan(true), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-truck me-1" - }), " Challan"] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-3", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-1", - children: [isChallan ? 'Challan Number' : 'Bill / Invoice No.', " ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: isChallan ? "e.g. CHL-2026-001" : "e.g. APX-9941", - value: invoiceNo, - onChange: e => setInvoiceNo(e.target.value) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: isChallan ? 'Challan Date' : 'Invoice Date' - }), /*#__PURE__*/_jsx("input", { - type: "date", - className: "form-control form-control-sm", - value: invoiceDate, - onChange: e => setInvoiceDate(e.target.value) - })] - }), isChallan && /*#__PURE__*/_jsx("div", { - className: "col-12 mt-1", - children: /*#__PURE__*/_jsxs("div", { - className: "badge bg-warning-subtle text-dark border border-warning px-2.5 py-1 d-inline-flex align-items-center gap-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-info-circle-fill text-warning" - }), /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("strong", { - children: "Challan Inward:" - }), " Adds physical stock immediately without ledger debt. This challan can later be imported directly into a final Tax Invoice."] - })] - }) - })] - }) - }), (!selectedSupplierId || !invoiceNo.trim()) && !editingPurchaseId ? /*#__PURE__*/_jsxs("div", { - className: "card border border-2 border-dashed bg-light text-center p-4 my-4", - style: { - borderRadius: '12px' - }, - children: [/*#__PURE__*/_jsx("div", { - className: "mx-auto mb-2 text-primary", - style: { - width: '48px', - height: '48px', - borderRadius: '50%', - background: '#e0f2fe', - display: 'flex', - alignItems: 'center', - justifyContent: 'center' - }, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-up-circle fs-3" - }) - }), /*#__PURE__*/_jsxs("h6", { - className: "fw-bold text-dark mb-1", - children: ["Step 1: Select Supplier & Enter ", isChallan ? 'Challan' : 'Invoice', " Details Above"] - }), /*#__PURE__*/_jsxs("p", { - className: "text-muted small mb-0", - style: { - maxWidth: '560px', - margin: '0 auto' - }, - children: ["Please choose the ", /*#__PURE__*/_jsx("strong", { - children: "Supplier / Distributor" - }), " and provide the ", /*#__PURE__*/_jsx("strong", { - children: isChallan ? 'Delivery Challan No.' : 'Supplier Bill / Invoice No.' - }), " above to unlock the medicine entry form, historical rate lookup, and pending challan imports."] - })] - }) : - /*#__PURE__*/ - /* Step 2: Main Pharma Entry Workstation (2-Column Grid) */ - _jsxs("div", { - className: "row g-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-xl-8 col-lg-7", - children: [/*#__PURE__*/_jsxs("div", { - className: "card border shadow-sm mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header bg-white py-2 px-3 d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("span", { - className: "fw-bold text-dark small", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-list-check me-1 text-primary" - }), "Invoice Line Items (", rows.length, ")"] - }), rows.length > 0 && /*#__PURE__*/_jsxs("span", { - className: "badge bg-primary-subtle text-primary border", - children: ["Total Items: ", rows.length] - })] - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive", - style: { - maxHeight: '280px', - overflowY: 'auto' - }, - children: /*#__PURE__*/_jsxs("table", { - className: "table table-sm table-hover table-bordered mb-0 align-middle", - style: { - fontSize: '11.5px' - }, - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light sticky-top", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - style: { - width: '30px' - }, - className: "text-center", - children: "#" - }), /*#__PURE__*/_jsx("th", { - style: { - width: '50px' - }, - className: "text-center", - children: "RecNo" - }), /*#__PURE__*/_jsx("th", { - style: { - minWidth: '130px', - maxWidth: '160px' - }, - children: "Item Name" - }), /*#__PURE__*/_jsx("th", { - style: { - width: '80px' - }, - children: "Batch No" - }), /*#__PURE__*/_jsx("th", { - style: { - width: '65px' - }, - className: "text-center", - children: "Exp." - }), /*#__PURE__*/_jsx("th", { - style: { - width: '65px' - }, - className: "text-end", - children: "MRP" - }), /*#__PURE__*/_jsx("th", { - style: { - width: '55px' - }, - className: "text-center", - children: "Qty." - }), /*#__PURE__*/_jsx("th", { - style: { - width: '65px' - }, - className: "text-end", - children: "Rate" - }), /*#__PURE__*/_jsx("th", { - style: { - width: '75px' - }, - className: "text-end", - children: "Amount" - }), /*#__PURE__*/_jsx("th", { - style: { - width: '50px' - }, - className: "text-end", - children: "Disc." - }), /*#__PURE__*/_jsx("th", { - style: { - width: '70px' - }, - className: "text-end", - children: "Tax Amount" - }), /*#__PURE__*/_jsx("th", { - style: { - width: '60px' - }, - className: "text-end", - children: "CGST" - }), /*#__PURE__*/_jsx("th", { - style: { - width: '60px' - }, - className: "text-end", - children: "SGST" - }), /*#__PURE__*/_jsx("th", { - style: { - width: '80px' - }, - className: "text-end", - children: "Net Amount" - }), /*#__PURE__*/_jsx("th", { - style: { - width: '60px' - }, - className: "text-center", - children: "Action" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: rows.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "15", - className: "text-center text-muted py-4", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-inbox fs-4 d-block mb-1 text-secondary" - }), /*#__PURE__*/_jsx("span", { - children: "No medicines added yet. Use the form below or include pending challans from the right." - })] - }) - }) : rows.map((r, i) => { - const expDisplay = r.exp_month && r.exp_year ? `${r.exp_month}/${r.exp_year}` : r.expiry_date ? r.expiry_date.slice(2, 7) : '-'; - const taxAmt = ((Number(r.cgst_amount) || 0) + (Number(r.sgst_amount) || 0)).toFixed(2); - const isReturn = Number(r.qty_packs) < 0 || Number(r.net_amount) < 0; - return /*#__PURE__*/_jsxs("tr", { - className: editingItemIndex === i ? 'table-warning' : isReturn ? 'table-danger bg-danger-subtle' : '', - children: [/*#__PURE__*/_jsx("td", { - className: "text-center text-secondary", - children: i + 1 - }), /*#__PURE__*/_jsx("td", { - className: "text-center text-secondary", - children: r.item_id || r.product_master_id || i + 1 - }), /*#__PURE__*/_jsxs("td", { - style: { - maxWidth: '160px' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-1", - children: [/*#__PURE__*/_jsx("span", { - className: "fw-bold text-truncate text-dark", - title: r.item_name, - children: r.item_name - }), isReturn && /*#__PURE__*/_jsx("span", { - className: "badge bg-danger text-white py-0 px-1", - style: { - fontSize: '9px' - }, - children: "RETURN" - })] - }), r.generic_name && /*#__PURE__*/_jsx("div", { - className: "text-muted text-truncate", - style: { - fontSize: '10px' - }, - title: r.generic_name, - children: r.generic_name - })] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: "badge bg-light text-dark border font-monospace", - children: r.batch_no || '-' - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: expDisplay - }), /*#__PURE__*/_jsxs("td", { - className: "text-end", - children: ["₹", Number(r.mrp || 0).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - className: "text-center", - children: [/*#__PURE__*/_jsx("span", { - className: `fw-bold ${isReturn ? 'text-danger' : ''}`, - children: r.qty_packs - }), Number(r.free_qty_packs) > 0 && /*#__PURE__*/_jsxs("span", { - className: "text-success", - style: { - fontSize: '10px' - }, - children: ["+", r.free_qty_packs, "F"] - })] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end", - children: ["₹", Number(r.ptr || 0).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - className: `text-end ${isReturn ? 'text-danger fw-semibold' : ''}`, - children: ["₹", Number(r.amount || 0).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end", - children: [Number(r.discount_pct || 0), "%"] - }), /*#__PURE__*/_jsxs("td", { - className: `text-end ${isReturn ? 'text-danger' : ''}`, - children: ["₹", taxAmt] - }), /*#__PURE__*/_jsxs("td", { - className: `text-end ${isReturn ? 'text-danger' : ''}`, - children: ["₹", Number(r.cgst_amount || Number(r.taxable_amount || 0) * (Number(r.cgst_pct || 6) / 100)).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - className: `text-end ${isReturn ? 'text-danger' : ''}`, - children: ["₹", Number(r.sgst_amount || Number(r.taxable_amount || 0) * (Number(r.sgst_pct || 6) / 100)).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - className: `text-end fw-bold ${isReturn ? 'text-danger' : 'text-dark'}`, - children: ["₹", Number(r.net_amount || 0).toFixed(2)] - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: /*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-outline-primary btn-sm py-0 px-1", - onClick: () => handleEditRow(i), - title: "Edit this row in form below", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-pencil" - }) - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-outline-danger btn-sm py-0 px-1", - onClick: () => removeRow(i), - title: "Delete this row", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-trash" - }) - })] - }) - })] - }, i); - }) - })] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "card-footer bg-light py-2 px-3 d-flex flex-wrap justify-content-end align-items-center gap-4 text-secondary small fw-semibold", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("span", { - className: "text-muted fw-normal", - children: "Total Taxable: " - }), /*#__PURE__*/_jsxs("strong", { - className: "text-dark fs-6", - children: ["₹", billTotals.taxable] - })] - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("span", { - className: "text-muted fw-normal", - children: "CGST: " - }), /*#__PURE__*/_jsxs("strong", { - className: "text-dark", - children: ["₹", billTotals.cgst] - })] - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("span", { - className: "text-muted fw-normal", - children: "SGST: " - }), /*#__PURE__*/_jsxs("strong", { - className: "text-dark", - children: ["₹", billTotals.sgst] - })] - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("span", { - className: "text-muted fw-normal", - children: "Net Amount: " - }), /*#__PURE__*/_jsxs("strong", { - className: "text-primary fs-5", - children: ["₹", billTotals.net] - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card border shadow-sm p-3 mb-3 bg-white", - style: { - borderRadius: '10px' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-2 pb-1 border-bottom", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold mb-0 text-dark", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-plus-circle-dotted text-primary me-1" - }), editingItemIndex !== null ? `Modify Row #${editingItemIndex + 1}` : 'Add Medicine to Inward Bill'] - }), editingItemIndex !== null && /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-link text-danger p-0 text-decoration-none", - onClick: resetItemForm, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-x-circle me-1" - }), " Cancel Row Edit"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-9 position-relative", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-1 d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("span", { - children: ["Product Search (Master Auto-Search) ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-link btn-sm p-0 text-decoration-none fw-semibold", - style: { - fontSize: '11px' - }, - onClick: () => openAddMasterModal(itemForm.item_name), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-plus-circle me-1" - }), "+ Add to Master"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "text", - id: "pharma_product_search_input", - className: `form-control form-control-sm fw-semibold ${itemForm.item_id ? 'border-success' : ''}`, - placeholder: "Type medicine name (e.g. ACEFE-P, Augmentin)...", - value: itemForm.item_name, - autoComplete: "off", - onChange: e => handleProductSearchChange(e.target.value), - onKeyDown: handleProductSearchKeyDown, - onFocus: () => { - if (itemForm.item_name.trim().length >= 1) { - handleProductSearchChange(itemForm.item_name); - } - } - }), itemForm.item_id > 0 && /*#__PURE__*/_jsx("span", { - className: "input-group-text bg-success text-white py-0 px-2", - title: "Matched in Master Catalog", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-check2" - }) - })] - }), itemForm.generic_name ? /*#__PURE__*/_jsxs("div", { - className: "text-muted text-truncate mt-1 d-flex align-items-center gap-1", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-light text-primary border", - style: { - fontSize: '9.5px' - }, - children: itemForm.category || 'Tablet' - }), /*#__PURE__*/_jsx("span", { - children: itemForm.generic_name - })] - }) : null, activeSearchRow && /*#__PURE__*/_jsxs("div", { - ref: suggestionsDropdownRef, - className: "shadow-lg border rounded-2 bg-white", - style: { - position: 'absolute', - top: '100%', - left: 0, - width: '100%', - maxHeight: '280px', - overflowY: 'auto', - zIndex: 1060, - marginTop: '2px' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "bg-light px-2.5 py-1.5 border-bottom d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsx("span", { - className: "small fw-bold text-secondary", - style: { - fontSize: '11px' - }, - children: isSearchingMeds ? /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hourglass-split spinner-border spinner-border-sm me-1" - }), "Searching master..."] - }) : /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-database-check me-1 text-primary" - }), "Pharmacy Master (", suggestions.length, " found)", suggestions.length > 0 && /*#__PURE__*/_jsx("span", { - className: "text-muted ms-2 fw-normal", - style: { - fontSize: '10px' - }, - children: "(Use ↑ ↓ & Enter)" - })] - }) - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close", - style: { - fontSize: '9px' - }, - onClick: () => { - setActiveSearchRow(false); - setSelectedSuggestionIndex(-1); - } - })] - }), suggestions.length > 0 ? suggestions.map((sug, sIdx) => { - const isSelected = sIdx === selectedSuggestionIndex; - return /*#__PURE__*/_jsxs("div", { - ref: isSelected ? activeSuggestionRef : null, - className: `p-2 border-bottom ${isSelected ? 'bg-primary-subtle' : 'hover-bg-light'}`, - style: { - cursor: 'pointer', - transition: 'all 0.12s ease', - borderLeft: isSelected ? '4px solid #0284c7' : '4px solid transparent', - backgroundColor: isSelected ? '#e0f2fe' : undefined - }, - onMouseEnter: () => setSelectedSuggestionIndex(sIdx), - onMouseDown: e => { - e.preventDefault(); - handleSelectMedicine(sug); - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("span", { - className: `text-dark ${isSelected ? 'fw-bold text-primary' : 'fw-semibold'}`, - style: { - fontSize: '12.5px' - }, - children: [isSelected && /*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-right-short text-primary me-1" - }), sug.item_name] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-1", - children: [isSelected && /*#__PURE__*/_jsxs("span", { - className: "badge bg-primary text-white", - style: { - fontSize: '9px', - fontWeight: 600 - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-return-left me-1" - }), "Enter"] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-light text-primary border", - style: { - fontSize: '10px' - }, - children: sug.category || 'Tablet' - })] - })] - }), sug.generic_name && /*#__PURE__*/_jsx("div", { - className: "text-muted text-truncate small", - style: { - fontSize: '11px' - }, - children: sug.generic_name - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2 mt-1 align-items-center", - style: { - fontSize: '10.5px' - }, - children: [/*#__PURE__*/_jsxs("span", { - className: "text-secondary", - children: ["Pack: ", /*#__PURE__*/_jsxs("strong", { - children: [sug.units_per_pack || 10, "s"] - })] - }), /*#__PURE__*/_jsxs("span", { - className: "text-secondary", - children: ["GST: ", /*#__PURE__*/_jsxs("strong", { - children: [sug.gst_rate, "%"] - })] - }), /*#__PURE__*/_jsxs("span", { - className: "text-secondary", - children: ["HSN: ", /*#__PURE__*/_jsx("strong", { - children: sug.hsn_code || '3004' - })] - }), sug.mrp ? /*#__PURE__*/_jsxs("span", { - className: "text-secondary", - children: ["MRP: ", /*#__PURE__*/_jsxs("strong", { - children: ["₹", sug.mrp] - })] - }) : null] - })] - }, sIdx); - }) : !isSearchingMeds && /*#__PURE__*/_jsxs("div", { - className: "p-3 text-center text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-search fs-4 d-block mb-1 text-secondary" - }), /*#__PURE__*/_jsxs("div", { - className: "small fw-semibold", - children: ["No medicine found matching \"", itemForm.item_name, "\""] - }), /*#__PURE__*/_jsx("div", { - className: "text-muted", - style: { - fontSize: '11px' - }, - children: "Click below to add it directly into Pharmacy Master" - })] - }), /*#__PURE__*/_jsx("div", { - className: "p-2 bg-light border-top text-center", - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-primary w-100 fw-bold py-1", - style: { - fontSize: '12px' - }, - onMouseDown: e => { - e.preventDefault(); - openAddMasterModal(itemForm.item_name); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-plus-circle-fill me-1" - }), "+ Add \"", itemForm.item_name || 'New Medicine', "\" in Master"] - }) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Product Code" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-light text-secondary font-monospace", - value: itemForm.product_master_id || itemForm.item_id || 'AUTO', - readOnly: true - })] - })] - }), itemForm.item_id > 0 || editingItemIndex !== null ? /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-between bg-primary-subtle border border-primary-subtle px-2.5 py-1 rounded mb-2", - children: [/*#__PURE__*/_jsxs("span", { - className: "small text-primary fw-semibold", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle-fill me-1 text-success" - }), editingItemIndex !== null ? `Editing: ${itemForm.item_name}` : `Selected: ${itemForm.item_name} (Auto-filled with last batch, rate & location)`] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-link btn-sm p-0 text-danger text-decoration-none fw-semibold", - style: { - fontSize: '11px' - }, - onClick: () => resetItemForm(true), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-x-circle me-1" - }), " Change Product"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Packaging" - }), /*#__PURE__*/_jsx("input", { - type: "number", - id: "pharma_packaging_input", - className: "form-control form-control-sm", - placeholder: "10", - value: itemForm.units_per_pack, - onChange: e => handleItemFormChange('units_per_pack', e.target.value), - onKeyDown: e => handleFieldKeyDown(e, 'pharma_batch_no_input') - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-1", - children: ["Batch No. ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsx("input", { - type: "text", - id: "pharma_batch_no_input", - className: "form-control form-control-sm text-uppercase font-monospace fw-bold", - placeholder: "e.g. B-902", - value: itemForm.batch_no, - onChange: e => handleItemFormChange('batch_no', e.target.value), - onKeyDown: e => handleFieldKeyDown(e, 'pharma_exp_month_input') - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Exp. Month" - }), /*#__PURE__*/_jsx("select", { - id: "pharma_exp_month_input", - className: "form-select form-select-sm", - value: itemForm.exp_month, - onChange: e => handleItemFormChange('exp_month', e.target.value), - onKeyDown: e => handleFieldKeyDown(e, 'pharma_exp_year_input'), - children: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'].map(m => /*#__PURE__*/_jsxs("option", { - value: m, - children: [m, " (", ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][parseInt(m) - 1], ")"] - }, m)) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Exp. Year" - }), /*#__PURE__*/_jsx("select", { - id: "pharma_exp_year_input", - className: "form-select form-select-sm", - value: itemForm.exp_year, - onChange: e => handleItemFormChange('exp_year', e.target.value), - onKeyDown: e => handleFieldKeyDown(e, 'pharma_mrp_input'), - children: ['24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36'].map(y => /*#__PURE__*/_jsxs("option", { - value: y, - children: ["20", y] - }, y)) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "MRP (₹)" - }), /*#__PURE__*/_jsx("input", { - type: "number", - step: "0.01", - id: "pharma_mrp_input", - className: "form-control form-control-sm", - placeholder: "0.00", - value: itemForm.mrp, - onChange: e => handleItemFormChange('mrp', e.target.value), - onKeyDown: e => handleFieldKeyDown(e, 'pharma_qty_input') - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-1", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-0", - children: ["Qty (Packs) ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), Number(itemForm.qty_packs) < 0 && /*#__PURE__*/_jsx("span", { - className: "badge bg-danger text-white py-0 px-1", - style: { - fontSize: '9px' - }, - children: "RETURN" - })] - }), /*#__PURE__*/_jsx("input", { - type: "number", - id: "pharma_qty_input", - className: `form-control form-control-sm fw-bold ${Number(itemForm.qty_packs) < 0 ? 'text-danger border-danger bg-danger-subtle' : ''}`, - placeholder: "Qty (+ In / - Ret)", - value: itemForm.qty_packs, - onChange: e => handleItemFormChange('qty_packs', e.target.value), - onKeyDown: e => handleFieldKeyDown(e, 'pharma_free_qty_input') - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Free Qty" - }), /*#__PURE__*/_jsx("input", { - type: "number", - min: "0", - id: "pharma_free_qty_input", - className: "form-control form-control-sm", - value: itemForm.free_qty_packs, - onChange: e => handleItemFormChange('free_qty_packs', e.target.value), - onKeyDown: e => handleFieldKeyDown(e, 'pharma_ptr_input') - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Purchase Rate (PTR)" - }), /*#__PURE__*/_jsx("input", { - type: "number", - step: "0.01", - id: "pharma_ptr_input", - className: "form-control form-control-sm", - placeholder: "0.00", - value: itemForm.ptr, - onChange: e => handleItemFormChange('ptr', e.target.value), - onKeyDown: e => handleFieldKeyDown(e, 'pharma_disc_pct_input') - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Amount" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-light text-secondary fw-semibold", - value: '₹' + Number(itemForm.amount || 0).toFixed(2), - readOnly: true - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Discount %" - }), /*#__PURE__*/_jsx("input", { - type: "number", - step: "0.1", - min: "0", - max: "100", - id: "pharma_disc_pct_input", - className: "form-control form-control-sm", - value: itemForm.discount_pct, - onChange: e => handleItemFormChange('discount_pct', e.target.value), - onKeyDown: e => handleFieldKeyDown(e, 'submit') - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "SCH Amount" - }), /*#__PURE__*/_jsx("input", { - type: "number", - step: "0.01", - min: "0", - id: "pharma_sch_amount_input", - className: "form-control form-control-sm", - value: itemForm.sch_disc_amount, - onChange: e => handleItemFormChange('sch_disc_amount', e.target.value), - onKeyDown: e => handleFieldKeyDown(e, 'pharma_sch_disc_input') - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "SCH Discount %" - }), /*#__PURE__*/_jsx("input", { - type: "number", - step: "0.1", - min: "0", - max: "100", - id: "pharma_sch_disc_input", - className: "form-control form-control-sm", - value: itemForm.sch_disc_pct, - onChange: e => handleItemFormChange('sch_disc_pct', e.target.value), - onKeyDown: e => handleFieldKeyDown(e, 'submit') - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Taxable Amount" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-light text-secondary fw-semibold", - value: '₹' + Number(itemForm.taxable_amount || 0).toFixed(2), - readOnly: true - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "CGST %" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: itemForm.cgst_pct, - onChange: e => { - const val = parseFloat(e.target.value) || 0; - handleItemFormChange('cgst_pct', val); - handleItemFormChange('sgst_pct', val); - }, - children: [/*#__PURE__*/_jsx("option", { - value: "0", - children: "0% (Nil / Exempt)" - }), /*#__PURE__*/_jsx("option", { - value: "2.5", - children: "2.5% (5% GST)" - }), /*#__PURE__*/_jsx("option", { - value: "9", - children: "9.0% (18% GST)" - }), /*#__PURE__*/_jsx("option", { - value: "20", - children: "20.0% (40% GST)" - }), /*#__PURE__*/_jsx("option", { - value: "6", - children: "6.0% (12% Legacy)" - }), /*#__PURE__*/_jsx("option", { - value: "14", - children: "14.0% (28% Legacy)" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "SGST / IGST %" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: itemForm.sgst_pct, - onChange: e => handleItemFormChange('sgst_pct', parseFloat(e.target.value) || 0), - children: [/*#__PURE__*/_jsx("option", { - value: "0", - children: "0% (Nil / Exempt)" - }), /*#__PURE__*/_jsx("option", { - value: "2.5", - children: "2.5% (5% GST)" - }), /*#__PURE__*/_jsx("option", { - value: "9", - children: "9.0% (18% GST)" - }), /*#__PURE__*/_jsx("option", { - value: "20", - children: "20.0% (40% GST)" - }), /*#__PURE__*/_jsx("option", { - value: "6", - children: "6.0% (12% Legacy)" - }), /*#__PURE__*/_jsx("option", { - value: "14", - children: "14.0% (28% Legacy)" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Net Amount" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-primary-subtle text-primary fw-bold", - value: '₹' + Number(itemForm.net_amount || 0).toFixed(2), - readOnly: true - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Selling Price" - }), /*#__PURE__*/_jsx("input", { - type: "number", - step: "0.01", - id: "pharma_selling_price_input", - className: "form-control form-control-sm", - placeholder: "MRP", - value: itemForm.selling_price, - onChange: e => handleItemFormChange('selling_price', e.target.value), - onKeyDown: e => handleFieldKeyDown(e, 'pharma_shelf_no_input') - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "HSNCODE" - }), /*#__PURE__*/_jsx("input", { - type: "text", - id: "pharma_hsn_input", - className: "form-control form-control-sm", - value: itemForm.hsn_code, - onChange: e => handleItemFormChange('hsn_code', e.target.value), - onKeyDown: e => handleFieldKeyDown(e, 'pharma_shelf_no_input') - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 align-items-end", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-3 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Storage" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: itemForm.storage_type, - onChange: e => handleItemFormChange('storage_type', e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "Normal", - children: "Normal" - }), /*#__PURE__*/_jsx("option", { - value: "Cold Storage", - children: "Cold Storage (2-8°C)" - }), /*#__PURE__*/_jsx("option", { - value: "Cool", - children: "Cool (8-15°C)" - }), /*#__PURE__*/_jsx("option", { - value: "Deep Freeze", - children: "Deep Freeze (-20°C)" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Shelf No." - }), /*#__PURE__*/_jsx("input", { - type: "text", - id: "pharma_shelf_no_input", - className: "form-control form-control-sm", - placeholder: "e.g. S-1", - value: itemForm.shelf_no, - onChange: e => handleItemFormChange('shelf_no', e.target.value), - onKeyDown: e => handleFieldKeyDown(e, 'pharma_rack_no_input') - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-2 col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Rack No." - }), /*#__PURE__*/_jsx("input", { - type: "text", - id: "pharma_rack_no_input", - className: "form-control form-control-sm", - placeholder: "e.g. R-10", - value: itemForm.rack_no, - onChange: e => handleItemFormChange('rack_no', e.target.value), - onKeyDown: e => handleFieldKeyDown(e, 'submit') - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-5 col-12 d-flex gap-2 justify-content-end mt-2 mt-md-0", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-outline-secondary btn-sm px-3", - onClick: () => resetItemForm(true), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-counterclockwise me-1" - }), " Clear"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - id: "pharma_add_stock_btn", - className: editingItemIndex !== null ? "btn btn-warning text-dark fw-bold btn-sm px-3 shadow-sm" : Number(itemForm.qty_packs) < 0 ? "btn btn-danger fw-bold btn-sm px-4 shadow-sm" : "btn btn-primary fw-bold btn-sm px-4 shadow-sm", - onClick: handleAddOrUpdateItem, - title: Number(itemForm.qty_packs) < 0 ? "Add Return / Debit Item (Press Ctrl+Enter anytime)" : "Add Stock (Press Ctrl+Enter anytime)", - children: [/*#__PURE__*/_jsx("i", { - className: editingItemIndex !== null ? "bi bi-check2-circle me-1" : Number(itemForm.qty_packs) < 0 ? "bi bi-dash-circle me-1" : "bi bi-plus-circle me-1" - }), editingItemIndex !== null ? 'Update Stock Item' : Number(itemForm.qty_packs) < 0 ? '⊖ Add Return Item' : '+ Add Stock', /*#__PURE__*/_jsx("span", { - className: "badge bg-white bg-opacity-25 ms-1.5 py-0.5 px-1.5 text-white", - style: { - fontSize: '10px' - }, - children: "Ctrl+↵" - })] - })] - })] - })] - }) : /*#__PURE__*/_jsxs("div", { - className: "text-center py-4 text-muted small bg-light rounded-2 border border-dashed mt-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-search text-primary me-1.5 fs-5 d-block mb-1" - }), /*#__PURE__*/_jsxs("span", { - children: ["Search and select a medicine in ", /*#__PURE__*/_jsx("strong", { - children: "Product Search" - }), " above to enter stock details and auto-fill last batch, expiry, MRP, rate & rack location."] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap justify-content-between align-items-center p-3 bg-light rounded-3 border", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("span", { - className: "text-muted small", - children: "Ready to commit to inventory:" - }), /*#__PURE__*/_jsxs("div", { - className: "fw-bold text-dark", - children: [rows.length, " ", rows.length === 1 ? 'medicine' : 'medicines', " | Net Payable: ", /*#__PURE__*/_jsxs("span", { - className: "text-primary fs-6", - children: ["₹", billTotals.net] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2", - children: [editingPurchaseId && /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-outline-secondary btn-sm px-3", - onClick: cancelEditPurchase, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-x-circle me-1" - }), " Cancel Edit"] - }), /*#__PURE__*/_jsxs("button", { - className: editingPurchaseId ? "btn btn-warning shadow-sm fw-bold px-3 py-2 text-dark" : isChallan ? "btn btn-warning fw-bold text-dark shadow-sm px-4 py-2" : "btn btn-success-custom shadow-sm px-4 py-2", - onClick: savePurchaseBill, - children: [/*#__PURE__*/_jsx("i", { - className: editingPurchaseId ? "bi bi-check2-all me-1" : isChallan ? "bi bi-truck me-1" : "bi bi-check-circle me-1" - }), editingPurchaseId ? `Update Purchase Invoice #${invoiceNo}` : isChallan ? 'Record Delivery Challan & Update Stock' : 'Record Inward Bill & Update Inventory'] - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-xl-4 col-lg-5", - children: [/*#__PURE__*/_jsxs("div", { - className: "card border shadow-sm mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header bg-white py-2 px-3 d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("span", { - className: "fw-bold text-dark small", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-truck text-warning me-1" - }), "Pending Delivery Challans"] - }), selectedSupplierId && /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-link p-0 text-decoration-none", - onClick: () => fetchSupplierChallans(selectedSupplierId), - title: "Refresh supplier challans", - children: /*#__PURE__*/_jsx("i", { - className: `bi bi-arrow-repeat ${isLoadingChallans ? 'spinner-border spinner-border-sm' : ''}` - }) - })] - }), /*#__PURE__*/_jsx("div", { - className: "card-body p-2", - style: { - maxHeight: '280px', - overflowY: 'auto' - }, - children: !selectedSupplierId ? /*#__PURE__*/_jsx("div", { - className: "text-muted small p-3 text-center bg-light rounded", - children: "Select a supplier above to view pending challans." - }) : isLoadingChallans ? /*#__PURE__*/_jsxs("div", { - className: "text-center py-3 text-muted small", - children: [/*#__PURE__*/_jsx("div", { - className: "spinner-border spinner-border-sm text-primary me-2" - }), "Loading supplier challans..."] - }) : supplierChallans.length === 0 ? /*#__PURE__*/_jsx("div", { - className: "text-muted small p-3 text-center bg-light rounded", - children: "No challan items available for this supplier." - }) : supplierChallans.map((ch, chIdx) => /*#__PURE__*/_jsxs("div", { - className: "border rounded-2 p-2 mb-2 bg-light", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-1.5 pb-1 border-bottom", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("strong", { - className: "text-dark", - style: { - fontSize: '12px' - }, - children: ["Challan #", ch.challan_no] - }), /*#__PURE__*/_jsxs("div", { - className: "text-muted", - style: { - fontSize: '10.5px' - }, - children: ["Date: ", ch.date || 'N/A', " • ", ch.items ? ch.items.length : 0, " items"] - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-outline-primary py-0.5 px-2", - style: { - fontSize: '11px' - }, - onClick: () => includeAllChallanItems(ch), - title: "Import all items from this challan into invoice", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-box-arrow-in-right me-1" - }), " Include All"] - })] - }), ch.items && ch.items.length > 0 ? /*#__PURE__*/_jsx("div", { - className: "d-flex flex-column gap-1", - children: ch.items.map((ci, cItemIdx) => /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center bg-white p-1.5 rounded border", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "text-truncate me-2", - style: { - maxWidth: '170px' - }, - children: [/*#__PURE__*/_jsx("div", { - className: "fw-semibold text-dark text-truncate", - children: ci.item_name - }), /*#__PURE__*/_jsxs("span", { - className: "text-muted font-monospace", - style: { - fontSize: '10px' - }, - children: ["Batch: ", ci.batch_no || '-', " | Qty: ", ci.qty_packs] - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-xs btn-primary py-0 px-1.5 text-nowrap", - style: { - fontSize: '10.5px' - }, - onClick: () => includeChallanItem(ch, ci), - title: "Import this item into invoice", - children: "+ Include" - })] - }, cItemIdx)) - }) : /*#__PURE__*/_jsx("div", { - className: "text-muted small", - style: { - fontSize: '11px' - }, - children: "No items found in this challan." - })] - }, chIdx)) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card border shadow-sm", - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header bg-white py-2 px-3 d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("span", { - className: "fw-bold text-dark small", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clock-history text-info me-1" - }), "Previous Purchase History"] - }), historyTargetItemName && /*#__PURE__*/_jsx("span", { - className: "badge bg-info-subtle text-info border text-truncate", - style: { - maxWidth: '140px', - fontSize: '10.5px' - }, - children: historyTargetItemName - })] - }), /*#__PURE__*/_jsx("div", { - className: "card-body p-2", - style: { - maxHeight: '310px', - overflowY: 'auto' - }, - children: isLoadingProductHistory ? /*#__PURE__*/_jsxs("div", { - className: "text-center py-3 text-muted small", - children: [/*#__PURE__*/_jsx("div", { - className: "spinner-border spinner-border-sm text-info me-2" - }), "Fetching purchase rate history..."] - }) : !historyTargetItemName && productHistory.length === 0 ? /*#__PURE__*/_jsxs("div", { - className: "text-muted small p-3 text-center bg-light rounded", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-search d-block mb-1 fs-5 text-secondary" - }), "Type or select a product in ", /*#__PURE__*/_jsx("strong", { - children: "Product Search" - }), " to check previous purchase prices & vendors."] - }) : productHistory.length === 0 ? /*#__PURE__*/_jsx("div", { - className: "text-muted small p-3 text-center bg-light rounded", - children: "No purchase history found for selected product." - }) : /*#__PURE__*/_jsx("div", { - className: "d-flex flex-column gap-2", - children: productHistory.map((ph, phIdx) => /*#__PURE__*/_jsxs("div", { - className: "p-2 border rounded-2 bg-light", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-1", - children: [/*#__PURE__*/_jsx("strong", { - className: "text-primary text-truncate", - style: { - maxWidth: '160px' - }, - children: ph.supplier_name || 'Distributor' - }), /*#__PURE__*/_jsx("span", { - className: "text-muted", - style: { - fontSize: '10px' - }, - children: ph.invoice_date || ph.created_at ? (ph.invoice_date || ph.created_at).slice(0, 10) : '' - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between text-secondary mb-1", - style: { - fontSize: '10.5px' - }, - children: [/*#__PURE__*/_jsxs("span", { - children: ["Inv: ", /*#__PURE__*/_jsx("strong", { - children: ph.supplier_invoice_no || '-' - })] - }), /*#__PURE__*/_jsxs("span", { - children: ["Batch: ", /*#__PURE__*/_jsx("span", { - className: "font-monospace", - children: ph.batch_no || '-' - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center pt-1 border-top mt-1", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("span", { - className: "text-muted", - children: "PTR: " - }), /*#__PURE__*/_jsxs("strong", { - className: "text-dark", - children: ["₹", Number(ph.ptr || 0).toFixed(2)] - }), ph.mrp ? /*#__PURE__*/_jsxs("span", { - className: "text-muted ms-2", - children: ["MRP: ₹", Number(ph.mrp).toFixed(2)] - }) : null, Number(ph.discount_pct) > 0 ? /*#__PURE__*/_jsxs("span", { - className: "text-success ms-1", - children: ["(-", ph.discount_pct, "%)"] - }) : null] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-xs btn-outline-info py-0 px-1.5", - style: { - fontSize: '10.5px' - }, - onClick: () => { - setItemForm(prev => recomputeItemForm({ - ...prev, - ptr: ph.ptr || prev.ptr, - mrp: ph.mrp || prev.mrp, - discount_pct: ph.discount_pct !== undefined ? ph.discount_pct : prev.discount_pct, - gst_rate: ph.gst_rate !== undefined ? ph.gst_rate : prev.gst_rate, - cgst_pct: (Number(ph.gst_rate) || 12) / 2, - sgst_pct: (Number(ph.gst_rate) || 12) / 2 - })); - notify(`Applied historical PTR ₹${ph.ptr} to entry form.`, 'info'); - }, - title: "Apply these purchase rates to current item form", - children: "Use Rate" - })] - })] - }, phIdx)) - }) - })] - })] - })] - })] - }), subTab === 'excel' && /*#__PURE__*/_jsxs("div", { - className: "counter-card", - children: [/*#__PURE__*/_jsxs("h5", { - className: "fw-bold text-success mb-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-spreadsheet me-1" - }), " Excel / CSV Inventory Importer"] - }), /*#__PURE__*/_jsxs("p", { - className: "text-muted small mb-3", - children: ["Upload your stock export from Microsoft Excel or CSV format to seamlessly import medicines, batch numbers, MRP, PTR, HSN codes, and opening stock into ", /*#__PURE__*/_jsx("strong", { - children: store.store_name - }), "."] - }), /*#__PURE__*/_jsxs("div", { - className: "p-4 bg-light rounded-3 border text-center mb-3", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cloud-arrow-up fs-1 text-success d-block mb-2" - }), /*#__PURE__*/_jsx("h6", { - className: "fw-bold", - children: "Upload CSV / Excel File" - }), /*#__PURE__*/_jsx("p", { - className: "small text-muted mb-3", - children: "Ensure file is formatted as standard CSV or Excel-exported CSV." - }), /*#__PURE__*/_jsx("input", { - type: "file", - id: "excel_file_input", - accept: ".csv, .txt", - className: "form-control form-control-sm w-50 mx-auto mb-3" - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-success-custom", - onClick: async () => { - const fileInput = document.getElementById('excel_file_input'); - if (!fileInput.files || fileInput.files.length === 0) { - alert('Please select a CSV file first.'); - return; - } - const formData = new FormData(); - formData.append('store_id', store.store_id); - formData.append('import_file', fileInput.files[0]); - try { - const res = await fetch(API_BASE + 'stock/import-excel', { - method: 'POST', - body: formData - }); - const data = await res.json(); - if (data.ok) { - alert(data.message); - fileInput.value = ''; - } else { - alert(data.error || 'Import failed.'); - } - } catch (e) { - alert('Import error: ' + e.message); - } - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-upload me-1" - }), " Import Inventory into ", store.store_name] - })] - })] - }), subTab === 'suppliers' && /*#__PURE__*/_jsxs("div", { - className: "counter-card", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap justify-content-between align-items-center gap-2 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("h5", { - className: "fw-bold mb-0 text-dark", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-truck text-primary me-1" - }), " Approved Drug Distributors & Suppliers"] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "Manage licensed pharmaceutical distributors, DL Form 20B/21B, GSTIN, and credit terms" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - style: { - width: 250 - }, - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-white border-end-0", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-search text-muted" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control border-start-0", - placeholder: "Search distributor, GST...", - value: supplierSearch, - onChange: e => setSupplierSearch(e.target.value) - }), supplierSearch && /*#__PURE__*/_jsx("button", { - className: "btn btn-outline-secondary", - type: "button", - onClick: () => setSupplierSearch(''), - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-x" - }) - })] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-primary btn-sm px-3", - onClick: openAddSupplier, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-plus-circle me-1" - }), " Add New Supplier"] - })] - })] - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-pos align-middle mb-0", - children: [/*#__PURE__*/_jsx("thead", { - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - style: { - width: 45 - }, - children: "#" - }), /*#__PURE__*/_jsx("th", { - children: "Distributor Name" - }), /*#__PURE__*/_jsx("th", { - children: "DL Form 20B / 21B" - }), /*#__PURE__*/_jsx("th", { - children: "GSTIN & PAN" - }), /*#__PURE__*/_jsx("th", { - children: "Phone / Contact" - }), /*#__PURE__*/_jsx("th", { - children: "Credit Terms" - }), /*#__PURE__*/_jsx("th", { - children: "Address / Bank" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 90 - }, - className: "text-end pe-3", - children: "Actions" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: filteredSuppliers.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "8", - className: "text-center py-4 text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-truck fs-2 d-block mb-1 text-secondary" - }), suppliers.length === 0 ? 'No distributors registered yet. Click "Add New Supplier" to create one.' : 'No suppliers match your search query.'] - }) - }) : filteredSuppliers.map((s, i) => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - className: "fw-semibold text-secondary", - children: i + 1 - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-dark fs-6", - children: s.supplier_name - }), s.email && /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-envelope me-1" - }), s.email] - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsxs("div", { - className: "small", - children: [/*#__PURE__*/_jsx("strong", { - children: "20B:" - }), " ", s.dl_no_20b || /*#__PURE__*/_jsx("span", { - className: "text-muted", - children: "N/A" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "small", - children: [/*#__PURE__*/_jsx("strong", { - children: "21B:" - }), " ", s.dl_no_21b || /*#__PURE__*/_jsx("span", { - className: "text-muted", - children: "N/A" - })] - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - children: /*#__PURE__*/_jsx("code", { - className: "text-primary fw-bold", - children: s.gstin || 'N/A' - }) - }), s.pan_no && /*#__PURE__*/_jsxs("small", { - className: "text-muted d-block", - children: ["PAN: ", s.pan_no] - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-semibold text-dark", - children: s.phone || 'N/A' - }), s.contact_person && /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person me-1" - }), s.contact_person] - })] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("span", { - className: "badge bg-light text-dark border px-2 py-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-calendar-check me-1 text-primary" - }), s.credit_days || 30, " Days"] - }) - }), /*#__PURE__*/_jsxs("td", { - style: { - maxWidth: 220 - }, - children: [s.address && /*#__PURE__*/_jsxs("div", { - className: "small text-truncate", - title: s.address, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-geo-alt me-1 text-muted" - }), s.address] - }), s.bank_details && /*#__PURE__*/_jsxs("div", { - className: "small text-muted text-truncate", - title: s.bank_details, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-bank me-1" - }), s.bank_details] - }), !s.address && !s.bank_details && /*#__PURE__*/_jsx("span", { - className: "text-muted small", - children: "-" - })] - }), /*#__PURE__*/_jsx("td", { - className: "text-end pe-3", - children: /*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm", - children: [/*#__PURE__*/_jsx("button", { - className: "btn btn-outline-primary py-0.5 px-2", - title: "Edit Supplier", - onClick: () => openEditSupplier(s), - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-pencil-square" - }) - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-outline-danger py-0.5 px-2", - title: "Remove Supplier", - onClick: () => handleDeleteSupplier(s.supplier_id, s.supplier_name), - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-trash" - }) - })] - }) - })] - }, s.supplier_id)) - })] - }) - })] - }), subTab === 'ledger' && /*#__PURE__*/_jsxs("div", { - className: "counter-card", - children: [/*#__PURE__*/_jsxs("div", { - className: "row g-3 mb-4", - children: [/*#__PURE__*/_jsx("div", { - className: "col-md-3", - children: /*#__PURE__*/_jsx("div", { - className: "card border-0 shadow-sm p-3 bg-white h-100 border-start border-4 border-primary", - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted fw-semibold text-uppercase", - style: { - fontSize: '11px' - }, - children: "Total Inward Purchases" - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bold text-dark mb-0 mt-1", - children: ["₹", Number(ledgerOverall.total_purchases || 0).toLocaleString('en-IN', { - minimumFractionDigits: 2, - maximumFractionDigits: 2 - })] - })] - }), /*#__PURE__*/_jsx("div", { - className: "bg-primary-subtle text-primary p-2.5 rounded-circle", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-box-arrow-in-down fs-4" - }) - })] - }) - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-3", - children: /*#__PURE__*/_jsx("div", { - className: "card border-0 shadow-sm p-3 bg-white h-100 border-start border-4 border-success", - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted fw-semibold text-uppercase", - style: { - fontSize: '11px' - }, - children: "Total Payments Settled" - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bold text-success mb-0 mt-1", - children: ["₹", Number(ledgerOverall.total_paid || 0).toLocaleString('en-IN', { - minimumFractionDigits: 2, - maximumFractionDigits: 2 - })] - })] - }), /*#__PURE__*/_jsx("div", { - className: "bg-success-subtle text-success p-2.5 rounded-circle", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-check2-circle fs-4" - }) - })] - }) - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-3", - children: /*#__PURE__*/_jsx("div", { - className: "card border-0 shadow-sm p-3 bg-white h-100 border-start border-4 border-danger", - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted fw-semibold text-uppercase", - style: { - fontSize: '11px' - }, - children: "Balance Outstanding" - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bold text-danger mb-0 mt-1", - children: ["₹", Number(ledgerOverall.outstanding_balance || 0).toLocaleString('en-IN', { - minimumFractionDigits: 2, - maximumFractionDigits: 2 - })] - })] - }), /*#__PURE__*/_jsx("div", { - className: "bg-danger-subtle text-danger p-2.5 rounded-circle", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-exclamation-octagon fs-4" - }) - })] - }) - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-3", - children: /*#__PURE__*/_jsx("div", { - className: "card border-0 shadow-sm p-3 bg-white h-100 border-start border-4 border-warning", - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted fw-semibold text-uppercase", - style: { - fontSize: '11px' - }, - children: "Pending Invoices" - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bold text-warning-emphasis mb-0 mt-1", - children: [ledgerOverall.total_pending_bills || 0, " Bills"] - })] - }), /*#__PURE__*/_jsx("div", { - className: "bg-warning-subtle text-warning-emphasis p-2.5 rounded-circle", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-receipt fs-4" - }) - })] - }) - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap justify-content-between align-items-center gap-2 mb-3 bg-light p-2.5 rounded-3 border", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2 flex-grow-1", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-0 text-nowrap", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-funnel me-1" - }), "Select Supplier:"] - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - style: { - maxWidth: 320 - }, - value: activeLedgerSupplierId, - onChange: e => { - const val = e.target.value; - setActiveLedgerSupplierId(val); - if (val) fetchSupplierLedger(val);else setActiveLedgerDetail(null); - }, - children: [/*#__PURE__*/_jsx("option", { - value: "", - children: "-- All Suppliers Summary --" - }), suppliers.map(s => /*#__PURE__*/_jsx("option", { - value: s.supplier_id, - children: s.supplier_name - }, s.supplier_id))] - }), activeLedgerSupplierId && /*#__PURE__*/_jsxs("button", { - className: "btn btn-outline-secondary btn-sm", - onClick: () => { - setActiveLedgerSupplierId(''); - setActiveLedgerDetail(null); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-x-circle me-1" - }), " View All"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-success btn-sm shadow-sm fw-semibold", - onClick: () => openPaymentModal(activeLedgerSupplierId), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cash-stack me-1" - }), " Record Supplier Payment"] - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-outline-primary btn-sm", - onClick: () => { - fetchLedgerSummary(); - if (activeLedgerSupplierId) fetchSupplierLedger(activeLedgerSupplierId); - }, - title: "Refresh Ledger Data", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-clockwise" - }) - })] - })] - }), !activeLedgerSupplierId && /*#__PURE__*/_jsx("div", { - className: "table-responsive shadow-sm rounded border", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-hover align-middle mb-0", - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - style: { - width: 45 - }, - children: "#" - }), /*#__PURE__*/_jsx("th", { - children: "Distributor / Agency" - }), /*#__PURE__*/_jsx("th", { - children: "GSTIN & Phone" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Total Purchases" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Total Paid" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Outstanding Due" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - children: "Pending Bills" - }), /*#__PURE__*/_jsx("th", { - className: "text-end pe-3", - children: "Actions" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: isLoadingLedger ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "8", - className: "text-center py-4", - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm me-2" - }), "Loading ledger summary..."] - }) - }) : ledgerSummary.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsx("td", { - colSpan: "8", - className: "text-center py-4 text-muted", - children: "No suppliers found." - }) - }) : ledgerSummary.map((sup, idx) => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - className: "text-muted fw-semibold", - children: idx + 1 - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-dark", - children: sup.supplier_name - }), sup.contact_person && /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person me-1" - }), sup.contact_person] - })] - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - children: /*#__PURE__*/_jsx("code", { - className: "text-primary fw-semibold", - children: sup.gstin || 'No GSTIN' - }) - }), sup.phone && /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-telephone me-1" - }), sup.phone] - })] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-semibold", - children: ["₹", Number(sup.total_purchases || 0).toLocaleString('en-IN', { - minimumFractionDigits: 2 - })] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end text-success fw-semibold", - children: ["₹", Number(sup.total_paid || 0).toLocaleString('en-IN', { - minimumFractionDigits: 2 - })] - }), /*#__PURE__*/_jsx("td", { - className: "text-end", - children: /*#__PURE__*/_jsxs("span", { - className: `badge ${sup.outstanding_balance > 0 ? 'bg-danger-subtle text-danger border border-danger-subtle fs-6' : 'bg-success-subtle text-success border border-success-subtle'} px-2.5 py-1.5`, - children: ["₹", Number(sup.outstanding_balance || 0).toLocaleString('en-IN', { - minimumFractionDigits: 2 - })] - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: sup.pending_invoices > 0 ? /*#__PURE__*/_jsxs("span", { - className: "badge bg-warning text-dark border border-warning px-2 py-1", - children: [sup.pending_invoices, " Unpaid"] - }) : /*#__PURE__*/_jsx("span", { - className: "badge bg-light text-muted border px-2 py-1", - children: "All Settled" - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-end pe-3", - children: /*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-outline-primary", - onClick: () => { - setActiveLedgerSupplierId(String(sup.supplier_id)); - fetchSupplierLedger(sup.supplier_id); - }, - title: "View detailed ledger statement", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-journal-text me-1" - }), " Statement"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-outline-success", - onClick: () => openPaymentModal(sup.supplier_id), - title: "Record payment against this supplier", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-credit-card me-1" - }), " Pay"] - })] - }) - })] - }, sup.supplier_id)) - })] - }) - }), activeLedgerSupplierId && activeLedgerDetail && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "card border-0 shadow-sm p-3 mb-3 bg-white border-start border-4 border-primary", - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap justify-content-between align-items-center gap-2", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("h5", { - className: "fw-bold text-dark mb-1 d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-building text-primary" - }), activeLedgerDetail.supplier.supplier_name] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap gap-3 text-muted small", - children: [/*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("strong", { - children: "GSTIN:" - }), " ", activeLedgerDetail.supplier.gstin || 'N/A'] - }), /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("strong", { - children: "DL No:" - }), " ", activeLedgerDetail.supplier.dl_no_20b || activeLedgerDetail.supplier.dl_no_21b || 'N/A'] - }), /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("strong", { - children: "Phone:" - }), " ", activeLedgerDetail.supplier.phone || 'N/A'] - }), /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("strong", { - children: "Credit Days:" - }), " ", activeLedgerDetail.supplier.credit_days || 30, " Days"] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "text-end", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted text-uppercase d-block", - style: { - fontSize: '11px' - }, - children: "Net Outstanding Balance" - }), /*#__PURE__*/_jsxs("span", { - className: `badge ${activeLedgerDetail.summary.outstanding_balance > 0 ? 'bg-danger text-white fs-5' : 'bg-success text-white fs-5'} px-3 py-2`, - children: ["₹", Number(activeLedgerDetail.summary.outstanding_balance || 0).toLocaleString('en-IN', { - minimumFractionDigits: 2 - })] - })] - })] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "card border-0 shadow-sm mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header bg-white py-2.5 px-3 d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold text-dark mb-0", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hourglass-split text-warning me-1" - }), " Pending Invoices (", activeLedgerDetail.pending_invoices?.length || 0, ")"] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "Invoices awaiting full or partial payment" - })] - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-hover align-middle mb-0", - style: { - fontSize: '13px' - }, - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "Bill / Invoice No" - }), /*#__PURE__*/_jsx("th", { - children: "Invoice Date" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Bill Amount" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Paid Amount" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Pending Amount" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - children: "Status" - }), /*#__PURE__*/_jsx("th", { - className: "text-end pe-3", - children: "Action" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: !activeLedgerDetail.pending_invoices || activeLedgerDetail.pending_invoices.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "7", - className: "text-center py-3 text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check2-all text-success me-1" - }), "All purchase bills for this supplier are fully paid."] - }) - }) : activeLedgerDetail.pending_invoices.map(inv => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - className: "fw-bold text-primary", - children: inv.supplier_invoice_no - }), /*#__PURE__*/_jsx("td", { - children: inv.invoice_date - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-semibold", - children: ["₹", Number(inv.net_amount).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end text-success", - children: ["₹", Number(inv.paid_amount).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-bold text-danger", - children: ["₹", Number(inv.pending_amount).toFixed(2)] - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: /*#__PURE__*/_jsx("span", { - className: `badge ${inv.payment_status === 'partially_paid' ? 'bg-warning text-dark' : 'bg-danger'} px-2 py-1`, - children: inv.payment_status === 'partially_paid' ? 'Partially Paid' : 'Unpaid' - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-end pe-3", - children: /*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-outline-primary py-1 px-2 shadow-sm", - onClick: () => loadPurchaseForEdit(inv.purchase_id), - title: "Edit this Purchase Invoice", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-pencil-square me-1" - }), " Edit"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-success py-1 px-2.5 shadow-sm fw-semibold", - onClick: () => openPaymentModal(activeLedgerDetail.supplier.supplier_id, inv.purchase_id, inv.pending_amount), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cash me-1" - }), " Pay Bill"] - })] - }) - })] - }, inv.purchase_id)) - })] - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card border-0 shadow-sm", - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header bg-white py-2.5 px-3 d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold text-dark mb-0", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-journal-check text-primary me-1" - }), " Complete Ledger Statement & Running Balance"] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-light text-dark border px-2 py-1", - children: ["Total Transactions: ", activeLedgerDetail.statement?.length || 0] - })] - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-bordered table-hover align-middle mb-0", - style: { - fontSize: '12.5px' - }, - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - style: { - width: 100 - }, - children: "Date" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 130 - }, - children: "Voucher / Ref" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 100 - }, - children: "Type" - }), /*#__PURE__*/_jsx("th", { - children: "Particulars & Details" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - style: { - width: 120 - }, - children: "Debit (₹ Payments)" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - style: { - width: 120 - }, - children: "Credit (₹ Inward)" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - style: { - width: 140 - }, - children: "Balance (₹ Payable)" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: !activeLedgerDetail.statement || activeLedgerDetail.statement.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsx("td", { - colSpan: "7", - className: "text-center py-4 text-muted", - children: "No transactions recorded for this supplier." - }) - }) : activeLedgerDetail.statement.map((row, idx) => /*#__PURE__*/_jsxs("tr", { - className: row.type === 'PAYMENT' ? 'table-success-subtle' : '', - children: [/*#__PURE__*/_jsx("td", { - className: "text-nowrap", - children: row.date - }), /*#__PURE__*/_jsx("td", { - className: "fw-semibold text-primary", - children: row.type === 'INVOICE' && row.invoice_id ? /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-link p-0 text-decoration-none fw-bold text-primary", - onClick: () => loadPurchaseForEdit(row.invoice_id), - title: "Click to edit purchase invoice", - children: [row.voucher_no, " ", /*#__PURE__*/_jsx("i", { - className: "bi bi-pencil-square text-muted ms-1", - style: { - fontSize: '11px' - } - })] - }) : row.voucher_no - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: `badge ${row.type === 'INVOICE' ? 'bg-primary-subtle text-primary border border-primary-subtle' : 'bg-success text-white'}`, - children: row.type === 'INVOICE' ? 'Purchase Bill' : 'Payment' - }) - }), /*#__PURE__*/_jsx("td", { - children: row.particulars - }), /*#__PURE__*/_jsx("td", { - className: "text-end text-success fw-bold", - children: row.debit > 0 ? '₹' + Number(row.debit).toFixed(2) : '-' - }), /*#__PURE__*/_jsx("td", { - className: "text-end text-dark fw-bold", - children: row.credit > 0 ? '₹' + Number(row.credit).toFixed(2) : '-' - }), /*#__PURE__*/_jsx("td", { - className: "text-end fw-bold", - children: /*#__PURE__*/_jsxs("span", { - className: row.balance > 0 ? 'text-danger' : 'text-success', - children: ["₹", Number(row.balance).toFixed(2)] - }) - })] - }, idx)) - }), activeLedgerDetail.statement?.length > 0 && /*#__PURE__*/_jsx("tfoot", { - className: "table-light fw-bold", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - colSpan: "4", - className: "text-end", - children: "Total Summary:" - }), /*#__PURE__*/_jsxs("td", { - className: "text-end text-success", - children: ["₹", Number(activeLedgerDetail.summary.total_paid || 0).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end text-dark", - children: ["₹", Number(activeLedgerDetail.summary.total_purchases || 0).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end text-danger fs-6", - children: ["₹", Number(activeLedgerDetail.summary.outstanding_balance || 0).toFixed(2)] - })] - }) - })] - }) - })] - })] - })] - }), subTab === 'short_items' && /*#__PURE__*/_jsxs("div", { - className: "counter-card", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap justify-content-between align-items-center gap-2 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("h5", { - className: "fw-bold mb-0 text-dark", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-exclamation-triangle text-warning me-1" - }), " Short Items & Deficiency Reorder Book"] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "Real-time inventory shortage detection. Select items to generate consolidated Purchase Orders in 1-click." - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-primary btn-sm px-3 shadow-sm fw-bold", - disabled: selectedShortItemIds.length === 0, - onClick: openCreatePoFromShortItems, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cart-plus me-1" - }), " Create Purchase Order (", selectedShortItemIds.length, " Selected)"] - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-outline-primary btn-sm", - onClick: fetchShortItems, - title: "Refresh Short List", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-clockwise" - }) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap justify-content-between align-items-center gap-2 mb-3 bg-light p-2.5 rounded-3 border", - children: [/*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm", - children: [/*#__PURE__*/_jsxs("button", { - className: `btn ${shortFilter === 'all' ? 'btn-primary' : 'btn-outline-secondary'}`, - onClick: () => setShortFilter('all'), - children: ["All Shortages (", shortItems.length, ")"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn ${shortFilter === 'out_of_stock' ? 'btn-danger' : 'btn-outline-secondary'}`, - onClick: () => setShortFilter('out_of_stock'), - children: ["Out of Stock (", shortItems.filter(s => s.status === 'OUT_OF_STOCK').length, ")"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn ${shortFilter === 'low_stock' ? 'btn-warning text-dark' : 'btn-outline-secondary'}`, - onClick: () => setShortFilter('low_stock'), - children: ["Low Stock (", shortItems.filter(s => s.status === 'LOW_STOCK').length, ")"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - style: { - width: 280 - }, - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-white border-end-0", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-search text-muted" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control border-start-0", - placeholder: "Filter short medicine...", - value: shortSearch, - onChange: e => setShortSearch(e.target.value) - }), shortSearch && /*#__PURE__*/_jsx("button", { - className: "btn btn-outline-secondary", - type: "button", - onClick: () => setShortSearch(''), - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-x" - }) - })] - })] - }), (() => { - const filtered = shortItems.filter(it => { - if (shortFilter === 'out_of_stock' && it.status !== 'OUT_OF_STOCK') return false; - if (shortFilter === 'low_stock' && it.status !== 'LOW_STOCK') return false; - if (shortSearch.trim()) { - const q = shortSearch.toLowerCase(); - return it.item_name && it.item_name.toLowerCase().includes(q) || it.category && it.category.toLowerCase().includes(q) || it.last_supplier_name && it.last_supplier_name.toLowerCase().includes(q); + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap gap-2 mb-3 align-items-center" + }, /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm ${subTab === 'inward' ? 'btn-primary shadow-sm' : 'btn-outline-secondary'}`, + onClick: () => setSubTab('inward') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-box-arrow-in-down me-1" + }), " Inward Purchase Bill"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm ${subTab === 'ledger' ? 'btn-primary shadow-sm' : 'btn-outline-secondary'}`, + onClick: () => { + setSubTab('ledger'); + fetchLedgerSummary(); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-journal-bookmark me-1" + }), " Supplier Ledger & Payments"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm ${subTab === 'short_items' ? 'btn-warning text-dark fw-bold shadow-sm' : 'btn-outline-secondary'}`, + onClick: () => { + setSubTab('short_items'); + fetchShortItems(); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-exclamation-triangle me-1" + }), " Short Items & PO Generator", shortItems.length > 0 && /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger ms-1" + }, shortItems.length)), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm ${subTab === 'purchase_orders' ? 'btn-primary shadow-sm' : 'btn-outline-secondary'}`, + onClick: () => { + setSubTab('purchase_orders'); + fetchPurchaseOrders(); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-text me-1" + }), " Purchase Orders"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm ${subTab === 'suppliers' ? 'btn-primary shadow-sm' : 'btn-outline-secondary'}`, + onClick: () => setSubTab('suppliers') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-truck me-1" + }), " Supplier Directory (", suppliers.length, ")"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm ${subTab === 'excel' ? 'btn-success shadow-sm' : 'btn-outline-secondary'}`, + onClick: () => setSubTab('excel') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-spreadsheet me-1" + }), " Excel / CSV Import")), subTab === 'inward' && /*#__PURE__*/React.createElement("div", { + className: "counter-card" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap justify-content-between align-items-center mb-3 gap-2" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h5", { + className: "fw-bold mb-0" + }, /*#__PURE__*/React.createElement("i", { + className: `bi ${isChallan ? 'bi-truck text-warning' : 'bi-receipt text-primary'} me-1.5` + }), editingPurchaseId ? `Edit Purchase Invoice #${invoiceNo}` : isChallan ? 'Distributor Delivery Challan (Stock Entry)' : 'Distributor Purchase Inward (Tax Invoice)'), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, editingPurchaseId ? `Modifying existing Bill #${invoiceNo} (Ref #${editingPurchaseId}) - adjustments reflect in stock & ledger` : isChallan ? 'Record inward stock under vendor delivery challan (can be converted to tax invoice later)' : 'Enter vendor tax invoice to replenish store inventory and post supplier ledger payable')), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-secondary", + onClick: () => { + fetchRecentPurchases(); + setShowPurchaseHistoryModal(true); + }, + title: "View recent inward bills and select one to edit" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clock-history me-1" + }), " Inward Bills History / Edit (", recentPurchases.length, ")"), loadedPoNumber ? /*#__PURE__*/React.createElement("div", { + className: "badge bg-info-subtle text-info border border-info px-2 py-1.5 d-flex align-items-center gap-1.5", + style: { + fontSize: '12px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-link-45deg fs-6" + }), /*#__PURE__*/React.createElement("span", null, "Linked PO: ", /*#__PURE__*/React.createElement("strong", null, loadedPoNumber)), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-dark ms-1", + style: { + fontSize: '9px' + }, + onClick: () => { + setLoadedPoId(null); + setLoadedPoNumber(''); + }, + title: "Unlink PO" + })) : /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-primary", + onClick: () => { + fetchPurchaseOrders(); + setSubTab('purchase_orders'); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-box-arrow-in-down-right me-1" + }), " Load from Purchase Order"))), editingPurchaseId && /*#__PURE__*/React.createElement("div", { + className: "alert alert-warning border border-warning-subtle shadow-sm py-2 px-3 mb-3 d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-warning text-dark fs-6 px-2.5 py-1.5" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-pencil-square me-1" + }), "EDIT MODE"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", { + className: "text-dark d-block" + }, "Editing Purchase Invoice #", invoiceNo, " (Purchase ID: #", editingPurchaseId, ")"), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "Updating this invoice will recalculate batch stock in this store and adjust supplier ledger balances."))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-outline-dark btn-sm fw-semibold", + onClick: cancelEditPurchase + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x-circle me-1" + }), " Cancel Edit & New Inward")), /*#__PURE__*/React.createElement("div", { + className: "card border-0 shadow-sm p-3 mb-3", + style: { + background: '#f8fafc', + borderRadius: '10px' + } + }, /*#__PURE__*/React.createElement("div", { + className: "row g-2 align-items-center" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-1" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-0" + }, "Supplier / Distributor ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-link btn-sm p-0 text-decoration-none fw-semibold", + style: { + fontSize: '11px' + }, + onClick: openAddSupplier + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-plus-circle me-1" + }), "+ Add New")), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: selectedSupplierId, + onChange: e => { + const sId = e.target.value; + setSelectedSupplierId(sId); + fetchSupplierChallans(sId); + } + }, /*#__PURE__*/React.createElement("option", { + value: "" + }, "-- Select Supplier --"), suppliers.map(s => /*#__PURE__*/React.createElement("option", { + key: s.supplier_id, + value: s.supplier_id + }, s.supplier_name, " (GST: ", s.gstin || 'N/A', ")")))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Entry Type"), /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm w-100", + role: "group" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn ${!isChallan ? 'btn-primary fw-bold' : 'btn-outline-secondary'}`, + onClick: () => setIsChallan(false) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-receipt me-1" + }), " Tax Invoice"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn ${isChallan ? 'btn-warning text-dark fw-bold' : 'btn-outline-secondary'}`, + onClick: () => setIsChallan(true) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-truck me-1" + }), " Challan"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, isChallan ? 'Challan Number' : 'Bill / Invoice No.', " ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: isChallan ? "e.g. CHL-2026-001" : "e.g. APX-9941", + value: invoiceNo, + onChange: e => setInvoiceNo(e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, isChallan ? 'Challan Date' : 'Invoice Date'), /*#__PURE__*/React.createElement("input", { + type: "date", + className: "form-control form-control-sm", + value: invoiceDate, + onChange: e => setInvoiceDate(e.target.value) + })), isChallan && /*#__PURE__*/React.createElement("div", { + className: "col-12 mt-1" + }, /*#__PURE__*/React.createElement("div", { + className: "badge bg-warning-subtle text-dark border border-warning px-2.5 py-1 d-inline-flex align-items-center gap-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-info-circle-fill text-warning" + }), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("strong", null, "Challan Inward:"), " Adds physical stock immediately without ledger debt. This challan can later be imported directly into a final Tax Invoice."))))), (!selectedSupplierId || !invoiceNo.trim()) && !editingPurchaseId ? /*#__PURE__*/React.createElement("div", { + className: "card border border-2 border-dashed bg-light text-center p-4 my-4", + style: { + borderRadius: '12px' + } + }, /*#__PURE__*/React.createElement("div", { + className: "mx-auto mb-2 text-primary", + style: { + width: '48px', + height: '48px', + borderRadius: '50%', + background: '#e0f2fe', + display: 'flex', + alignItems: 'center', + justifyContent: 'center' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-up-circle fs-3" + })), /*#__PURE__*/React.createElement("h6", { + className: "fw-bold text-dark mb-1" + }, "Step 1: Select Supplier & Enter ", isChallan ? 'Challan' : 'Invoice', " Details Above"), /*#__PURE__*/React.createElement("p", { + className: "text-muted small mb-0", + style: { + maxWidth: '560px', + margin: '0 auto' + } + }, "Please choose the ", /*#__PURE__*/React.createElement("strong", null, "Supplier / Distributor"), " and provide the ", /*#__PURE__*/React.createElement("strong", null, isChallan ? 'Delivery Challan No.' : 'Supplier Bill / Invoice No.'), " above to unlock the medicine entry form, historical rate lookup, and pending challan imports.")) : + /*#__PURE__*/ + /* Step 2: Main Pharma Entry Workstation (2-Column Grid) */ + React.createElement("div", { + className: "row g-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-xl-8 col-lg-7" + }, /*#__PURE__*/React.createElement("div", { + className: "card border shadow-sm mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "card-header bg-white py-2 px-3 d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-dark small" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-list-check me-1 text-primary" + }), "Invoice Line Items (", rows.length, ")"), rows.length > 0 && /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary border" + }, "Total Items: ", rows.length)), /*#__PURE__*/React.createElement("div", { + className: "table-responsive", + style: { + maxHeight: '280px', + overflowY: 'auto' + } + }, /*#__PURE__*/React.createElement("table", { + className: "table table-sm table-hover table-bordered mb-0 align-middle", + style: { + fontSize: '11.5px' + } + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light sticky-top" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", { + style: { + width: '30px' + }, + className: "text-center" + }, "#"), /*#__PURE__*/React.createElement("th", { + style: { + width: '50px' + }, + className: "text-center" + }, "RecNo"), /*#__PURE__*/React.createElement("th", { + style: { + minWidth: '130px', + maxWidth: '160px' + } + }, "Item Name"), /*#__PURE__*/React.createElement("th", { + style: { + width: '80px' + } + }, "Batch No"), /*#__PURE__*/React.createElement("th", { + style: { + width: '65px' + }, + className: "text-center" + }, "Exp."), /*#__PURE__*/React.createElement("th", { + style: { + width: '65px' + }, + className: "text-end" + }, "MRP"), /*#__PURE__*/React.createElement("th", { + style: { + width: '55px' + }, + className: "text-center" + }, "Qty."), /*#__PURE__*/React.createElement("th", { + style: { + width: '65px' + }, + className: "text-end" + }, "Rate"), /*#__PURE__*/React.createElement("th", { + style: { + width: '75px' + }, + className: "text-end" + }, "Amount"), /*#__PURE__*/React.createElement("th", { + style: { + width: '50px' + }, + className: "text-end" + }, "Disc."), /*#__PURE__*/React.createElement("th", { + style: { + width: '70px' + }, + className: "text-end" + }, "Tax Amount"), /*#__PURE__*/React.createElement("th", { + style: { + width: '60px' + }, + className: "text-end" + }, "CGST"), /*#__PURE__*/React.createElement("th", { + style: { + width: '60px' + }, + className: "text-end" + }, "SGST"), /*#__PURE__*/React.createElement("th", { + style: { + width: '80px' + }, + className: "text-end" + }, "Net Amount"), /*#__PURE__*/React.createElement("th", { + style: { + width: '60px' + }, + className: "text-center" + }, "Action"))), /*#__PURE__*/React.createElement("tbody", null, rows.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "15", + className: "text-center text-muted py-4" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-inbox fs-4 d-block mb-1 text-secondary" + }), /*#__PURE__*/React.createElement("span", null, "No medicines added yet. Use the form below or include pending challans from the right."))) : rows.map((r, i) => { + const expDisplay = r.exp_month && r.exp_year ? `${r.exp_month}/${r.exp_year}` : r.expiry_date ? r.expiry_date.slice(2, 7) : '-'; + const taxAmt = ((Number(r.cgst_amount) || 0) + (Number(r.sgst_amount) || 0)).toFixed(2); + const isReturn = Number(r.qty_packs) < 0 || Number(r.net_amount) < 0; + return /*#__PURE__*/React.createElement("tr", { + key: i, + className: editingItemIndex === i ? 'table-warning' : isReturn ? 'table-danger bg-danger-subtle' : '' + }, /*#__PURE__*/React.createElement("td", { + className: "text-center text-secondary" + }, i + 1), /*#__PURE__*/React.createElement("td", { + className: "text-center text-secondary" + }, r.item_id || r.product_master_id || i + 1), /*#__PURE__*/React.createElement("td", { + style: { + maxWidth: '160px' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-1" + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-truncate text-dark", + title: r.item_name + }, r.item_name), isReturn && /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger text-white py-0 px-1", + style: { + fontSize: '9px' + } + }, "RETURN")), r.generic_name && /*#__PURE__*/React.createElement("div", { + className: "text-muted text-truncate", + style: { + fontSize: '10px' + }, + title: r.generic_name + }, r.generic_name)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border font-monospace" + }, r.batch_no || '-')), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, expDisplay), /*#__PURE__*/React.createElement("td", { + className: "text-end" + }, "₹", Number(r.mrp || 0).toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, /*#__PURE__*/React.createElement("span", { + className: `fw-bold ${isReturn ? 'text-danger' : ''}` + }, r.qty_packs), Number(r.free_qty_packs) > 0 && /*#__PURE__*/React.createElement("span", { + className: "text-success", + style: { + fontSize: '10px' + } + }, "+", r.free_qty_packs, "F")), /*#__PURE__*/React.createElement("td", { + className: "text-end" + }, "₹", Number(r.ptr || 0).toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: `text-end ${isReturn ? 'text-danger fw-semibold' : ''}` + }, "₹", Number(r.amount || 0).toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: "text-end" + }, Number(r.discount_pct || 0), "%"), /*#__PURE__*/React.createElement("td", { + className: `text-end ${isReturn ? 'text-danger' : ''}` + }, "₹", taxAmt), /*#__PURE__*/React.createElement("td", { + className: `text-end ${isReturn ? 'text-danger' : ''}` + }, "₹", Number(r.cgst_amount || Number(r.taxable_amount || 0) * (Number(r.cgst_pct || 6) / 100)).toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: `text-end ${isReturn ? 'text-danger' : ''}` + }, "₹", Number(r.sgst_amount || Number(r.taxable_amount || 0) * (Number(r.sgst_pct || 6) / 100)).toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: `text-end fw-bold ${isReturn ? 'text-danger' : 'text-dark'}` + }, "₹", Number(r.net_amount || 0).toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-outline-primary btn-sm py-0 px-1", + onClick: () => handleEditRow(i), + title: "Edit this row in form below" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-pencil" + })), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-outline-danger btn-sm py-0 px-1", + onClick: () => removeRow(i), + title: "Delete this row" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-trash" + }))))); + })))), /*#__PURE__*/React.createElement("div", { + className: "card-footer bg-light py-2 px-3 d-flex flex-wrap justify-content-end align-items-center gap-4 text-secondary small fw-semibold" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", { + className: "text-muted fw-normal" + }, "Total Taxable: "), /*#__PURE__*/React.createElement("strong", { + className: "text-dark fs-6" + }, "₹", billTotals.taxable)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", { + className: "text-muted fw-normal" + }, "CGST: "), /*#__PURE__*/React.createElement("strong", { + className: "text-dark" + }, "₹", billTotals.cgst)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", { + className: "text-muted fw-normal" + }, "SGST: "), /*#__PURE__*/React.createElement("strong", { + className: "text-dark" + }, "₹", billTotals.sgst)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", { + className: "text-muted fw-normal" + }, "Net Amount: "), /*#__PURE__*/React.createElement("strong", { + className: "text-primary fs-5" + }, "₹", billTotals.net)))), /*#__PURE__*/React.createElement("div", { + className: "card border shadow-sm p-3 mb-3 bg-white", + style: { + borderRadius: '10px' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-2 pb-1 border-bottom" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold mb-0 text-dark" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-plus-circle-dotted text-primary me-1" + }), editingItemIndex !== null ? `Modify Row #${editingItemIndex + 1}` : 'Add Medicine to Inward Bill'), editingItemIndex !== null && /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-link text-danger p-0 text-decoration-none", + onClick: resetItemForm + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x-circle me-1" + }), " Cancel Row Edit")), /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-9 position-relative" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1 d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("span", null, "Product Search (Master Auto-Search) ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-link btn-sm p-0 text-decoration-none fw-semibold", + style: { + fontSize: '11px' + }, + onClick: () => openAddMasterModal(itemForm.item_name) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-plus-circle me-1" + }), "+ Add to Master")), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "text", + id: "pharma_product_search_input", + className: `form-control form-control-sm fw-semibold ${itemForm.item_id ? 'border-success' : ''}`, + placeholder: "Type medicine name (e.g. ACEFE-P, Augmentin)...", + value: itemForm.item_name, + autoComplete: "off", + onChange: e => handleProductSearchChange(e.target.value), + onKeyDown: handleProductSearchKeyDown, + onFocus: () => { + if (itemForm.item_name.trim().length >= 1) { + handleProductSearchChange(itemForm.item_name); + } + } + }), itemForm.item_id > 0 && /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-success text-white py-0 px-2", + title: "Matched in Master Catalog" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check2" + }))), itemForm.generic_name ? /*#__PURE__*/React.createElement("div", { + className: "text-muted text-truncate mt-1 d-flex align-items-center gap-1", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-primary border", + style: { + fontSize: '9.5px' + } + }, itemForm.category || 'Tablet'), /*#__PURE__*/React.createElement("span", null, itemForm.generic_name)) : null, activeSearchRow && /*#__PURE__*/React.createElement("div", { + ref: suggestionsDropdownRef, + className: "shadow-lg border rounded-2 bg-white", + style: { + position: 'absolute', + top: '100%', + left: 0, + width: '100%', + maxHeight: '280px', + overflowY: 'auto', + zIndex: 1060, + marginTop: '2px' + } + }, /*#__PURE__*/React.createElement("div", { + className: "bg-light px-2.5 py-1.5 border-bottom d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("span", { + className: "small fw-bold text-secondary", + style: { + fontSize: '11px' + } + }, isSearchingMeds ? /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hourglass-split spinner-border spinner-border-sm me-1" + }), "Searching master...") : /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-database-check me-1 text-primary" + }), "Pharmacy Master (", suggestions.length, " found)", suggestions.length > 0 && /*#__PURE__*/React.createElement("span", { + className: "text-muted ms-2 fw-normal", + style: { + fontSize: '10px' + } + }, "(Use ↑ ↓ & Enter)"))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close", + style: { + fontSize: '9px' + }, + onClick: () => { + setActiveSearchRow(false); + setSelectedSuggestionIndex(-1); + } + })), suggestions.length > 0 ? suggestions.map((sug, sIdx) => { + const isSelected = sIdx === selectedSuggestionIndex; + return /*#__PURE__*/React.createElement("div", { + key: sIdx, + ref: isSelected ? activeSuggestionRef : null, + className: `p-2 border-bottom ${isSelected ? 'bg-primary-subtle' : 'hover-bg-light'}`, + style: { + cursor: 'pointer', + transition: 'all 0.12s ease', + borderLeft: isSelected ? '4px solid #0284c7' : '4px solid transparent', + backgroundColor: isSelected ? '#e0f2fe' : undefined + }, + onMouseEnter: () => setSelectedSuggestionIndex(sIdx), + onMouseDown: e => { + e.preventDefault(); + handleSelectMedicine(sug); + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("span", { + className: `text-dark ${isSelected ? 'fw-bold text-primary' : 'fw-semibold'}`, + style: { + fontSize: '12.5px' + } + }, isSelected && /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-right-short text-primary me-1" + }), sug.item_name), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-1" + }, isSelected && /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary text-white", + style: { + fontSize: '9px', + fontWeight: 600 + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-return-left me-1" + }), "Enter"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-primary border", + style: { + fontSize: '10px' + } + }, sug.category || 'Tablet'))), sug.generic_name && /*#__PURE__*/React.createElement("div", { + className: "text-muted text-truncate small", + style: { + fontSize: '11px' + } + }, sug.generic_name), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2 mt-1 align-items-center", + style: { + fontSize: '10.5px' + } + }, /*#__PURE__*/React.createElement("span", { + className: "text-secondary" + }, "Pack: ", /*#__PURE__*/React.createElement("strong", null, sug.units_per_pack || 10, "s")), /*#__PURE__*/React.createElement("span", { + className: "text-secondary" + }, "GST: ", /*#__PURE__*/React.createElement("strong", null, sug.gst_rate, "%")), /*#__PURE__*/React.createElement("span", { + className: "text-secondary" + }, "HSN: ", /*#__PURE__*/React.createElement("strong", null, sug.hsn_code || '3004')), sug.mrp ? /*#__PURE__*/React.createElement("span", { + className: "text-secondary" + }, "MRP: ", /*#__PURE__*/React.createElement("strong", null, "₹", sug.mrp)) : null)); + }) : !isSearchingMeds && /*#__PURE__*/React.createElement("div", { + className: "p-3 text-center text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search fs-4 d-block mb-1 text-secondary" + }), /*#__PURE__*/React.createElement("div", { + className: "small fw-semibold" + }, "No medicine found matching \"", itemForm.item_name, "\""), /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '11px' + } + }, "Click below to add it directly into Pharmacy Master")), /*#__PURE__*/React.createElement("div", { + className: "p-2 bg-light border-top text-center" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-primary w-100 fw-bold py-1", + style: { + fontSize: '12px' + }, + onMouseDown: e => { + e.preventDefault(); + openAddMasterModal(itemForm.item_name); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-plus-circle-fill me-1" + }), "+ Add \"", itemForm.item_name || 'New Medicine', "\" in Master")))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Product Code"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-light text-secondary font-monospace", + value: itemForm.product_master_id || itemForm.item_id || 'AUTO', + readOnly: true + }))), itemForm.item_id > 0 || editingItemIndex !== null ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-between bg-primary-subtle border border-primary-subtle px-2.5 py-1 rounded mb-2" + }, /*#__PURE__*/React.createElement("span", { + className: "small text-primary fw-semibold" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle-fill me-1 text-success" + }), editingItemIndex !== null ? `Editing: ${itemForm.item_name}` : `Selected: ${itemForm.item_name} (Auto-filled with last batch, rate & location)`), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-link btn-sm p-0 text-danger text-decoration-none fw-semibold", + style: { + fontSize: '11px' + }, + onClick: () => resetItemForm(true) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x-circle me-1" + }), " Change Product")), /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Packaging"), /*#__PURE__*/React.createElement("input", { + type: "number", + id: "pharma_packaging_input", + className: "form-control form-control-sm", + placeholder: "10", + value: itemForm.units_per_pack, + onChange: e => handleItemFormChange('units_per_pack', e.target.value), + onKeyDown: e => handleFieldKeyDown(e, 'pharma_batch_no_input') + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Batch No. ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("input", { + type: "text", + id: "pharma_batch_no_input", + className: "form-control form-control-sm text-uppercase font-monospace fw-bold", + placeholder: "e.g. B-902", + value: itemForm.batch_no, + onChange: e => handleItemFormChange('batch_no', e.target.value), + onKeyDown: e => handleFieldKeyDown(e, 'pharma_exp_month_input') + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Exp. Month"), /*#__PURE__*/React.createElement("select", { + id: "pharma_exp_month_input", + className: "form-select form-select-sm", + value: itemForm.exp_month, + onChange: e => handleItemFormChange('exp_month', e.target.value), + onKeyDown: e => handleFieldKeyDown(e, 'pharma_exp_year_input') + }, ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'].map(m => /*#__PURE__*/React.createElement("option", { + key: m, + value: m + }, m, " (", ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][parseInt(m) - 1], ")")))), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Exp. Year"), /*#__PURE__*/React.createElement("select", { + id: "pharma_exp_year_input", + className: "form-select form-select-sm", + value: itemForm.exp_year, + onChange: e => handleItemFormChange('exp_year', e.target.value), + onKeyDown: e => handleFieldKeyDown(e, 'pharma_mrp_input') + }, ['24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36'].map(y => /*#__PURE__*/React.createElement("option", { + key: y, + value: y + }, "20", y)))), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "MRP (₹)"), /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.01", + id: "pharma_mrp_input", + className: "form-control form-control-sm", + placeholder: "0.00", + value: itemForm.mrp, + onChange: e => handleItemFormChange('mrp', e.target.value), + onKeyDown: e => handleFieldKeyDown(e, 'pharma_qty_input') + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-1" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-0" + }, "Qty (Packs) ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), Number(itemForm.qty_packs) < 0 && /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger text-white py-0 px-1", + style: { + fontSize: '9px' + } + }, "RETURN")), /*#__PURE__*/React.createElement("input", { + type: "number", + id: "pharma_qty_input", + className: `form-control form-control-sm fw-bold ${Number(itemForm.qty_packs) < 0 ? 'text-danger border-danger bg-danger-subtle' : ''}`, + placeholder: "Qty (+ In / - Ret)", + value: itemForm.qty_packs, + onChange: e => handleItemFormChange('qty_packs', e.target.value), + onKeyDown: e => handleFieldKeyDown(e, 'pharma_free_qty_input') + }))), /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Free Qty"), /*#__PURE__*/React.createElement("input", { + type: "number", + min: "0", + id: "pharma_free_qty_input", + className: "form-control form-control-sm", + value: itemForm.free_qty_packs, + onChange: e => handleItemFormChange('free_qty_packs', e.target.value), + onKeyDown: e => handleFieldKeyDown(e, 'pharma_ptr_input') + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Purchase Rate (PTR)"), /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.01", + id: "pharma_ptr_input", + className: "form-control form-control-sm", + placeholder: "0.00", + value: itemForm.ptr, + onChange: e => handleItemFormChange('ptr', e.target.value), + onKeyDown: e => handleFieldKeyDown(e, 'pharma_disc_pct_input') + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Amount"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-light text-secondary fw-semibold", + value: '₹' + Number(itemForm.amount || 0).toFixed(2), + readOnly: true + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Discount %"), /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.1", + min: "0", + max: "100", + id: "pharma_disc_pct_input", + className: "form-control form-control-sm", + value: itemForm.discount_pct, + onChange: e => handleItemFormChange('discount_pct', e.target.value), + onKeyDown: e => handleFieldKeyDown(e, 'submit') + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "SCH Amount"), /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.01", + min: "0", + id: "pharma_sch_amount_input", + className: "form-control form-control-sm", + value: itemForm.sch_disc_amount, + onChange: e => handleItemFormChange('sch_disc_amount', e.target.value), + onKeyDown: e => handleFieldKeyDown(e, 'pharma_sch_disc_input') + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "SCH Discount %"), /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.1", + min: "0", + max: "100", + id: "pharma_sch_disc_input", + className: "form-control form-control-sm", + value: itemForm.sch_disc_pct, + onChange: e => handleItemFormChange('sch_disc_pct', e.target.value), + onKeyDown: e => handleFieldKeyDown(e, 'submit') + }))), /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Taxable Amount"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-light text-secondary fw-semibold", + value: '₹' + Number(itemForm.taxable_amount || 0).toFixed(2), + readOnly: true + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "CGST %"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: itemForm.cgst_pct, + onChange: e => { + const val = parseFloat(e.target.value) || 0; + handleItemFormChange('cgst_pct', val); + handleItemFormChange('sgst_pct', val); + } + }, /*#__PURE__*/React.createElement("option", { + value: "0" + }, "0% (Nil / Exempt)"), /*#__PURE__*/React.createElement("option", { + value: "2.5" + }, "2.5% (5% GST)"), /*#__PURE__*/React.createElement("option", { + value: "9" + }, "9.0% (18% GST)"), /*#__PURE__*/React.createElement("option", { + value: "20" + }, "20.0% (40% GST)"), /*#__PURE__*/React.createElement("option", { + value: "6" + }, "6.0% (12% Legacy)"), /*#__PURE__*/React.createElement("option", { + value: "14" + }, "14.0% (28% Legacy)"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "SGST / IGST %"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: itemForm.sgst_pct, + onChange: e => handleItemFormChange('sgst_pct', parseFloat(e.target.value) || 0) + }, /*#__PURE__*/React.createElement("option", { + value: "0" + }, "0% (Nil / Exempt)"), /*#__PURE__*/React.createElement("option", { + value: "2.5" + }, "2.5% (5% GST)"), /*#__PURE__*/React.createElement("option", { + value: "9" + }, "9.0% (18% GST)"), /*#__PURE__*/React.createElement("option", { + value: "20" + }, "20.0% (40% GST)"), /*#__PURE__*/React.createElement("option", { + value: "6" + }, "6.0% (12% Legacy)"), /*#__PURE__*/React.createElement("option", { + value: "14" + }, "14.0% (28% Legacy)"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Net Amount"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-primary-subtle text-primary fw-bold", + value: '₹' + Number(itemForm.net_amount || 0).toFixed(2), + readOnly: true + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Selling Price"), /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.01", + id: "pharma_selling_price_input", + className: "form-control form-control-sm", + placeholder: "MRP", + value: itemForm.selling_price, + onChange: e => handleItemFormChange('selling_price', e.target.value), + onKeyDown: e => handleFieldKeyDown(e, 'pharma_shelf_no_input') + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "HSNCODE"), /*#__PURE__*/React.createElement("input", { + type: "text", + id: "pharma_hsn_input", + className: "form-control form-control-sm", + value: itemForm.hsn_code, + onChange: e => handleItemFormChange('hsn_code', e.target.value), + onKeyDown: e => handleFieldKeyDown(e, 'pharma_shelf_no_input') + }))), /*#__PURE__*/React.createElement("div", { + className: "row g-2 align-items-end" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-3 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Storage"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: itemForm.storage_type, + onChange: e => handleItemFormChange('storage_type', e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "Normal" + }, "Normal"), /*#__PURE__*/React.createElement("option", { + value: "Cold Storage" + }, "Cold Storage (2-8°C)"), /*#__PURE__*/React.createElement("option", { + value: "Cool" + }, "Cool (8-15°C)"), /*#__PURE__*/React.createElement("option", { + value: "Deep Freeze" + }, "Deep Freeze (-20°C)"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Shelf No."), /*#__PURE__*/React.createElement("input", { + type: "text", + id: "pharma_shelf_no_input", + className: "form-control form-control-sm", + placeholder: "e.g. S-1", + value: itemForm.shelf_no, + onChange: e => handleItemFormChange('shelf_no', e.target.value), + onKeyDown: e => handleFieldKeyDown(e, 'pharma_rack_no_input') + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-2 col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Rack No."), /*#__PURE__*/React.createElement("input", { + type: "text", + id: "pharma_rack_no_input", + className: "form-control form-control-sm", + placeholder: "e.g. R-10", + value: itemForm.rack_no, + onChange: e => handleItemFormChange('rack_no', e.target.value), + onKeyDown: e => handleFieldKeyDown(e, 'submit') + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-5 col-12 d-flex gap-2 justify-content-end mt-2 mt-md-0" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-outline-secondary btn-sm px-3", + onClick: () => resetItemForm(true) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-counterclockwise me-1" + }), " Clear"), /*#__PURE__*/React.createElement("button", { + type: "button", + id: "pharma_add_stock_btn", + className: editingItemIndex !== null ? "btn btn-warning text-dark fw-bold btn-sm px-3 shadow-sm" : Number(itemForm.qty_packs) < 0 ? "btn btn-danger fw-bold btn-sm px-4 shadow-sm" : "btn btn-primary fw-bold btn-sm px-4 shadow-sm", + onClick: handleAddOrUpdateItem, + title: Number(itemForm.qty_packs) < 0 ? "Add Return / Debit Item (Press Ctrl+Enter anytime)" : "Add Stock (Press Ctrl+Enter anytime)" + }, /*#__PURE__*/React.createElement("i", { + className: editingItemIndex !== null ? "bi bi-check2-circle me-1" : Number(itemForm.qty_packs) < 0 ? "bi bi-dash-circle me-1" : "bi bi-plus-circle me-1" + }), editingItemIndex !== null ? 'Update Stock Item' : Number(itemForm.qty_packs) < 0 ? '⊖ Add Return Item' : '+ Add Stock', /*#__PURE__*/React.createElement("span", { + className: "badge bg-white bg-opacity-25 ms-1.5 py-0.5 px-1.5 text-white", + style: { + fontSize: '10px' + } + }, "Ctrl+↵"))))) : /*#__PURE__*/React.createElement("div", { + className: "text-center py-4 text-muted small bg-light rounded-2 border border-dashed mt-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search text-primary me-1.5 fs-5 d-block mb-1" + }), /*#__PURE__*/React.createElement("span", null, "Search and select a medicine in ", /*#__PURE__*/React.createElement("strong", null, "Product Search"), " above to enter stock details and auto-fill last batch, expiry, MRP, rate & rack location."))), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap justify-content-between align-items-center p-3 bg-light rounded-3 border" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", { + className: "text-muted small" + }, "Ready to commit to inventory:"), /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark" + }, rows.length, " ", rows.length === 1 ? 'medicine' : 'medicines', " | Net Payable: ", /*#__PURE__*/React.createElement("span", { + className: "text-primary fs-6" + }, "₹", billTotals.net))), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2" + }, editingPurchaseId && /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-outline-secondary btn-sm px-3", + onClick: cancelEditPurchase + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x-circle me-1" + }), " Cancel Edit"), /*#__PURE__*/React.createElement("button", { + className: editingPurchaseId ? "btn btn-warning shadow-sm fw-bold px-3 py-2 text-dark" : isChallan ? "btn btn-warning fw-bold text-dark shadow-sm px-4 py-2" : "btn btn-success-custom shadow-sm px-4 py-2", + onClick: savePurchaseBill + }, /*#__PURE__*/React.createElement("i", { + className: editingPurchaseId ? "bi bi-check2-all me-1" : isChallan ? "bi bi-truck me-1" : "bi bi-check-circle me-1" + }), editingPurchaseId ? `Update Purchase Invoice #${invoiceNo}` : isChallan ? 'Record Delivery Challan & Update Stock' : 'Record Inward Bill & Update Inventory')))), /*#__PURE__*/React.createElement("div", { + className: "col-xl-4 col-lg-5" + }, /*#__PURE__*/React.createElement("div", { + className: "card border shadow-sm mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "card-header bg-white py-2 px-3 d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-dark small" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-truck text-warning me-1" + }), "Pending Delivery Challans"), selectedSupplierId && /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-link p-0 text-decoration-none", + onClick: () => fetchSupplierChallans(selectedSupplierId), + title: "Refresh supplier challans" + }, /*#__PURE__*/React.createElement("i", { + className: `bi bi-arrow-repeat ${isLoadingChallans ? 'spinner-border spinner-border-sm' : ''}` + }))), /*#__PURE__*/React.createElement("div", { + className: "card-body p-2", + style: { + maxHeight: '280px', + overflowY: 'auto' + } + }, !selectedSupplierId ? /*#__PURE__*/React.createElement("div", { + className: "text-muted small p-3 text-center bg-light rounded" + }, "Select a supplier above to view pending challans.") : isLoadingChallans ? /*#__PURE__*/React.createElement("div", { + className: "text-center py-3 text-muted small" + }, /*#__PURE__*/React.createElement("div", { + className: "spinner-border spinner-border-sm text-primary me-2" + }), "Loading supplier challans...") : supplierChallans.length === 0 ? /*#__PURE__*/React.createElement("div", { + className: "text-muted small p-3 text-center bg-light rounded" + }, "No challan items available for this supplier.") : supplierChallans.map((ch, chIdx) => /*#__PURE__*/React.createElement("div", { + key: chIdx, + className: "border rounded-2 p-2 mb-2 bg-light" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-1.5 pb-1 border-bottom" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", { + className: "text-dark", + style: { + fontSize: '12px' + } + }, "Challan #", ch.challan_no), /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '10.5px' + } + }, "Date: ", ch.date || 'N/A', " • ", ch.items ? ch.items.length : 0, " items")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-primary py-0.5 px-2", + style: { + fontSize: '11px' + }, + onClick: () => includeAllChallanItems(ch), + title: "Import all items from this challan into invoice" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-box-arrow-in-right me-1" + }), " Include All")), ch.items && ch.items.length > 0 ? /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-column gap-1" + }, ch.items.map((ci, cItemIdx) => /*#__PURE__*/React.createElement("div", { + key: cItemIdx, + className: "d-flex justify-content-between align-items-center bg-white p-1.5 rounded border", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("div", { + className: "text-truncate me-2", + style: { + maxWidth: '170px' + } + }, /*#__PURE__*/React.createElement("div", { + className: "fw-semibold text-dark text-truncate" + }, ci.item_name), /*#__PURE__*/React.createElement("span", { + className: "text-muted font-monospace", + style: { + fontSize: '10px' + } + }, "Batch: ", ci.batch_no || '-', " | Qty: ", ci.qty_packs)), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-primary py-0 px-1.5 text-nowrap", + style: { + fontSize: '10.5px' + }, + onClick: () => includeChallanItem(ch, ci), + title: "Import this item into invoice" + }, "+ Include")))) : /*#__PURE__*/React.createElement("div", { + className: "text-muted small", + style: { + fontSize: '11px' + } + }, "No items found in this challan."))))), /*#__PURE__*/React.createElement("div", { + className: "card border shadow-sm" + }, /*#__PURE__*/React.createElement("div", { + className: "card-header bg-white py-2 px-3 d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-dark small" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clock-history text-info me-1" + }), "Previous Purchase History"), historyTargetItemName && /*#__PURE__*/React.createElement("span", { + className: "badge bg-info-subtle text-info border text-truncate", + style: { + maxWidth: '140px', + fontSize: '10.5px' + } + }, historyTargetItemName)), /*#__PURE__*/React.createElement("div", { + className: "card-body p-2", + style: { + maxHeight: '310px', + overflowY: 'auto' + } + }, isLoadingProductHistory ? /*#__PURE__*/React.createElement("div", { + className: "text-center py-3 text-muted small" + }, /*#__PURE__*/React.createElement("div", { + className: "spinner-border spinner-border-sm text-info me-2" + }), "Fetching purchase rate history...") : !historyTargetItemName && productHistory.length === 0 ? /*#__PURE__*/React.createElement("div", { + className: "text-muted small p-3 text-center bg-light rounded" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search d-block mb-1 fs-5 text-secondary" + }), "Type or select a product in ", /*#__PURE__*/React.createElement("strong", null, "Product Search"), " to check previous purchase prices & vendors.") : productHistory.length === 0 ? /*#__PURE__*/React.createElement("div", { + className: "text-muted small p-3 text-center bg-light rounded" + }, "No purchase history found for selected product.") : /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-column gap-2" + }, productHistory.map((ph, phIdx) => /*#__PURE__*/React.createElement("div", { + key: phIdx, + className: "p-2 border rounded-2 bg-light", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-1" + }, /*#__PURE__*/React.createElement("strong", { + className: "text-primary text-truncate", + style: { + maxWidth: '160px' + } + }, ph.supplier_name || 'Distributor'), /*#__PURE__*/React.createElement("span", { + className: "text-muted", + style: { + fontSize: '10px' + } + }, ph.invoice_date || ph.created_at ? (ph.invoice_date || ph.created_at).slice(0, 10) : '')), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between text-secondary mb-1", + style: { + fontSize: '10.5px' + } + }, /*#__PURE__*/React.createElement("span", null, "Inv: ", /*#__PURE__*/React.createElement("strong", null, ph.supplier_invoice_no || '-')), /*#__PURE__*/React.createElement("span", null, "Batch: ", /*#__PURE__*/React.createElement("span", { + className: "font-monospace" + }, ph.batch_no || '-'))), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center pt-1 border-top mt-1" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", { + className: "text-muted" + }, "PTR: "), /*#__PURE__*/React.createElement("strong", { + className: "text-dark" + }, "₹", Number(ph.ptr || 0).toFixed(2)), ph.mrp ? /*#__PURE__*/React.createElement("span", { + className: "text-muted ms-2" + }, "MRP: ₹", Number(ph.mrp).toFixed(2)) : null, Number(ph.discount_pct) > 0 ? /*#__PURE__*/React.createElement("span", { + className: "text-success ms-1" + }, "(-", ph.discount_pct, "%)") : null), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-info py-0 px-1.5", + style: { + fontSize: '10.5px' + }, + onClick: () => { + setItemForm(prev => recomputeItemForm({ + ...prev, + ptr: ph.ptr || prev.ptr, + mrp: ph.mrp || prev.mrp, + discount_pct: ph.discount_pct !== undefined ? ph.discount_pct : prev.discount_pct, + gst_rate: ph.gst_rate !== undefined ? ph.gst_rate : prev.gst_rate, + cgst_pct: (Number(ph.gst_rate) || 12) / 2, + sgst_pct: (Number(ph.gst_rate) || 12) / 2 + })); + notify(`Applied historical PTR ₹${ph.ptr} to entry form.`, 'info'); + }, + title: "Apply these purchase rates to current item form" + }, "Use Rate")))))))))), subTab === 'excel' && /*#__PURE__*/React.createElement("div", { + className: "counter-card" + }, /*#__PURE__*/React.createElement("h5", { + className: "fw-bold text-success mb-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-spreadsheet me-1" + }), " Excel / CSV Inventory Importer"), /*#__PURE__*/React.createElement("p", { + className: "text-muted small mb-3" + }, "Upload your stock export from Microsoft Excel or CSV format to seamlessly import medicines, batch numbers, MRP, PTR, HSN codes, and opening stock into ", /*#__PURE__*/React.createElement("strong", null, store.store_name), "."), /*#__PURE__*/React.createElement("div", { + className: "p-4 bg-light rounded-3 border text-center mb-3" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cloud-arrow-up fs-1 text-success d-block mb-2" + }), /*#__PURE__*/React.createElement("h6", { + className: "fw-bold" + }, "Upload CSV / Excel File"), /*#__PURE__*/React.createElement("p", { + className: "small text-muted mb-3" + }, "Ensure file is formatted as standard CSV or Excel-exported CSV."), /*#__PURE__*/React.createElement("input", { + type: "file", + id: "excel_file_input", + accept: ".csv, .txt", + className: "form-control form-control-sm w-50 mx-auto mb-3" + }), /*#__PURE__*/React.createElement("button", { + className: "btn btn-success-custom", + onClick: async () => { + const fileInput = document.getElementById('excel_file_input'); + if (!fileInput.files || fileInput.files.length === 0) { + alert('Please select a CSV file first.'); + return; + } + const formData = new FormData(); + formData.append('store_id', store.store_id); + formData.append('import_file', fileInput.files[0]); + try { + const res = await fetch(API_BASE + 'stock/import-excel', { + method: 'POST', + body: formData + }); + const data = await res.json(); + if (data.ok) { + alert(data.message); + fileInput.value = ''; + } else { + alert(data.error || 'Import failed.'); + } + } catch (e) { + alert('Import error: ' + e.message); + } + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-upload me-1" + }), " Import Inventory into ", store.store_name))), subTab === 'suppliers' && /*#__PURE__*/React.createElement("div", { + className: "counter-card" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap justify-content-between align-items-center gap-2 mb-3" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h5", { + className: "fw-bold mb-0 text-dark" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-truck text-primary me-1" + }), " Approved Drug Distributors & Suppliers"), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "Manage licensed pharmaceutical distributors, DL Form 20B/21B, GSTIN, and credit terms")), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm", + style: { + width: 250 + } + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-white border-end-0" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search text-muted" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control border-start-0", + placeholder: "Search distributor, GST...", + value: supplierSearch, + onChange: e => setSupplierSearch(e.target.value) + }), supplierSearch && /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-secondary", + type: "button", + onClick: () => setSupplierSearch('') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x" + }))), /*#__PURE__*/React.createElement("button", { + className: "btn btn-primary btn-sm px-3", + onClick: openAddSupplier + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-plus-circle me-1" + }), " Add New Supplier"))), /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-pos align-middle mb-0" + }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", { + style: { + width: 45 + } + }, "#"), /*#__PURE__*/React.createElement("th", null, "Distributor Name"), /*#__PURE__*/React.createElement("th", null, "DL Form 20B / 21B"), /*#__PURE__*/React.createElement("th", null, "GSTIN & PAN"), /*#__PURE__*/React.createElement("th", null, "Phone / Contact"), /*#__PURE__*/React.createElement("th", null, "Credit Terms"), /*#__PURE__*/React.createElement("th", null, "Address / Bank"), /*#__PURE__*/React.createElement("th", { + style: { + width: 90 + }, + className: "text-end pe-3" + }, "Actions"))), /*#__PURE__*/React.createElement("tbody", null, filteredSuppliers.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "8", + className: "text-center py-4 text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-truck fs-2 d-block mb-1 text-secondary" + }), suppliers.length === 0 ? 'No distributors registered yet. Click "Add New Supplier" to create one.' : 'No suppliers match your search query.')) : filteredSuppliers.map((s, i) => /*#__PURE__*/React.createElement("tr", { + key: s.supplier_id + }, /*#__PURE__*/React.createElement("td", { + className: "fw-semibold text-secondary" + }, i + 1), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark fs-6" + }, s.supplier_name), s.email && /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-envelope me-1" + }), s.email)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "small" + }, /*#__PURE__*/React.createElement("strong", null, "20B:"), " ", s.dl_no_20b || /*#__PURE__*/React.createElement("span", { + className: "text-muted" + }, "N/A")), /*#__PURE__*/React.createElement("div", { + className: "small" + }, /*#__PURE__*/React.createElement("strong", null, "21B:"), " ", s.dl_no_21b || /*#__PURE__*/React.createElement("span", { + className: "text-muted" + }, "N/A"))), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("code", { + className: "text-primary fw-bold" + }, s.gstin || 'N/A')), s.pan_no && /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block" + }, "PAN: ", s.pan_no)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-semibold text-dark" + }, s.phone || 'N/A'), s.contact_person && /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person me-1" + }), s.contact_person)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border px-2 py-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-calendar-check me-1 text-primary" + }), s.credit_days || 30, " Days")), /*#__PURE__*/React.createElement("td", { + style: { + maxWidth: 220 + } + }, s.address && /*#__PURE__*/React.createElement("div", { + className: "small text-truncate", + title: s.address + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-geo-alt me-1 text-muted" + }), s.address), s.bank_details && /*#__PURE__*/React.createElement("div", { + className: "small text-muted text-truncate", + title: s.bank_details + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-bank me-1" + }), s.bank_details), !s.address && !s.bank_details && /*#__PURE__*/React.createElement("span", { + className: "text-muted small" + }, "-")), /*#__PURE__*/React.createElement("td", { + className: "text-end pe-3" + }, /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-primary py-0.5 px-2", + title: "Edit Supplier", + onClick: () => openEditSupplier(s) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-pencil-square" + })), /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-danger py-0.5 px-2", + title: "Remove Supplier", + onClick: () => handleDeleteSupplier(s.supplier_id, s.supplier_name) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-trash" + })))))))))), subTab === 'ledger' && /*#__PURE__*/React.createElement("div", { + className: "counter-card" + }, /*#__PURE__*/React.createElement("div", { + className: "row g-3 mb-4" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("div", { + className: "card border-0 shadow-sm p-3 bg-white h-100 border-start border-4 border-primary" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-semibold text-uppercase", + style: { + fontSize: '11px' + } + }, "Total Inward Purchases"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bold text-dark mb-0 mt-1" + }, "₹", Number(ledgerOverall.total_purchases || 0).toLocaleString('en-IN', { + minimumFractionDigits: 2, + maximumFractionDigits: 2 + }))), /*#__PURE__*/React.createElement("div", { + className: "bg-primary-subtle text-primary p-2.5 rounded-circle" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-box-arrow-in-down fs-4" + }))))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("div", { + className: "card border-0 shadow-sm p-3 bg-white h-100 border-start border-4 border-success" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-semibold text-uppercase", + style: { + fontSize: '11px' + } + }, "Total Payments Settled"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bold text-success mb-0 mt-1" + }, "₹", Number(ledgerOverall.total_paid || 0).toLocaleString('en-IN', { + minimumFractionDigits: 2, + maximumFractionDigits: 2 + }))), /*#__PURE__*/React.createElement("div", { + className: "bg-success-subtle text-success p-2.5 rounded-circle" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check2-circle fs-4" + }))))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("div", { + className: "card border-0 shadow-sm p-3 bg-white h-100 border-start border-4 border-danger" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-semibold text-uppercase", + style: { + fontSize: '11px' + } + }, "Balance Outstanding"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bold text-danger mb-0 mt-1" + }, "₹", Number(ledgerOverall.outstanding_balance || 0).toLocaleString('en-IN', { + minimumFractionDigits: 2, + maximumFractionDigits: 2 + }))), /*#__PURE__*/React.createElement("div", { + className: "bg-danger-subtle text-danger p-2.5 rounded-circle" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-exclamation-octagon fs-4" + }))))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("div", { + className: "card border-0 shadow-sm p-3 bg-white h-100 border-start border-4 border-warning" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-semibold text-uppercase", + style: { + fontSize: '11px' + } + }, "Pending Invoices"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bold text-warning-emphasis mb-0 mt-1" + }, ledgerOverall.total_pending_bills || 0, " Bills")), /*#__PURE__*/React.createElement("div", { + className: "bg-warning-subtle text-warning-emphasis p-2.5 rounded-circle" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-receipt fs-4" + })))))), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap justify-content-between align-items-center gap-2 mb-3 bg-light p-2.5 rounded-3 border" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2 flex-grow-1" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-0 text-nowrap" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-funnel me-1" + }), "Select Supplier:"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + style: { + maxWidth: 320 + }, + value: activeLedgerSupplierId, + onChange: e => { + const val = e.target.value; + setActiveLedgerSupplierId(val); + if (val) fetchSupplierLedger(val);else setActiveLedgerDetail(null); + } + }, /*#__PURE__*/React.createElement("option", { + value: "" + }, "-- All Suppliers Summary --"), suppliers.map(s => /*#__PURE__*/React.createElement("option", { + key: s.supplier_id, + value: s.supplier_id + }, s.supplier_name))), activeLedgerSupplierId && /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-secondary btn-sm", + onClick: () => { + setActiveLedgerSupplierId(''); + setActiveLedgerDetail(null); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x-circle me-1" + }), " View All")), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-success btn-sm shadow-sm fw-semibold", + onClick: () => openPaymentModal(activeLedgerSupplierId) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cash-stack me-1" + }), " Record Supplier Payment"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-primary btn-sm", + onClick: () => { + fetchLedgerSummary(); + if (activeLedgerSupplierId) fetchSupplierLedger(activeLedgerSupplierId); + }, + title: "Refresh Ledger Data" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-clockwise" + })))), !activeLedgerSupplierId && /*#__PURE__*/React.createElement("div", { + className: "table-responsive shadow-sm rounded border" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-hover align-middle mb-0" + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", { + style: { + width: 45 + } + }, "#"), /*#__PURE__*/React.createElement("th", null, "Distributor / Agency"), /*#__PURE__*/React.createElement("th", null, "GSTIN & Phone"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Total Purchases"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Total Paid"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Outstanding Due"), /*#__PURE__*/React.createElement("th", { + className: "text-center" + }, "Pending Bills"), /*#__PURE__*/React.createElement("th", { + className: "text-end pe-3" + }, "Actions"))), /*#__PURE__*/React.createElement("tbody", null, isLoadingLedger ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "8", + className: "text-center py-4" + }, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm me-2" + }), "Loading ledger summary...")) : ledgerSummary.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "8", + className: "text-center py-4 text-muted" + }, "No suppliers found.")) : ledgerSummary.map((sup, idx) => /*#__PURE__*/React.createElement("tr", { + key: sup.supplier_id + }, /*#__PURE__*/React.createElement("td", { + className: "text-muted fw-semibold" + }, idx + 1), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark" + }, sup.supplier_name), sup.contact_person && /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person me-1" + }), sup.contact_person)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("code", { + className: "text-primary fw-semibold" + }, sup.gstin || 'No GSTIN')), sup.phone && /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-telephone me-1" + }), sup.phone)), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-semibold" + }, "₹", Number(sup.total_purchases || 0).toLocaleString('en-IN', { + minimumFractionDigits: 2 + })), /*#__PURE__*/React.createElement("td", { + className: "text-end text-success fw-semibold" + }, "₹", Number(sup.total_paid || 0).toLocaleString('en-IN', { + minimumFractionDigits: 2 + })), /*#__PURE__*/React.createElement("td", { + className: "text-end" + }, /*#__PURE__*/React.createElement("span", { + className: `badge ${sup.outstanding_balance > 0 ? 'bg-danger-subtle text-danger border border-danger-subtle fs-6' : 'bg-success-subtle text-success border border-success-subtle'} px-2.5 py-1.5` + }, "₹", Number(sup.outstanding_balance || 0).toLocaleString('en-IN', { + minimumFractionDigits: 2 + }))), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, sup.pending_invoices > 0 ? /*#__PURE__*/React.createElement("span", { + className: "badge bg-warning text-dark border border-warning px-2 py-1" + }, sup.pending_invoices, " Unpaid") : /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-muted border px-2 py-1" + }, "All Settled")), /*#__PURE__*/React.createElement("td", { + className: "text-end pe-3" + }, /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-primary", + onClick: () => { + setActiveLedgerSupplierId(String(sup.supplier_id)); + fetchSupplierLedger(sup.supplier_id); + }, + title: "View detailed ledger statement" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-journal-text me-1" + }), " Statement"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-success", + onClick: () => openPaymentModal(sup.supplier_id), + title: "Record payment against this supplier" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-credit-card me-1" + }), " Pay")))))))), activeLedgerSupplierId && activeLedgerDetail && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "card border-0 shadow-sm p-3 mb-3 bg-white border-start border-4 border-primary" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap justify-content-between align-items-center gap-2" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h5", { + className: "fw-bold text-dark mb-1 d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-building text-primary" + }), activeLedgerDetail.supplier.supplier_name), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap gap-3 text-muted small" + }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("strong", null, "GSTIN:"), " ", activeLedgerDetail.supplier.gstin || 'N/A'), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("strong", null, "DL No:"), " ", activeLedgerDetail.supplier.dl_no_20b || activeLedgerDetail.supplier.dl_no_21b || 'N/A'), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("strong", null, "Phone:"), " ", activeLedgerDetail.supplier.phone || 'N/A'), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("strong", null, "Credit Days:"), " ", activeLedgerDetail.supplier.credit_days || 30, " Days"))), /*#__PURE__*/React.createElement("div", { + className: "text-end" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted text-uppercase d-block", + style: { + fontSize: '11px' + } + }, "Net Outstanding Balance"), /*#__PURE__*/React.createElement("span", { + className: `badge ${activeLedgerDetail.summary.outstanding_balance > 0 ? 'bg-danger text-white fs-5' : 'bg-success text-white fs-5'} px-3 py-2` + }, "₹", Number(activeLedgerDetail.summary.outstanding_balance || 0).toLocaleString('en-IN', { + minimumFractionDigits: 2 + }))))), /*#__PURE__*/React.createElement("div", { + className: "card border-0 shadow-sm mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "card-header bg-white py-2.5 px-3 d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold text-dark mb-0" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hourglass-split text-warning me-1" + }), " Pending Invoices (", activeLedgerDetail.pending_invoices?.length || 0, ")"), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "Invoices awaiting full or partial payment")), /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-hover align-middle mb-0", + style: { + fontSize: '13px' + } + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "Bill / Invoice No"), /*#__PURE__*/React.createElement("th", null, "Invoice Date"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Bill Amount"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Paid Amount"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Pending Amount"), /*#__PURE__*/React.createElement("th", { + className: "text-center" + }, "Status"), /*#__PURE__*/React.createElement("th", { + className: "text-end pe-3" + }, "Action"))), /*#__PURE__*/React.createElement("tbody", null, !activeLedgerDetail.pending_invoices || activeLedgerDetail.pending_invoices.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "7", + className: "text-center py-3 text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check2-all text-success me-1" + }), "All purchase bills for this supplier are fully paid.")) : activeLedgerDetail.pending_invoices.map(inv => /*#__PURE__*/React.createElement("tr", { + key: inv.purchase_id + }, /*#__PURE__*/React.createElement("td", { + className: "fw-bold text-primary" + }, inv.supplier_invoice_no), /*#__PURE__*/React.createElement("td", null, inv.invoice_date), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-semibold" + }, "₹", Number(inv.net_amount).toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: "text-end text-success" + }, "₹", Number(inv.paid_amount).toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold text-danger" + }, "₹", Number(inv.pending_amount).toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, /*#__PURE__*/React.createElement("span", { + className: `badge ${inv.payment_status === 'partially_paid' ? 'bg-warning text-dark' : 'bg-danger'} px-2 py-1` + }, inv.payment_status === 'partially_paid' ? 'Partially Paid' : 'Unpaid')), /*#__PURE__*/React.createElement("td", { + className: "text-end pe-3" + }, /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-primary py-1 px-2 shadow-sm", + onClick: () => loadPurchaseForEdit(inv.purchase_id), + title: "Edit this Purchase Invoice" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-pencil-square me-1" + }), " Edit"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-success py-1 px-2.5 shadow-sm fw-semibold", + onClick: () => openPaymentModal(activeLedgerDetail.supplier.supplier_id, inv.purchase_id, inv.pending_amount) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cash me-1" + }), " Pay Bill"))))))))), /*#__PURE__*/React.createElement("div", { + className: "card border-0 shadow-sm" + }, /*#__PURE__*/React.createElement("div", { + className: "card-header bg-white py-2.5 px-3 d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold text-dark mb-0" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-journal-check text-primary me-1" + }), " Complete Ledger Statement & Running Balance"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border px-2 py-1" + }, "Total Transactions: ", activeLedgerDetail.statement?.length || 0)), /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-bordered table-hover align-middle mb-0", + style: { + fontSize: '12.5px' + } + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", { + style: { + width: 100 + } + }, "Date"), /*#__PURE__*/React.createElement("th", { + style: { + width: 130 + } + }, "Voucher / Ref"), /*#__PURE__*/React.createElement("th", { + style: { + width: 100 + } + }, "Type"), /*#__PURE__*/React.createElement("th", null, "Particulars & Details"), /*#__PURE__*/React.createElement("th", { + className: "text-end", + style: { + width: 120 + } + }, "Debit (₹ Payments)"), /*#__PURE__*/React.createElement("th", { + className: "text-end", + style: { + width: 120 + } + }, "Credit (₹ Inward)"), /*#__PURE__*/React.createElement("th", { + className: "text-end", + style: { + width: 140 + } + }, "Balance (₹ Payable)"))), /*#__PURE__*/React.createElement("tbody", null, !activeLedgerDetail.statement || activeLedgerDetail.statement.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "7", + className: "text-center py-4 text-muted" + }, "No transactions recorded for this supplier.")) : activeLedgerDetail.statement.map((row, idx) => /*#__PURE__*/React.createElement("tr", { + key: idx, + className: row.type === 'PAYMENT' ? 'table-success-subtle' : '' + }, /*#__PURE__*/React.createElement("td", { + className: "text-nowrap" + }, row.date), /*#__PURE__*/React.createElement("td", { + className: "fw-semibold text-primary" + }, row.type === 'INVOICE' && row.invoice_id ? /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-link p-0 text-decoration-none fw-bold text-primary", + onClick: () => loadPurchaseForEdit(row.invoice_id), + title: "Click to edit purchase invoice" + }, row.voucher_no, " ", /*#__PURE__*/React.createElement("i", { + className: "bi bi-pencil-square text-muted ms-1", + style: { + fontSize: '11px' + } + })) : row.voucher_no), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: `badge ${row.type === 'INVOICE' ? 'bg-primary-subtle text-primary border border-primary-subtle' : 'bg-success text-white'}` + }, row.type === 'INVOICE' ? 'Purchase Bill' : 'Payment')), /*#__PURE__*/React.createElement("td", null, row.particulars), /*#__PURE__*/React.createElement("td", { + className: "text-end text-success fw-bold" + }, row.debit > 0 ? '₹' + Number(row.debit).toFixed(2) : '-'), /*#__PURE__*/React.createElement("td", { + className: "text-end text-dark fw-bold" + }, row.credit > 0 ? '₹' + Number(row.credit).toFixed(2) : '-'), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold" + }, /*#__PURE__*/React.createElement("span", { + className: row.balance > 0 ? 'text-danger' : 'text-success' + }, "₹", Number(row.balance).toFixed(2)))))), activeLedgerDetail.statement?.length > 0 && /*#__PURE__*/React.createElement("tfoot", { + className: "table-light fw-bold" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "4", + className: "text-end" + }, "Total Summary:"), /*#__PURE__*/React.createElement("td", { + className: "text-end text-success" + }, "₹", Number(activeLedgerDetail.summary.total_paid || 0).toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: "text-end text-dark" + }, "₹", Number(activeLedgerDetail.summary.total_purchases || 0).toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: "text-end text-danger fs-6" + }, "₹", Number(activeLedgerDetail.summary.outstanding_balance || 0).toFixed(2))))))))), subTab === 'short_items' && /*#__PURE__*/React.createElement("div", { + className: "counter-card" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap justify-content-between align-items-center gap-2 mb-3" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h5", { + className: "fw-bold mb-0 text-dark" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-exclamation-triangle text-warning me-1" + }), " Short Items & Deficiency Reorder Book"), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "Real-time inventory shortage detection. Select items to generate consolidated Purchase Orders in 1-click.")), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-primary btn-sm px-3 shadow-sm fw-bold", + disabled: selectedShortItemIds.length === 0, + onClick: openCreatePoFromShortItems + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cart-plus me-1" + }), " Create Purchase Order (", selectedShortItemIds.length, " Selected)"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-primary btn-sm", + onClick: fetchShortItems, + title: "Refresh Short List" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-clockwise" + })))), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap justify-content-between align-items-center gap-2 mb-3 bg-light p-2.5 rounded-3 border" + }, /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm" + }, /*#__PURE__*/React.createElement("button", { + className: `btn ${shortFilter === 'all' ? 'btn-primary' : 'btn-outline-secondary'}`, + onClick: () => setShortFilter('all') + }, "All Shortages (", shortItems.length, ")"), /*#__PURE__*/React.createElement("button", { + className: `btn ${shortFilter === 'out_of_stock' ? 'btn-danger' : 'btn-outline-secondary'}`, + onClick: () => setShortFilter('out_of_stock') + }, "Out of Stock (", shortItems.filter(s => s.status === 'OUT_OF_STOCK').length, ")"), /*#__PURE__*/React.createElement("button", { + className: `btn ${shortFilter === 'low_stock' ? 'btn-warning text-dark' : 'btn-outline-secondary'}`, + onClick: () => setShortFilter('low_stock') + }, "Low Stock (", shortItems.filter(s => s.status === 'LOW_STOCK').length, ")")), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm", + style: { + width: 280 + } + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-white border-end-0" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search text-muted" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control border-start-0", + placeholder: "Filter short medicine...", + value: shortSearch, + onChange: e => setShortSearch(e.target.value) + }), shortSearch && /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-secondary", + type: "button", + onClick: () => setShortSearch('') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x" + })))), (() => { + const filtered = shortItems.filter(it => { + if (shortFilter === 'out_of_stock' && it.status !== 'OUT_OF_STOCK') return false; + if (shortFilter === 'low_stock' && it.status !== 'LOW_STOCK') return false; + if (shortSearch.trim()) { + const q = shortSearch.toLowerCase(); + return it.item_name && it.item_name.toLowerCase().includes(q) || it.category && it.category.toLowerCase().includes(q) || it.last_supplier_name && it.last_supplier_name.toLowerCase().includes(q); + } + return true; + }); + const allSelected = filtered.length > 0 && filtered.every(it => selectedShortItemIds.includes(it.item_id)); + return /*#__PURE__*/React.createElement("div", { + className: "table-responsive shadow-sm rounded border" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-hover align-middle mb-0" + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", { + style: { + width: 40 + }, + className: "text-center" + }, /*#__PURE__*/React.createElement("input", { + type: "checkbox", + className: "form-check-input", + checked: allSelected, + onChange: e => { + if (e.target.checked) { + setSelectedShortItemIds(filtered.map(it => it.item_id)); + } else { + setSelectedShortItemIds([]); + } + } + })), /*#__PURE__*/React.createElement("th", null, "Medicine / Formulation"), /*#__PURE__*/React.createElement("th", null, "Stock Status"), /*#__PURE__*/React.createElement("th", { + className: "text-center" + }, "Current Stock"), /*#__PURE__*/React.createElement("th", { + className: "text-center" + }, "Min Reorder"), /*#__PURE__*/React.createElement("th", { + style: { + width: 110 + } + }, "Suggested Order"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Estimated PTR"), /*#__PURE__*/React.createElement("th", null, "Last Supplier"), /*#__PURE__*/React.createElement("th", { + className: "text-end pe-3" + }, "Action"))), /*#__PURE__*/React.createElement("tbody", null, isLoadingShortItems ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "9", + className: "text-center py-4" + }, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm me-2" + }), "Checking stock levels...")) : filtered.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "9", + className: "text-center py-4 text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle text-success fs-3 d-block mb-1" + }), "No medicines currently below reorder levels. Inventory is well-stocked!")) : filtered.map(it => { + const isSelected = selectedShortItemIds.includes(it.item_id); + return /*#__PURE__*/React.createElement("tr", { + key: it.item_id, + className: isSelected ? 'table-primary-subtle' : '' + }, /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, /*#__PURE__*/React.createElement("input", { + type: "checkbox", + className: "form-check-input", + checked: isSelected, + onChange: e => { + if (e.target.checked) { + setSelectedShortItemIds([...selectedShortItemIds, it.item_id]); + } else { + setSelectedShortItemIds(selectedShortItemIds.filter(id => id !== it.item_id)); } - return true; + } + })), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark fs-6" + }, it.item_name), /*#__PURE__*/React.createElement("div", { + className: "small text-muted d-flex gap-2 align-items-center" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border" + }, it.category || 'Tablet'), /*#__PURE__*/React.createElement("span", null, it.unit_pack || it.units_per_pack + ' Units/Pack'), it.drug_schedule && /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger-subtle text-danger border" + }, it.drug_schedule))), /*#__PURE__*/React.createElement("td", null, it.status === 'OUT_OF_STOCK' ? /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger-subtle text-danger border border-danger-subtle px-2 py-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x-circle me-1" + }), "Out of Stock") : /*#__PURE__*/React.createElement("span", { + className: "badge bg-warning-subtle text-warning-emphasis border border-warning-subtle px-2 py-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-exclamation-triangle me-1" + }), "Low Stock")), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold fs-6 text-danger" + }, it.current_qty), /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block", + style: { + fontSize: '11px' + } + }, "(", it.current_packs, " packs)")), /*#__PURE__*/React.createElement("td", { + className: "text-center text-muted fw-semibold" + }, it.min_reorder_level, " units"), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm fw-bold text-center", + min: "1", + value: it.suggested_packs, + onChange: e => { + const val = Math.max(1, parseInt(e.target.value) || 1); + setShortItems(shortItems.map(si => si.item_id === it.item_id ? { + ...si, + suggested_packs: val + } : si)); + } + }), /*#__PURE__*/React.createElement("span", { + className: "input-group-text py-0 px-1 text-muted", + style: { + fontSize: '11px' + } + }, "Pks"))), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-semibold" + }, it.last_ptr > 0 ? '₹' + Number(it.last_ptr).toFixed(2) : /*#__PURE__*/React.createElement("span", { + className: "text-muted" + }, "-")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-semibold text-truncate", + style: { + maxWidth: 180 + }, + title: it.last_supplier_name + }, it.last_supplier_name), it.last_purchase_date && /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '11px' + } + }, "Last: ", it.last_purchase_date)), /*#__PURE__*/React.createElement("td", { + className: "text-end pe-3" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-primary py-1 px-2 text-nowrap", + onClick: () => { + setSelectedShortItemIds([it.item_id]); + openCreatePoFromShortItems(); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cart-plus me-1" + }), " Order"))); + })))); + })()), subTab === 'purchase_orders' && /*#__PURE__*/React.createElement("div", { + className: "counter-card" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap justify-content-between align-items-center gap-2 mb-3" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h5", { + className: "fw-bold mb-0 text-dark" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-text text-primary me-1" + }), " Hospital Purchase Orders Directory"), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "Track order status, print official supplier order formats, and load directly into inward bills.")), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-primary btn-sm px-3 shadow-sm fw-semibold", + onClick: () => { + setPoCreateForm({ + supplier_id: suppliers[0]?.supplier_id ? String(suppliers[0].supplier_id) : '', + expected_delivery_date: new Date(Date.now() + 3 * 24 * 60 * 60 * 1000).toISOString().split('T')[0], + remarks: '', + items: [{ + item_id: null, + item_name: '', + generic_name: '', + category: 'Tablet', + order_packs: 5, + units_per_pack: 10, + estimated_ptr: 0, + gst_rate: 12 + }] + }); + setShowPoCreateModal(true); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-plus-circle me-1" + }), " New Purchase Order"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-primary btn-sm", + onClick: fetchPurchaseOrders, + title: "Refresh PO List" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-clockwise" + })))), /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm mb-3" + }, /*#__PURE__*/React.createElement("button", { + className: `btn ${poStatusFilter === 'all' ? 'btn-primary' : 'btn-outline-secondary'}`, + onClick: () => { + setPoStatusFilter('all'); + fetchPurchaseOrders(); + } + }, "All Orders"), /*#__PURE__*/React.createElement("button", { + className: `btn ${poStatusFilter === 'ordered' ? 'btn-primary' : 'btn-outline-secondary'}`, + onClick: () => { + setPoStatusFilter('ordered'); + fetchPurchaseOrders(); + } + }, "Ordered / In-Transit"), /*#__PURE__*/React.createElement("button", { + className: `btn ${poStatusFilter === 'received' ? 'btn-success' : 'btn-outline-secondary'}`, + onClick: () => { + setPoStatusFilter('received'); + fetchPurchaseOrders(); + } + }, "Received / Inwarded"), /*#__PURE__*/React.createElement("button", { + className: `btn ${poStatusFilter === 'cancelled' ? 'btn-danger' : 'btn-outline-secondary'}`, + onClick: () => { + setPoStatusFilter('cancelled'); + fetchPurchaseOrders(); + } + }, "Cancelled")), /*#__PURE__*/React.createElement("div", { + className: "table-responsive shadow-sm rounded border" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-hover align-middle mb-0" + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "PO Number"), /*#__PURE__*/React.createElement("th", null, "PO Date"), /*#__PURE__*/React.createElement("th", null, "Expected Delivery"), /*#__PURE__*/React.createElement("th", null, "Supplier / Distributor"), /*#__PURE__*/React.createElement("th", { + className: "text-center" + }, "Items"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Est. Total Amount"), /*#__PURE__*/React.createElement("th", { + className: "text-center" + }, "Status"), /*#__PURE__*/React.createElement("th", { + className: "text-end pe-3" + }, "Actions"))), /*#__PURE__*/React.createElement("tbody", null, isLoadingPOs ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "8", + className: "text-center py-4" + }, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm me-2" + }), "Loading purchase orders...")) : purchaseOrders.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "8", + className: "text-center py-4 text-muted" + }, "No purchase orders found. Click \"New Purchase Order\" or generate from Short Items.")) : purchaseOrders.map(po => /*#__PURE__*/React.createElement("tr", { + key: po.po_id + }, /*#__PURE__*/React.createElement("td", { + className: "fw-bold text-primary" + }, po.po_number), /*#__PURE__*/React.createElement("td", null, po.po_date), /*#__PURE__*/React.createElement("td", null, po.expected_delivery_date || /*#__PURE__*/React.createElement("span", { + className: "text-muted" + }, "-")), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-semibold text-dark" + }, po.supplier_name), po.phone && /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-telephone me-1" + }), po.phone)), /*#__PURE__*/React.createElement("td", { + className: "text-center fw-bold" + }, po.total_items), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold" + }, "₹", Number(po.total_estimated_amount || 0).toLocaleString('en-IN', { + minimumFractionDigits: 2 + })), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, po.status === 'ordered' && /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary border border-primary-subtle px-2 py-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clock me-1" + }), "Ordered"), po.status === 'received' && /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success border border-success-subtle px-2 py-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check2-circle me-1" + }), "Received"), po.status === 'cancelled' && /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-secondary border px-2 py-1" + }, "Cancelled")), /*#__PURE__*/React.createElement("td", { + className: "text-end pe-3" + }, /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-primary", + onClick: () => handleViewPo(po.po_id), + title: "View & Print PO" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer me-1" + }), " Print"), po.status === 'ordered' && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", { + className: "btn btn-success", + onClick: () => loadPoIntoInwardBill(po.po_id), + title: "Load this PO into Inward Purchase Bill" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-box-arrow-in-down me-1" + }), " Inward"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-danger", + onClick: () => handleCancelPo(po.po_id), + title: "Cancel this PO" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x" + }))))))))))), showSupplierModal && /*#__PURE__*/React.createElement("div", { + className: "modal fade show d-block", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.75)' + }, + tabIndex: "-1" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content border-0 shadow-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2.5 px-3 d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "bg-primary text-white rounded p-1.5 d-flex align-items-center justify-content-center", + style: { + width: 32, + height: 32 + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-truck fs-5" + })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "modal-title mb-0 fw-bold" + }, supplierForm.supplier_id ? 'Edit Supplier / Distributor Details' : 'Add New Drug Distributor & Supplier'), /*#__PURE__*/React.createElement("small", { + className: "text-light opacity-75" + }, "Statutory Drug Licenses, GSTIN, contact & credit terms"))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setShowSupplierModal(false) + })), /*#__PURE__*/React.createElement("form", { + onSubmit: handleSaveSupplier + }, /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3 bg-light" + }, /*#__PURE__*/React.createElement("div", { + className: "card border-0 shadow-sm p-3 mb-3 bg-white" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold text-primary mb-2", + style: { + fontSize: '13px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-building me-1" + }), " Basic Distributor Information"), /*#__PURE__*/React.createElement("div", { + className: "row g-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-8" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Distributor / Agency Name ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "e.g. Apex Healthcare Distributors Pvt Ltd", + value: supplierForm.supplier_name, + onChange: e => setSupplierForm({ + ...supplierForm, + supplier_name: e.target.value + }), + required: true, + autoFocus: true + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Contact Person"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "e.g. Ramesh Gupta", + value: supplierForm.contact_person, + onChange: e => setSupplierForm({ + ...supplierForm, + contact_person: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Phone / Mobile No."), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "+91 9811002233", + value: supplierForm.phone, + onChange: e => setSupplierForm({ + ...supplierForm, + phone: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Email Address"), /*#__PURE__*/React.createElement("input", { + type: "email", + className: "form-control form-control-sm", + placeholder: "sales@distributor.com", + value: supplierForm.email, + onChange: e => setSupplierForm({ + ...supplierForm, + email: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Credit Terms"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm", + min: "0", + placeholder: "30", + value: supplierForm.credit_days, + onChange: e => setSupplierForm({ + ...supplierForm, + credit_days: e.target.value + }) + }), /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light" + }, "Days"))))), /*#__PURE__*/React.createElement("div", { + className: "card border-0 shadow-sm p-3 mb-3 bg-white" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold text-primary mb-2", + style: { + fontSize: '13px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-check me-1" + }), " Indian Statutory Drug Licenses & GSTIN"), /*#__PURE__*/React.createElement("div", { + className: "row g-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Drug License Form 20-B (Allopathic)"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "e.g. DL-20B-DEL-98441", + value: supplierForm.dl_no_20b, + onChange: e => setSupplierForm({ + ...supplierForm, + dl_no_20b: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Drug License Form 21-B (Schedule C & C1)"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "e.g. DL-21B-DEL-98442", + value: supplierForm.dl_no_21b, + onChange: e => setSupplierForm({ + ...supplierForm, + dl_no_21b: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "GSTIN (15-Digit)"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm text-uppercase", + maxLength: "15", + placeholder: "07AACCA1234F1Z9", + value: supplierForm.gstin, + onChange: e => setSupplierForm({ + ...supplierForm, + gstin: e.target.value.toUpperCase() + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "PAN No. (10-Digit)"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm text-uppercase", + maxLength: "10", + placeholder: "AACCA1234F", + value: supplierForm.pan_no, + onChange: e => setSupplierForm({ + ...supplierForm, + pan_no: e.target.value.toUpperCase() + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "State Code (GST)"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "07 (Delhi)", + value: supplierForm.state_code, + onChange: e => setSupplierForm({ + ...supplierForm, + state_code: e.target.value + }) + })))), /*#__PURE__*/React.createElement("div", { + className: "card border-0 shadow-sm p-3 bg-white" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold text-primary mb-2", + style: { + fontSize: '13px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-geo-alt me-1" + }), " Address & Banking Details"), /*#__PURE__*/React.createElement("div", { + className: "row g-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Full Postal Address"), /*#__PURE__*/React.createElement("textarea", { + className: "form-control form-control-sm", + rows: "2", + placeholder: "Shop / Office No, Market, City, Pincode", + value: supplierForm.address, + onChange: e => setSupplierForm({ + ...supplierForm, + address: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Bank Account & Settlement Details"), /*#__PURE__*/React.createElement("textarea", { + className: "form-control form-control-sm", + rows: "2", + placeholder: "Bank Name, A/c Number, IFSC Code, UPI ID", + value: supplierForm.bank_details, + onChange: e => setSupplierForm({ + ...supplierForm, + bank_details: e.target.value + }) + }))))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer py-2 px-3 bg-white d-flex justify-content-between" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-outline-secondary btn-sm", + onClick: () => setShowSupplierModal(false) + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + type: "submit", + className: "btn btn-primary btn-sm px-4", + disabled: isSavingSupplier + }, isSavingSupplier ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm me-1", + role: "status" + }), "Saving...") : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check2-circle me-1" + }), supplierForm.supplier_id ? 'Update Supplier' : 'Save Supplier'))))))), showMasterModal && /*#__PURE__*/React.createElement("div", { + className: "modal fade show d-block", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.75)' + }, + tabIndex: "-1" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content border-0 shadow-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2.5 px-3 d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "bg-success text-white rounded p-1.5 d-flex align-items-center justify-content-center", + style: { + width: 32, + height: 32 + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-capsule fs-5" + })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "modal-title mb-0 fw-bold" + }, "Add New Medicine to Pharmacy Master"), /*#__PURE__*/React.createElement("small", { + className: "text-light opacity-75" + }, "Saved to shared master ", /*#__PURE__*/React.createElement("code", null, "med_product_master"), " (shared between MedicalStore & HMSPharmacy)"))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setShowMasterModal(false) + })), /*#__PURE__*/React.createElement("form", { + onSubmit: handleSaveMasterMedicine + }, /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3 bg-light" + }, /*#__PURE__*/React.createElement("div", { + className: "card border-0 shadow-sm p-3 mb-3 bg-white" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold text-primary mb-2", + style: { + fontSize: '13px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-prescription2 me-1" + }), " Medicine Name & Formulation"), /*#__PURE__*/React.createElement("div", { + className: "row g-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-7" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Brand / Medicine Name ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm fw-semibold", + placeholder: "e.g. Augmentin 625 Duo Tablet", + value: masterForm.item_name, + onChange: e => setMasterForm({ + ...masterForm, + item_name: e.target.value + }), + required: true, + autoFocus: true + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-5" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Formulation / Category"), /*#__PURE__*/React.createElement("input", { + type: "text", + list: "ms-formulation-list", + className: "form-control form-control-sm", + placeholder: "e.g. Tablet, Capsule, Syrup...", + value: masterForm.formulation, + onChange: e => setMasterForm({ + ...masterForm, + formulation: e.target.value + }) + }), /*#__PURE__*/React.createElement("datalist", { + id: "ms-formulation-list" + }, (supportData.formulations || []).map((f, idx) => /*#__PURE__*/React.createElement("option", { + key: idx, + value: f + })))), /*#__PURE__*/React.createElement("div", { + className: "col-12" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Generic Molecule Composition"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "e.g. Amoxycillin (500mg) + Clavulanic Acid (125mg)", + value: masterForm.generic_name, + onChange: e => setMasterForm({ + ...masterForm, + generic_name: e.target.value + }) + })))), /*#__PURE__*/React.createElement("div", { + className: "card border-0 shadow-sm p-3 bg-white" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold text-primary mb-2", + style: { + fontSize: '13px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-box-seam me-1" + }), " Packing, Tax & Regulatory Specifications"), /*#__PURE__*/React.createElement("div", { + className: "row g-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Units per Pack (Strip/Bottle) ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("input", { + type: "number", + min: "1", + className: "form-control form-control-sm fw-bold", + placeholder: "10", + value: masterForm.units_per_pack, + onChange: e => setMasterForm({ + ...masterForm, + units_per_pack: e.target.value, + packing: e.target.value + }), + required: true + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "GST Rate (%)"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm fw-bold", + value: masterForm.gst_rate, + onChange: e => setMasterForm({ + ...masterForm, + gst_rate: Number(e.target.value) + }) + }, /*#__PURE__*/React.createElement("option", { + value: "0" + }, "0% (Nil / Exempt)"), /*#__PURE__*/React.createElement("option", { + value: "5" + }, "5% (Common / Basic Services)"), /*#__PURE__*/React.createElement("option", { + value: "18" + }, "18% (Standard - Most Products)"), /*#__PURE__*/React.createElement("option", { + value: "40" + }, "40% (Demerit / Sin Tax)"), /*#__PURE__*/React.createElement("option", { + value: "12" + }, "12% (Legacy Medicine Slab)"), /*#__PURE__*/React.createElement("option", { + value: "28" + }, "28% (Legacy High Slab)"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "HSN Code"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "3004", + value: masterForm.hsn_code, + onChange: e => setMasterForm({ + ...masterForm, + hsn_code: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Drug Schedule"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: masterForm.drug_schedule, + onChange: e => setMasterForm({ + ...masterForm, + drug_schedule: e.target.value + }) + }, (supportData.schedules || ['OTC', 'Schedule H', 'Schedule H1', 'Schedule X', 'Narcotic']).map((sc, idx) => /*#__PURE__*/React.createElement("option", { + key: idx, + value: sc + }, sc)))), /*#__PURE__*/React.createElement("div", { + className: "col-md-8" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Manufacturer / Pharma Company"), /*#__PURE__*/React.createElement("input", { + type: "text", + list: "ms-company-list", + className: "form-control form-control-sm", + placeholder: "e.g. Cipla Ltd, Sun Pharma, Alkem...", + value: masterForm.company_name, + onChange: e => setMasterForm({ + ...masterForm, + company_name: e.target.value + }) + }), /*#__PURE__*/React.createElement("datalist", { + id: "ms-company-list" + }, (supportData.companies || []).map((c, idx) => /*#__PURE__*/React.createElement("option", { + key: idx, + value: c + })))), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Min Reorder Level"), /*#__PURE__*/React.createElement("input", { + type: "number", + min: "1", + className: "form-control form-control-sm", + placeholder: "10", + value: masterForm.min_reorder_level, + onChange: e => setMasterForm({ + ...masterForm, + min_reorder_level: e.target.value + }) + }))))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer py-2 px-3 bg-white d-flex justify-content-between" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-outline-secondary btn-sm", + onClick: () => setShowMasterModal(false) + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + type: "submit", + className: "btn btn-success btn-sm fw-bold px-4", + disabled: isSavingMaster + }, isSavingMaster ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm me-1", + role: "status" + }), "Saving to Master...") : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle me-1" + }), "Save to Master & Select into Bill"))))))), showPaymentModal && /*#__PURE__*/React.createElement("div", { + className: "modal fade show d-block", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.75)' + }, + tabIndex: "-1" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-md modal-dialog-centered" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content border-0 shadow-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2.5 px-3 d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "bg-success text-white rounded p-1.5 d-flex align-items-center justify-content-center", + style: { + width: 32, + height: 32 + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cash-coin fs-5" + })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "modal-title mb-0 fw-bold" + }, "Record Supplier Payment Voucher"), /*#__PURE__*/React.createElement("small", { + className: "text-light opacity-75" + }, "Outflow accounting against invoice or on-account"))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setShowPaymentModal(false) + })), /*#__PURE__*/React.createElement("form", { + onSubmit: handleRecordPayment + }, /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3 bg-light" + }, /*#__PURE__*/React.createElement("div", { + className: "card border-0 shadow-sm p-3 mb-3 bg-white" + }, /*#__PURE__*/React.createElement("div", { + className: "row g-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-12" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Supplier / Distributor ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm fw-semibold", + value: paymentForm.supplier_id, + onChange: e => setPaymentForm({ + ...paymentForm, + supplier_id: e.target.value + }), + required: true + }, /*#__PURE__*/React.createElement("option", { + value: "" + }, "-- Choose Supplier --"), suppliers.map(s => /*#__PURE__*/React.createElement("option", { + key: s.supplier_id, + value: s.supplier_id + }, s.supplier_name, " (GST: ", s.gstin || 'N/A', ")")))), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Payment Amount (₹) ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.01", + min: "0.01", + className: "form-control form-control-sm fw-bold text-success fs-6", + placeholder: "0.00", + value: paymentForm.amount, + onChange: e => setPaymentForm({ + ...paymentForm, + amount: e.target.value + }), + required: true, + autoFocus: true + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Payment Mode"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: paymentForm.payment_mode, + onChange: e => setPaymentForm({ + ...paymentForm, + payment_mode: e.target.value + }) + }, /*#__PURE__*/React.createElement("option", { + value: "Bank" + }, "Bank Transfer (NEFT/RTGS)"), /*#__PURE__*/React.createElement("option", { + value: "UPI" + }, "UPI / QR Code"), /*#__PURE__*/React.createElement("option", { + value: "Cash" + }, "Cash in Hand"), /*#__PURE__*/React.createElement("option", { + value: "Cheque" + }, "Bank Cheque"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Payment Date"), /*#__PURE__*/React.createElement("input", { + type: "date", + className: "form-control form-control-sm", + value: paymentForm.payment_date, + onChange: e => setPaymentForm({ + ...paymentForm, + payment_date: e.target.value + }), + required: true + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "UTR / Cheque / Ref No"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "e.g. UTR-9988112", + value: paymentForm.reference_no, + onChange: e => setPaymentForm({ + ...paymentForm, + reference_no: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-12" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Bank Name / Account Details"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "e.g. HDFC Bank - Main Current A/c", + value: paymentForm.bank_name, + onChange: e => setPaymentForm({ + ...paymentForm, + bank_name: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-12" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Remarks / Settlement Note"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "e.g. Cleared bill #APX-9941", + value: paymentForm.remarks, + onChange: e => setPaymentForm({ + ...paymentForm, + remarks: e.target.value + }) + }))))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer py-2 px-3 bg-white d-flex justify-content-between" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-outline-secondary btn-sm", + onClick: () => setShowPaymentModal(false) + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + type: "submit", + className: "btn btn-success btn-sm fw-bold px-4 shadow-sm", + disabled: isRecordingPayment + }, isRecordingPayment ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm me-1" + }), "Recording Voucher...") : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check2-circle me-1" + }), "Record Payment Voucher"))))))), showPoCreateModal && /*#__PURE__*/React.createElement("div", { + className: "modal fade show d-block", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.75)' + }, + tabIndex: "-1" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-xl modal-dialog-centered modal-dialog-scrollable" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content border-0 shadow-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2.5 px-3 d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "bg-primary text-white rounded p-1.5 d-flex align-items-center justify-content-center", + style: { + width: 32, + height: 32 + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cart-check fs-5" + })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "modal-title mb-0 fw-bold" + }, "Generate New Purchase Order (PO)"), /*#__PURE__*/React.createElement("small", { + className: "text-light opacity-75" + }, "Order requisition for pharmaceutical distributor"))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setShowPoCreateModal(false) + })), /*#__PURE__*/React.createElement("form", { + onSubmit: handleSavePurchaseOrder + }, /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3 bg-light" + }, /*#__PURE__*/React.createElement("div", { + className: "card border-0 shadow-sm p-3 mb-3 bg-white" + }, /*#__PURE__*/React.createElement("div", { + className: "row g-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-5" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Target Supplier / Agency ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm fw-semibold", + value: poCreateForm.supplier_id, + onChange: e => setPoCreateForm({ + ...poCreateForm, + supplier_id: e.target.value + }), + required: true + }, /*#__PURE__*/React.createElement("option", { + value: "" + }, "-- Choose Supplier --"), suppliers.map(s => /*#__PURE__*/React.createElement("option", { + key: s.supplier_id, + value: s.supplier_id + }, s.supplier_name, " (GST: ", s.gstin || 'N/A', ")")))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Expected Delivery Date"), /*#__PURE__*/React.createElement("input", { + type: "date", + className: "form-control form-control-sm", + value: poCreateForm.expected_delivery_date, + onChange: e => setPoCreateForm({ + ...poCreateForm, + expected_delivery_date: e.target.value + }), + required: true + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Remarks / Order Instructions"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "e.g. Urgent stock replenishment", + value: poCreateForm.remarks, + onChange: e => setPoCreateForm({ + ...poCreateForm, + remarks: e.target.value + }) + })))), /*#__PURE__*/React.createElement("div", { + className: "card border-0 shadow-sm p-3 bg-white" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-2" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold text-primary mb-0", + style: { + fontSize: '13px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-box-seam me-1" + }), " Ordered Items (", poCreateForm.items.length, ")"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-outline-primary btn-sm py-0.5 px-2", + onClick: () => { + setPoCreateForm({ + ...poCreateForm, + items: [...poCreateForm.items, { + item_id: null, + item_name: '', + generic_name: '', + category: 'Tablet', + order_packs: 1, + units_per_pack: 10, + estimated_ptr: 0, + gst_rate: 12 + }] + }); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-plus me-1" + }), " Add Another Medicine")), /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-bordered align-middle mb-0", + style: { + fontSize: '12.5px' + } + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", { + style: { + minWidth: 240 + } + }, "Medicine Name"), /*#__PURE__*/React.createElement("th", { + style: { + width: 100 + } + }, "Category"), /*#__PURE__*/React.createElement("th", { + style: { + width: 90 + } + }, "Packs"), /*#__PURE__*/React.createElement("th", { + style: { + width: 90 + } + }, "Units/Pack"), /*#__PURE__*/React.createElement("th", { + style: { + width: 100 + } + }, "Est. PTR (₹)"), /*#__PURE__*/React.createElement("th", { + style: { + width: 85 + } + }, "GST%"), /*#__PURE__*/React.createElement("th", { + style: { + width: 120 + }, + className: "text-end" + }, "Est. Total (₹)"), /*#__PURE__*/React.createElement("th", { + style: { + width: 40 + } + }))), /*#__PURE__*/React.createElement("tbody", null, poCreateForm.items.map((it, idx) => { + const lineTotal = Number(it.order_packs || 0) * Number(it.estimated_ptr || 0) * (1 + Number(it.gst_rate || 0) / 100); + return /*#__PURE__*/React.createElement("tr", { + key: idx + }, /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm fw-semibold", + placeholder: "Medicine name...", + value: it.item_name, + onChange: e => { + const items = [...poCreateForm.items]; + items[idx].item_name = e.target.value; + setPoCreateForm({ + ...poCreateForm, + items }); - const allSelected = filtered.length > 0 && filtered.every(it => selectedShortItemIds.includes(it.item_id)); - return /*#__PURE__*/_jsx("div", { - className: "table-responsive shadow-sm rounded border", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-hover align-middle mb-0", - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - style: { - width: 40 - }, - className: "text-center", - children: /*#__PURE__*/_jsx("input", { - type: "checkbox", - className: "form-check-input", - checked: allSelected, - onChange: e => { - if (e.target.checked) { - setSelectedShortItemIds(filtered.map(it => it.item_id)); - } else { - setSelectedShortItemIds([]); - } - } - }) - }), /*#__PURE__*/_jsx("th", { - children: "Medicine / Formulation" - }), /*#__PURE__*/_jsx("th", { - children: "Stock Status" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - children: "Current Stock" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - children: "Min Reorder" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 110 - }, - children: "Suggested Order" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Estimated PTR" - }), /*#__PURE__*/_jsx("th", { - children: "Last Supplier" - }), /*#__PURE__*/_jsx("th", { - className: "text-end pe-3", - children: "Action" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: isLoadingShortItems ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "9", - className: "text-center py-4", - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm me-2" - }), "Checking stock levels..."] - }) - }) : filtered.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "9", - className: "text-center py-4 text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle text-success fs-3 d-block mb-1" - }), "No medicines currently below reorder levels. Inventory is well-stocked!"] - }) - }) : filtered.map(it => { - const isSelected = selectedShortItemIds.includes(it.item_id); - return /*#__PURE__*/_jsxs("tr", { - className: isSelected ? 'table-primary-subtle' : '', - children: [/*#__PURE__*/_jsx("td", { - className: "text-center", - children: /*#__PURE__*/_jsx("input", { - type: "checkbox", - className: "form-check-input", - checked: isSelected, - onChange: e => { - if (e.target.checked) { - setSelectedShortItemIds([...selectedShortItemIds, it.item_id]); - } else { - setSelectedShortItemIds(selectedShortItemIds.filter(id => id !== it.item_id)); - } - } - }) - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-dark fs-6", - children: it.item_name - }), /*#__PURE__*/_jsxs("div", { - className: "small text-muted d-flex gap-2 align-items-center", - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-light text-dark border", - children: it.category || 'Tablet' - }), /*#__PURE__*/_jsx("span", { - children: it.unit_pack || it.units_per_pack + ' Units/Pack' - }), it.drug_schedule && /*#__PURE__*/_jsx("span", { - className: "badge bg-danger-subtle text-danger border", - children: it.drug_schedule - })] - })] - }), /*#__PURE__*/_jsx("td", { - children: it.status === 'OUT_OF_STOCK' ? /*#__PURE__*/_jsxs("span", { - className: "badge bg-danger-subtle text-danger border border-danger-subtle px-2 py-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-x-circle me-1" - }), "Out of Stock"] - }) : /*#__PURE__*/_jsxs("span", { - className: "badge bg-warning-subtle text-warning-emphasis border border-warning-subtle px-2 py-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-exclamation-triangle me-1" - }), "Low Stock"] - }) - }), /*#__PURE__*/_jsxs("td", { - className: "text-center", - children: [/*#__PURE__*/_jsx("span", { - className: "fw-bold fs-6 text-danger", - children: it.current_qty - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted d-block", - style: { - fontSize: '11px' - }, - children: ["(", it.current_packs, " packs)"] - })] - }), /*#__PURE__*/_jsxs("td", { - className: "text-center text-muted fw-semibold", - children: [it.min_reorder_level, " units"] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm fw-bold text-center", - min: "1", - value: it.suggested_packs, - onChange: e => { - const val = Math.max(1, parseInt(e.target.value) || 1); - setShortItems(shortItems.map(si => si.item_id === it.item_id ? { - ...si, - suggested_packs: val - } : si)); - } - }), /*#__PURE__*/_jsx("span", { - className: "input-group-text py-0 px-1 text-muted", - style: { - fontSize: '11px' - }, - children: "Pks" - })] - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-end fw-semibold", - children: it.last_ptr > 0 ? '₹' + Number(it.last_ptr).toFixed(2) : /*#__PURE__*/_jsx("span", { - className: "text-muted", - children: "-" - }) - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-semibold text-truncate", - style: { - maxWidth: 180 - }, - title: it.last_supplier_name, - children: it.last_supplier_name - }), it.last_purchase_date && /*#__PURE__*/_jsxs("small", { - className: "text-muted", - style: { - fontSize: '11px' - }, - children: ["Last: ", it.last_purchase_date] - })] - }), /*#__PURE__*/_jsx("td", { - className: "text-end pe-3", - children: /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-primary py-1 px-2 text-nowrap", - onClick: () => { - setSelectedShortItemIds([it.item_id]); - openCreatePoFromShortItems(); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cart-plus me-1" - }), " Order"] - }) - })] - }, it.item_id); - }) - })] - }) + }, + required: true + })), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: it.category, + onChange: e => { + const items = [...poCreateForm.items]; + items[idx].category = e.target.value; + setPoCreateForm({ + ...poCreateForm, + items + }); + } + })), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("input", { + type: "number", + min: "1", + className: "form-control form-control-sm text-center fw-bold", + value: it.order_packs, + onChange: e => { + const items = [...poCreateForm.items]; + items[idx].order_packs = Math.max(1, parseInt(e.target.value) || 1); + setPoCreateForm({ + ...poCreateForm, + items }); - })()] - }), subTab === 'purchase_orders' && /*#__PURE__*/_jsxs("div", { - className: "counter-card", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap justify-content-between align-items-center gap-2 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("h5", { - className: "fw-bold mb-0 text-dark", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-text text-primary me-1" - }), " Hospital Purchase Orders Directory"] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "Track order status, print official supplier order formats, and load directly into inward bills." - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-primary btn-sm px-3 shadow-sm fw-semibold", - onClick: () => { - setPoCreateForm({ - supplier_id: suppliers[0]?.supplier_id ? String(suppliers[0].supplier_id) : '', - expected_delivery_date: new Date(Date.now() + 3 * 24 * 60 * 60 * 1000).toISOString().split('T')[0], - remarks: '', - items: [{ - item_id: null, - item_name: '', - generic_name: '', - category: 'Tablet', - order_packs: 5, - units_per_pack: 10, - estimated_ptr: 0, - gst_rate: 12 - }] - }); - setShowPoCreateModal(true); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-plus-circle me-1" - }), " New Purchase Order"] - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-outline-primary btn-sm", - onClick: fetchPurchaseOrders, - title: "Refresh PO List", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-clockwise" - }) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm mb-3", - children: [/*#__PURE__*/_jsx("button", { - className: `btn ${poStatusFilter === 'all' ? 'btn-primary' : 'btn-outline-secondary'}`, - onClick: () => { - setPoStatusFilter('all'); - fetchPurchaseOrders(); - }, - children: "All Orders" - }), /*#__PURE__*/_jsx("button", { - className: `btn ${poStatusFilter === 'ordered' ? 'btn-primary' : 'btn-outline-secondary'}`, - onClick: () => { - setPoStatusFilter('ordered'); - fetchPurchaseOrders(); - }, - children: "Ordered / In-Transit" - }), /*#__PURE__*/_jsx("button", { - className: `btn ${poStatusFilter === 'received' ? 'btn-success' : 'btn-outline-secondary'}`, - onClick: () => { - setPoStatusFilter('received'); - fetchPurchaseOrders(); - }, - children: "Received / Inwarded" - }), /*#__PURE__*/_jsx("button", { - className: `btn ${poStatusFilter === 'cancelled' ? 'btn-danger' : 'btn-outline-secondary'}`, - onClick: () => { - setPoStatusFilter('cancelled'); - fetchPurchaseOrders(); - }, - children: "Cancelled" - })] - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive shadow-sm rounded border", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-hover align-middle mb-0", - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "PO Number" - }), /*#__PURE__*/_jsx("th", { - children: "PO Date" - }), /*#__PURE__*/_jsx("th", { - children: "Expected Delivery" - }), /*#__PURE__*/_jsx("th", { - children: "Supplier / Distributor" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - children: "Items" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Est. Total Amount" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - children: "Status" - }), /*#__PURE__*/_jsx("th", { - className: "text-end pe-3", - children: "Actions" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: isLoadingPOs ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "8", - className: "text-center py-4", - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm me-2" - }), "Loading purchase orders..."] - }) - }) : purchaseOrders.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsx("td", { - colSpan: "8", - className: "text-center py-4 text-muted", - children: "No purchase orders found. Click \"New Purchase Order\" or generate from Short Items." - }) - }) : purchaseOrders.map(po => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - className: "fw-bold text-primary", - children: po.po_number - }), /*#__PURE__*/_jsx("td", { - children: po.po_date - }), /*#__PURE__*/_jsx("td", { - children: po.expected_delivery_date || /*#__PURE__*/_jsx("span", { - className: "text-muted", - children: "-" - }) - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-semibold text-dark", - children: po.supplier_name - }), po.phone && /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-telephone me-1" - }), po.phone] - })] - }), /*#__PURE__*/_jsx("td", { - className: "text-center fw-bold", - children: po.total_items - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-bold", - children: ["₹", Number(po.total_estimated_amount || 0).toLocaleString('en-IN', { - minimumFractionDigits: 2 - })] - }), /*#__PURE__*/_jsxs("td", { - className: "text-center", - children: [po.status === 'ordered' && /*#__PURE__*/_jsxs("span", { - className: "badge bg-primary-subtle text-primary border border-primary-subtle px-2 py-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clock me-1" - }), "Ordered"] - }), po.status === 'received' && /*#__PURE__*/_jsxs("span", { - className: "badge bg-success-subtle text-success border border-success-subtle px-2 py-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check2-circle me-1" - }), "Received"] - }), po.status === 'cancelled' && /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary-subtle text-secondary border px-2 py-1", - children: "Cancelled" - })] - }), /*#__PURE__*/_jsx("td", { - className: "text-end pe-3", - children: /*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-outline-primary", - onClick: () => handleViewPo(po.po_id), - title: "View & Print PO", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer me-1" - }), " Print"] - }), po.status === 'ordered' && /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-success", - onClick: () => loadPoIntoInwardBill(po.po_id), - title: "Load this PO into Inward Purchase Bill", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-box-arrow-in-down me-1" - }), " Inward"] - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-outline-danger", - onClick: () => handleCancelPo(po.po_id), - title: "Cancel this PO", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-x" - }) - })] - })] - }) - })] - }, po.po_id)) - })] - }) - })] - }), showSupplierModal && /*#__PURE__*/_jsx("div", { - className: "modal fade show d-block", - style: { - backgroundColor: 'rgba(15, 23, 42, 0.75)' }, - tabIndex: "-1", - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content border-0 shadow-lg", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2.5 px-3 d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("div", { - className: "bg-primary text-white rounded p-1.5 d-flex align-items-center justify-content-center", - style: { - width: 32, - height: 32 - }, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-truck fs-5" - }) - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "modal-title mb-0 fw-bold", - children: supplierForm.supplier_id ? 'Edit Supplier / Distributor Details' : 'Add New Drug Distributor & Supplier' - }), /*#__PURE__*/_jsx("small", { - className: "text-light opacity-75", - children: "Statutory Drug Licenses, GSTIN, contact & credit terms" - })] - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setShowSupplierModal(false) - })] - }), /*#__PURE__*/_jsxs("form", { - onSubmit: handleSaveSupplier, - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-body p-3 bg-light", - children: [/*#__PURE__*/_jsxs("div", { - className: "card border-0 shadow-sm p-3 mb-3 bg-white", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold text-primary mb-2", - style: { - fontSize: '13px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-building me-1" - }), " Basic Distributor Information"] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-8", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-1", - children: ["Distributor / Agency Name ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "e.g. Apex Healthcare Distributors Pvt Ltd", - value: supplierForm.supplier_name, - onChange: e => setSupplierForm({ - ...supplierForm, - supplier_name: e.target.value - }), - required: true, - autoFocus: true - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Contact Person" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "e.g. Ramesh Gupta", - value: supplierForm.contact_person, - onChange: e => setSupplierForm({ - ...supplierForm, - contact_person: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Phone / Mobile No." - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "+91 9811002233", - value: supplierForm.phone, - onChange: e => setSupplierForm({ - ...supplierForm, - phone: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Email Address" - }), /*#__PURE__*/_jsx("input", { - type: "email", - className: "form-control form-control-sm", - placeholder: "sales@distributor.com", - value: supplierForm.email, - onChange: e => setSupplierForm({ - ...supplierForm, - email: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Credit Terms" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm", - min: "0", - placeholder: "30", - value: supplierForm.credit_days, - onChange: e => setSupplierForm({ - ...supplierForm, - credit_days: e.target.value - }) - }), /*#__PURE__*/_jsx("span", { - className: "input-group-text bg-light", - children: "Days" - })] - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card border-0 shadow-sm p-3 mb-3 bg-white", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold text-primary mb-2", - style: { - fontSize: '13px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-check me-1" - }), " Indian Statutory Drug Licenses & GSTIN"] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Drug License Form 20-B (Allopathic)" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "e.g. DL-20B-DEL-98441", - value: supplierForm.dl_no_20b, - onChange: e => setSupplierForm({ - ...supplierForm, - dl_no_20b: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Drug License Form 21-B (Schedule C & C1)" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "e.g. DL-21B-DEL-98442", - value: supplierForm.dl_no_21b, - onChange: e => setSupplierForm({ - ...supplierForm, - dl_no_21b: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "GSTIN (15-Digit)" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm text-uppercase", - maxLength: "15", - placeholder: "07AACCA1234F1Z9", - value: supplierForm.gstin, - onChange: e => setSupplierForm({ - ...supplierForm, - gstin: e.target.value.toUpperCase() - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "PAN No. (10-Digit)" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm text-uppercase", - maxLength: "10", - placeholder: "AACCA1234F", - value: supplierForm.pan_no, - onChange: e => setSupplierForm({ - ...supplierForm, - pan_no: e.target.value.toUpperCase() - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "State Code (GST)" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "07 (Delhi)", - value: supplierForm.state_code, - onChange: e => setSupplierForm({ - ...supplierForm, - state_code: e.target.value - }) - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card border-0 shadow-sm p-3 bg-white", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold text-primary mb-2", - style: { - fontSize: '13px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-geo-alt me-1" - }), " Address & Banking Details"] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Full Postal Address" - }), /*#__PURE__*/_jsx("textarea", { - className: "form-control form-control-sm", - rows: "2", - placeholder: "Shop / Office No, Market, City, Pincode", - value: supplierForm.address, - onChange: e => setSupplierForm({ - ...supplierForm, - address: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Bank Account & Settlement Details" - }), /*#__PURE__*/_jsx("textarea", { - className: "form-control form-control-sm", - rows: "2", - placeholder: "Bank Name, A/c Number, IFSC Code, UPI ID", - value: supplierForm.bank_details, - onChange: e => setSupplierForm({ - ...supplierForm, - bank_details: e.target.value - }) - })] - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer py-2 px-3 bg-white d-flex justify-content-between", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-outline-secondary btn-sm", - onClick: () => setShowSupplierModal(false), - children: "Cancel" - }), /*#__PURE__*/_jsx("button", { - type: "submit", - className: "btn btn-primary btn-sm px-4", - disabled: isSavingSupplier, - children: isSavingSupplier ? /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm me-1", - role: "status" - }), "Saving..."] - }) : /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check2-circle me-1" - }), supplierForm.supplier_id ? 'Update Supplier' : 'Save Supplier'] - }) - })] - })] - })] - }) - }) - }), showMasterModal && /*#__PURE__*/_jsx("div", { - className: "modal fade show d-block", - style: { - backgroundColor: 'rgba(15, 23, 42, 0.75)' - }, - tabIndex: "-1", - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content border-0 shadow-lg", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2.5 px-3 d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("div", { - className: "bg-success text-white rounded p-1.5 d-flex align-items-center justify-content-center", - style: { - width: 32, - height: 32 - }, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-capsule fs-5" - }) - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "modal-title mb-0 fw-bold", - children: "Add New Medicine to Pharmacy Master" - }), /*#__PURE__*/_jsxs("small", { - className: "text-light opacity-75", - children: ["Saved to shared master ", /*#__PURE__*/_jsx("code", { - children: "med_product_master" - }), " (shared between MedicalStore & HMSPharmacy)"] - })] - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setShowMasterModal(false) - })] - }), /*#__PURE__*/_jsxs("form", { - onSubmit: handleSaveMasterMedicine, - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-body p-3 bg-light", - children: [/*#__PURE__*/_jsxs("div", { - className: "card border-0 shadow-sm p-3 mb-3 bg-white", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold text-primary mb-2", - style: { - fontSize: '13px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-prescription2 me-1" - }), " Medicine Name & Formulation"] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-7", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-1", - children: ["Brand / Medicine Name ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm fw-semibold", - placeholder: "e.g. Augmentin 625 Duo Tablet", - value: masterForm.item_name, - onChange: e => setMasterForm({ - ...masterForm, - item_name: e.target.value - }), - required: true, - autoFocus: true - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-5", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Formulation / Category" - }), /*#__PURE__*/_jsx("input", { - type: "text", - list: "ms-formulation-list", - className: "form-control form-control-sm", - placeholder: "e.g. Tablet, Capsule, Syrup...", - value: masterForm.formulation, - onChange: e => setMasterForm({ - ...masterForm, - formulation: e.target.value - }) - }), /*#__PURE__*/_jsx("datalist", { - id: "ms-formulation-list", - children: (supportData.formulations || []).map((f, idx) => /*#__PURE__*/_jsx("option", { - value: f - }, idx)) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-12", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Generic Molecule Composition" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "e.g. Amoxycillin (500mg) + Clavulanic Acid (125mg)", - value: masterForm.generic_name, - onChange: e => setMasterForm({ - ...masterForm, - generic_name: e.target.value - }) - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card border-0 shadow-sm p-3 bg-white", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold text-primary mb-2", - style: { - fontSize: '13px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-box-seam me-1" - }), " Packing, Tax & Regulatory Specifications"] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-3", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-1", - children: ["Units per Pack (Strip/Bottle) ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsx("input", { - type: "number", - min: "1", - className: "form-control form-control-sm fw-bold", - placeholder: "10", - value: masterForm.units_per_pack, - onChange: e => setMasterForm({ - ...masterForm, - units_per_pack: e.target.value, - packing: e.target.value - }), - required: true - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "GST Rate (%)" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm fw-bold", - value: masterForm.gst_rate, - onChange: e => setMasterForm({ - ...masterForm, - gst_rate: Number(e.target.value) - }), - children: [/*#__PURE__*/_jsx("option", { - value: "0", - children: "0% (Nil / Exempt)" - }), /*#__PURE__*/_jsx("option", { - value: "5", - children: "5% (Common / Basic Services)" - }), /*#__PURE__*/_jsx("option", { - value: "18", - children: "18% (Standard - Most Products)" - }), /*#__PURE__*/_jsx("option", { - value: "40", - children: "40% (Demerit / Sin Tax)" - }), /*#__PURE__*/_jsx("option", { - value: "12", - children: "12% (Legacy Medicine Slab)" - }), /*#__PURE__*/_jsx("option", { - value: "28", - children: "28% (Legacy High Slab)" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "HSN Code" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "3004", - value: masterForm.hsn_code, - onChange: e => setMasterForm({ - ...masterForm, - hsn_code: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Drug Schedule" - }), /*#__PURE__*/_jsx("select", { - className: "form-select form-select-sm", - value: masterForm.drug_schedule, - onChange: e => setMasterForm({ - ...masterForm, - drug_schedule: e.target.value - }), - children: (supportData.schedules || ['OTC', 'Schedule H', 'Schedule H1', 'Schedule X', 'Narcotic']).map((sc, idx) => /*#__PURE__*/_jsx("option", { - value: sc, - children: sc - }, idx)) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-8", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Manufacturer / Pharma Company" - }), /*#__PURE__*/_jsx("input", { - type: "text", - list: "ms-company-list", - className: "form-control form-control-sm", - placeholder: "e.g. Cipla Ltd, Sun Pharma, Alkem...", - value: masterForm.company_name, - onChange: e => setMasterForm({ - ...masterForm, - company_name: e.target.value - }) - }), /*#__PURE__*/_jsx("datalist", { - id: "ms-company-list", - children: (supportData.companies || []).map((c, idx) => /*#__PURE__*/_jsx("option", { - value: c - }, idx)) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Min Reorder Level" - }), /*#__PURE__*/_jsx("input", { - type: "number", - min: "1", - className: "form-control form-control-sm", - placeholder: "10", - value: masterForm.min_reorder_level, - onChange: e => setMasterForm({ - ...masterForm, - min_reorder_level: e.target.value - }) - })] - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer py-2 px-3 bg-white d-flex justify-content-between", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-outline-secondary btn-sm", - onClick: () => setShowMasterModal(false), - children: "Cancel" - }), /*#__PURE__*/_jsx("button", { - type: "submit", - className: "btn btn-success btn-sm fw-bold px-4", - disabled: isSavingMaster, - children: isSavingMaster ? /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm me-1", - role: "status" - }), "Saving to Master..."] - }) : /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle me-1" - }), "Save to Master & Select into Bill"] - }) - })] - })] - })] - }) - }) - }), showPaymentModal && /*#__PURE__*/_jsx("div", { - className: "modal fade show d-block", - style: { - backgroundColor: 'rgba(15, 23, 42, 0.75)' - }, - tabIndex: "-1", - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-md modal-dialog-centered", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content border-0 shadow-lg", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2.5 px-3 d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("div", { - className: "bg-success text-white rounded p-1.5 d-flex align-items-center justify-content-center", - style: { - width: 32, - height: 32 - }, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-cash-coin fs-5" - }) - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "modal-title mb-0 fw-bold", - children: "Record Supplier Payment Voucher" - }), /*#__PURE__*/_jsx("small", { - className: "text-light opacity-75", - children: "Outflow accounting against invoice or on-account" - })] - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setShowPaymentModal(false) - })] - }), /*#__PURE__*/_jsxs("form", { - onSubmit: handleRecordPayment, - children: [/*#__PURE__*/_jsx("div", { - className: "modal-body p-3 bg-light", - children: /*#__PURE__*/_jsx("div", { - className: "card border-0 shadow-sm p-3 mb-3 bg-white", - children: /*#__PURE__*/_jsxs("div", { - className: "row g-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-12", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-1", - children: ["Supplier / Distributor ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm fw-semibold", - value: paymentForm.supplier_id, - onChange: e => setPaymentForm({ - ...paymentForm, - supplier_id: e.target.value - }), - required: true, - children: [/*#__PURE__*/_jsx("option", { - value: "", - children: "-- Choose Supplier --" - }), suppliers.map(s => /*#__PURE__*/_jsxs("option", { - value: s.supplier_id, - children: [s.supplier_name, " (GST: ", s.gstin || 'N/A', ")"] - }, s.supplier_id))] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-1", - children: ["Payment Amount (₹) ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsx("input", { - type: "number", - step: "0.01", - min: "0.01", - className: "form-control form-control-sm fw-bold text-success fs-6", - placeholder: "0.00", - value: paymentForm.amount, - onChange: e => setPaymentForm({ - ...paymentForm, - amount: e.target.value - }), - required: true, - autoFocus: true - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Payment Mode" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: paymentForm.payment_mode, - onChange: e => setPaymentForm({ - ...paymentForm, - payment_mode: e.target.value - }), - children: [/*#__PURE__*/_jsx("option", { - value: "Bank", - children: "Bank Transfer (NEFT/RTGS)" - }), /*#__PURE__*/_jsx("option", { - value: "UPI", - children: "UPI / QR Code" - }), /*#__PURE__*/_jsx("option", { - value: "Cash", - children: "Cash in Hand" - }), /*#__PURE__*/_jsx("option", { - value: "Cheque", - children: "Bank Cheque" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Payment Date" - }), /*#__PURE__*/_jsx("input", { - type: "date", - className: "form-control form-control-sm", - value: paymentForm.payment_date, - onChange: e => setPaymentForm({ - ...paymentForm, - payment_date: e.target.value - }), - required: true - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "UTR / Cheque / Ref No" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "e.g. UTR-9988112", - value: paymentForm.reference_no, - onChange: e => setPaymentForm({ - ...paymentForm, - reference_no: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-12", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Bank Name / Account Details" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "e.g. HDFC Bank - Main Current A/c", - value: paymentForm.bank_name, - onChange: e => setPaymentForm({ - ...paymentForm, - bank_name: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-12", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Remarks / Settlement Note" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "e.g. Cleared bill #APX-9941", - value: paymentForm.remarks, - onChange: e => setPaymentForm({ - ...paymentForm, - remarks: e.target.value - }) - })] - })] - }) - }) - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer py-2 px-3 bg-white d-flex justify-content-between", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-outline-secondary btn-sm", - onClick: () => setShowPaymentModal(false), - children: "Cancel" - }), /*#__PURE__*/_jsx("button", { - type: "submit", - className: "btn btn-success btn-sm fw-bold px-4 shadow-sm", - disabled: isRecordingPayment, - children: isRecordingPayment ? /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm me-1" - }), "Recording Voucher..."] - }) : /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check2-circle me-1" - }), "Record Payment Voucher"] - }) - })] - })] - })] - }) - }) - }), showPoCreateModal && /*#__PURE__*/_jsx("div", { - className: "modal fade show d-block", - style: { - backgroundColor: 'rgba(15, 23, 42, 0.75)' - }, - tabIndex: "-1", - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-xl modal-dialog-centered modal-dialog-scrollable", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content border-0 shadow-lg", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2.5 px-3 d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("div", { - className: "bg-primary text-white rounded p-1.5 d-flex align-items-center justify-content-center", - style: { - width: 32, - height: 32 - }, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-cart-check fs-5" - }) - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "modal-title mb-0 fw-bold", - children: "Generate New Purchase Order (PO)" - }), /*#__PURE__*/_jsx("small", { - className: "text-light opacity-75", - children: "Order requisition for pharmaceutical distributor" - })] - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setShowPoCreateModal(false) - })] - }), /*#__PURE__*/_jsxs("form", { - onSubmit: handleSavePurchaseOrder, - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-body p-3 bg-light", - children: [/*#__PURE__*/_jsx("div", { - className: "card border-0 shadow-sm p-3 mb-3 bg-white", - children: /*#__PURE__*/_jsxs("div", { - className: "row g-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-5", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-1", - children: ["Target Supplier / Agency ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm fw-semibold", - value: poCreateForm.supplier_id, - onChange: e => setPoCreateForm({ - ...poCreateForm, - supplier_id: e.target.value - }), - required: true, - children: [/*#__PURE__*/_jsx("option", { - value: "", - children: "-- Choose Supplier --" - }), suppliers.map(s => /*#__PURE__*/_jsxs("option", { - value: s.supplier_id, - children: [s.supplier_name, " (GST: ", s.gstin || 'N/A', ")"] - }, s.supplier_id))] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Expected Delivery Date" - }), /*#__PURE__*/_jsx("input", { - type: "date", - className: "form-control form-control-sm", - value: poCreateForm.expected_delivery_date, - onChange: e => setPoCreateForm({ - ...poCreateForm, - expected_delivery_date: e.target.value - }), - required: true - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Remarks / Order Instructions" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "e.g. Urgent stock replenishment", - value: poCreateForm.remarks, - onChange: e => setPoCreateForm({ - ...poCreateForm, - remarks: e.target.value - }) - })] - })] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "card border-0 shadow-sm p-3 bg-white", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-2", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold text-primary mb-0", - style: { - fontSize: '13px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-box-seam me-1" - }), " Ordered Items (", poCreateForm.items.length, ")"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-outline-primary btn-sm py-0.5 px-2", - onClick: () => { - setPoCreateForm({ - ...poCreateForm, - items: [...poCreateForm.items, { - item_id: null, - item_name: '', - generic_name: '', - category: 'Tablet', - order_packs: 1, - units_per_pack: 10, - estimated_ptr: 0, - gst_rate: 12 - }] - }); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-plus me-1" - }), " Add Another Medicine"] - })] - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-bordered align-middle mb-0", - style: { - fontSize: '12.5px' - }, - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - style: { - minWidth: 240 - }, - children: "Medicine Name" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 100 - }, - children: "Category" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 90 - }, - children: "Packs" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 90 - }, - children: "Units/Pack" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 100 - }, - children: "Est. PTR (₹)" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 85 - }, - children: "GST%" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 120 - }, - className: "text-end", - children: "Est. Total (₹)" - }), /*#__PURE__*/_jsx("th", { - style: { - width: 40 - } - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: poCreateForm.items.map((it, idx) => { - const lineTotal = Number(it.order_packs || 0) * Number(it.estimated_ptr || 0) * (1 + Number(it.gst_rate || 0) / 100); - return /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm fw-semibold", - placeholder: "Medicine name...", - value: it.item_name, - onChange: e => { - const items = [...poCreateForm.items]; - items[idx].item_name = e.target.value; - setPoCreateForm({ - ...poCreateForm, - items - }); - }, - required: true - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: it.category, - onChange: e => { - const items = [...poCreateForm.items]; - items[idx].category = e.target.value; - setPoCreateForm({ - ...poCreateForm, - items - }); - } - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("input", { - type: "number", - min: "1", - className: "form-control form-control-sm text-center fw-bold", - value: it.order_packs, - onChange: e => { - const items = [...poCreateForm.items]; - items[idx].order_packs = Math.max(1, parseInt(e.target.value) || 1); - setPoCreateForm({ - ...poCreateForm, - items - }); - }, - required: true - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("input", { - type: "number", - min: "1", - className: "form-control form-control-sm text-center", - value: it.units_per_pack, - onChange: e => { - const items = [...poCreateForm.items]; - items[idx].units_per_pack = Math.max(1, parseInt(e.target.value) || 1); - setPoCreateForm({ - ...poCreateForm, - items - }); - } - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("input", { - type: "number", - step: "0.01", - min: "0", - className: "form-control form-control-sm text-end", - value: it.estimated_ptr, - onChange: e => { - const items = [...poCreateForm.items]; - items[idx].estimated_ptr = parseFloat(e.target.value) || 0; - setPoCreateForm({ - ...poCreateForm, - items - }); - } - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: it.gst_rate, - onChange: e => { - const items = [...poCreateForm.items]; - items[idx].gst_rate = parseFloat(e.target.value) || 0; - setPoCreateForm({ - ...poCreateForm, - items - }); - }, - children: [/*#__PURE__*/_jsx("option", { - value: "0", - children: "0% (Exempt)" - }), /*#__PURE__*/_jsx("option", { - value: "5", - children: "5%" - }), /*#__PURE__*/_jsx("option", { - value: "18", - children: "18%" - }), /*#__PURE__*/_jsx("option", { - value: "40", - children: "40%" - }), /*#__PURE__*/_jsx("option", { - value: "12", - children: "12% (Legacy)" - }), /*#__PURE__*/_jsx("option", { - value: "28", - children: "28% (Legacy)" - })] - }) - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-bold", - children: ["₹", lineTotal.toFixed(2)] - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: poCreateForm.items.length > 1 && /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-danger py-0 px-1", - onClick: () => { - setPoCreateForm({ - ...poCreateForm, - items: poCreateForm.items.filter((_, i) => i !== idx) - }); - }, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-x" - }) - }) - })] - }, idx); - }) - }), /*#__PURE__*/_jsx("tfoot", { - className: "table-light fw-bold", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - colSpan: "6", - className: "text-end", - children: "Estimated Total Amount:" - }), /*#__PURE__*/_jsxs("td", { - className: "text-end text-primary fs-6", - children: ["₹", poCreateForm.items.reduce((sum, it) => sum + Number(it.order_packs || 0) * Number(it.estimated_ptr || 0) * (1 + Number(it.gst_rate || 0) / 100), 0).toFixed(2)] - }), /*#__PURE__*/_jsx("td", {})] - }) - })] - }) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer py-2 px-3 bg-white d-flex justify-content-between", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-outline-secondary btn-sm", - onClick: () => setShowPoCreateModal(false), - children: "Cancel" - }), /*#__PURE__*/_jsx("button", { - type: "submit", - className: "btn btn-primary btn-sm fw-bold px-4 shadow-sm", - disabled: isSavingPO, - children: isSavingPO ? /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm me-1" - }), "Generating PO..."] - }) : /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check2-circle me-1" - }), "Generate Purchase Order"] - }) - })] - })] - })] - }) - }) - }), showPoViewModal && activeViewPo && /*#__PURE__*/_jsx("div", { - className: "modal fade show d-block", - style: { - backgroundColor: 'rgba(15, 23, 42, 0.75)' - }, - tabIndex: "-1", - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content border-0 shadow-lg", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2.5 px-3 d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("div", { - className: "bg-primary text-white rounded p-1.5 d-flex align-items-center justify-content-center", - style: { - width: 32, - height: 32 - }, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-printer fs-5" - }) - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("h6", { - className: "modal-title mb-0 fw-bold", - children: ["Purchase Order Document: ", activeViewPo.purchase_order.po_number] - }), /*#__PURE__*/_jsxs("small", { - className: "text-light opacity-75", - children: ["Status: ", /*#__PURE__*/_jsx("span", { - className: "text-uppercase fw-bold text-info", - children: activeViewPo.purchase_order.status - })] - })] - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setShowPoViewModal(false) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-4 bg-white", - id: "printable-po-document", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-start border-bottom pb-3 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h4", { - className: "fw-bold text-primary mb-1", - children: store.store_name - }), /*#__PURE__*/_jsxs("div", { - className: "text-muted small", - children: [store.building_name, " | ", store.room_no] - }), /*#__PURE__*/_jsx("div", { - className: "text-muted small", - children: "Hospital Pharmacy & Medical Supplies Dept." - })] - }), /*#__PURE__*/_jsxs("div", { - className: "text-end", - children: [/*#__PURE__*/_jsx("h5", { - className: "fw-bold mb-0 text-dark", - children: "PURCHASE ORDER" - }), /*#__PURE__*/_jsx("div", { - className: "badge bg-primary fs-6 mt-1", - children: activeViewPo.purchase_order.po_number - }), /*#__PURE__*/_jsxs("div", { - className: "small text-muted mt-1", - children: ["Date: ", /*#__PURE__*/_jsx("strong", { - children: activeViewPo.purchase_order.po_date - })] - }), /*#__PURE__*/_jsxs("div", { - className: "small text-muted", - children: ["Delivery: ", /*#__PURE__*/_jsx("strong", { - children: activeViewPo.purchase_order.expected_delivery_date || 'Prompt' - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-3 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "col-md-6", - children: /*#__PURE__*/_jsxs("div", { - className: "p-2.5 bg-light rounded border", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted text-uppercase fw-bold", - style: { - fontSize: '10px' - }, - children: "Vendor / Supplier:" - }), /*#__PURE__*/_jsx("h6", { - className: "fw-bold mb-1 text-dark", - children: activeViewPo.purchase_order.supplier_name - }), activeViewPo.purchase_order.address && /*#__PURE__*/_jsx("div", { - className: "small text-muted", - children: activeViewPo.purchase_order.address - }), /*#__PURE__*/_jsxs("div", { - className: "small text-muted", - children: ["GSTIN: ", /*#__PURE__*/_jsx("strong", { - children: activeViewPo.purchase_order.gstin || 'N/A' - })] - }), /*#__PURE__*/_jsxs("div", { - className: "small text-muted", - children: ["Phone: ", activeViewPo.purchase_order.phone || 'N/A'] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-6", - children: /*#__PURE__*/_jsxs("div", { - className: "p-2.5 bg-light rounded border", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted text-uppercase fw-bold", - style: { - fontSize: '10px' - }, - children: "Ship To / Delivery Destination:" - }), /*#__PURE__*/_jsx("h6", { - className: "fw-bold mb-1 text-dark", - children: store.store_name - }), /*#__PURE__*/_jsxs("div", { - className: "small text-muted", - children: [store.building_name, ", ", store.floor_no] - }), /*#__PURE__*/_jsxs("div", { - className: "small text-muted", - children: ["Remarks: ", /*#__PURE__*/_jsx("em", { - children: activeViewPo.purchase_order.remarks || 'Supply per hospital contract terms' - })] - })] - }) - })] - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive mb-3", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-bordered table-sm align-middle mb-0", - style: { - fontSize: '12px' - }, - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - style: { - width: 35 - }, - children: "#" - }), /*#__PURE__*/_jsx("th", { - children: "Item Name & Description" - }), /*#__PURE__*/_jsx("th", { - children: "Category" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - style: { - width: 85 - }, - children: "Ordered Packs" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - style: { - width: 85 - }, - children: "Units/Pack" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - style: { - width: 95 - }, - children: "Est. PTR" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - style: { - width: 65 - }, - children: "GST%" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - style: { - width: 110 - }, - children: "Est. Amount" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: activeViewPo.items?.map((it, idx) => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - className: "text-muted text-center", - children: idx + 1 - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-dark", - children: it.item_name - }), it.generic_name && /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: it.generic_name - })] - }), /*#__PURE__*/_jsx("td", { - children: it.category || 'Tablet' - }), /*#__PURE__*/_jsx("td", { - className: "text-center fw-bold", - children: it.order_packs - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: it.units_per_pack - }), /*#__PURE__*/_jsxs("td", { - className: "text-end", - children: ["₹", Number(it.estimated_ptr).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - className: "text-center", - children: [it.gst_rate, "%"] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-bold", - children: ["₹", Number(it.estimated_amount).toFixed(2)] - })] - }, idx)) - }), /*#__PURE__*/_jsx("tfoot", { - className: "table-light fw-bold", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - colSpan: "7", - className: "text-end", - children: "Total Estimated Value:" - }), /*#__PURE__*/_jsxs("td", { - className: "text-end text-primary fs-6", - children: ["₹", Number(activeViewPo.purchase_order.total_estimated_amount).toFixed(2)] - })] - }) - })] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-end pt-4 mt-4 border-top", - children: [/*#__PURE__*/_jsxs("div", { - className: "text-center", - style: { - width: 180 - }, - children: [/*#__PURE__*/_jsx("div", { - className: "border-bottom pb-4 mb-1" - }), /*#__PURE__*/_jsx("small", { - className: "text-muted fw-bold", - children: "Prepared By / Pharmacist" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "text-center", - style: { - width: 180 - }, - children: [/*#__PURE__*/_jsx("div", { - className: "border-bottom pb-4 mb-1" - }), /*#__PURE__*/_jsx("small", { - className: "text-muted fw-bold", - children: "Authorized Signatory" - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer py-2 px-3 bg-light d-flex justify-content-between", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-outline-secondary btn-sm", - onClick: () => setShowPoViewModal(false), - children: "Close" - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2", - children: [activeViewPo.purchase_order.status === 'ordered' && /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-success btn-sm fw-bold px-3 shadow-sm", - onClick: () => loadPoIntoInwardBill(activeViewPo.purchase_order.po_id), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-box-arrow-in-down me-1" - }), " Inward into Purchase Bill"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-primary btn-sm fw-bold px-3 shadow-sm", - onClick: () => window.print(), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer me-1" - }), " Print PO"] - })] - })] - })] - }) - }) - }), showPurchaseHistoryModal && /*#__PURE__*/_jsx("div", { - className: "modal fade show d-block", - style: { - backgroundColor: 'rgba(15, 23, 42, 0.75)' - }, - tabIndex: "-1", - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-xl modal-dialog-centered modal-dialog-scrollable", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content border-0 shadow-lg", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2.5 px-3 d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("div", { - className: "bg-primary text-white rounded p-1.5 d-flex align-items-center justify-content-center", - style: { - width: 32, - height: 32 - }, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-clock-history fs-5" - }) - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "modal-title mb-0 fw-bold", - children: "Inward Purchase Bills History & Edit" - }), /*#__PURE__*/_jsx("small", { - className: "text-light opacity-75", - children: "Browse past invoices and click Edit to modify lines, rates, or batches" - })] - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setShowPurchaseHistoryModal(false) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-3 bg-light", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center gap-2 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - style: { - maxWidth: 350 - }, - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-white", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-search text-muted" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control", - placeholder: "Search by Bill No or Supplier Name...", - value: purchaseHistorySearch, - onChange: e => setPurchaseHistorySearch(e.target.value) - }), purchaseHistorySearch && /*#__PURE__*/_jsx("button", { - className: "btn btn-outline-secondary", - onClick: () => setPurchaseHistorySearch(''), - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-x" - }) - })] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-outline-primary btn-sm", - onClick: fetchRecentPurchases, - title: "Refresh Invoices", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-clockwise me-1" - }), " Refresh"] - })] - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive bg-white rounded border shadow-sm", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-hover align-middle mb-0", - style: { - fontSize: '13px' - }, - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - style: { - width: 110 - }, - children: "Date" - }), /*#__PURE__*/_jsx("th", { - children: "Bill / Invoice No" - }), /*#__PURE__*/_jsx("th", { - children: "Supplier / Distributor" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - children: "Items" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Net Bill Amount" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Paid Amount" - }), /*#__PURE__*/_jsx("th", { - className: "text-center", - children: "Payment Status" - }), /*#__PURE__*/_jsx("th", { - className: "text-end pe-3", - children: "Action" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: isLoadingPurchases ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "8", - className: "text-center py-4", - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm me-2" - }), "Loading invoices..."] - }) - }) : recentPurchases.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsx("td", { - colSpan: "8", - className: "text-center py-4 text-muted", - children: "No inward purchase bills recorded yet." - }) - }) : recentPurchases.filter(p => { - if (!purchaseHistorySearch) return true; - const q = purchaseHistorySearch.toLowerCase(); - return (p.supplier_invoice_no || '').toLowerCase().includes(q) || (p.supplier_name || '').toLowerCase().includes(q); - }).map(p => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - children: p.invoice_date - }), /*#__PURE__*/_jsx("td", { - className: "fw-bold text-primary", - children: p.supplier_invoice_no - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-semibold text-dark", - children: p.supplier_name || 'Unknown Supplier' - }), p.gstin && /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: ["GST: ", p.gstin] - })] - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: /*#__PURE__*/_jsxs("span", { - className: "badge bg-light text-dark border px-2 py-1", - children: [p.items_count || 1, " lines"] - }) - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-bold text-dark", - children: ["₹", Number(p.net_amount || 0).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end text-success", - children: ["₹", Number(p.paid_amount || 0).toFixed(2)] - }), /*#__PURE__*/_jsx("td", { - className: "text-center", - children: /*#__PURE__*/_jsx("span", { - className: `badge ${p.payment_status === 'paid' ? 'bg-success' : p.payment_status === 'partially_paid' ? 'bg-warning text-dark' : 'bg-danger'} px-2 py-1`, - children: p.payment_status === 'paid' ? 'Paid' : p.payment_status === 'partially_paid' ? 'Partially Paid' : 'Unpaid' - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-end pe-3", - children: /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-primary py-1 px-2.5 shadow-sm fw-semibold", - onClick: () => loadPurchaseForEdit(p.purchase_id), - title: "Load this bill into Inward form to edit items and rates", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-pencil-square me-1" - }), " Edit Invoice"] - }) - })] - }, p.purchase_id)) - })] - }) - })] - }), /*#__PURE__*/_jsx("div", { - className: "modal-footer py-2 bg-light", - children: /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-secondary btn-sm", - onClick: () => setShowPurchaseHistoryModal(false), - children: "Close" - }) - })] - }) - }) - })] - }); + required: true + })), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("input", { + type: "number", + min: "1", + className: "form-control form-control-sm text-center", + value: it.units_per_pack, + onChange: e => { + const items = [...poCreateForm.items]; + items[idx].units_per_pack = Math.max(1, parseInt(e.target.value) || 1); + setPoCreateForm({ + ...poCreateForm, + items + }); + } + })), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.01", + min: "0", + className: "form-control form-control-sm text-end", + value: it.estimated_ptr, + onChange: e => { + const items = [...poCreateForm.items]; + items[idx].estimated_ptr = parseFloat(e.target.value) || 0; + setPoCreateForm({ + ...poCreateForm, + items + }); + } + })), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: it.gst_rate, + onChange: e => { + const items = [...poCreateForm.items]; + items[idx].gst_rate = parseFloat(e.target.value) || 0; + setPoCreateForm({ + ...poCreateForm, + items + }); + } + }, /*#__PURE__*/React.createElement("option", { + value: "0" + }, "0% (Exempt)"), /*#__PURE__*/React.createElement("option", { + value: "5" + }, "5%"), /*#__PURE__*/React.createElement("option", { + value: "18" + }, "18%"), /*#__PURE__*/React.createElement("option", { + value: "40" + }, "40%"), /*#__PURE__*/React.createElement("option", { + value: "12" + }, "12% (Legacy)"), /*#__PURE__*/React.createElement("option", { + value: "28" + }, "28% (Legacy)"))), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold" + }, "₹", lineTotal.toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, poCreateForm.items.length > 1 && /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-danger py-0 px-1", + onClick: () => { + setPoCreateForm({ + ...poCreateForm, + items: poCreateForm.items.filter((_, i) => i !== idx) + }); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x" + })))); + })), /*#__PURE__*/React.createElement("tfoot", { + className: "table-light fw-bold" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "6", + className: "text-end" + }, "Estimated Total Amount:"), /*#__PURE__*/React.createElement("td", { + className: "text-end text-primary fs-6" + }, "₹", poCreateForm.items.reduce((sum, it) => sum + Number(it.order_packs || 0) * Number(it.estimated_ptr || 0) * (1 + Number(it.gst_rate || 0) / 100), 0).toFixed(2)), /*#__PURE__*/React.createElement("td", null))))))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer py-2 px-3 bg-white d-flex justify-content-between" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-outline-secondary btn-sm", + onClick: () => setShowPoCreateModal(false) + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + type: "submit", + className: "btn btn-primary btn-sm fw-bold px-4 shadow-sm", + disabled: isSavingPO + }, isSavingPO ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm me-1" + }), "Generating PO...") : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check2-circle me-1" + }), "Generate Purchase Order"))))))), showPoViewModal && activeViewPo && /*#__PURE__*/React.createElement("div", { + className: "modal fade show d-block", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.75)' + }, + tabIndex: "-1" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content border-0 shadow-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2.5 px-3 d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "bg-primary text-white rounded p-1.5 d-flex align-items-center justify-content-center", + style: { + width: 32, + height: 32 + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer fs-5" + })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "modal-title mb-0 fw-bold" + }, "Purchase Order Document: ", activeViewPo.purchase_order.po_number), /*#__PURE__*/React.createElement("small", { + className: "text-light opacity-75" + }, "Status: ", /*#__PURE__*/React.createElement("span", { + className: "text-uppercase fw-bold text-info" + }, activeViewPo.purchase_order.status)))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setShowPoViewModal(false) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-4 bg-white", + id: "printable-po-document" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-start border-bottom pb-3 mb-3" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h4", { + className: "fw-bold text-primary mb-1" + }, store.store_name), /*#__PURE__*/React.createElement("div", { + className: "text-muted small" + }, store.building_name, " | ", store.room_no), /*#__PURE__*/React.createElement("div", { + className: "text-muted small" + }, "Hospital Pharmacy & Medical Supplies Dept.")), /*#__PURE__*/React.createElement("div", { + className: "text-end" + }, /*#__PURE__*/React.createElement("h5", { + className: "fw-bold mb-0 text-dark" + }, "PURCHASE ORDER"), /*#__PURE__*/React.createElement("div", { + className: "badge bg-primary fs-6 mt-1" + }, activeViewPo.purchase_order.po_number), /*#__PURE__*/React.createElement("div", { + className: "small text-muted mt-1" + }, "Date: ", /*#__PURE__*/React.createElement("strong", null, activeViewPo.purchase_order.po_date)), /*#__PURE__*/React.createElement("div", { + className: "small text-muted" + }, "Delivery: ", /*#__PURE__*/React.createElement("strong", null, activeViewPo.purchase_order.expected_delivery_date || 'Prompt')))), /*#__PURE__*/React.createElement("div", { + className: "row g-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("div", { + className: "p-2.5 bg-light rounded border" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted text-uppercase fw-bold", + style: { + fontSize: '10px' + } + }, "Vendor / Supplier:"), /*#__PURE__*/React.createElement("h6", { + className: "fw-bold mb-1 text-dark" + }, activeViewPo.purchase_order.supplier_name), activeViewPo.purchase_order.address && /*#__PURE__*/React.createElement("div", { + className: "small text-muted" + }, activeViewPo.purchase_order.address), /*#__PURE__*/React.createElement("div", { + className: "small text-muted" + }, "GSTIN: ", /*#__PURE__*/React.createElement("strong", null, activeViewPo.purchase_order.gstin || 'N/A')), /*#__PURE__*/React.createElement("div", { + className: "small text-muted" + }, "Phone: ", activeViewPo.purchase_order.phone || 'N/A'))), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("div", { + className: "p-2.5 bg-light rounded border" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted text-uppercase fw-bold", + style: { + fontSize: '10px' + } + }, "Ship To / Delivery Destination:"), /*#__PURE__*/React.createElement("h6", { + className: "fw-bold mb-1 text-dark" + }, store.store_name), /*#__PURE__*/React.createElement("div", { + className: "small text-muted" + }, store.building_name, ", ", store.floor_no), /*#__PURE__*/React.createElement("div", { + className: "small text-muted" + }, "Remarks: ", /*#__PURE__*/React.createElement("em", null, activeViewPo.purchase_order.remarks || 'Supply per hospital contract terms'))))), /*#__PURE__*/React.createElement("div", { + className: "table-responsive mb-3" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-bordered table-sm align-middle mb-0", + style: { + fontSize: '12px' + } + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", { + style: { + width: 35 + } + }, "#"), /*#__PURE__*/React.createElement("th", null, "Item Name & Description"), /*#__PURE__*/React.createElement("th", null, "Category"), /*#__PURE__*/React.createElement("th", { + className: "text-center", + style: { + width: 85 + } + }, "Ordered Packs"), /*#__PURE__*/React.createElement("th", { + className: "text-center", + style: { + width: 85 + } + }, "Units/Pack"), /*#__PURE__*/React.createElement("th", { + className: "text-end", + style: { + width: 95 + } + }, "Est. PTR"), /*#__PURE__*/React.createElement("th", { + className: "text-center", + style: { + width: 65 + } + }, "GST%"), /*#__PURE__*/React.createElement("th", { + className: "text-end", + style: { + width: 110 + } + }, "Est. Amount"))), /*#__PURE__*/React.createElement("tbody", null, activeViewPo.items?.map((it, idx) => /*#__PURE__*/React.createElement("tr", { + key: idx + }, /*#__PURE__*/React.createElement("td", { + className: "text-muted text-center" + }, idx + 1), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark" + }, it.item_name), it.generic_name && /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, it.generic_name)), /*#__PURE__*/React.createElement("td", null, it.category || 'Tablet'), /*#__PURE__*/React.createElement("td", { + className: "text-center fw-bold" + }, it.order_packs), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, it.units_per_pack), /*#__PURE__*/React.createElement("td", { + className: "text-end" + }, "₹", Number(it.estimated_ptr).toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, it.gst_rate, "%"), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold" + }, "₹", Number(it.estimated_amount).toFixed(2))))), /*#__PURE__*/React.createElement("tfoot", { + className: "table-light fw-bold" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "7", + className: "text-end" + }, "Total Estimated Value:"), /*#__PURE__*/React.createElement("td", { + className: "text-end text-primary fs-6" + }, "₹", Number(activeViewPo.purchase_order.total_estimated_amount).toFixed(2)))))), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-end pt-4 mt-4 border-top" + }, /*#__PURE__*/React.createElement("div", { + className: "text-center", + style: { + width: 180 + } + }, /*#__PURE__*/React.createElement("div", { + className: "border-bottom pb-4 mb-1" + }), /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-bold" + }, "Prepared By / Pharmacist")), /*#__PURE__*/React.createElement("div", { + className: "text-center", + style: { + width: 180 + } + }, /*#__PURE__*/React.createElement("div", { + className: "border-bottom pb-4 mb-1" + }), /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-bold" + }, "Authorized Signatory")))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer py-2 px-3 bg-light d-flex justify-content-between" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-outline-secondary btn-sm", + onClick: () => setShowPoViewModal(false) + }, "Close"), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2" + }, activeViewPo.purchase_order.status === 'ordered' && /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-success btn-sm fw-bold px-3 shadow-sm", + onClick: () => loadPoIntoInwardBill(activeViewPo.purchase_order.po_id) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-box-arrow-in-down me-1" + }), " Inward into Purchase Bill"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-primary btn-sm fw-bold px-3 shadow-sm", + onClick: () => window.print() + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer me-1" + }), " Print PO")))))), showPurchaseHistoryModal && /*#__PURE__*/React.createElement("div", { + className: "modal fade show d-block", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.75)' + }, + tabIndex: "-1" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-xl modal-dialog-centered modal-dialog-scrollable" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content border-0 shadow-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2.5 px-3 d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "bg-primary text-white rounded p-1.5 d-flex align-items-center justify-content-center", + style: { + width: 32, + height: 32 + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clock-history fs-5" + })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "modal-title mb-0 fw-bold" + }, "Inward Purchase Bills History & Edit"), /*#__PURE__*/React.createElement("small", { + className: "text-light opacity-75" + }, "Browse past invoices and click Edit to modify lines, rates, or batches"))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setShowPurchaseHistoryModal(false) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3 bg-light" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center gap-2 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm", + style: { + maxWidth: 350 + } + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-white" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search text-muted" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control", + placeholder: "Search by Bill No or Supplier Name...", + value: purchaseHistorySearch, + onChange: e => setPurchaseHistorySearch(e.target.value) + }), purchaseHistorySearch && /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-secondary", + onClick: () => setPurchaseHistorySearch('') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x" + }))), /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-primary btn-sm", + onClick: fetchRecentPurchases, + title: "Refresh Invoices" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-clockwise me-1" + }), " Refresh")), /*#__PURE__*/React.createElement("div", { + className: "table-responsive bg-white rounded border shadow-sm" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-hover align-middle mb-0", + style: { + fontSize: '13px' + } + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", { + style: { + width: 110 + } + }, "Date"), /*#__PURE__*/React.createElement("th", null, "Bill / Invoice No"), /*#__PURE__*/React.createElement("th", null, "Supplier / Distributor"), /*#__PURE__*/React.createElement("th", { + className: "text-center" + }, "Items"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Net Bill Amount"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Paid Amount"), /*#__PURE__*/React.createElement("th", { + className: "text-center" + }, "Payment Status"), /*#__PURE__*/React.createElement("th", { + className: "text-end pe-3" + }, "Action"))), /*#__PURE__*/React.createElement("tbody", null, isLoadingPurchases ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "8", + className: "text-center py-4" + }, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm me-2" + }), "Loading invoices...")) : recentPurchases.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "8", + className: "text-center py-4 text-muted" + }, "No inward purchase bills recorded yet.")) : recentPurchases.filter(p => { + if (!purchaseHistorySearch) return true; + const q = purchaseHistorySearch.toLowerCase(); + return (p.supplier_invoice_no || '').toLowerCase().includes(q) || (p.supplier_name || '').toLowerCase().includes(q); + }).map(p => /*#__PURE__*/React.createElement("tr", { + key: p.purchase_id + }, /*#__PURE__*/React.createElement("td", null, p.invoice_date), /*#__PURE__*/React.createElement("td", { + className: "fw-bold text-primary" + }, p.supplier_invoice_no), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-semibold text-dark" + }, p.supplier_name || 'Unknown Supplier'), p.gstin && /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "GST: ", p.gstin)), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border px-2 py-1" + }, p.items_count || 1, " lines")), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold text-dark" + }, "₹", Number(p.net_amount || 0).toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: "text-end text-success" + }, "₹", Number(p.paid_amount || 0).toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: "text-center" + }, /*#__PURE__*/React.createElement("span", { + className: `badge ${p.payment_status === 'paid' ? 'bg-success' : p.payment_status === 'partially_paid' ? 'bg-warning text-dark' : 'bg-danger'} px-2 py-1` + }, p.payment_status === 'paid' ? 'Paid' : p.payment_status === 'partially_paid' ? 'Partially Paid' : 'Unpaid')), /*#__PURE__*/React.createElement("td", { + className: "text-end pe-3" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-primary py-1 px-2.5 shadow-sm fw-semibold", + onClick: () => loadPurchaseForEdit(p.purchase_id), + title: "Load this bill into Inward form to edit items and rates" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-pencil-square me-1" + }), " Edit Invoice")))))))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer py-2 bg-light" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-secondary btn-sm", + onClick: () => setShowPurchaseHistoryModal(false) + }, "Close")))))); } // ========================================================================= @@ -15930,97 +12614,81 @@ function TransferView({ notify('Indent error: ' + e.message, 'error'); } }; - return /*#__PURE__*/_jsxs("div", { - className: "counter-card", - children: [/*#__PURE__*/_jsxs("h5", { - className: "fw-bold mb-3", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-left-right text-primary me-1" - }), " Multi-Building Store Requisition (Indent)"] - }), /*#__PURE__*/_jsx("p", { - className: "text-muted small", - children: "Building counters can requisition medicines from the Main Hospital Central Store. Once dispatched and physically verified, stock transfers automatically." - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold", - children: "Source Store (From)" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: store.store_name, - disabled: true - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold", - children: "Target Counter / Building (To)" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: toStoreId, - onChange: e => setToStoreId(e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "", - children: "-- Select Destination Store --" - }), stores.filter(s => s.store_id !== store.store_id).map(s => /*#__PURE__*/_jsxs("option", { - value: s.store_id, - children: [s.store_name, " (", s.store_slug, ")"] - }, s.store_id))] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold", - children: "Requested Medicines" - }), transferItems.map((ti, i) => /*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-2", - children: [/*#__PURE__*/_jsx("div", { - className: "col-8", - children: /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "Medicine Name", - value: ti.item_name, - onChange: e => { - const updated = [...transferItems]; - updated[i].item_name = e.target.value; - setTransferItems(updated); - } - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-4", - children: /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm", - placeholder: "Quantity Required", - min: "1", - value: ti.qty, - onChange: e => { - const updated = [...transferItems]; - updated[i].qty = e.target.value; - setTransferItems(updated); - } - }) - })] - }, i)), /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-primary mt-1", - onClick: addTransferRow, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-plus-circle me-1" - }), " Add Another Medicine"] - })] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-primary-custom", - onClick: submitIndent, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-send me-1" - }), " Submit Store Indent Requisition"] - })] - }); + return /*#__PURE__*/React.createElement("div", { + className: "counter-card" + }, /*#__PURE__*/React.createElement("h5", { + className: "fw-bold mb-3" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-left-right text-primary me-1" + }), " Multi-Building Store Requisition (Indent)"), /*#__PURE__*/React.createElement("p", { + className: "text-muted small" + }, "Building counters can requisition medicines from the Main Hospital Central Store. Once dispatched and physically verified, stock transfers automatically."), /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold" + }, "Source Store (From)"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: store.store_name, + disabled: true + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold" + }, "Target Counter / Building (To)"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: toStoreId, + onChange: e => setToStoreId(e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "" + }, "-- Select Destination Store --"), stores.filter(s => s.store_id !== store.store_id).map(s => /*#__PURE__*/React.createElement("option", { + key: s.store_id, + value: s.store_id + }, s.store_name, " (", s.store_slug, ")"))))), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold" + }, "Requested Medicines"), transferItems.map((ti, i) => /*#__PURE__*/React.createElement("div", { + key: i, + className: "row g-2 mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-8" + }, /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "Medicine Name", + value: ti.item_name, + onChange: e => { + const updated = [...transferItems]; + updated[i].item_name = e.target.value; + setTransferItems(updated); + } + })), /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm", + placeholder: "Quantity Required", + min: "1", + value: ti.qty, + onChange: e => { + const updated = [...transferItems]; + updated[i].qty = e.target.value; + setTransferItems(updated); + } + })))), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-primary mt-1", + onClick: addTransferRow + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-plus-circle me-1" + }), " Add Another Medicine")), /*#__PURE__*/React.createElement("button", { + className: "btn btn-primary-custom", + onClick: submitIndent + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-send me-1" + }), " Submit Store Indent Requisition")); } // ========================================================================= @@ -16587,1524 +13255,993 @@ function LedgersView({ return acc.account_name && acc.account_name.toLowerCase().includes(q) || acc.phone && acc.phone.includes(q) || acc.staff_id && acc.staff_id.toLowerCase().includes(q) || acc.department && acc.department.toLowerCase().includes(q); }); const totalOutstandingCredit = creditAccounts.reduce((sum, a) => sum + Number(a.current_balance || 0), 0); - return /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap gap-2 mb-3", - children: [/*#__PURE__*/_jsxs("button", { - className: `btn btn-sm ${accTab === 'daybook' ? 'btn-primary' : 'btn-outline-secondary'}`, - onClick: () => setAccTab('daybook'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-journal-check me-1" - }), " Daily Cash Book / Day Book"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm ${accTab === 'bank_audit' ? 'btn-primary' : 'btn-outline-secondary'}`, - onClick: () => setAccTab('bank_audit'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-bank2 me-1" - }), " Bank & UPI Statement Audit"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm ${accTab === 'gst' ? 'btn-primary' : 'btn-outline-secondary'}`, - onClick: () => setAccTab('gst'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-spreadsheet me-1" - }), " GST Returns (GSTR-1 & 2)"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm ${accTab === 'schedule_h1' ? 'btn-primary' : 'btn-outline-secondary'}`, - onClick: () => setAccTab('schedule_h1'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-check me-1" - }), " Statutory Schedule H1 Register"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm ${accTab === 'credit_accounts' ? 'btn-primary' : 'btn-outline-secondary'}`, - onClick: () => setAccTab('credit_accounts'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-people-fill me-1" - }), " Staff & Customer Credit Accounts", totalOutstandingCredit > 0 && /*#__PURE__*/_jsxs("span", { - className: "badge bg-danger rounded-pill ms-1.5", - style: { - fontSize: '0.65rem' - }, - children: ["₹", totalOutstandingCredit.toLocaleString('en-IN')] - })] - })] - }), accTab === 'daybook' && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "counter-card p-3 mb-3", - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap align-items-center justify-content-between gap-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap align-items-center gap-2", - children: [/*#__PURE__*/_jsxs("span", { - className: "fw-bold text-dark small", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-funnel text-primary me-1" - }), " Quick Filter:"] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-secondary py-1 px-2.5", - onClick: () => handleDaybookFilterPreset('today'), - children: "Today" - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-secondary py-1 px-2.5", - onClick: () => handleDaybookFilterPreset('yesterday'), - children: "Yesterday" - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-secondary py-1 px-2.5", - onClick: () => handleDaybookFilterPreset('last7'), - children: "Last 7 Days" - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-secondary py-1 px-2.5", - onClick: () => handleDaybookFilterPreset('month'), - children: "This Month" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2 flex-wrap", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-1", - children: [/*#__PURE__*/_jsx("label", { - className: "small text-muted mb-0", - children: "From:" - }), /*#__PURE__*/_jsx("input", { - type: "date", - className: "form-control form-control-sm", - value: daybookFromDate, - onChange: e => setDaybookFromDate(e.target.value) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-1", - children: [/*#__PURE__*/_jsx("label", { - className: "small text-muted mb-0", - children: "To:" - }), /*#__PURE__*/_jsx("input", { - type: "date", - className: "form-control form-control-sm", - value: daybookToDate, - onChange: e => setDaybookToDate(e.target.value) - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-primary px-3 fw-bold", - onClick: () => loadDaybook(daybookFromDate, daybookToDate), - disabled: loadingDaybook, - children: loadingDaybook ? 'Loading...' : 'Apply' - }), /*#__PURE__*/_jsxs("div", { - className: "border-start ps-2 d-flex gap-1.5", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-dark px-2.5 d-flex align-items-center gap-1", - onClick: printDaybook, - title: "Print Daybook Statement", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer" - }), " Print"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-success px-2.5 d-flex align-items-center gap-1", - onClick: exportDaybookCsv, - title: "Download Excel / CSV", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-excel" - }), " Export CSV"] - })] - })] - })] - }) - }), daybookData && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "row g-3 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "col-md-3 col-sm-6", - children: /*#__PURE__*/_jsxs("div", { - className: "counter-card p-3 border-start border-4 border-success shadow-sm", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted fw-bold", - children: "TOTAL PERIOD SALES" - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bolder text-dark mt-1", - children: ["₹", Number(daybookData.summary.total_sales || 0).toLocaleString('en-IN')] - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [daybookData.summary.total_invoices, " Bills"] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-3 col-sm-6", - children: /*#__PURE__*/_jsxs("div", { - className: "counter-card p-3 border-start border-4 border-primary shadow-sm", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted fw-bold", - children: "CASH IN DRAWER" - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bolder text-primary mt-1", - children: ["₹", Number(daybookData.summary.cash_in_drawer || 0).toLocaleString('en-IN')] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-3 col-sm-6", - children: /*#__PURE__*/_jsxs("div", { - className: "counter-card p-3 border-start border-4 border-warning shadow-sm", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted fw-bold", - children: "UPI / QR COLLECTIONS" - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bolder text-warning mt-1", - children: ["₹", Number(daybookData.summary.upi_collection || 0).toLocaleString('en-IN')] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-3 col-sm-6", - children: /*#__PURE__*/_jsxs("div", { - className: "counter-card p-3 border-start border-4 border-danger shadow-sm", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted fw-bold", - children: "CREDIT BILLED (IPD + STAFF)" - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bolder text-danger mt-1", - children: ["₹", Number(daybookData.summary.ipd_credit || 0).toLocaleString('en-IN')] - })] - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "counter-card p-0 overflow-hidden shadow-sm", - children: [/*#__PURE__*/_jsxs("div", { - className: "p-3 border-bottom d-flex justify-content-between align-items-center bg-light", - children: [/*#__PURE__*/_jsxs("h6", { - className: "mb-0 fw-bold", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-receipt text-primary me-1" - }), " Transactions Journal (", daybookFromDate, " to ", daybookToDate, ")"] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-secondary", - children: [daybookData.transactions.length, " Records"] - })] - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-pos mb-0", - children: [/*#__PURE__*/_jsx("thead", { - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "Invoice No" - }), /*#__PURE__*/_jsx("th", { - children: "Date & Time" - }), /*#__PURE__*/_jsx("th", { - children: "Patient (UHID)" - }), /*#__PURE__*/_jsx("th", { - children: "Doctor" - }), /*#__PURE__*/_jsx("th", { - children: "Mode" - }), /*#__PURE__*/_jsx("th", { - children: "CGST (₹)" - }), /*#__PURE__*/_jsx("th", { - children: "SGST (₹)" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Net Amount" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: daybookData.transactions.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsx("td", { - colSpan: "8", - className: "text-center py-4 text-muted", - children: "No transactions found for the selected date range." - }) - }) : daybookData.transactions.map(t => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - className: "fw-bold", - children: t.invoice_no - }), /*#__PURE__*/_jsx("td", { - children: t.sale_date - }), /*#__PURE__*/_jsxs("td", { - children: [t.patient_name, " ", t.uhid ? `(${t.uhid})` : ''] - }), /*#__PURE__*/_jsx("td", { - children: t.doctor_name - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary", - children: t.payment_mode - }) - }), /*#__PURE__*/_jsxs("td", { - children: ["₹", t.cgst_amount] - }), /*#__PURE__*/_jsxs("td", { - children: ["₹", t.sgst_amount] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-bold text-success", - children: ["₹", t.net_amount] - })] - }, t.sale_id)) - })] - }) - })] - })] - })] - }), accTab === 'bank_audit' && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "row g-3 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "col-md-4 col-sm-6", - children: /*#__PURE__*/_jsxs("div", { - className: "counter-card p-3 border-start border-4 border-primary shadow-sm", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted fw-bold", - children: "TOTAL ONLINE / UPI SALES" - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bolder text-dark mt-1", - children: ["₹", Number(bankAuditData?.summary?.total_amount || 0).toLocaleString('en-IN', { - minimumFractionDigits: 2 - })] - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [bankAuditData?.summary?.total_count || 0, " Transactions Recorded"] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-4 col-sm-6", - children: /*#__PURE__*/_jsxs("div", { - className: "counter-card p-3 border-start border-4 border-success shadow-sm", - children: [/*#__PURE__*/_jsx("small", { - className: "text-success fw-bold", - children: "STATEMENT RECONCILED (VERIFIED)" - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bolder text-success mt-1", - children: ["₹", Number(bankAuditData?.summary?.reconciled_amount || 0).toLocaleString('en-IN', { - minimumFractionDigits: 2 - })] - }), /*#__PURE__*/_jsxs("small", { - className: "text-success", - children: [bankAuditData?.summary?.reconciled_count || 0, " Bills Matched with Bank"] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-4 col-sm-6", - children: /*#__PURE__*/_jsxs("div", { - className: "counter-card p-3 border-start border-4 border-warning shadow-sm", - children: [/*#__PURE__*/_jsx("small", { - className: "text-warning fw-bold", - children: "PENDING AUDIT VERIFICATION" - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bolder text-warning mt-1", - children: ["₹", Number(bankAuditData?.summary?.pending_amount || 0).toLocaleString('en-IN', { - minimumFractionDigits: 2 - })] - }), /*#__PURE__*/_jsxs("small", { - className: "text-warning", - children: [bankAuditData?.summary?.pending_count || 0, " Bills Unverified"] - })] - }) - })] - }), /*#__PURE__*/_jsx("div", { - className: "counter-card p-3 mb-3", - children: /*#__PURE__*/_jsxs("div", { - className: "row g-2 align-items-center", - children: [/*#__PURE__*/_jsx("div", { - className: "col-md-5", - children: /*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm", - children: [/*#__PURE__*/_jsxs("button", { - className: `btn ${auditFilterStatus === 'all' ? 'btn-primary' : 'btn-outline-secondary'}`, - onClick: () => { - setAuditFilterStatus('all'); - loadBankAudit('all', auditSearch); - }, - children: ["All (", bankAuditData?.summary?.total_count || 0, ")"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn ${auditFilterStatus === 'pending' ? 'btn-warning text-dark fw-bold' : 'btn-outline-secondary'}`, - onClick: () => { - setAuditFilterStatus('pending'); - loadBankAudit('pending', auditSearch); - }, - children: ["Pending Verification (", bankAuditData?.summary?.pending_count || 0, ")"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn ${auditFilterStatus === 'reconciled' ? 'btn-success fw-bold' : 'btn-outline-secondary'}`, - onClick: () => { - setAuditFilterStatus('reconciled'); - loadBankAudit('reconciled', auditSearch); - }, - children: ["Reconciled (", bankAuditData?.summary?.reconciled_count || 0, ")"] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-4", - children: /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-light", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-search" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control", - placeholder: "Search by Bill No, UTR / UPI Ref...", - value: auditSearch, - onChange: e => { - setAuditSearch(e.target.value); - loadBankAudit(auditFilterStatus, e.target.value); - } - })] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-3 text-end d-flex gap-1.5 justify-content-end", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-dark", - onClick: printBankAudit, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer me-1" - }), " Print"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-success", - onClick: exportBankCsv, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-excel me-1" - }), " Export CSV"] - })] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "counter-card p-0 overflow-hidden shadow-sm", - children: /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-pos mb-0", - children: [/*#__PURE__*/_jsx("thead", { - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "Invoice No" - }), /*#__PURE__*/_jsx("th", { - children: "Date & Time" - }), /*#__PURE__*/_jsx("th", { - children: "Patient" - }), /*#__PURE__*/_jsx("th", { - children: "Mode" - }), /*#__PURE__*/_jsx("th", { - children: "Bill Total" - }), /*#__PURE__*/_jsx("th", { - children: "Bank / UTR Reference" - }), /*#__PURE__*/_jsx("th", { - children: "Audit Status" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Action" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: (() => { - const txns = bankAuditData?.transactions || bankAuditData?.records || []; - if (!bankAuditData) { - return /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "8", - className: "text-center py-4 text-muted", - children: [/*#__PURE__*/_jsx("div", { - className: "spinner-border spinner-border-sm text-primary me-2" - }), "Loading bank audit records..."] - }) - }); - } - if (txns.length === 0) { - return /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsx("td", { - colSpan: "8", - className: "text-center py-4 text-muted", - children: "No transactions found matching the filter." - }) - }); - } - return txns.map(t => /*#__PURE__*/_jsxs("tr", { - className: t.is_reconciled == 1 ? 'bg-success-subtle' : '', - children: [/*#__PURE__*/_jsx("td", { - className: "fw-bold", - children: t.invoice_no - }), /*#__PURE__*/_jsx("td", { - children: t.sale_date - }), /*#__PURE__*/_jsx("td", { - children: t.patient_name - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary", - children: t.payment_mode - }) - }), /*#__PURE__*/_jsxs("td", { - className: "fw-bold text-primary", - children: ["₹", t.net_amount] - }), /*#__PURE__*/_jsx("td", { - children: t.upi_ref_no ? /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-info text-dark", - children: "UPI" - }), " ", /*#__PURE__*/_jsx("code", { - children: t.upi_ref_no - })] - }) : t.card_ref_no ? /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("span", { - className: "badge bg-primary", - children: "CARD" - }), " ", /*#__PURE__*/_jsx("code", { - children: t.card_ref_no - })] - }) : /*#__PURE__*/_jsx("span", { - className: "text-muted", - children: "Direct QR" - }) - }), /*#__PURE__*/_jsx("td", { - children: t.is_reconciled == 1 ? /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-success", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle me-1" - }), " Reconciled"] - }), /*#__PURE__*/_jsxs("div", { - className: "small text-muted mt-0.5", - children: [t.reconciled_by, " • ", t.reconciled_at?.split(' ')[0]] - })] - }) : /*#__PURE__*/_jsxs("span", { - className: "badge bg-warning text-dark", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clock me-1" - }), " Pending Statement"] - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-end", - children: t.is_reconciled == 1 ? /*#__PURE__*/_jsx("button", { - className: "btn btn-sm btn-outline-danger py-0.5 px-2", - style: { - fontSize: '0.75rem' - }, - onClick: () => handleReconcileSubmit(t.sale_id, 0), - children: "Un-reconcile" - }) : /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-success py-0.5 px-2.5 fw-bold", - style: { - fontSize: '0.75rem' - }, - onClick: () => { - setReconcilingSale(t); - setAuditNotes(''); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check2-circle me-1" - }), " Verify Entry"] - }) - })] - }, t.sale_id)); - })() - })] - }) - }) - }), reconcilingSale && /*#__PURE__*/_jsx("div", { - className: "modal show d-block", - tabIndex: "-1", - style: { - backgroundColor: 'rgba(15, 23, 42, 0.7)' - }, - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content shadow-lg border-0", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2.5 px-3", - children: [/*#__PURE__*/_jsxs("h6", { - className: "modal-title fw-bold mb-0", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-bank me-2 text-primary" - }), " Reconcile Bank / UPI Statement"] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setReconcilingSale(null) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "card bg-light border p-2.5 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-1", - children: [/*#__PURE__*/_jsx("span", { - className: "text-muted", - children: "Invoice No:" - }), /*#__PURE__*/_jsx("span", { - className: "fw-bold text-dark", - children: reconcilingSale.invoice_no - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-1", - children: [/*#__PURE__*/_jsx("span", { - className: "text-muted", - children: "Amount:" - }), /*#__PURE__*/_jsxs("span", { - className: "fw-bold text-success fs-6", - children: ["₹", reconcilingSale.net_amount] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-1", - children: [/*#__PURE__*/_jsx("span", { - className: "text-muted", - children: "Recorded Ref / UTR:" - }), /*#__PURE__*/_jsx("code", { - children: reconcilingSale.upi_ref_no || reconcilingSale.card_ref_no || 'Direct Store QR' - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-2", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Audited By (Accountant / User)" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: auditorName, - onChange: e => setAuditorName(e.target.value) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Accountant Statement Audit Note" - }), /*#__PURE__*/_jsx("textarea", { - className: "form-control form-control-sm", - rows: "2", - value: auditNotes, - onChange: e => setAuditNotes(e.target.value), - placeholder: "e.g. Matched in Bank A/c statement entry on 08-Sep-2026, Credit Ref verified" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer py-2 px-3 bg-light", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-secondary", - onClick: () => setReconcilingSale(null), - children: "Cancel" - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-success fw-bold", - onClick: () => handleReconcileSubmit(reconcilingSale.sale_id, 1), - disabled: isSubmittingAudit, - children: isSubmittingAudit ? 'Saving...' : 'Mark Verified with Statement' - })] - })] - }) - }) - })] - }), accTab === 'gst' && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "counter-card p-3 mb-3", - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap align-items-center justify-content-between gap-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsxs("label", { - className: "small fw-bold text-dark mb-0", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-calendar-month text-primary me-1" - }), " Return Filing Month:"] - }), /*#__PURE__*/_jsx("input", { - type: "month", - className: "form-control form-control-sm", - value: gstMonth, - onChange: e => { - setGstMonth(e.target.value); - loadGst(e.target.value); - } - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-primary px-3 fw-bold", - onClick: () => loadGst(gstMonth), - disabled: loadingGst, - children: loadingGst ? 'Loading...' : 'Refresh' - })] - }), /*#__PURE__*/_jsx("div", { - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-success px-3 fw-bold d-flex align-items-center gap-1.5", - onClick: exportGstCsv, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-excel" - }), " Export GSTR-1 Excel / CSV"] - }) - })] - }) - }), gstData && /*#__PURE__*/_jsxs("div", { - className: "counter-card mb-3 shadow-sm", - children: [/*#__PURE__*/_jsxs("div", { - className: "p-3 border-bottom d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold mb-0", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-spreadsheet text-primary me-1" - }), " GSTR-1 Outward Sales Summary (HSN-wise) for ", gstMonth] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-primary", - children: ["GSTIN: ", store.gst_no || 'N/A'] - })] - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-pos mb-0", - children: [/*#__PURE__*/_jsx("thead", { - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "HSN Code" - }), /*#__PURE__*/_jsx("th", { - children: "GST Slab" - }), /*#__PURE__*/_jsx("th", { - children: "Taxable Value (₹)" - }), /*#__PURE__*/_jsx("th", { - children: "CGST (₹)" - }), /*#__PURE__*/_jsx("th", { - children: "SGST (₹)" - }), /*#__PURE__*/_jsx("th", { - children: "IGST (₹)" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Total Invoice Value (₹)" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: gstData.gstr1_sales.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsxs("td", { - colSpan: "7", - className: "text-center py-4 text-muted", - children: ["No sales recorded for GST filing in month ", gstMonth, "."] - }) - }) : gstData.gstr1_sales.map((g, i) => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("code", { - children: g.hsn_code - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("span", { - className: "badge bg-primary", - children: [g.gst_rate, "%"] - }) - }), /*#__PURE__*/_jsxs("td", { - children: ["₹", Number(g.taxable_val).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - children: ["₹", Number(g.cgst_val).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - children: ["₹", Number(g.sgst_val).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - children: ["₹", Number(g.igst_val).toFixed(2)] - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-bold", - children: ["₹", Number(g.total_val).toFixed(2)] - })] - }, i)) - })] - }) - })] - })] - }), accTab === 'schedule_h1' && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "counter-card p-3 mb-3", - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap align-items-center justify-content-between gap-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2 flex-wrap", - children: [/*#__PURE__*/_jsxs("span", { - className: "small fw-bold text-dark", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-funnel text-success me-1" - }), " Date Filter:"] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-1", - children: [/*#__PURE__*/_jsx("input", { - type: "date", - className: "form-control form-control-sm", - value: h1FromDate, - onChange: e => setH1FromDate(e.target.value) - }), /*#__PURE__*/_jsx("span", { - children: "to" - }), /*#__PURE__*/_jsx("input", { - type: "date", - className: "form-control form-control-sm", - value: h1ToDate, - onChange: e => setH1ToDate(e.target.value) - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-primary fw-bold", - onClick: () => loadScheduleH1(h1FromDate, h1ToDate, h1Search), - disabled: loadingH1, - children: loadingH1 ? 'Loading...' : 'Filter' - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "Search medicine or doctor...", - value: h1Search, - onChange: e => { - setH1Search(e.target.value); - loadScheduleH1(h1FromDate, h1ToDate, e.target.value); - } - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-dark", - onClick: printH1Register, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-printer me-1" - }), " Print"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-success", - onClick: exportH1Csv, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-excel me-1" - }), " Export CSV"] - })] - })] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "counter-card shadow-sm", - children: [/*#__PURE__*/_jsxs("div", { - className: "p-3 border-bottom d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold mb-0", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-check text-success me-1" - }), " Statutory Schedule H1 Drug Register"] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "Mandatory under Indian Drugs & Cosmetics Rules (4th Amendment 2013). Retain for 3 years." - })] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-danger-subtle text-danger border border-danger", - children: [h1Records.length, " Dispensed Entries"] - })] - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-pos table-bordered mb-0", - children: [/*#__PURE__*/_jsx("thead", { - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "Date" - }), /*#__PURE__*/_jsx("th", { - children: "Bill No" - }), /*#__PURE__*/_jsx("th", { - children: "Patient Name & Address" - }), /*#__PURE__*/_jsx("th", { - children: "Prescribing Doctor & Reg No" - }), /*#__PURE__*/_jsx("th", { - children: "Medicine Name" - }), /*#__PURE__*/_jsx("th", { - children: "Batch No" - }), /*#__PURE__*/_jsx("th", { - children: "Qty Supplied" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: h1Records.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsx("td", { - colSpan: "7", - className: "text-center py-4 text-muted", - children: "No Schedule H1 medicines dispensed in this period." - }) - }) : h1Records.map((h, i) => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - children: h.sale_date?.split(' ')[0] - }), /*#__PURE__*/_jsx("td", { - className: "fw-bold", - children: h.invoice_no - }), /*#__PURE__*/_jsxs("td", { - children: [h.patient_name, " ", h.patient_address ? `(${h.patient_address})` : ''] - }), /*#__PURE__*/_jsxs("td", { - children: [h.doctor_name, " ", h.doctor_reg_no ? `(Reg: ${h.doctor_reg_no})` : ''] - }), /*#__PURE__*/_jsx("td", { - className: "fw-bold text-danger", - children: h.item_name - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("code", { - children: h.batch_no - }) - }), /*#__PURE__*/_jsx("td", { - className: "fw-bold", - children: h.qty - })] - }, i)) - })] - }) - })] - })] - }), accTab === 'credit_accounts' && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "row g-3 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "col-md-4 col-sm-6", - children: /*#__PURE__*/_jsxs("div", { - className: "counter-card p-3 border-start border-4 border-primary shadow-sm", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted fw-bold", - children: "TOTAL REGISTERED ACCOUNTS" - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bolder text-dark mt-1", - children: [creditAccounts.length, " Accounts"] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "Staff, Doctors, Institutional & Patients" - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-4 col-sm-6", - children: /*#__PURE__*/_jsxs("div", { - className: "counter-card p-3 border-start border-4 border-danger shadow-sm", - children: [/*#__PURE__*/_jsx("small", { - className: "text-danger fw-bold", - children: "TOTAL OUTSTANDING DUES" - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bolder text-danger mt-1", - children: ["₹", totalOutstandingCredit.toLocaleString('en-IN', { - minimumFractionDigits: 2 - })] - }), /*#__PURE__*/_jsx("small", { - className: "text-danger", - children: "Unsettled Pharmacy Debits" - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-4 col-sm-6", - children: /*#__PURE__*/_jsxs("div", { - className: "counter-card p-3 border-start border-4 border-success shadow-sm", - children: [/*#__PURE__*/_jsx("small", { - className: "text-success fw-bold", - children: "TOTAL CREDIT LIMIT SANCTIONED" - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bolder text-success mt-1", - children: ["₹", creditAccounts.reduce((sum, a) => sum + Number(a.credit_limit || 0), 0).toLocaleString('en-IN', { - minimumFractionDigits: 2 - })] - }), /*#__PURE__*/_jsx("small", { - className: "text-success", - children: "Authorized Spending Cap" - })] - }) - })] - }), /*#__PURE__*/_jsx("div", { - className: "counter-card p-3 mb-3 shadow-sm", - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap align-items-center justify-content-between gap-3", - children: [/*#__PURE__*/_jsx("div", { - className: "d-flex align-items-center gap-2 flex-grow-1", - style: { - maxWidth: 420 - }, - children: /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-light", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-search" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control", - placeholder: "Search by name, phone, dept, staff ID...", - value: creditSearch, - onChange: e => setCreditSearch(e.target.value) - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "d-flex align-items-center gap-2", - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-primary px-3 py-1.5 fw-bold shadow-sm d-flex align-items-center gap-1.5", - onClick: () => setShowAddAccountModal(true), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-plus-fill" - }), " New Credit Account"] - }) - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "counter-card p-0 overflow-hidden shadow-sm", - children: /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-pos mb-0", - children: [/*#__PURE__*/_jsx("thead", { - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "Account / Person Name" - }), /*#__PURE__*/_jsx("th", { - children: "Account Type" - }), /*#__PURE__*/_jsx("th", { - children: "Dept / Staff ID" - }), /*#__PURE__*/_jsx("th", { - children: "Phone" - }), /*#__PURE__*/_jsx("th", { - children: "Credit Limit" - }), /*#__PURE__*/_jsx("th", { - children: "Current Balance" - }), /*#__PURE__*/_jsx("th", { - children: "Status" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Actions" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: loadingCredit ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsx("td", { - colSpan: "8", - className: "text-center py-4 text-muted", - children: "Loading credit accounts..." - }) - }) : filteredCreditAccounts.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsx("td", { - colSpan: "8", - className: "text-center py-4 text-muted", - children: "No credit accounts found. Click \"New Credit Account\" to create one." - }) - }) : filteredCreditAccounts.map(acc => { - const typeColor = acc.account_type === 'staff' ? 'primary' : acc.account_type === 'doctor' ? 'success' : acc.account_type === 'corporate' ? 'dark' : 'warning'; - const bal = Number(acc.current_balance || 0); - return /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsxs("td", { - className: "fw-bold text-dark", - children: [acc.account_name, acc.remarks && /*#__PURE__*/_jsx("small", { - className: "d-block text-muted", - children: acc.remarks - })] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: `badge bg-${typeColor}-subtle text-${typeColor} border border-${typeColor} text-uppercase px-2`, - style: { - fontSize: '0.65rem' - }, - children: acc.account_type - }) - }), /*#__PURE__*/_jsx("td", { - children: acc.department || acc.staff_id || '-' - }), /*#__PURE__*/_jsx("td", { - children: acc.phone || '-' - }), /*#__PURE__*/_jsxs("td", { - className: "fw-bold", - children: ["₹", Number(acc.credit_limit || 0).toLocaleString('en-IN')] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("span", { - className: `fw-bold fs-6 ${bal > 0 ? 'text-danger' : 'text-success'}`, - children: ["₹", bal.toLocaleString('en-IN', { - minimumFractionDigits: 2 - })] - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: `badge ${acc.is_active == 1 ? 'bg-success' : 'bg-secondary'}`, - children: acc.is_active == 1 ? 'ACTIVE' : 'INACTIVE' - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-end", - children: /*#__PURE__*/_jsxs("div", { - className: "btn-group btn-group-sm", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-outline-primary py-0.5 px-2", - style: { - fontSize: '0.75rem' - }, - onClick: () => openAccountLedger(acc), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-journal-text me-1" - }), " Ledger"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-outline-success py-0.5 px-2 fw-bold", - style: { - fontSize: '0.75rem' - }, - onClick: () => openSettlePaymentModal(acc), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cash-coin me-1" - }), " Settle"] - })] - }) - })] - }, acc.account_id); - }) - })] - }) - }) - }), showAddAccountModal && /*#__PURE__*/_jsx("div", { - className: "modal show d-block", - tabIndex: "-1", - style: { - backgroundColor: 'rgba(15, 23, 42, 0.7)' - }, - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered", - children: /*#__PURE__*/_jsx("div", { - className: "modal-content shadow-lg border-0", - children: /*#__PURE__*/_jsxs("form", { - onSubmit: handleSaveCreditAccount, - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2.5 px-3", - children: [/*#__PURE__*/_jsxs("h6", { - className: "modal-title fw-bold mb-0", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-plus-fill text-primary me-2" - }), " Create Credit Account"] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setShowAddAccountModal(false) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "row g-3 mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Account Type" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: accFormType, - onChange: e => setAccFormType(e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "staff", - children: "Staff Member" - }), /*#__PURE__*/_jsx("option", { - value: "doctor", - children: "Consultant / Doctor" - }), /*#__PURE__*/_jsx("option", { - value: "corporate", - children: "Hospital Trust / Corporate" - }), /*#__PURE__*/_jsx("option", { - value: "customer", - children: "Regular Customer / VIP" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Credit Limit (₹)" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm", - value: accFormLimit, - onChange: e => setAccFormLimit(e.target.value), - placeholder: "5000" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-2", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-1", - children: ["Person / Organization Name ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - required: true, - value: accFormName, - onChange: e => setAccFormName(e.target.value), - placeholder: "e.g. Dr. Rajesh Sharma / Sister Sunita" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-3 mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Phone Number" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: accFormPhone, - onChange: e => setAccFormPhone(e.target.value), - placeholder: "e.g. 9876543210" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Staff ID / Employee Code" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: accFormStaffId, - onChange: e => setAccFormStaffId(e.target.value), - placeholder: "e.g. EMP-1042" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-2", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Department" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: accFormDept, - onChange: e => setAccFormDept(e.target.value), - placeholder: "e.g. ICU Nursing / General Surgery / Administration" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-2", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Remarks / Terms" - }), /*#__PURE__*/_jsx("textarea", { - className: "form-control form-control-sm", - rows: "2", - value: accFormRemarks, - onChange: e => setAccFormRemarks(e.target.value), - placeholder: "e.g. Deducted monthly from hospital payroll or settled at month end" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer py-2 px-3 bg-light", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-secondary", - onClick: () => setShowAddAccountModal(false), - children: "Cancel" - }), /*#__PURE__*/_jsx("button", { - type: "submit", - className: "btn btn-sm btn-primary fw-bold", - disabled: isSavingAccount, - children: isSavingAccount ? 'Creating...' : 'Create Account' - })] - })] - }) - }) - }) - }), selectedCreditAcc && creditLedgerData && /*#__PURE__*/_jsx("div", { - className: "modal show d-block", - tabIndex: "-1", - style: { - backgroundColor: 'rgba(15, 23, 42, 0.7)' - }, - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered modal-xl", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content shadow-lg border-0", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2.5 px-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-journal-text text-primary fs-5" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("h6", { - className: "modal-title fw-bold mb-0", - children: [selectedCreditAcc.account_name, " — Credit Statement"] - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [selectedCreditAcc.account_type.toUpperCase(), " • ", selectedCreditAcc.department || 'General'] - })] - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => { - setSelectedCreditAcc(null); - setCreditLedgerData(null); - } - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-3", - children: [/*#__PURE__*/_jsx("div", { - className: "card p-3 mb-3 bg-light border", - children: /*#__PURE__*/_jsxs("div", { - className: "row g-2 align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-3", - children: [/*#__PURE__*/_jsx("small", { - className: "text-muted fw-bold", - children: "CREDIT LIMIT" - }), /*#__PURE__*/_jsxs("h5", { - className: "fw-bold mb-0", - children: ["₹", Number(selectedCreditAcc.credit_limit || 0).toLocaleString('en-IN')] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-3", - children: [/*#__PURE__*/_jsx("small", { - className: "text-danger fw-bold", - children: "OUTSTANDING BALANCE" - }), /*#__PURE__*/_jsxs("h4", { - className: "fw-bold text-danger mb-0", - children: ["₹", Number(selectedCreditAcc.current_balance || 0).toLocaleString('en-IN', { - minimumFractionDigits: 2 - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-3", - children: [/*#__PURE__*/_jsx("small", { - className: "text-success fw-bold", - children: "AVAILABLE CREDIT" - }), /*#__PURE__*/_jsxs("h5", { - className: "fw-bold text-success mb-0", - children: ["₹", Math.max(0, Number(selectedCreditAcc.credit_limit || 0) - Number(selectedCreditAcc.current_balance || 0)).toLocaleString('en-IN')] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-3 text-end", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-success fw-bold px-3 py-1.5 shadow-sm me-2", - onClick: () => openSettlePaymentModal(selectedCreditAcc), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cash-stack me-1" - }), " Settle Payment"] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-dark px-2.5 py-1.5", - onClick: printAccountLedger, - title: "Print Account Statement", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-printer" - }) - })] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive", - style: { - maxHeight: 380, - overflowY: 'auto' - }, - children: /*#__PURE__*/_jsxs("table", { - className: "table table-pos table-bordered mb-0", - children: [/*#__PURE__*/_jsx("thead", { - className: "table-dark sticky-top", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "Timestamp" - }), /*#__PURE__*/_jsx("th", { - children: "Type" - }), /*#__PURE__*/_jsx("th", { - children: "Invoice / Receipt Ref" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Debit (Bills)" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Credit (Payments)" - }), /*#__PURE__*/_jsx("th", { - className: "text-end", - children: "Running Balance" - }), /*#__PURE__*/_jsx("th", { - children: "Mode" - }), /*#__PURE__*/_jsx("th", { - children: "Recorded By / Notes" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: creditLedgerData.entries.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsx("td", { - colSpan: "8", - className: "text-center py-4 text-muted", - children: "No transactions on this account yet." - }) - }) : creditLedgerData.entries.map(ent => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - children: ent.created_at - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: `badge ${ent.entry_type === 'DEBIT' ? 'bg-danger' : 'bg-success'}`, - children: ent.entry_type - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("strong", { - children: ent.invoice_no || ent.payment_ref || '-' - }) - }), /*#__PURE__*/_jsx("td", { - className: "text-end fw-bold text-danger", - children: Number(ent.debit_amount) > 0 ? '₹' + Number(ent.debit_amount).toFixed(2) : '-' - }), /*#__PURE__*/_jsx("td", { - className: "text-end fw-bold text-success", - children: Number(ent.credit_amount) > 0 ? '₹' + Number(ent.credit_amount).toFixed(2) : '-' - }), /*#__PURE__*/_jsxs("td", { - className: "text-end fw-bold", - children: ["₹", Number(ent.balance_after).toFixed(2)] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary", - children: ent.payment_mode - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [ent.remarks || 'Bill Charge', " (", ent.recorded_by_name || 'System', ")"] - }) - })] - }, ent.ledger_id)) - })] - }) - })] - }), /*#__PURE__*/_jsx("div", { - className: "modal-footer py-2 px-3 bg-light", - children: /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-secondary", - onClick: () => { - setSelectedCreditAcc(null); - setCreditLedgerData(null); - }, - children: "Close Statement" - }) - })] - }) - }) - }), showPaymentModal && selectedCreditAcc && /*#__PURE__*/_jsx("div", { - className: "modal show d-block", - tabIndex: "-1", - style: { - backgroundColor: 'rgba(15, 23, 42, 0.7)' - }, - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered", - children: /*#__PURE__*/_jsx("div", { - className: "modal-content shadow-lg border-0", - children: /*#__PURE__*/_jsxs("form", { - onSubmit: handleRecordPayment, - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2.5 px-3", - children: [/*#__PURE__*/_jsxs("h6", { - className: "modal-title fw-bold mb-0", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cash-coin text-success me-2" - }), " Record Credit Settlement Payment"] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setShowPaymentModal(false) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "card bg-light border p-2.5 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between mb-1", - children: [/*#__PURE__*/_jsx("span", { - className: "text-muted", - children: "Account:" - }), /*#__PURE__*/_jsx("span", { - className: "fw-bold text-dark", - children: selectedCreditAcc.account_name - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between", - children: [/*#__PURE__*/_jsx("span", { - className: "text-muted", - children: "Total Outstanding Due:" - }), /*#__PURE__*/_jsxs("span", { - className: "fw-bold text-danger fs-6", - children: ["₹", Number(selectedCreditAcc.current_balance || 0).toFixed(2)] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-1", - children: ["Settlement Amount Received (₹) ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-light fw-bold", - children: "₹" - }), /*#__PURE__*/_jsx("input", { - type: "number", - step: "0.01", - className: "form-control form-control-sm fs-6 fw-bold text-success", - required: true, - value: payAmount, - onChange: e => setPayAmount(e.target.value), - placeholder: "Enter amount" - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-outline-secondary", - onClick: () => setPayAmount(String(selectedCreditAcc.current_balance)), - children: "Full Pay" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Payment Method" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: payMode, - onChange: e => setPayMode(e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "Cash", - children: "Cash in Drawer" - }), /*#__PURE__*/_jsx("option", { - value: "UPI", - children: "UPI / QR Code" - }), /*#__PURE__*/_jsx("option", { - value: "Bank", - children: "Direct Bank Transfer / NEFT" - }), /*#__PURE__*/_jsx("option", { - value: "Salary_Deduction", - children: "Payroll / Salary Deduction" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Receipt / UTR / Ref No" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: payRef, - onChange: e => setPayRef(e.target.value), - placeholder: "e.g. UTR-991823" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-2", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Remarks / Receipt Note" - }), /*#__PURE__*/_jsx("textarea", { - className: "form-control form-control-sm", - rows: "2", - value: payRemarks, - onChange: e => setPayRemarks(e.target.value), - placeholder: "e.g. Cash received at pharmacy counter by cashier" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer py-2 px-3 bg-light", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-secondary", - onClick: () => setShowPaymentModal(false), - children: "Cancel" - }), /*#__PURE__*/_jsx("button", { - type: "submit", - className: "btn btn-sm btn-success fw-bold", - disabled: isRecordingPayment, - children: isRecordingPayment ? 'Recording...' : 'Confirm Payment & Update Balance' - })] - })] - }) - }) - }) - })] - })] - }); + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap gap-2 mb-3" + }, /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm ${accTab === 'daybook' ? 'btn-primary' : 'btn-outline-secondary'}`, + onClick: () => setAccTab('daybook') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-journal-check me-1" + }), " Daily Cash Book / Day Book"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm ${accTab === 'bank_audit' ? 'btn-primary' : 'btn-outline-secondary'}`, + onClick: () => setAccTab('bank_audit') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-bank2 me-1" + }), " Bank & UPI Statement Audit"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm ${accTab === 'gst' ? 'btn-primary' : 'btn-outline-secondary'}`, + onClick: () => setAccTab('gst') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-spreadsheet me-1" + }), " GST Returns (GSTR-1 & 2)"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm ${accTab === 'schedule_h1' ? 'btn-primary' : 'btn-outline-secondary'}`, + onClick: () => setAccTab('schedule_h1') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-check me-1" + }), " Statutory Schedule H1 Register"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm ${accTab === 'credit_accounts' ? 'btn-primary' : 'btn-outline-secondary'}`, + onClick: () => setAccTab('credit_accounts') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-people-fill me-1" + }), " Staff & Customer Credit Accounts", totalOutstandingCredit > 0 && /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger rounded-pill ms-1.5", + style: { + fontSize: '0.65rem' + } + }, "₹", totalOutstandingCredit.toLocaleString('en-IN')))), accTab === 'daybook' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap align-items-center justify-content-between gap-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap align-items-center gap-2" + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-dark small" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-funnel text-primary me-1" + }), " Quick Filter:"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-secondary py-1 px-2.5", + onClick: () => handleDaybookFilterPreset('today') + }, "Today"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-secondary py-1 px-2.5", + onClick: () => handleDaybookFilterPreset('yesterday') + }, "Yesterday"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-secondary py-1 px-2.5", + onClick: () => handleDaybookFilterPreset('last7') + }, "Last 7 Days"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-secondary py-1 px-2.5", + onClick: () => handleDaybookFilterPreset('month') + }, "This Month")), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2 flex-wrap" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-1" + }, /*#__PURE__*/React.createElement("label", { + className: "small text-muted mb-0" + }, "From:"), /*#__PURE__*/React.createElement("input", { + type: "date", + className: "form-control form-control-sm", + value: daybookFromDate, + onChange: e => setDaybookFromDate(e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-1" + }, /*#__PURE__*/React.createElement("label", { + className: "small text-muted mb-0" + }, "To:"), /*#__PURE__*/React.createElement("input", { + type: "date", + className: "form-control form-control-sm", + value: daybookToDate, + onChange: e => setDaybookToDate(e.target.value) + })), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-primary px-3 fw-bold", + onClick: () => loadDaybook(daybookFromDate, daybookToDate), + disabled: loadingDaybook + }, loadingDaybook ? 'Loading...' : 'Apply'), /*#__PURE__*/React.createElement("div", { + className: "border-start ps-2 d-flex gap-1.5" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-dark px-2.5 d-flex align-items-center gap-1", + onClick: printDaybook, + title: "Print Daybook Statement" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer" + }), " Print"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-success px-2.5 d-flex align-items-center gap-1", + onClick: exportDaybookCsv, + title: "Download Excel / CSV" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-excel" + }), " Export CSV"))))), daybookData && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "row g-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-3 col-sm-6" + }, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 border-start border-4 border-success shadow-sm" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-bold" + }, "TOTAL PERIOD SALES"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bolder text-dark mt-1" + }, "₹", Number(daybookData.summary.total_sales || 0).toLocaleString('en-IN')), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, daybookData.summary.total_invoices, " Bills"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3 col-sm-6" + }, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 border-start border-4 border-primary shadow-sm" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-bold" + }, "CASH IN DRAWER"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bolder text-primary mt-1" + }, "₹", Number(daybookData.summary.cash_in_drawer || 0).toLocaleString('en-IN')))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3 col-sm-6" + }, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 border-start border-4 border-warning shadow-sm" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-bold" + }, "UPI / QR COLLECTIONS"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bolder text-warning mt-1" + }, "₹", Number(daybookData.summary.upi_collection || 0).toLocaleString('en-IN')))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3 col-sm-6" + }, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 border-start border-4 border-danger shadow-sm" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-bold" + }, "CREDIT BILLED (IPD + STAFF)"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bolder text-danger mt-1" + }, "₹", Number(daybookData.summary.ipd_credit || 0).toLocaleString('en-IN'))))), /*#__PURE__*/React.createElement("div", { + className: "counter-card p-0 overflow-hidden shadow-sm" + }, /*#__PURE__*/React.createElement("div", { + className: "p-3 border-bottom d-flex justify-content-between align-items-center bg-light" + }, /*#__PURE__*/React.createElement("h6", { + className: "mb-0 fw-bold" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-receipt text-primary me-1" + }), " Transactions Journal (", daybookFromDate, " to ", daybookToDate, ")"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary" + }, daybookData.transactions.length, " Records")), /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-pos mb-0" + }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "Invoice No"), /*#__PURE__*/React.createElement("th", null, "Date & Time"), /*#__PURE__*/React.createElement("th", null, "Patient (UHID)"), /*#__PURE__*/React.createElement("th", null, "Doctor"), /*#__PURE__*/React.createElement("th", null, "Mode"), /*#__PURE__*/React.createElement("th", null, "CGST (₹)"), /*#__PURE__*/React.createElement("th", null, "SGST (₹)"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Net Amount"))), /*#__PURE__*/React.createElement("tbody", null, daybookData.transactions.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "8", + className: "text-center py-4 text-muted" + }, "No transactions found for the selected date range.")) : daybookData.transactions.map(t => /*#__PURE__*/React.createElement("tr", { + key: t.sale_id + }, /*#__PURE__*/React.createElement("td", { + className: "fw-bold" + }, t.invoice_no), /*#__PURE__*/React.createElement("td", null, t.sale_date), /*#__PURE__*/React.createElement("td", null, t.patient_name, " ", t.uhid ? `(${t.uhid})` : ''), /*#__PURE__*/React.createElement("td", null, t.doctor_name), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary" + }, t.payment_mode)), /*#__PURE__*/React.createElement("td", null, "₹", t.cgst_amount), /*#__PURE__*/React.createElement("td", null, "₹", t.sgst_amount), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold text-success" + }, "₹", t.net_amount))))))))), accTab === 'bank_audit' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "row g-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-4 col-sm-6" + }, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 border-start border-4 border-primary shadow-sm" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-bold" + }, "TOTAL ONLINE / UPI SALES"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bolder text-dark mt-1" + }, "₹", Number(bankAuditData?.summary?.total_amount || 0).toLocaleString('en-IN', { + minimumFractionDigits: 2 + })), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, bankAuditData?.summary?.total_count || 0, " Transactions Recorded"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-4 col-sm-6" + }, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 border-start border-4 border-success shadow-sm" + }, /*#__PURE__*/React.createElement("small", { + className: "text-success fw-bold" + }, "STATEMENT RECONCILED (VERIFIED)"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bolder text-success mt-1" + }, "₹", Number(bankAuditData?.summary?.reconciled_amount || 0).toLocaleString('en-IN', { + minimumFractionDigits: 2 + })), /*#__PURE__*/React.createElement("small", { + className: "text-success" + }, bankAuditData?.summary?.reconciled_count || 0, " Bills Matched with Bank"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-4 col-sm-6" + }, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 border-start border-4 border-warning shadow-sm" + }, /*#__PURE__*/React.createElement("small", { + className: "text-warning fw-bold" + }, "PENDING AUDIT VERIFICATION"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bolder text-warning mt-1" + }, "₹", Number(bankAuditData?.summary?.pending_amount || 0).toLocaleString('en-IN', { + minimumFractionDigits: 2 + })), /*#__PURE__*/React.createElement("small", { + className: "text-warning" + }, bankAuditData?.summary?.pending_count || 0, " Bills Unverified")))), /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "row g-2 align-items-center" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-5" + }, /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm" + }, /*#__PURE__*/React.createElement("button", { + className: `btn ${auditFilterStatus === 'all' ? 'btn-primary' : 'btn-outline-secondary'}`, + onClick: () => { + setAuditFilterStatus('all'); + loadBankAudit('all', auditSearch); + } + }, "All (", bankAuditData?.summary?.total_count || 0, ")"), /*#__PURE__*/React.createElement("button", { + className: `btn ${auditFilterStatus === 'pending' ? 'btn-warning text-dark fw-bold' : 'btn-outline-secondary'}`, + onClick: () => { + setAuditFilterStatus('pending'); + loadBankAudit('pending', auditSearch); + } + }, "Pending Verification (", bankAuditData?.summary?.pending_count || 0, ")"), /*#__PURE__*/React.createElement("button", { + className: `btn ${auditFilterStatus === 'reconciled' ? 'btn-success fw-bold' : 'btn-outline-secondary'}`, + onClick: () => { + setAuditFilterStatus('reconciled'); + loadBankAudit('reconciled', auditSearch); + } + }, "Reconciled (", bankAuditData?.summary?.reconciled_count || 0, ")"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control", + placeholder: "Search by Bill No, UTR / UPI Ref...", + value: auditSearch, + onChange: e => { + setAuditSearch(e.target.value); + loadBankAudit(auditFilterStatus, e.target.value); + } + }))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3 text-end d-flex gap-1.5 justify-content-end" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-dark", + onClick: printBankAudit + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer me-1" + }), " Print"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-success", + onClick: exportBankCsv + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-excel me-1" + }), " Export CSV")))), /*#__PURE__*/React.createElement("div", { + className: "counter-card p-0 overflow-hidden shadow-sm" + }, /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-pos mb-0" + }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "Invoice No"), /*#__PURE__*/React.createElement("th", null, "Date & Time"), /*#__PURE__*/React.createElement("th", null, "Patient"), /*#__PURE__*/React.createElement("th", null, "Mode"), /*#__PURE__*/React.createElement("th", null, "Bill Total"), /*#__PURE__*/React.createElement("th", null, "Bank / UTR Reference"), /*#__PURE__*/React.createElement("th", null, "Audit Status"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Action"))), /*#__PURE__*/React.createElement("tbody", null, (() => { + const txns = bankAuditData?.transactions || bankAuditData?.records || []; + if (!bankAuditData) { + return /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "8", + className: "text-center py-4 text-muted" + }, /*#__PURE__*/React.createElement("div", { + className: "spinner-border spinner-border-sm text-primary me-2" + }), "Loading bank audit records...")); + } + if (txns.length === 0) { + return /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "8", + className: "text-center py-4 text-muted" + }, "No transactions found matching the filter.")); + } + return txns.map(t => /*#__PURE__*/React.createElement("tr", { + key: t.sale_id, + className: t.is_reconciled == 1 ? 'bg-success-subtle' : '' + }, /*#__PURE__*/React.createElement("td", { + className: "fw-bold" + }, t.invoice_no), /*#__PURE__*/React.createElement("td", null, t.sale_date), /*#__PURE__*/React.createElement("td", null, t.patient_name), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary" + }, t.payment_mode)), /*#__PURE__*/React.createElement("td", { + className: "fw-bold text-primary" + }, "₹", t.net_amount), /*#__PURE__*/React.createElement("td", null, t.upi_ref_no ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-info text-dark" + }, "UPI"), " ", /*#__PURE__*/React.createElement("code", null, t.upi_ref_no)) : t.card_ref_no ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary" + }, "CARD"), " ", /*#__PURE__*/React.createElement("code", null, t.card_ref_no)) : /*#__PURE__*/React.createElement("span", { + className: "text-muted" + }, "Direct QR")), /*#__PURE__*/React.createElement("td", null, t.is_reconciled == 1 ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-success" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle me-1" + }), " Reconciled"), /*#__PURE__*/React.createElement("div", { + className: "small text-muted mt-0.5" + }, t.reconciled_by, " • ", t.reconciled_at?.split(' ')[0])) : /*#__PURE__*/React.createElement("span", { + className: "badge bg-warning text-dark" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clock me-1" + }), " Pending Statement")), /*#__PURE__*/React.createElement("td", { + className: "text-end" + }, t.is_reconciled == 1 ? /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-danger py-0.5 px-2", + style: { + fontSize: '0.75rem' + }, + onClick: () => handleReconcileSubmit(t.sale_id, 0) + }, "Un-reconcile") : /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-success py-0.5 px-2.5 fw-bold", + style: { + fontSize: '0.75rem' + }, + onClick: () => { + setReconcilingSale(t); + setAuditNotes(''); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check2-circle me-1" + }), " Verify Entry")))); + })())))), reconcilingSale && /*#__PURE__*/React.createElement("div", { + className: "modal show d-block", + tabIndex: "-1", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.7)' + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content shadow-lg border-0" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2.5 px-3" + }, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold mb-0" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-bank me-2 text-primary" + }), " Reconcile Bank / UPI Statement"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setReconcilingSale(null) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3" + }, /*#__PURE__*/React.createElement("div", { + className: "card bg-light border p-2.5 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-1" + }, /*#__PURE__*/React.createElement("span", { + className: "text-muted" + }, "Invoice No:"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-dark" + }, reconcilingSale.invoice_no)), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-1" + }, /*#__PURE__*/React.createElement("span", { + className: "text-muted" + }, "Amount:"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-success fs-6" + }, "₹", reconcilingSale.net_amount)), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-1" + }, /*#__PURE__*/React.createElement("span", { + className: "text-muted" + }, "Recorded Ref / UTR:"), /*#__PURE__*/React.createElement("code", null, reconcilingSale.upi_ref_no || reconcilingSale.card_ref_no || 'Direct Store QR'))), /*#__PURE__*/React.createElement("div", { + className: "mb-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Audited By (Accountant / User)"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: auditorName, + onChange: e => setAuditorName(e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Accountant Statement Audit Note"), /*#__PURE__*/React.createElement("textarea", { + className: "form-control form-control-sm", + rows: "2", + value: auditNotes, + onChange: e => setAuditNotes(e.target.value), + placeholder: "e.g. Matched in Bank A/c statement entry on 08-Sep-2026, Credit Ref verified" + }))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer py-2 px-3 bg-light" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-secondary", + onClick: () => setReconcilingSale(null) + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-success fw-bold", + onClick: () => handleReconcileSubmit(reconcilingSale.sale_id, 1), + disabled: isSubmittingAudit + }, isSubmittingAudit ? 'Saving...' : 'Mark Verified with Statement')))))), accTab === 'gst' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap align-items-center justify-content-between gap-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("label", { + className: "small fw-bold text-dark mb-0" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-calendar-month text-primary me-1" + }), " Return Filing Month:"), /*#__PURE__*/React.createElement("input", { + type: "month", + className: "form-control form-control-sm", + value: gstMonth, + onChange: e => { + setGstMonth(e.target.value); + loadGst(e.target.value); + } + }), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-primary px-3 fw-bold", + onClick: () => loadGst(gstMonth), + disabled: loadingGst + }, loadingGst ? 'Loading...' : 'Refresh')), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-success px-3 fw-bold d-flex align-items-center gap-1.5", + onClick: exportGstCsv + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-excel" + }), " Export GSTR-1 Excel / CSV")))), gstData && /*#__PURE__*/React.createElement("div", { + className: "counter-card mb-3 shadow-sm" + }, /*#__PURE__*/React.createElement("div", { + className: "p-3 border-bottom d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold mb-0" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-spreadsheet text-primary me-1" + }), " GSTR-1 Outward Sales Summary (HSN-wise) for ", gstMonth), /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary" + }, "GSTIN: ", store.gst_no || 'N/A')), /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-pos mb-0" + }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "HSN Code"), /*#__PURE__*/React.createElement("th", null, "GST Slab"), /*#__PURE__*/React.createElement("th", null, "Taxable Value (₹)"), /*#__PURE__*/React.createElement("th", null, "CGST (₹)"), /*#__PURE__*/React.createElement("th", null, "SGST (₹)"), /*#__PURE__*/React.createElement("th", null, "IGST (₹)"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Total Invoice Value (₹)"))), /*#__PURE__*/React.createElement("tbody", null, gstData.gstr1_sales.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "7", + className: "text-center py-4 text-muted" + }, "No sales recorded for GST filing in month ", gstMonth, ".")) : gstData.gstr1_sales.map((g, i) => /*#__PURE__*/React.createElement("tr", { + key: i + }, /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("code", null, g.hsn_code)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary" + }, g.gst_rate, "%")), /*#__PURE__*/React.createElement("td", null, "₹", Number(g.taxable_val).toFixed(2)), /*#__PURE__*/React.createElement("td", null, "₹", Number(g.cgst_val).toFixed(2)), /*#__PURE__*/React.createElement("td", null, "₹", Number(g.sgst_val).toFixed(2)), /*#__PURE__*/React.createElement("td", null, "₹", Number(g.igst_val).toFixed(2)), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold" + }, "₹", Number(g.total_val).toFixed(2))))))))), accTab === 'schedule_h1' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap align-items-center justify-content-between gap-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2 flex-wrap" + }, /*#__PURE__*/React.createElement("span", { + className: "small fw-bold text-dark" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-funnel text-success me-1" + }), " Date Filter:"), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-1" + }, /*#__PURE__*/React.createElement("input", { + type: "date", + className: "form-control form-control-sm", + value: h1FromDate, + onChange: e => setH1FromDate(e.target.value) + }), /*#__PURE__*/React.createElement("span", null, "to"), /*#__PURE__*/React.createElement("input", { + type: "date", + className: "form-control form-control-sm", + value: h1ToDate, + onChange: e => setH1ToDate(e.target.value) + })), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-primary fw-bold", + onClick: () => loadScheduleH1(h1FromDate, h1ToDate, h1Search), + disabled: loadingH1 + }, loadingH1 ? 'Loading...' : 'Filter')), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "Search medicine or doctor...", + value: h1Search, + onChange: e => { + setH1Search(e.target.value); + loadScheduleH1(h1FromDate, h1ToDate, e.target.value); + } + }), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-dark", + onClick: printH1Register + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer me-1" + }), " Print"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-success", + onClick: exportH1Csv + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-excel me-1" + }), " Export CSV")))), /*#__PURE__*/React.createElement("div", { + className: "counter-card shadow-sm" + }, /*#__PURE__*/React.createElement("div", { + className: "p-3 border-bottom d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold mb-0" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-check text-success me-1" + }), " Statutory Schedule H1 Drug Register"), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "Mandatory under Indian Drugs & Cosmetics Rules (4th Amendment 2013). Retain for 3 years.")), /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger-subtle text-danger border border-danger" + }, h1Records.length, " Dispensed Entries")), /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-pos table-bordered mb-0" + }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "Date"), /*#__PURE__*/React.createElement("th", null, "Bill No"), /*#__PURE__*/React.createElement("th", null, "Patient Name & Address"), /*#__PURE__*/React.createElement("th", null, "Prescribing Doctor & Reg No"), /*#__PURE__*/React.createElement("th", null, "Medicine Name"), /*#__PURE__*/React.createElement("th", null, "Batch No"), /*#__PURE__*/React.createElement("th", null, "Qty Supplied"))), /*#__PURE__*/React.createElement("tbody", null, h1Records.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "7", + className: "text-center py-4 text-muted" + }, "No Schedule H1 medicines dispensed in this period.")) : h1Records.map((h, i) => /*#__PURE__*/React.createElement("tr", { + key: i + }, /*#__PURE__*/React.createElement("td", null, h.sale_date?.split(' ')[0]), /*#__PURE__*/React.createElement("td", { + className: "fw-bold" + }, h.invoice_no), /*#__PURE__*/React.createElement("td", null, h.patient_name, " ", h.patient_address ? `(${h.patient_address})` : ''), /*#__PURE__*/React.createElement("td", null, h.doctor_name, " ", h.doctor_reg_no ? `(Reg: ${h.doctor_reg_no})` : ''), /*#__PURE__*/React.createElement("td", { + className: "fw-bold text-danger" + }, h.item_name), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("code", null, h.batch_no)), /*#__PURE__*/React.createElement("td", { + className: "fw-bold" + }, h.qty)))))))), accTab === 'credit_accounts' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "row g-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-4 col-sm-6" + }, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 border-start border-4 border-primary shadow-sm" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-bold" + }, "TOTAL REGISTERED ACCOUNTS"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bolder text-dark mt-1" + }, creditAccounts.length, " Accounts"), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "Staff, Doctors, Institutional & Patients"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-4 col-sm-6" + }, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 border-start border-4 border-danger shadow-sm" + }, /*#__PURE__*/React.createElement("small", { + className: "text-danger fw-bold" + }, "TOTAL OUTSTANDING DUES"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bolder text-danger mt-1" + }, "₹", totalOutstandingCredit.toLocaleString('en-IN', { + minimumFractionDigits: 2 + })), /*#__PURE__*/React.createElement("small", { + className: "text-danger" + }, "Unsettled Pharmacy Debits"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-4 col-sm-6" + }, /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 border-start border-4 border-success shadow-sm" + }, /*#__PURE__*/React.createElement("small", { + className: "text-success fw-bold" + }, "TOTAL CREDIT LIMIT SANCTIONED"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bolder text-success mt-1" + }, "₹", creditAccounts.reduce((sum, a) => sum + Number(a.credit_limit || 0), 0).toLocaleString('en-IN', { + minimumFractionDigits: 2 + })), /*#__PURE__*/React.createElement("small", { + className: "text-success" + }, "Authorized Spending Cap")))), /*#__PURE__*/React.createElement("div", { + className: "counter-card p-3 mb-3 shadow-sm" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap align-items-center justify-content-between gap-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2 flex-grow-1", + style: { + maxWidth: 420 + } + }, /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control", + placeholder: "Search by name, phone, dept, staff ID...", + value: creditSearch, + onChange: e => setCreditSearch(e.target.value) + }))), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-primary px-3 py-1.5 fw-bold shadow-sm d-flex align-items-center gap-1.5", + onClick: () => setShowAddAccountModal(true) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-plus-fill" + }), " New Credit Account")))), /*#__PURE__*/React.createElement("div", { + className: "counter-card p-0 overflow-hidden shadow-sm" + }, /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-pos mb-0" + }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "Account / Person Name"), /*#__PURE__*/React.createElement("th", null, "Account Type"), /*#__PURE__*/React.createElement("th", null, "Dept / Staff ID"), /*#__PURE__*/React.createElement("th", null, "Phone"), /*#__PURE__*/React.createElement("th", null, "Credit Limit"), /*#__PURE__*/React.createElement("th", null, "Current Balance"), /*#__PURE__*/React.createElement("th", null, "Status"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Actions"))), /*#__PURE__*/React.createElement("tbody", null, loadingCredit ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "8", + className: "text-center py-4 text-muted" + }, "Loading credit accounts...")) : filteredCreditAccounts.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "8", + className: "text-center py-4 text-muted" + }, "No credit accounts found. Click \"New Credit Account\" to create one.")) : filteredCreditAccounts.map(acc => { + const typeColor = acc.account_type === 'staff' ? 'primary' : acc.account_type === 'doctor' ? 'success' : acc.account_type === 'corporate' ? 'dark' : 'warning'; + const bal = Number(acc.current_balance || 0); + return /*#__PURE__*/React.createElement("tr", { + key: acc.account_id + }, /*#__PURE__*/React.createElement("td", { + className: "fw-bold text-dark" + }, acc.account_name, acc.remarks && /*#__PURE__*/React.createElement("small", { + className: "d-block text-muted" + }, acc.remarks)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: `badge bg-${typeColor}-subtle text-${typeColor} border border-${typeColor} text-uppercase px-2`, + style: { + fontSize: '0.65rem' + } + }, acc.account_type)), /*#__PURE__*/React.createElement("td", null, acc.department || acc.staff_id || '-'), /*#__PURE__*/React.createElement("td", null, acc.phone || '-'), /*#__PURE__*/React.createElement("td", { + className: "fw-bold" + }, "₹", Number(acc.credit_limit || 0).toLocaleString('en-IN')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: `fw-bold fs-6 ${bal > 0 ? 'text-danger' : 'text-success'}` + }, "₹", bal.toLocaleString('en-IN', { + minimumFractionDigits: 2 + }))), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: `badge ${acc.is_active == 1 ? 'bg-success' : 'bg-secondary'}` + }, acc.is_active == 1 ? 'ACTIVE' : 'INACTIVE')), /*#__PURE__*/React.createElement("td", { + className: "text-end" + }, /*#__PURE__*/React.createElement("div", { + className: "btn-group btn-group-sm" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-outline-primary py-0.5 px-2", + style: { + fontSize: '0.75rem' + }, + onClick: () => openAccountLedger(acc) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-journal-text me-1" + }), " Ledger"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-outline-success py-0.5 px-2 fw-bold", + style: { + fontSize: '0.75rem' + }, + onClick: () => openSettlePaymentModal(acc) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cash-coin me-1" + }), " Settle")))); + }))))), showAddAccountModal && /*#__PURE__*/React.createElement("div", { + className: "modal show d-block", + tabIndex: "-1", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.7)' + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content shadow-lg border-0" + }, /*#__PURE__*/React.createElement("form", { + onSubmit: handleSaveCreditAccount + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2.5 px-3" + }, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold mb-0" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-plus-fill text-primary me-2" + }), " Create Credit Account"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setShowAddAccountModal(false) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3" + }, /*#__PURE__*/React.createElement("div", { + className: "row g-3 mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Account Type"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: accFormType, + onChange: e => setAccFormType(e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "staff" + }, "Staff Member"), /*#__PURE__*/React.createElement("option", { + value: "doctor" + }, "Consultant / Doctor"), /*#__PURE__*/React.createElement("option", { + value: "corporate" + }, "Hospital Trust / Corporate"), /*#__PURE__*/React.createElement("option", { + value: "customer" + }, "Regular Customer / VIP"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Credit Limit (₹)"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm", + value: accFormLimit, + onChange: e => setAccFormLimit(e.target.value), + placeholder: "5000" + }))), /*#__PURE__*/React.createElement("div", { + className: "mb-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Person / Organization Name ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + required: true, + value: accFormName, + onChange: e => setAccFormName(e.target.value), + placeholder: "e.g. Dr. Rajesh Sharma / Sister Sunita" + })), /*#__PURE__*/React.createElement("div", { + className: "row g-3 mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Phone Number"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: accFormPhone, + onChange: e => setAccFormPhone(e.target.value), + placeholder: "e.g. 9876543210" + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Staff ID / Employee Code"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: accFormStaffId, + onChange: e => setAccFormStaffId(e.target.value), + placeholder: "e.g. EMP-1042" + }))), /*#__PURE__*/React.createElement("div", { + className: "mb-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Department"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: accFormDept, + onChange: e => setAccFormDept(e.target.value), + placeholder: "e.g. ICU Nursing / General Surgery / Administration" + })), /*#__PURE__*/React.createElement("div", { + className: "mb-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Remarks / Terms"), /*#__PURE__*/React.createElement("textarea", { + className: "form-control form-control-sm", + rows: "2", + value: accFormRemarks, + onChange: e => setAccFormRemarks(e.target.value), + placeholder: "e.g. Deducted monthly from hospital payroll or settled at month end" + }))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer py-2 px-3 bg-light" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-secondary", + onClick: () => setShowAddAccountModal(false) + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + type: "submit", + className: "btn btn-sm btn-primary fw-bold", + disabled: isSavingAccount + }, isSavingAccount ? 'Creating...' : 'Create Account')))))), selectedCreditAcc && creditLedgerData && /*#__PURE__*/React.createElement("div", { + className: "modal show d-block", + tabIndex: "-1", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.7)' + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered modal-xl" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content shadow-lg border-0" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2.5 px-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-journal-text text-primary fs-5" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold mb-0" + }, selectedCreditAcc.account_name, " — Credit Statement"), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, selectedCreditAcc.account_type.toUpperCase(), " • ", selectedCreditAcc.department || 'General'))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => { + setSelectedCreditAcc(null); + setCreditLedgerData(null); + } + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3" + }, /*#__PURE__*/React.createElement("div", { + className: "card p-3 mb-3 bg-light border" + }, /*#__PURE__*/React.createElement("div", { + className: "row g-2 align-items-center" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-bold" + }, "CREDIT LIMIT"), /*#__PURE__*/React.createElement("h5", { + className: "fw-bold mb-0" + }, "₹", Number(selectedCreditAcc.credit_limit || 0).toLocaleString('en-IN'))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("small", { + className: "text-danger fw-bold" + }, "OUTSTANDING BALANCE"), /*#__PURE__*/React.createElement("h4", { + className: "fw-bold text-danger mb-0" + }, "₹", Number(selectedCreditAcc.current_balance || 0).toLocaleString('en-IN', { + minimumFractionDigits: 2 + }))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3" + }, /*#__PURE__*/React.createElement("small", { + className: "text-success fw-bold" + }, "AVAILABLE CREDIT"), /*#__PURE__*/React.createElement("h5", { + className: "fw-bold text-success mb-0" + }, "₹", Math.max(0, Number(selectedCreditAcc.credit_limit || 0) - Number(selectedCreditAcc.current_balance || 0)).toLocaleString('en-IN'))), /*#__PURE__*/React.createElement("div", { + className: "col-md-3 text-end" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-success fw-bold px-3 py-1.5 shadow-sm me-2", + onClick: () => openSettlePaymentModal(selectedCreditAcc) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cash-stack me-1" + }), " Settle Payment"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-dark px-2.5 py-1.5", + onClick: printAccountLedger, + title: "Print Account Statement" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-printer" + }))))), /*#__PURE__*/React.createElement("div", { + className: "table-responsive", + style: { + maxHeight: 380, + overflowY: 'auto' + } + }, /*#__PURE__*/React.createElement("table", { + className: "table table-pos table-bordered mb-0" + }, /*#__PURE__*/React.createElement("thead", { + className: "table-dark sticky-top" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "Timestamp"), /*#__PURE__*/React.createElement("th", null, "Type"), /*#__PURE__*/React.createElement("th", null, "Invoice / Receipt Ref"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Debit (Bills)"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Credit (Payments)"), /*#__PURE__*/React.createElement("th", { + className: "text-end" + }, "Running Balance"), /*#__PURE__*/React.createElement("th", null, "Mode"), /*#__PURE__*/React.createElement("th", null, "Recorded By / Notes"))), /*#__PURE__*/React.createElement("tbody", null, creditLedgerData.entries.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "8", + className: "text-center py-4 text-muted" + }, "No transactions on this account yet.")) : creditLedgerData.entries.map(ent => /*#__PURE__*/React.createElement("tr", { + key: ent.ledger_id + }, /*#__PURE__*/React.createElement("td", null, ent.created_at), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: `badge ${ent.entry_type === 'DEBIT' ? 'bg-danger' : 'bg-success'}` + }, ent.entry_type)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("strong", null, ent.invoice_no || ent.payment_ref || '-')), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold text-danger" + }, Number(ent.debit_amount) > 0 ? '₹' + Number(ent.debit_amount).toFixed(2) : '-'), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold text-success" + }, Number(ent.credit_amount) > 0 ? '₹' + Number(ent.credit_amount).toFixed(2) : '-'), /*#__PURE__*/React.createElement("td", { + className: "text-end fw-bold" + }, "₹", Number(ent.balance_after).toFixed(2)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary" + }, ent.payment_mode)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, ent.remarks || 'Bill Charge', " (", ent.recorded_by_name || 'System', ")")))))))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer py-2 px-3 bg-light" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-secondary", + onClick: () => { + setSelectedCreditAcc(null); + setCreditLedgerData(null); + } + }, "Close Statement"))))), showPaymentModal && selectedCreditAcc && /*#__PURE__*/React.createElement("div", { + className: "modal show d-block", + tabIndex: "-1", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.7)' + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content shadow-lg border-0" + }, /*#__PURE__*/React.createElement("form", { + onSubmit: handleRecordPayment + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2.5 px-3" + }, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold mb-0" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cash-coin text-success me-2" + }), " Record Credit Settlement Payment"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setShowPaymentModal(false) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3" + }, /*#__PURE__*/React.createElement("div", { + className: "card bg-light border p-2.5 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between mb-1" + }, /*#__PURE__*/React.createElement("span", { + className: "text-muted" + }, "Account:"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-dark" + }, selectedCreditAcc.account_name)), /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between" + }, /*#__PURE__*/React.createElement("span", { + className: "text-muted" + }, "Total Outstanding Due:"), /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-danger fs-6" + }, "₹", Number(selectedCreditAcc.current_balance || 0).toFixed(2)))), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Settlement Amount Received (₹) ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light fw-bold" + }, "₹"), /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.01", + className: "form-control form-control-sm fs-6 fw-bold text-success", + required: true, + value: payAmount, + onChange: e => setPayAmount(e.target.value), + placeholder: "Enter amount" + }), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-outline-secondary", + onClick: () => setPayAmount(String(selectedCreditAcc.current_balance)) + }, "Full Pay"))), /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Payment Method"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: payMode, + onChange: e => setPayMode(e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "Cash" + }, "Cash in Drawer"), /*#__PURE__*/React.createElement("option", { + value: "UPI" + }, "UPI / QR Code"), /*#__PURE__*/React.createElement("option", { + value: "Bank" + }, "Direct Bank Transfer / NEFT"), /*#__PURE__*/React.createElement("option", { + value: "Salary_Deduction" + }, "Payroll / Salary Deduction"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Receipt / UTR / Ref No"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: payRef, + onChange: e => setPayRef(e.target.value), + placeholder: "e.g. UTR-991823" + }))), /*#__PURE__*/React.createElement("div", { + className: "mb-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Remarks / Receipt Note"), /*#__PURE__*/React.createElement("textarea", { + className: "form-control form-control-sm", + rows: "2", + value: payRemarks, + onChange: e => setPayRemarks(e.target.value), + placeholder: "e.g. Cash received at pharmacy counter by cashier" + }))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer py-2 px-3 bg-light" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-secondary", + onClick: () => setShowPaymentModal(false) + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + type: "submit", + className: "btn btn-sm btn-success fw-bold", + disabled: isRecordingPayment + }, isRecordingPayment ? 'Recording...' : 'Confirm Payment & Update Balance')))))))); } function StaffManagementView({ store, @@ -18295,529 +14432,417 @@ function StaffManagementView({ setIsSaving(false); } }; - return /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap align-items-center justify-content-between gap-3 mb-4 pb-3 border-bottom", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("h5", { - className: "fw-bolder text-dark mb-1 d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-lock-fill text-primary" - }), " Medical Store Staff & 6-Tier Permission Matrix"] - }), /*#__PURE__*/_jsxs("p", { - className: "text-muted small mb-0", - children: ["Manage pharmacy staff credentials, cashier PINs, and granular audit/sale/purchase rights for ", /*#__PURE__*/_jsx("strong", { - children: store.store_name - })] - })] - }), /*#__PURE__*/_jsx("div", { - className: "d-flex align-items-center gap-2", - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-primary px-3 py-2 fw-bold shadow-sm d-flex align-items-center gap-1.5", - onClick: openAddModal, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-plus-fill" - }), " Add Staff Member"] - }) - })] - }), /*#__PURE__*/_jsx("div", { - className: "row g-3", - children: loading ? /*#__PURE__*/_jsxs("div", { - className: "col-12 text-center py-5 text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hourglass-split fs-3 d-block mb-2 text-primary" - }), " Loading staff profiles..."] - }) : staffList.length === 0 ? /*#__PURE__*/_jsxs("div", { - className: "col-12 text-center py-5 text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-people fs-3 d-block mb-1 text-secondary" - }), "No staff members assigned to this store yet. Click \"Add Staff Member\" to get started."] - }) : staffList.map(user => { - const isCurrent = activeOperator?.user_id == user.user_id; - const roleColor = user.user_role === 'store_manager' ? 'primary' : user.user_role === 'pharmacist' ? 'success' : user.user_role === 'auditor' ? 'info' : user.user_role === 'cashier' ? 'warning' : 'secondary'; - let perms = {}; - try { - perms = typeof user.permissions === 'string' ? JSON.parse(user.permissions || '{}') : user.permissions || {}; - } catch (e) { - perms = {}; - } - return /*#__PURE__*/_jsx("div", { - className: "col-md-6 col-lg-4", - children: /*#__PURE__*/_jsxs("div", { - className: `counter-card p-3 h-100 position-relative border-start border-4 border-${roleColor} shadow-sm`, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-start justify-content-between gap-2 mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("div", { - className: `rounded-circle bg-${roleColor}-subtle text-${roleColor} fw-bold d-flex align-items-center justify-content-center`, - style: { - width: 42, - height: 42, - fontSize: '1rem' - }, - children: user.full_name ? user.full_name[0] : 'U' - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "fw-bold text-dark mb-0", - children: user.full_name - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: ["@", user.username] - })] - })] - }), /*#__PURE__*/_jsx("span", { - className: `badge bg-${roleColor}-subtle text-${roleColor} border border-${roleColor} text-uppercase px-2 py-1`, - style: { - fontSize: '0.65rem' - }, - children: user.user_role ? user.user_role.replace(/_/g, ' ') : 'STAFF' - })] - }), /*#__PURE__*/_jsxs("div", { - className: "small text-muted mb-2.5 d-flex flex-column gap-1", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-telephone me-1.5 text-secondary" - }), " ", user.phone || 'No phone set'] - }), user.pharmacist_reg_no ? /*#__PURE__*/_jsxs("div", { - className: "text-truncate", - title: user.pharmacist_reg_no, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-medical me-1.5 text-success" - }), " Reg: ", /*#__PURE__*/_jsx("strong", { - children: user.pharmacist_reg_no - })] - }) : null] - }), /*#__PURE__*/_jsxs("div", { - className: "p-2 bg-light rounded-2 mb-3 border", - children: [/*#__PURE__*/_jsx("div", { - className: "text-muted fw-bold mb-1", - style: { - fontSize: '0.68rem', - textTransform: 'uppercase' - }, - children: "Assigned Rights" - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap gap-1", - children: [/*#__PURE__*/_jsx("span", { - className: `badge ${perms.admin ? 'bg-danger text-white' : 'bg-secondary-subtle text-muted text-decoration-line-through'}`, - style: { - fontSize: '0.62rem' - }, - children: "Admin" - }), /*#__PURE__*/_jsx("span", { - className: `badge ${perms.sale ? 'bg-primary text-white' : 'bg-secondary-subtle text-muted text-decoration-line-through'}`, - style: { - fontSize: '0.62rem' - }, - children: "Sale" - }), /*#__PURE__*/_jsx("span", { - className: `badge ${perms.purchase ? 'bg-success text-white' : 'bg-secondary-subtle text-muted text-decoration-line-through'}`, - style: { - fontSize: '0.62rem' - }, - children: "Purchase" - }), /*#__PURE__*/_jsx("span", { - className: `badge ${perms.sale_edit_after_1h ? 'bg-warning text-dark' : 'bg-secondary-subtle text-muted text-decoration-line-through'}`, - style: { - fontSize: '0.62rem' - }, - title: "Can edit sale bill after 1 hour", - children: "Sale Edit >1h" - }), /*#__PURE__*/_jsx("span", { - className: `badge ${perms.purchase_edit_verified ? 'bg-warning text-dark' : 'bg-secondary-subtle text-muted text-decoration-line-through'}`, - style: { - fontSize: '0.62rem' - }, - title: "Can edit verified purchase challan", - children: "Purch Edit Verif" - }), /*#__PURE__*/_jsx("span", { - className: `badge ${perms.bank_upi_audit ? 'bg-info text-dark' : 'bg-secondary-subtle text-muted text-decoration-line-through'}`, - style: { - fontSize: '0.62rem' - }, - children: "Bank Audit" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-between pt-2 border-top", - children: [/*#__PURE__*/_jsx("div", { - children: isCurrent ? /*#__PURE__*/_jsxs("span", { - className: "badge bg-success-subtle text-success border border-success px-2 py-1", - style: { - fontSize: '0.7rem' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-check-fill me-1" - }), " Active Cashier"] - }) : /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-secondary py-0.5 px-2", - style: { - fontSize: '0.72rem' - }, - onClick: () => onSelectOperator && onSelectOperator(user), - title: "Switch active counter login to this user", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-left-right me-1" - }), " Switch To"] - }) - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-outline-primary py-0.5 px-2", - style: { - fontSize: '0.72rem' - }, - onClick: () => openEditModal(user), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-pencil-square me-1" - }), " Edit & Rights"] - })] - })] - }) - }, user.user_id); - }) - }), showEditModal && /*#__PURE__*/_jsx("div", { - className: "modal show d-block", - tabIndex: "-1", + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap align-items-center justify-content-between gap-3 mb-4 pb-3 border-bottom" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h5", { + className: "fw-bolder text-dark mb-1 d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-lock-fill text-primary" + }), " Medical Store Staff & 6-Tier Permission Matrix"), /*#__PURE__*/React.createElement("p", { + className: "text-muted small mb-0" + }, "Manage pharmacy staff credentials, cashier PINs, and granular audit/sale/purchase rights for ", /*#__PURE__*/React.createElement("strong", null, store.store_name))), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-primary px-3 py-2 fw-bold shadow-sm d-flex align-items-center gap-1.5", + onClick: openAddModal + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-plus-fill" + }), " Add Staff Member"))), /*#__PURE__*/React.createElement("div", { + className: "row g-3" + }, loading ? /*#__PURE__*/React.createElement("div", { + className: "col-12 text-center py-5 text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hourglass-split fs-3 d-block mb-2 text-primary" + }), " Loading staff profiles...") : staffList.length === 0 ? /*#__PURE__*/React.createElement("div", { + className: "col-12 text-center py-5 text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-people fs-3 d-block mb-1 text-secondary" + }), "No staff members assigned to this store yet. Click \"Add Staff Member\" to get started.") : staffList.map(user => { + const isCurrent = activeOperator?.user_id == user.user_id; + const roleColor = user.user_role === 'store_manager' ? 'primary' : user.user_role === 'pharmacist' ? 'success' : user.user_role === 'auditor' ? 'info' : user.user_role === 'cashier' ? 'warning' : 'secondary'; + let perms = {}; + try { + perms = typeof user.permissions === 'string' ? JSON.parse(user.permissions || '{}') : user.permissions || {}; + } catch (e) { + perms = {}; + } + return /*#__PURE__*/React.createElement("div", { + className: "col-md-6 col-lg-4", + key: user.user_id + }, /*#__PURE__*/React.createElement("div", { + className: `counter-card p-3 h-100 position-relative border-start border-4 border-${roleColor} shadow-sm` + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-start justify-content-between gap-2 mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: `rounded-circle bg-${roleColor}-subtle text-${roleColor} fw-bold d-flex align-items-center justify-content-center`, style: { - backgroundColor: 'rgba(15, 23, 42, 0.7)' + width: 42, + height: 42, + fontSize: '1rem' + } + }, user.full_name ? user.full_name[0] : 'U'), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold text-dark mb-0" + }, user.full_name), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "@", user.username))), /*#__PURE__*/React.createElement("span", { + className: `badge bg-${roleColor}-subtle text-${roleColor} border border-${roleColor} text-uppercase px-2 py-1`, + style: { + fontSize: '0.65rem' + } + }, user.user_role ? user.user_role.replace(/_/g, ' ') : 'STAFF')), /*#__PURE__*/React.createElement("div", { + className: "small text-muted mb-2.5 d-flex flex-column gap-1" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-telephone me-1.5 text-secondary" + }), " ", user.phone || 'No phone set'), user.pharmacist_reg_no ? /*#__PURE__*/React.createElement("div", { + className: "text-truncate", + title: user.pharmacist_reg_no + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-medical me-1.5 text-success" + }), " Reg: ", /*#__PURE__*/React.createElement("strong", null, user.pharmacist_reg_no)) : null), /*#__PURE__*/React.createElement("div", { + className: "p-2 bg-light rounded-2 mb-3 border" + }, /*#__PURE__*/React.createElement("div", { + className: "text-muted fw-bold mb-1", + style: { + fontSize: '0.68rem', + textTransform: 'uppercase' + } + }, "Assigned Rights"), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap gap-1" + }, /*#__PURE__*/React.createElement("span", { + className: `badge ${perms.admin ? 'bg-danger text-white' : 'bg-secondary-subtle text-muted text-decoration-line-through'}`, + style: { + fontSize: '0.62rem' + } + }, "Admin"), /*#__PURE__*/React.createElement("span", { + className: `badge ${perms.sale ? 'bg-primary text-white' : 'bg-secondary-subtle text-muted text-decoration-line-through'}`, + style: { + fontSize: '0.62rem' + } + }, "Sale"), /*#__PURE__*/React.createElement("span", { + className: `badge ${perms.purchase ? 'bg-success text-white' : 'bg-secondary-subtle text-muted text-decoration-line-through'}`, + style: { + fontSize: '0.62rem' + } + }, "Purchase"), /*#__PURE__*/React.createElement("span", { + className: `badge ${perms.sale_edit_after_1h ? 'bg-warning text-dark' : 'bg-secondary-subtle text-muted text-decoration-line-through'}`, + style: { + fontSize: '0.62rem' }, - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered modal-lg", - children: /*#__PURE__*/_jsx("div", { - className: "modal-content shadow-lg border-0", - children: /*#__PURE__*/_jsxs("form", { - onSubmit: handleSaveStaff, - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2.5 px-3", - children: [/*#__PURE__*/_jsxs("h6", { - className: "modal-title fw-bold mb-0", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-badge-fill text-primary me-2" - }), editingUser ? 'Edit Staff Profile & Permissions' : 'Register New Staff Member'] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setShowEditModal(false) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "row g-3 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-1", - children: ["Full Name ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - required: true, - value: formFullName, - onChange: e => setFormFullName(e.target.value), - placeholder: "e.g. Rahul Sharma" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-1", - children: ["Username (Login ID) ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - required: true, - value: formUsername, - onChange: e => setFormUsername(e.target.value), - placeholder: "e.g. rahul_pharma" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-3 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Role" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: formRole, - onChange: e => applyRoleDefaults(e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "store_manager", - children: "Store Manager (Admin)" - }), /*#__PURE__*/_jsx("option", { - value: "pharmacist", - children: "Pharmacist" - }), /*#__PURE__*/_jsx("option", { - value: "cashier", - children: "Cashier" - }), /*#__PURE__*/_jsx("option", { - value: "auditor", - children: "Auditor / Accountant" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: editingUser ? 'Reset Quick PIN (4 Digits)' : 'Quick Login PIN (4 Digits)' - }), /*#__PURE__*/_jsx("input", { - type: "password", - maxLength: "6", - className: "form-control form-control-sm", - value: formPinCode, - onChange: e => setFormPinCode(e.target.value), - placeholder: editingUser ? 'Leave blank to keep current PIN' : 'e.g. 1234' - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Phone Number" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: formPhone, - onChange: e => setFormPhone(e.target.value), - placeholder: "e.g. 9876543210" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-3 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Pharmacy State Reg No" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: formRegNo, - onChange: e => setFormRegNo(e.target.value), - placeholder: "e.g. PB-PH-99214" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "ABDM Healthcare Professional Registry (HPR) ID" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - value: formHprId, - onChange: e => setFormHprId(e.target.value), - placeholder: "e.g. rahul@hpr.abdm" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card bg-light border p-3 mb-3 rounded-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-between mb-2", - children: [/*#__PURE__*/_jsxs("span", { - className: "fw-bold small text-dark", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-check text-success me-1" - }), " Granular Access & Audit Permissions"] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary-subtle text-secondary", - style: { - fontSize: '0.65rem' - }, - children: "Audit Compliant" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2", - children: [/*#__PURE__*/_jsx("div", { - className: "col-md-4", - children: /*#__PURE__*/_jsxs("div", { - className: "form-check form-switch", - children: [/*#__PURE__*/_jsx("input", { - className: "form-check-input", - type: "checkbox", - id: "permAdmin", - checked: formPermissions.admin || false, - onChange: () => togglePermission('admin') - }), /*#__PURE__*/_jsx("label", { - className: "form-check-label small fw-semibold", - htmlFor: "permAdmin", - children: "1. Admin Control" - }), /*#__PURE__*/_jsx("div", { - className: "text-muted", - style: { - fontSize: '0.65rem' - }, - children: "Store config & user management" - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-4", - children: /*#__PURE__*/_jsxs("div", { - className: "form-check form-switch", - children: [/*#__PURE__*/_jsx("input", { - className: "form-check-input", - type: "checkbox", - id: "permSale", - checked: formPermissions.sale || false, - onChange: () => togglePermission('sale') - }), /*#__PURE__*/_jsx("label", { - className: "form-check-label small fw-semibold", - htmlFor: "permSale", - children: "2. Sale Billing" - }), /*#__PURE__*/_jsx("div", { - className: "text-muted", - style: { - fontSize: '0.65rem' - }, - children: "Counter POS and draft billing" - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-4", - children: /*#__PURE__*/_jsxs("div", { - className: "form-check form-switch", - children: [/*#__PURE__*/_jsx("input", { - className: "form-check-input", - type: "checkbox", - id: "permPurchase", - checked: formPermissions.purchase || false, - onChange: () => togglePermission('purchase') - }), /*#__PURE__*/_jsx("label", { - className: "form-check-label small fw-semibold", - htmlFor: "permPurchase", - children: "3. Purchase Inward" - }), /*#__PURE__*/_jsx("div", { - className: "text-muted", - style: { - fontSize: '0.65rem' - }, - children: "Challans & stock additions" - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-4", - children: /*#__PURE__*/_jsxs("div", { - className: "form-check form-switch", - children: [/*#__PURE__*/_jsx("input", { - className: "form-check-input", - type: "checkbox", - id: "permSaleEdit", - checked: formPermissions.sale_edit_after_1h || false, - onChange: () => togglePermission('sale_edit_after_1h') - }), /*#__PURE__*/_jsx("label", { - className: "form-check-label small fw-semibold", - htmlFor: "permSaleEdit", - children: "4. Sale Edit >1 Hour" - }), /*#__PURE__*/_jsx("div", { - className: "text-muted", - style: { - fontSize: '0.65rem' - }, - children: "Modify bills older than 60 mins" - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-4", - children: /*#__PURE__*/_jsxs("div", { - className: "form-check form-switch", - children: [/*#__PURE__*/_jsx("input", { - className: "form-check-input", - type: "checkbox", - id: "permPurchEdit", - checked: formPermissions.purchase_edit_verified || false, - onChange: () => togglePermission('purchase_edit_verified') - }), /*#__PURE__*/_jsx("label", { - className: "form-check-label small fw-semibold", - htmlFor: "permPurchEdit", - children: "5. Purch Edit Verified" - }), /*#__PURE__*/_jsx("div", { - className: "text-muted", - style: { - fontSize: '0.65rem' - }, - children: "Edit purchase after verification" - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-md-4", - children: /*#__PURE__*/_jsxs("div", { - className: "form-check form-switch", - children: [/*#__PURE__*/_jsx("input", { - className: "form-check-input", - type: "checkbox", - id: "permBankAudit", - checked: formPermissions.bank_upi_audit || false, - onChange: () => togglePermission('bank_upi_audit') - }), /*#__PURE__*/_jsx("label", { - className: "form-check-label small fw-semibold", - htmlFor: "permBankAudit", - children: "6. Bank & UPI Audit" - }), /*#__PURE__*/_jsx("div", { - className: "text-muted", - style: { - fontSize: '0.65rem' - }, - children: "Verify statements & reconciliations" - })] - }) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-4", - children: [/*#__PURE__*/_jsxs("div", { - className: "form-check", - children: [/*#__PURE__*/_jsx("input", { - className: "form-check-input", - type: "checkbox", - id: "isDefCheck", - checked: formIsDefault, - onChange: e => setFormIsDefault(e.target.checked) - }), /*#__PURE__*/_jsx("label", { - className: "form-check-label small", - htmlFor: "isDefCheck", - children: "Default Cashier on store open" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "form-check", - children: [/*#__PURE__*/_jsx("input", { - className: "form-check-input", - type: "checkbox", - id: "isActiveCheck", - checked: formIsActive, - onChange: e => setFormIsActive(e.target.checked) - }), /*#__PURE__*/_jsx("label", { - className: "form-check-label small", - htmlFor: "isActiveCheck", - children: "Account Active" - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer py-2 px-3 bg-light", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-secondary", - onClick: () => setShowEditModal(false), - children: "Cancel" - }), /*#__PURE__*/_jsx("button", { - type: "submit", - className: "btn btn-sm btn-primary fw-bold", - disabled: isSaving, - children: isSaving ? 'Saving...' : editingUser ? 'Update Staff & Permissions' : 'Save Staff Member' - })] - })] - }) - }) - }) - })] - }); + title: "Can edit sale bill after 1 hour" + }, "Sale Edit >1h"), /*#__PURE__*/React.createElement("span", { + className: `badge ${perms.purchase_edit_verified ? 'bg-warning text-dark' : 'bg-secondary-subtle text-muted text-decoration-line-through'}`, + style: { + fontSize: '0.62rem' + }, + title: "Can edit verified purchase challan" + }, "Purch Edit Verif"), /*#__PURE__*/React.createElement("span", { + className: `badge ${perms.bank_upi_audit ? 'bg-info text-dark' : 'bg-secondary-subtle text-muted text-decoration-line-through'}`, + style: { + fontSize: '0.62rem' + } + }, "Bank Audit"))), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-between pt-2 border-top" + }, /*#__PURE__*/React.createElement("div", null, isCurrent ? /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success border border-success px-2 py-1", + style: { + fontSize: '0.7rem' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-check-fill me-1" + }), " Active Cashier") : /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-secondary py-0.5 px-2", + style: { + fontSize: '0.72rem' + }, + onClick: () => onSelectOperator && onSelectOperator(user), + title: "Switch active counter login to this user" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-left-right me-1" + }), " Switch To")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-primary py-0.5 px-2", + style: { + fontSize: '0.72rem' + }, + onClick: () => openEditModal(user) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-pencil-square me-1" + }), " Edit & Rights")))); + })), showEditModal && /*#__PURE__*/React.createElement("div", { + className: "modal show d-block", + tabIndex: "-1", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.7)' + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered modal-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content shadow-lg border-0" + }, /*#__PURE__*/React.createElement("form", { + onSubmit: handleSaveStaff + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2.5 px-3" + }, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold mb-0" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-badge-fill text-primary me-2" + }), editingUser ? 'Edit Staff Profile & Permissions' : 'Register New Staff Member'), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setShowEditModal(false) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3" + }, /*#__PURE__*/React.createElement("div", { + className: "row g-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Full Name ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + required: true, + value: formFullName, + onChange: e => setFormFullName(e.target.value), + placeholder: "e.g. Rahul Sharma" + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Username (Login ID) ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + required: true, + value: formUsername, + onChange: e => setFormUsername(e.target.value), + placeholder: "e.g. rahul_pharma" + }))), /*#__PURE__*/React.createElement("div", { + className: "row g-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Role"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: formRole, + onChange: e => applyRoleDefaults(e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "store_manager" + }, "Store Manager (Admin)"), /*#__PURE__*/React.createElement("option", { + value: "pharmacist" + }, "Pharmacist"), /*#__PURE__*/React.createElement("option", { + value: "cashier" + }, "Cashier"), /*#__PURE__*/React.createElement("option", { + value: "auditor" + }, "Auditor / Accountant"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, editingUser ? 'Reset Quick PIN (4 Digits)' : 'Quick Login PIN (4 Digits)'), /*#__PURE__*/React.createElement("input", { + type: "password", + maxLength: "6", + className: "form-control form-control-sm", + value: formPinCode, + onChange: e => setFormPinCode(e.target.value), + placeholder: editingUser ? 'Leave blank to keep current PIN' : 'e.g. 1234' + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Phone Number"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: formPhone, + onChange: e => setFormPhone(e.target.value), + placeholder: "e.g. 9876543210" + }))), /*#__PURE__*/React.createElement("div", { + className: "row g-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Pharmacy State Reg No"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: formRegNo, + onChange: e => setFormRegNo(e.target.value), + placeholder: "e.g. PB-PH-99214" + })), /*#__PURE__*/React.createElement("div", { + className: "col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "ABDM Healthcare Professional Registry (HPR) ID"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + value: formHprId, + onChange: e => setFormHprId(e.target.value), + placeholder: "e.g. rahul@hpr.abdm" + }))), /*#__PURE__*/React.createElement("div", { + className: "card bg-light border p-3 mb-3 rounded-2" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-between mb-2" + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold small text-dark" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-check text-success me-1" + }), " Granular Access & Audit Permissions"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-secondary", + style: { + fontSize: '0.65rem' + } + }, "Audit Compliant")), /*#__PURE__*/React.createElement("div", { + className: "row g-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("div", { + className: "form-check form-switch" + }, /*#__PURE__*/React.createElement("input", { + className: "form-check-input", + type: "checkbox", + id: "permAdmin", + checked: formPermissions.admin || false, + onChange: () => togglePermission('admin') + }), /*#__PURE__*/React.createElement("label", { + className: "form-check-label small fw-semibold", + htmlFor: "permAdmin" + }, "1. Admin Control"), /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '0.65rem' + } + }, "Store config & user management"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("div", { + className: "form-check form-switch" + }, /*#__PURE__*/React.createElement("input", { + className: "form-check-input", + type: "checkbox", + id: "permSale", + checked: formPermissions.sale || false, + onChange: () => togglePermission('sale') + }), /*#__PURE__*/React.createElement("label", { + className: "form-check-label small fw-semibold", + htmlFor: "permSale" + }, "2. Sale Billing"), /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '0.65rem' + } + }, "Counter POS and draft billing"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("div", { + className: "form-check form-switch" + }, /*#__PURE__*/React.createElement("input", { + className: "form-check-input", + type: "checkbox", + id: "permPurchase", + checked: formPermissions.purchase || false, + onChange: () => togglePermission('purchase') + }), /*#__PURE__*/React.createElement("label", { + className: "form-check-label small fw-semibold", + htmlFor: "permPurchase" + }, "3. Purchase Inward"), /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '0.65rem' + } + }, "Challans & stock additions"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("div", { + className: "form-check form-switch" + }, /*#__PURE__*/React.createElement("input", { + className: "form-check-input", + type: "checkbox", + id: "permSaleEdit", + checked: formPermissions.sale_edit_after_1h || false, + onChange: () => togglePermission('sale_edit_after_1h') + }), /*#__PURE__*/React.createElement("label", { + className: "form-check-label small fw-semibold", + htmlFor: "permSaleEdit" + }, "4. Sale Edit >1 Hour"), /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '0.65rem' + } + }, "Modify bills older than 60 mins"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("div", { + className: "form-check form-switch" + }, /*#__PURE__*/React.createElement("input", { + className: "form-check-input", + type: "checkbox", + id: "permPurchEdit", + checked: formPermissions.purchase_edit_verified || false, + onChange: () => togglePermission('purchase_edit_verified') + }), /*#__PURE__*/React.createElement("label", { + className: "form-check-label small fw-semibold", + htmlFor: "permPurchEdit" + }, "5. Purch Edit Verified"), /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '0.65rem' + } + }, "Edit purchase after verification"))), /*#__PURE__*/React.createElement("div", { + className: "col-md-4" + }, /*#__PURE__*/React.createElement("div", { + className: "form-check form-switch" + }, /*#__PURE__*/React.createElement("input", { + className: "form-check-input", + type: "checkbox", + id: "permBankAudit", + checked: formPermissions.bank_upi_audit || false, + onChange: () => togglePermission('bank_upi_audit') + }), /*#__PURE__*/React.createElement("label", { + className: "form-check-label small fw-semibold", + htmlFor: "permBankAudit" + }, "6. Bank & UPI Audit"), /*#__PURE__*/React.createElement("div", { + className: "text-muted", + style: { + fontSize: '0.65rem' + } + }, "Verify statements & reconciliations"))))), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-4" + }, /*#__PURE__*/React.createElement("div", { + className: "form-check" + }, /*#__PURE__*/React.createElement("input", { + className: "form-check-input", + type: "checkbox", + id: "isDefCheck", + checked: formIsDefault, + onChange: e => setFormIsDefault(e.target.checked) + }), /*#__PURE__*/React.createElement("label", { + className: "form-check-label small", + htmlFor: "isDefCheck" + }, "Default Cashier on store open")), /*#__PURE__*/React.createElement("div", { + className: "form-check" + }, /*#__PURE__*/React.createElement("input", { + className: "form-check-input", + type: "checkbox", + id: "isActiveCheck", + checked: formIsActive, + onChange: e => setFormIsActive(e.target.checked) + }), /*#__PURE__*/React.createElement("label", { + className: "form-check-label small", + htmlFor: "isActiveCheck" + }, "Account Active")))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer py-2 px-3 bg-light" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-secondary", + onClick: () => setShowEditModal(false) + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + type: "submit", + className: "btn btn-sm btn-primary fw-bold", + disabled: isSaving + }, isSaving ? 'Saving...' : editingUser ? 'Update Staff & Permissions' : 'Save Staff Member'))))))); } // Note: Store & Statutory Licensing Setup is managed centrally in HMS -> Admin -> Medical Store. @@ -19112,1164 +15137,903 @@ function MobileAppView({ setIsUploadingPhoto(false); } }; - return /*#__PURE__*/_jsxs("div", { + return /*#__PURE__*/React.createElement("div", { className: "mobile-app-wrapper", style: { background: '#0b1329', minHeight: '100vh', color: '#f8fafc', paddingBottom: '75px' + } + }, /*#__PURE__*/React.createElement("div", { + className: "p-3 border-bottom border-slate-800 d-flex align-items-center justify-content-between sticky-top", + style: { + background: '#0f172a', + zIndex: 1020 + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "p-2 rounded-3 bg-primary text-white d-flex align-items-center justify-content-center", + style: { + width: 34, + height: 34 + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-capsule fs-6" + })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "mb-0 fw-bold text-white fs-6 lh-1" + }, store.store_name), /*#__PURE__*/React.createElement("small", { + className: "text-cyan-400", + style: { + fontSize: '0.68rem', + color: '#38bdf8' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-fill me-0.5" + }), " ", activeOperator ? activeOperator.full_name : 'Staff'))), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-1.5" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-info text-white rounded-pill px-2 py-1", + onClick: onSwitchOperator, + title: "Switch Operator" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-badge" + }), " PIN"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-success rounded-pill px-2 py-1", + onClick: triggerPwaInstall, + title: "Install PWA on Phone" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-phone" + }), " Install"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-secondary text-white rounded-pill px-2 py-1", + onClick: onExitMobile, + title: "Switch to Desktop Mode" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-laptop" + }), " Desktop"))), /*#__PURE__*/React.createElement("div", { + className: "p-3" + }, mobTab === 'dashboard' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-between mb-3" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold mb-0 text-white d-flex align-items-center gap-1.5" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-speedometer2 text-primary" + }), " Pharmacy Health Dashboard"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-xs btn-outline-secondary text-white", + onClick: loadDashboard + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-clockwise" + }), " Refresh")), loadingDash || !dashData ? /*#__PURE__*/React.createElement("div", { + className: "text-center py-5 text-slate-400" + }, /*#__PURE__*/React.createElement("div", { + className: "spinner-border spinner-border-sm text-primary mb-2" + }), /*#__PURE__*/React.createElement("div", null, "Loading store telemetry...")) : /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("div", { + className: "p-2.5 rounded-3 border border-secondary", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("small", { + className: "text-slate-400 d-block", + style: { + fontSize: '0.68rem', + color: '#94a3b8' + } + }, "TOTAL BATCHES"), /*#__PURE__*/React.createElement("span", { + className: "fs-5 fw-bolder text-white" + }, dashData.summary?.total_batches || 0), /*#__PURE__*/React.createElement("span", { + className: "small text-slate-400 ms-1", + style: { + fontSize: '0.68rem' + } + }, "(", dashData.summary?.total_units || 0, " Units)"))), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("div", { + className: "p-2.5 rounded-3 border border-primary", + style: { + background: 'rgba(14, 165, 233, 0.15)' + } + }, /*#__PURE__*/React.createElement("small", { + className: "text-cyan-300 d-block", + style: { + fontSize: '0.68rem', + color: '#38bdf8' + } + }, "STOCK VALUATION (PTR)"), /*#__PURE__*/React.createElement("span", { + className: "fs-5 fw-bolder text-white" + }, "₹", Number(dashData.summary?.cost_valuation || 0).toLocaleString('en-IN')))), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("div", { + className: "p-2.5 rounded-3 border border-warning", + style: { + background: 'rgba(234, 179, 8, 0.12)' + } + }, /*#__PURE__*/React.createElement("small", { + className: "text-warning d-block", + style: { + fontSize: '0.68rem' + } + }, "NEAR EXPIRY (<90d)"), /*#__PURE__*/React.createElement("span", { + className: "fs-5 fw-bolder text-warning" + }, dashData.summary?.near_expiry_count || 0, " Batches"))), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("div", { + className: "p-2.5 rounded-3 border border-danger", + style: { + background: 'rgba(239, 68, 68, 0.12)' + } + }, /*#__PURE__*/React.createElement("small", { + className: "text-danger d-block", + style: { + fontSize: '0.68rem' + } + }, "SUPPLIER PENDING"), /*#__PURE__*/React.createElement("span", { + className: "fs-5 fw-bolder text-danger" + }, "₹", Number(dashData.summary?.total_supplier_pending || 0).toLocaleString('en-IN'))))), /*#__PURE__*/React.createElement("div", { + className: "card border-0 mb-3 rounded-3 overflow-hidden", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("div", { + className: "card-header border-bottom border-secondary py-2 px-3 d-flex align-items-center justify-content-between" + }, /*#__PURE__*/React.createElement("span", { + className: "small fw-bold text-warning d-flex align-items-center gap-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clock-history" + }), " Nearest Expiry Batches"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-warning text-dark", + style: { + fontSize: '0.65rem' + } + }, "Priority Action")), /*#__PURE__*/React.createElement("div", { + className: "p-0" + }, dashData.near_expiry?.length === 0 ? /*#__PURE__*/React.createElement("div", { + className: "p-3 text-center small text-slate-400" + }, "No batches expiring in next 90 days.") : dashData.near_expiry.map((item, i) => /*#__PURE__*/React.createElement("div", { + key: i, + className: "p-2.5 border-bottom border-slate-700 d-flex align-items-center justify-content-between small" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-white" + }, item.item_name), /*#__PURE__*/React.createElement("div", { + className: "text-slate-400", + style: { + fontSize: '0.7rem', + color: '#94a3b8' + } + }, "Batch: ", /*#__PURE__*/React.createElement("strong", { + className: "text-cyan-300" + }, item.batch_no), " ", item.shelf_no ? `• Sh: ${item.shelf_no}` : '')), /*#__PURE__*/React.createElement("div", { + className: "text-end" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger-subtle text-danger border border-danger mb-0.5", + style: { + fontSize: '0.68rem' + } + }, "Exp: ", item.expiry_date), /*#__PURE__*/React.createElement("div", { + className: "text-slate-400", + style: { + fontSize: '0.7rem' + } + }, item.current_qty, " Units")))))), /*#__PURE__*/React.createElement("div", { + className: "card border-0 mb-3 rounded-3 overflow-hidden", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("div", { + className: "card-header border-bottom border-secondary py-2 px-3 d-flex align-items-center justify-content-between" + }, /*#__PURE__*/React.createElement("span", { + className: "small fw-bold text-success d-flex align-items-center gap-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-graph-up-arrow" + }), " Fast Moving Medicines"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success", + style: { + fontSize: '0.65rem' + } + }, "Top Sales")), /*#__PURE__*/React.createElement("div", { + className: "p-0" + }, dashData.high_sales?.length === 0 ? /*#__PURE__*/React.createElement("div", { + className: "p-3 text-center small text-slate-400" + }, "No sale records yet.") : dashData.high_sales.map((item, i) => /*#__PURE__*/React.createElement("div", { + key: i, + className: "p-2.5 border-bottom border-slate-700 d-flex align-items-center justify-content-between small" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-white" + }, "#", i + 1, " ", item.item_name), /*#__PURE__*/React.createElement("div", { + className: "text-slate-400", + style: { + fontSize: '0.7rem', + color: '#94a3b8' + } + }, item.generic_name || 'Allopathic')), /*#__PURE__*/React.createElement("div", { + className: "text-end" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-success", + style: { + fontSize: '0.7rem' + } + }, item.total_sold, " Units Sold"), /*#__PURE__*/React.createElement("div", { + className: "text-slate-400", + style: { + fontSize: '0.7rem' + } + }, "₹", item.total_revenue)))))), /*#__PURE__*/React.createElement("div", { + className: "card border-0 mb-3 rounded-3 overflow-hidden", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("div", { + className: "card-header border-bottom border-secondary py-2 px-3 d-flex align-items-center justify-content-between" + }, /*#__PURE__*/React.createElement("span", { + className: "small fw-bold text-danger d-flex align-items-center gap-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-exclamation-triangle-fill" + }), " Dead / Dump Stock (>60d No Movement)"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger-subtle text-danger", + style: { + fontSize: '0.65rem' + } + }, "Capital Blocked")), /*#__PURE__*/React.createElement("div", { + className: "p-0" + }, dashData.dump_stock?.length === 0 ? /*#__PURE__*/React.createElement("div", { + className: "p-3 text-center small text-slate-400" + }, "No stagnant stock detected.") : dashData.dump_stock.map((item, i) => /*#__PURE__*/React.createElement("div", { + key: i, + className: "p-2.5 border-bottom border-slate-700 d-flex align-items-center justify-content-between small" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-white" + }, item.item_name), /*#__PURE__*/React.createElement("div", { + className: "text-slate-400", + style: { + fontSize: '0.7rem', + color: '#94a3b8' + } + }, "Batch: ", item.batch_no, " • Exp: ", item.expiry_date)), /*#__PURE__*/React.createElement("div", { + className: "text-end" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary", + style: { + fontSize: '0.7rem' + } + }, item.current_qty, " Units Stagnant"), /*#__PURE__*/React.createElement("div", { + className: "text-slate-400", + style: { + fontSize: '0.7rem' + } + }, "MRP: ₹", item.mrp)))))), /*#__PURE__*/React.createElement("div", { + className: "card border-0 mb-3 rounded-3 overflow-hidden", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("div", { + className: "card-header border-bottom border-secondary py-2 px-3 d-flex align-items-center justify-content-between" + }, /*#__PURE__*/React.createElement("span", { + className: "small fw-bold text-info d-flex align-items-center gap-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-wallet2" + }), " Supplier Payments Pending"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-info-subtle text-info", + style: { + fontSize: '0.65rem' + } + }, "Accounts Payable")), /*#__PURE__*/React.createElement("div", { + className: "p-0" + }, dashData.supplier_pending?.length === 0 ? /*#__PURE__*/React.createElement("div", { + className: "p-3 text-center small text-slate-400" + }, "All supplier bills are settled!") : dashData.supplier_pending.map((item, i) => /*#__PURE__*/React.createElement("div", { + key: i, + className: "p-2.5 border-bottom border-slate-700 d-flex align-items-center justify-content-between small" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-white" + }, item.supplier_name || 'Distributor'), /*#__PURE__*/React.createElement("div", { + className: "text-slate-400", + style: { + fontSize: '0.7rem', + color: '#94a3b8' + } + }, "Inv: ", item.supplier_invoice_no, " • Due: ", item.due_date)), /*#__PURE__*/React.createElement("div", { + className: "text-end" + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-danger" + }, "₹", Number(item.pending_amount).toFixed(2)), /*#__PURE__*/React.createElement("small", { + className: "text-slate-400 d-block", + style: { + fontSize: '0.65rem' + } + }, "Paid: ₹", item.paid_amount)))))))), mobTab === 'collector' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-between mb-2" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold mb-0 text-white d-flex align-items-center gap-1.5" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-basket-fill text-warning" + }), " Shelf & Rack Collector"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-warning text-dark small fw-bold" + }, collectorItems.length, " Items in Basket")), /*#__PURE__*/React.createElement("p", { + className: "text-slate-400 small mb-3", + style: { + fontSize: '0.75rem', + color: '#94a3b8' + } + }, "Collect medicines from shelves, add to mobile basket, and tap \"Save Draft\" so the cashier on counter PC can bill it immediately."), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-slate-300 mb-1" + }, "Search Medicine to Pick"), /*#__PURE__*/React.createElement("div", { + className: "input-group" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-dark border-secondary text-slate-400" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-dark text-white border-secondary", + placeholder: "Type medicine name / barcode...", + value: itemSearchQuery, + onChange: e => handleSearchItems(e.target.value) + })), searchResults.length > 0 && /*#__PURE__*/React.createElement("div", { + className: "rounded-3 border border-secondary mt-1 p-1 shadow-lg", + style: { + background: '#1e293b', + maxHeight: 200, + overflowY: 'auto' + } + }, searchResults.map(item => /*#__PURE__*/React.createElement("div", { + key: item.item_id, + className: "p-2 border-bottom border-slate-700 cursor-pointer text-start hover-bg", + onClick: () => { + setSelectedItem(item); + setSelectedBatch(item.batches && item.batches[0] ? item.batches[0] : null); + setSearchResults([]); }, - children: [/*#__PURE__*/_jsxs("div", { - className: "p-3 border-bottom border-slate-800 d-flex align-items-center justify-content-between sticky-top", - style: { - background: '#0f172a', - zIndex: 1020 - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("div", { - className: "p-2 rounded-3 bg-primary text-white d-flex align-items-center justify-content-center", - style: { - width: 34, - height: 34 - }, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-capsule fs-6" - }) - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "mb-0 fw-bold text-white fs-6 lh-1", - children: store.store_name - }), /*#__PURE__*/_jsxs("small", { - className: "text-cyan-400", - style: { - fontSize: '0.68rem', - color: '#38bdf8' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-fill me-0.5" - }), " ", activeOperator ? activeOperator.full_name : 'Staff'] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-1.5", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-outline-info text-white rounded-pill px-2 py-1", - onClick: onSwitchOperator, - title: "Switch Operator", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-badge" - }), " PIN"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-outline-success rounded-pill px-2 py-1", - onClick: triggerPwaInstall, - title: "Install PWA on Phone", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-phone" - }), " Install"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-outline-secondary text-white rounded-pill px-2 py-1", - onClick: onExitMobile, - title: "Switch to Desktop Mode", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-laptop" - }), " Desktop"] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "p-3", - children: [mobTab === 'dashboard' && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-between mb-3", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold mb-0 text-white d-flex align-items-center gap-1.5", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-speedometer2 text-primary" - }), " Pharmacy Health Dashboard"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-xs btn-outline-secondary text-white", - onClick: loadDashboard, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-clockwise" - }), " Refresh"] - })] - }), loadingDash || !dashData ? /*#__PURE__*/_jsxs("div", { - className: "text-center py-5 text-slate-400", - children: [/*#__PURE__*/_jsx("div", { - className: "spinner-border spinner-border-sm text-primary mb-2" - }), /*#__PURE__*/_jsx("div", { - children: "Loading store telemetry..." - })] - }) : /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "col-6", - children: /*#__PURE__*/_jsxs("div", { - className: "p-2.5 rounded-3 border border-secondary", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsx("small", { - className: "text-slate-400 d-block", - style: { - fontSize: '0.68rem', - color: '#94a3b8' - }, - children: "TOTAL BATCHES" - }), /*#__PURE__*/_jsx("span", { - className: "fs-5 fw-bolder text-white", - children: dashData.summary?.total_batches || 0 - }), /*#__PURE__*/_jsxs("span", { - className: "small text-slate-400 ms-1", - style: { - fontSize: '0.68rem' - }, - children: ["(", dashData.summary?.total_units || 0, " Units)"] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-6", - children: /*#__PURE__*/_jsxs("div", { - className: "p-2.5 rounded-3 border border-primary", - style: { - background: 'rgba(14, 165, 233, 0.15)' - }, - children: [/*#__PURE__*/_jsx("small", { - className: "text-cyan-300 d-block", - style: { - fontSize: '0.68rem', - color: '#38bdf8' - }, - children: "STOCK VALUATION (PTR)" - }), /*#__PURE__*/_jsxs("span", { - className: "fs-5 fw-bolder text-white", - children: ["₹", Number(dashData.summary?.cost_valuation || 0).toLocaleString('en-IN')] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-6", - children: /*#__PURE__*/_jsxs("div", { - className: "p-2.5 rounded-3 border border-warning", - style: { - background: 'rgba(234, 179, 8, 0.12)' - }, - children: [/*#__PURE__*/_jsx("small", { - className: "text-warning d-block", - style: { - fontSize: '0.68rem' - }, - children: "NEAR EXPIRY (<90d)" - }), /*#__PURE__*/_jsxs("span", { - className: "fs-5 fw-bolder text-warning", - children: [dashData.summary?.near_expiry_count || 0, " Batches"] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-6", - children: /*#__PURE__*/_jsxs("div", { - className: "p-2.5 rounded-3 border border-danger", - style: { - background: 'rgba(239, 68, 68, 0.12)' - }, - children: [/*#__PURE__*/_jsx("small", { - className: "text-danger d-block", - style: { - fontSize: '0.68rem' - }, - children: "SUPPLIER PENDING" - }), /*#__PURE__*/_jsxs("span", { - className: "fs-5 fw-bolder text-danger", - children: ["₹", Number(dashData.summary?.total_supplier_pending || 0).toLocaleString('en-IN')] - })] - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card border-0 mb-3 rounded-3 overflow-hidden", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header border-bottom border-secondary py-2 px-3 d-flex align-items-center justify-content-between", - children: [/*#__PURE__*/_jsxs("span", { - className: "small fw-bold text-warning d-flex align-items-center gap-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clock-history" - }), " Nearest Expiry Batches"] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-warning text-dark", - style: { - fontSize: '0.65rem' - }, - children: "Priority Action" - })] - }), /*#__PURE__*/_jsx("div", { - className: "p-0", - children: dashData.near_expiry?.length === 0 ? /*#__PURE__*/_jsx("div", { - className: "p-3 text-center small text-slate-400", - children: "No batches expiring in next 90 days." - }) : dashData.near_expiry.map((item, i) => /*#__PURE__*/_jsxs("div", { - className: "p-2.5 border-bottom border-slate-700 d-flex align-items-center justify-content-between small", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-white", - children: item.item_name - }), /*#__PURE__*/_jsxs("div", { - className: "text-slate-400", - style: { - fontSize: '0.7rem', - color: '#94a3b8' - }, - children: ["Batch: ", /*#__PURE__*/_jsx("strong", { - className: "text-cyan-300", - children: item.batch_no - }), " ", item.shelf_no ? `• Sh: ${item.shelf_no}` : ''] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "text-end", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-danger-subtle text-danger border border-danger mb-0.5", - style: { - fontSize: '0.68rem' - }, - children: ["Exp: ", item.expiry_date] - }), /*#__PURE__*/_jsxs("div", { - className: "text-slate-400", - style: { - fontSize: '0.7rem' - }, - children: [item.current_qty, " Units"] - })] - })] - }, i)) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card border-0 mb-3 rounded-3 overflow-hidden", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header border-bottom border-secondary py-2 px-3 d-flex align-items-center justify-content-between", - children: [/*#__PURE__*/_jsxs("span", { - className: "small fw-bold text-success d-flex align-items-center gap-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-graph-up-arrow" - }), " Fast Moving Medicines"] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-success-subtle text-success", - style: { - fontSize: '0.65rem' - }, - children: "Top Sales" - })] - }), /*#__PURE__*/_jsx("div", { - className: "p-0", - children: dashData.high_sales?.length === 0 ? /*#__PURE__*/_jsx("div", { - className: "p-3 text-center small text-slate-400", - children: "No sale records yet." - }) : dashData.high_sales.map((item, i) => /*#__PURE__*/_jsxs("div", { - className: "p-2.5 border-bottom border-slate-700 d-flex align-items-center justify-content-between small", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "fw-bold text-white", - children: ["#", i + 1, " ", item.item_name] - }), /*#__PURE__*/_jsx("div", { - className: "text-slate-400", - style: { - fontSize: '0.7rem', - color: '#94a3b8' - }, - children: item.generic_name || 'Allopathic' - })] - }), /*#__PURE__*/_jsxs("div", { - className: "text-end", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-success", - style: { - fontSize: '0.7rem' - }, - children: [item.total_sold, " Units Sold"] - }), /*#__PURE__*/_jsxs("div", { - className: "text-slate-400", - style: { - fontSize: '0.7rem' - }, - children: ["₹", item.total_revenue] - })] - })] - }, i)) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card border-0 mb-3 rounded-3 overflow-hidden", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header border-bottom border-secondary py-2 px-3 d-flex align-items-center justify-content-between", - children: [/*#__PURE__*/_jsxs("span", { - className: "small fw-bold text-danger d-flex align-items-center gap-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-exclamation-triangle-fill" - }), " Dead / Dump Stock (>60d No Movement)"] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-danger-subtle text-danger", - style: { - fontSize: '0.65rem' - }, - children: "Capital Blocked" - })] - }), /*#__PURE__*/_jsx("div", { - className: "p-0", - children: dashData.dump_stock?.length === 0 ? /*#__PURE__*/_jsx("div", { - className: "p-3 text-center small text-slate-400", - children: "No stagnant stock detected." - }) : dashData.dump_stock.map((item, i) => /*#__PURE__*/_jsxs("div", { - className: "p-2.5 border-bottom border-slate-700 d-flex align-items-center justify-content-between small", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-white", - children: item.item_name - }), /*#__PURE__*/_jsxs("div", { - className: "text-slate-400", - style: { - fontSize: '0.7rem', - color: '#94a3b8' - }, - children: ["Batch: ", item.batch_no, " • Exp: ", item.expiry_date] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "text-end", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-secondary", - style: { - fontSize: '0.7rem' - }, - children: [item.current_qty, " Units Stagnant"] - }), /*#__PURE__*/_jsxs("div", { - className: "text-slate-400", - style: { - fontSize: '0.7rem' - }, - children: ["MRP: ₹", item.mrp] - })] - })] - }, i)) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card border-0 mb-3 rounded-3 overflow-hidden", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header border-bottom border-secondary py-2 px-3 d-flex align-items-center justify-content-between", - children: [/*#__PURE__*/_jsxs("span", { - className: "small fw-bold text-info d-flex align-items-center gap-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-wallet2" - }), " Supplier Payments Pending"] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-info-subtle text-info", - style: { - fontSize: '0.65rem' - }, - children: "Accounts Payable" - })] - }), /*#__PURE__*/_jsx("div", { - className: "p-0", - children: dashData.supplier_pending?.length === 0 ? /*#__PURE__*/_jsx("div", { - className: "p-3 text-center small text-slate-400", - children: "All supplier bills are settled!" - }) : dashData.supplier_pending.map((item, i) => /*#__PURE__*/_jsxs("div", { - className: "p-2.5 border-bottom border-slate-700 d-flex align-items-center justify-content-between small", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-white", - children: item.supplier_name || 'Distributor' - }), /*#__PURE__*/_jsxs("div", { - className: "text-slate-400", - style: { - fontSize: '0.7rem', - color: '#94a3b8' - }, - children: ["Inv: ", item.supplier_invoice_no, " • Due: ", item.due_date] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "text-end", - children: [/*#__PURE__*/_jsxs("span", { - className: "fw-bold text-danger", - children: ["₹", Number(item.pending_amount).toFixed(2)] - }), /*#__PURE__*/_jsxs("small", { - className: "text-slate-400 d-block", - style: { - fontSize: '0.65rem' - }, - children: ["Paid: ₹", item.paid_amount] - })] - })] - }, i)) - })] - })] - })] - }), mobTab === 'collector' && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-between mb-2", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold mb-0 text-white d-flex align-items-center gap-1.5", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-basket-fill text-warning" - }), " Shelf & Rack Collector"] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-warning text-dark small fw-bold", - children: [collectorItems.length, " Items in Basket"] - })] - }), /*#__PURE__*/_jsx("p", { - className: "text-slate-400 small mb-3", - style: { - fontSize: '0.75rem', - color: '#94a3b8' - }, - children: "Collect medicines from shelves, add to mobile basket, and tap \"Save Draft\" so the cashier on counter PC can bill it immediately." - }), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold text-slate-300 mb-1", - children: "Search Medicine to Pick" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-dark border-secondary text-slate-400", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-search" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-dark text-white border-secondary", - placeholder: "Type medicine name / barcode...", - value: itemSearchQuery, - onChange: e => handleSearchItems(e.target.value) - })] - }), searchResults.length > 0 && /*#__PURE__*/_jsx("div", { - className: "rounded-3 border border-secondary mt-1 p-1 shadow-lg", - style: { - background: '#1e293b', - maxHeight: 200, - overflowY: 'auto' - }, - children: searchResults.map(item => /*#__PURE__*/_jsxs("div", { - className: "p-2 border-bottom border-slate-700 cursor-pointer text-start hover-bg", - onClick: () => { - setSelectedItem(item); - setSelectedBatch(item.batches && item.batches[0] ? item.batches[0] : null); - setSearchResults([]); - }, - style: { - cursor: 'pointer' - }, - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-white small", - children: item.item_name - }), /*#__PURE__*/_jsxs("small", { - className: "text-slate-400", - style: { - fontSize: '0.7rem', - color: '#94a3b8' - }, - children: [item.generic_name, " • Stock: ", /*#__PURE__*/_jsx("strong", { - className: "text-success", - children: item.total_stock - }), " Units"] - })] - }, item.item_id)) - })] - }), selectedItem && /*#__PURE__*/_jsxs("div", { - className: "p-3 rounded-3 mb-3 border border-primary", - style: { - background: 'rgba(14, 165, 233, 0.12)' - }, - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-white fs-6 mb-1", - children: selectedItem.item_name - }), /*#__PURE__*/_jsx("small", { - className: "text-slate-400 d-block mb-2", - children: selectedItem.generic_name - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-12", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-slate-300 small mb-1", - children: "Select Batch from Shelf" - }), /*#__PURE__*/_jsx("select", { - className: "form-select form-select-sm bg-dark text-white border-secondary", - value: selectedBatch?.batch_id || '', - onChange: e => { - const b = selectedItem.batches?.find(bt => bt.batch_id == e.target.value); - setSelectedBatch(b || null); - }, - children: (selectedItem.batches || []).map(b => /*#__PURE__*/_jsxs("option", { - value: b.batch_id, - children: ["Batch: ", b.batch_no, " | Exp: ", b.expiry_date, " | Stock: ", b.current_qty, " | Sh: ", b.shelf_no || '-'] - }, b.batch_id)) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-slate-300 small mb-1", - children: "Sell Unit" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm bg-dark text-white border-secondary", - value: collectUnit, - onChange: e => setCollectUnit(e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "Tablet", - children: "Tablet / Loose" - }), /*#__PURE__*/_jsx("option", { - value: "Strip", - children: "Strip / Full Pack" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-slate-300 small mb-1", - children: "Quantity" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("button", { - className: "btn btn-outline-secondary text-white", - type: "button", - onClick: () => setCollectQty(Math.max(1, collectQty - 1)), - children: "-" - }), /*#__PURE__*/_jsx("input", { - type: "number", - min: "1", - className: "form-control text-center fw-bold bg-dark text-white border-secondary", - value: collectQty, - onChange: e => setCollectQty(Math.max(1, Number(e.target.value))) - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-outline-secondary text-white", - type: "button", - onClick: () => setCollectQty(collectQty + 1), - children: "+" - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-between pt-2", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-xs btn-outline-secondary text-white", - onClick: () => setSelectedItem(null), - children: "Cancel" - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-primary fw-bold", - onClick: addItemToDraft, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-plus-circle me-1" - }), " Add to Basket"] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card border-0 rounded-3 mb-3", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header border-bottom border-secondary py-2 px-3 d-flex align-items-center justify-content-between", - children: [/*#__PURE__*/_jsxs("span", { - className: "small fw-bold text-white", - children: ["Draft Basket Items (", collectorItems.length, ")"] - }), collectorItems.length > 0 && /*#__PURE__*/_jsx("button", { - className: "btn btn-xs btn-outline-danger", - onClick: () => setCollectorItems([]), - children: "Clear" - })] - }), /*#__PURE__*/_jsx("div", { - className: "p-0", - children: collectorItems.length === 0 ? /*#__PURE__*/_jsxs("div", { - className: "p-4 text-center text-slate-400 small", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cart3 fs-3 d-block mb-1 text-slate-600" - }), "No medicines collected yet. Search and pick items above."] - }) : collectorItems.map((it, idx) => /*#__PURE__*/_jsxs("div", { - className: "p-2.5 border-bottom border-slate-700 d-flex align-items-center justify-content-between small", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-white", - children: it.item_name - }), /*#__PURE__*/_jsxs("div", { - className: "text-slate-400", - style: { - fontSize: '0.7rem' - }, - children: ["Batch: ", it.batch_no, " • Qty: ", /*#__PURE__*/_jsxs("strong", { - className: "text-cyan-300", - children: [it.qty, " ", it.sell_unit] - }), " • Rate: ", /*#__PURE__*/_jsxs("strong", { - className: "text-warning", - children: ["₹", it.effective_rate] - }), " • Total: ", /*#__PURE__*/_jsxs("strong", { - className: "text-success", - children: ["₹", it.line_gross] - })] - })] - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-xs btn-outline-danger p-1", - onClick: () => setCollectorItems(collectorItems.filter((_, i) => i !== idx)), - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-trash" - }) - })] - }, idx)) - })] - }), collectorItems.length > 0 && /*#__PURE__*/_jsxs("div", { - className: "p-3 rounded-3 mb-3 border border-secondary", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-slate-300 small fw-bold text-uppercase mb-2", - style: { - color: '#cbd5e1' - }, - children: "Patient / Counter Destination" - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "col-6", - children: /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-dark text-white border-secondary", - placeholder: "Patient Name / Walk-in", - value: patientName, - onChange: e => setPatientName(e.target.value) - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-6", - children: /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-dark text-white border-secondary", - placeholder: "Mobile Number", - value: patientMobile, - onChange: e => setPatientMobile(e.target.value) - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-6", - children: /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-dark text-white border-secondary", - placeholder: "Bed / Room No (optional)", - value: bedNo, - onChange: e => setBedNo(e.target.value) - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-6", - children: /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-dark text-white border-secondary", - placeholder: "Ward Name", - value: wardName, - onChange: e => setWardName(e.target.value) - }) - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-primary w-100 py-2 fw-bold d-flex align-items-center justify-content-center gap-2 shadow", - onClick: handleSaveDraft, - disabled: isSavingDraft, - children: isSavingDraft ? /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm" - }), " Transmitting to Counter Desk..."] - }) : /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-send-check-fill" - }), " Save Draft to Counter Desk"] - }) - })] - })] - }), mobTab === 'auditor' && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-between mb-2", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold mb-0 text-white d-flex align-items-center gap-1.5", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-sliders2 text-info" - }), " Mobile Shelf Auditor"] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-info-subtle text-info border border-info", - style: { - fontSize: '0.65rem' - }, - children: "Routine Count" - })] - }), /*#__PURE__*/_jsx("p", { - className: "text-slate-400 small mb-3", - style: { - fontSize: '0.75rem', - color: '#94a3b8' - }, - children: "During low workload hours, search medicine or rack, check shelf count against system records, and reconcile stock with 1 tap." - }), /*#__PURE__*/_jsxs("div", { - className: "input-group mb-3", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-dark border-secondary text-slate-400", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-search" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-dark text-white border-secondary", - placeholder: "Search medicine, batch, shelf no...", - value: auditSearch, - onChange: e => handleSearchAudit(e.target.value) - })] - }), /*#__PURE__*/_jsx("div", { - className: "d-flex flex-column gap-2", - children: auditResults.length === 0 ? /*#__PURE__*/_jsx("div", { - className: "text-center py-4 text-slate-500 small", - children: "Type medicine or batch to verify shelf stock." - }) : auditResults.map((item, idx) => /*#__PURE__*/_jsxs("div", { - className: "p-3 rounded-3 border border-secondary", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-start justify-content-between gap-2 mb-1", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-white small", - children: item.item_name - }), /*#__PURE__*/_jsxs("div", { - className: "text-slate-400", - style: { - fontSize: '0.72rem', - color: '#94a3b8' - }, - children: ["Batch: ", /*#__PURE__*/_jsx("strong", { - className: "text-cyan-300", - children: item.batch_no - }), " • Exp: ", item.expiry_display || item.expiry_date] - })] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary", - style: { - fontSize: '0.65rem' - }, - children: item.shelf_no ? `Shelf: ${item.shelf_no}` : 'Normal' - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-between pt-2 border-top border-slate-700 mt-2", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("small", { - className: "text-slate-400 d-block", - style: { - fontSize: '0.65rem' - }, - children: "SYSTEM STOCK" - }), /*#__PURE__*/_jsxs("span", { - className: "fs-6 fw-bold text-success", - children: [item.current_qty, " Units"] - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-xs btn-outline-info text-white px-2.5 py-1 rounded-pill d-flex align-items-center gap-1", - onClick: () => { - setAuditModalItem(item); - setAuditCount(item.current_qty); - setAuditReason('PHYSICAL_VARIATION'); - setAuditRemarks(''); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-pencil-square" - }), " Count & Reconcile"] - })] - })] - }, idx)) - }), auditModalItem && /*#__PURE__*/_jsx("div", { - className: "modal fade show d-block", - style: { - backgroundColor: 'rgba(15, 23, 42, 0.85)', - zIndex: 10700 - }, - tabIndex: "-1", - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content border-0 shadow-2xl rounded-4 overflow-hidden", - style: { - background: '#0f172a', - color: '#f8fafc', - border: '1px solid #334155' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header border-bottom border-secondary py-2.5 px-3", - children: [/*#__PURE__*/_jsxs("h6", { - className: "modal-title fw-bold text-white mb-0 small", - children: ["Reconcile: ", auditModalItem.item_name] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: () => setAuditModalItem(null) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "col-6", - children: /*#__PURE__*/_jsxs("div", { - className: "p-2 rounded-3 border border-secondary text-center", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsx("small", { - className: "text-slate-400 d-block", - style: { - fontSize: '0.65rem' - }, - children: "System Qty" - }), /*#__PURE__*/_jsx("span", { - className: "fs-4 fw-bolder text-white", - children: auditModalItem.current_qty - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-6", - children: /*#__PURE__*/_jsxs("div", { - className: "p-2 rounded-3 border border-primary text-center", - style: { - background: 'rgba(14, 165, 233, 0.15)' - }, - children: [/*#__PURE__*/_jsx("small", { - className: "text-cyan-300 d-block", - style: { - fontSize: '0.65rem' - }, - children: "Physical Count" - }), /*#__PURE__*/_jsx("input", { - type: "number", - min: "0", - className: "form-control form-control-sm text-center fw-bolder text-cyan-300 bg-dark border-primary", - value: auditCount, - onChange: e => setAuditCount(e.target.value), - autoFocus: true - })] - }) - })] - }), (() => { - const sys = Number(auditModalItem.current_qty); - const phy = Number(auditCount !== '' ? auditCount : sys); - const diff = phy - sys; - const rate = Number(auditModalItem.ptr || auditModalItem.mrp || 0); - const val = Math.abs(diff) * rate; - if (diff === 0) { - return /*#__PURE__*/_jsx("div", { - className: "alert alert-success py-1.5 px-2 small mb-2", - children: "✓ Counts match (0 diff)." - }); - } else if (diff < 0) { - return /*#__PURE__*/_jsxs("div", { - className: "alert alert-danger py-1.5 px-2 small mb-2", - children: [/*#__PURE__*/_jsxs("strong", { - children: ["Shortage: ", Math.abs(diff), " units"] - }), " (Loss: ₹", val.toFixed(2), ")"] - }); - } else { - return /*#__PURE__*/_jsxs("div", { - className: "alert alert-info py-1.5 px-2 small mb-2", - children: [/*#__PURE__*/_jsxs("strong", { - children: ["Surplus: +", diff, " units"] - }), " (Valuation: ₹", val.toFixed(2), ")"] - }); - } - })(), /*#__PURE__*/_jsxs("div", { - className: "mb-2", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-slate-300 small mb-1", - children: "Reason" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm bg-dark text-white border-secondary", - value: auditReason, - onChange: e => setAuditReason(e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "PHYSICAL_VARIATION", - children: "Physical Shelf Miscount" - }), /*#__PURE__*/_jsx("option", { - value: "DAMAGE", - children: "Damaged Foil / Bottle" - }), /*#__PURE__*/_jsx("option", { - value: "BREAKAGE", - children: "Breakage / Leakage" - }), /*#__PURE__*/_jsx("option", { - value: "EXPIRY_DUMP", - children: "Expired Stock Disposed" - }), /*#__PURE__*/_jsx("option", { - value: "SURPLUS_FOUND", - children: "Surplus Found" - }), /*#__PURE__*/_jsx("option", { - value: "THEFT_LOSS", - children: "Unaccounted Shortage" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-2", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-slate-300 small mb-1", - children: "Remarks" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm bg-dark text-white border-secondary", - placeholder: "Shelf location / note", - value: auditRemarks, - onChange: e => setAuditRemarks(e.target.value) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer border-top border-secondary py-2 px-3", - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-xs btn-outline-secondary", - onClick: () => setAuditModalItem(null), - children: "Cancel" - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-primary fw-bold", - onClick: handleMobileReconcile, - disabled: isSubmittingAudit, - children: isSubmittingAudit ? 'Saving...' : 'Commit Adjustment' - })] - })] - }) - }) - })] - }), mobTab === 'purchase_photo' && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-between mb-2", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold mb-0 text-white d-flex align-items-center gap-1.5", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-camera-fill text-primary" - }), " Inward Bill Camera Attachment"] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-primary-subtle text-primary border border-primary", - style: { - fontSize: '0.65rem' - }, - children: "Audit Proof" - })] - }), /*#__PURE__*/_jsx("p", { - className: "text-slate-400 small mb-3", - style: { - fontSize: '0.75rem', - color: '#94a3b8' - }, - children: "Take a direct photo of the distributor's delivery challan or paper tax invoice and attach it to the inward record." - }), /*#__PURE__*/_jsxs("div", { - className: "p-3 rounded-3 mb-3 border border-secondary", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsx("label", { - className: "form-label text-slate-300 small fw-bold text-uppercase mb-1", - style: { - color: '#cbd5e1' - }, - children: "1. Select Inward Purchase Bill" - }), /*#__PURE__*/_jsx("select", { - className: "form-select form-select-sm bg-dark text-white border-secondary mb-3", - value: selectedPurchaseId, - onChange: e => setSelectedPurchaseId(e.target.value), - children: recentPurchases.map(p => /*#__PURE__*/_jsxs("option", { - value: p.purchase_id, - children: ["#", p.purchase_id, " | Inv: ", p.supplier_invoice_no, " | ", p.supplier_name || 'Distributor', " (₹", p.net_amount, ")"] - }, p.purchase_id)) - }), /*#__PURE__*/_jsx("label", { - className: "form-label text-slate-300 small fw-bold text-uppercase mb-1", - style: { - color: '#cbd5e1' - }, - children: "2. Take Paper Invoice Photo" - }), /*#__PURE__*/_jsx("div", { - className: "mb-3", - children: /*#__PURE__*/_jsxs("label", { - className: "btn btn-outline-primary btn-sm w-100 py-3 d-flex flex-column align-items-center justify-content-center gap-1.5 rounded-3", - style: { - borderStyle: 'dashed', - borderWidth: '2px', - cursor: 'pointer' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-camera fs-3" - }), /*#__PURE__*/_jsx("span", { - className: "fw-bold small", - children: "Snap Photo with Phone Camera" - }), /*#__PURE__*/_jsx("small", { - className: "text-slate-400", - style: { - fontSize: '0.68rem' - }, - children: "or choose from device gallery" - }), /*#__PURE__*/_jsx("input", { - type: "file", - accept: "image/*", - capture: "environment", - className: "d-none", - onChange: handleCaptureFile - })] - }) - }), capturedImageBase64 && /*#__PURE__*/_jsxs("div", { - className: "mb-3 text-center", - children: [/*#__PURE__*/_jsx("div", { - className: "small text-slate-400 mb-1 text-start", - children: "Preview of Captured Bill:" - }), /*#__PURE__*/_jsx("img", { - src: capturedImageBase64, - alt: "Captured Invoice", - className: "rounded-3 border border-secondary shadow-sm", - style: { - maxWidth: '100%', - maxHeight: 220, - objectFit: 'contain', - background: '#000' - } - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-primary w-100 py-2 fw-bold d-flex align-items-center justify-content-center gap-2 shadow", - onClick: handleUploadPhoto, - disabled: isUploadingPhoto || !capturedImageBase64, - children: isUploadingPhoto ? /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm" - }), " Attaching Image..."] - }) : /*#__PURE__*/_jsxs(_Fragment, { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cloud-arrow-up-fill" - }), " Upload & Attach to Purchase"] - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card border-0 rounded-3", - style: { - background: '#1e293b' - }, - children: [/*#__PURE__*/_jsx("div", { - className: "card-header border-bottom border-secondary py-2 px-3", - children: /*#__PURE__*/_jsx("span", { - className: "small fw-bold text-white", - children: "Recent Purchases with Photo Status" - }) - }), /*#__PURE__*/_jsx("div", { - className: "p-0", - children: recentPurchases.slice(0, 5).map(p => /*#__PURE__*/_jsxs("div", { - className: "p-2.5 border-bottom border-slate-700 d-flex align-items-center justify-content-between small", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-white", - children: p.supplier_invoice_no - }), /*#__PURE__*/_jsxs("div", { - className: "text-slate-400", - style: { - fontSize: '0.7rem' - }, - children: [p.supplier_name || 'Distributor', " • ₹", p.net_amount] - })] - }), /*#__PURE__*/_jsx("div", { - children: p.invoice_photo ? /*#__PURE__*/_jsxs("a", { - href: p.invoice_photo, - target: "_blank", - rel: "noreferrer", - className: "btn btn-xs btn-outline-success d-flex align-items-center gap-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-image" - }), " View Photo"] - }) : /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary-subtle text-secondary", - style: { - fontSize: '0.65rem' - }, - children: "No Photo" - }) - })] - }, p.purchase_id)) - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "fixed-bottom border-top border-slate-800 d-flex align-items-center justify-content-around py-2 px-1 shadow-lg", - style: { - background: '#0f172a', - zIndex: 1030 - }, - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn btn-link text-decoration-none p-1 d-flex flex-column align-items-center ${mobTab === 'dashboard' ? 'text-primary fw-bold' : 'text-slate-400'}`, - onClick: () => setMobTab('dashboard'), - style: { - fontSize: '0.72rem', - color: mobTab === 'dashboard' ? '#38bdf8' : '#94a3b8' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-speedometer2 fs-5" - }), /*#__PURE__*/_jsx("span", { - children: "Dashboard" - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn btn-link text-decoration-none p-1 d-flex flex-column align-items-center position-relative ${mobTab === 'collector' ? 'text-primary fw-bold' : 'text-slate-400'}`, - onClick: () => setMobTab('collector'), - style: { - fontSize: '0.72rem', - color: mobTab === 'collector' ? '#38bdf8' : '#94a3b8' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-basket-fill fs-5" - }), /*#__PURE__*/_jsx("span", { - children: "Rack Drafts" - }), collectorItems.length > 0 && /*#__PURE__*/_jsx("span", { - className: "position-absolute top-0 start-50 translate-middle badge rounded-pill bg-danger", - style: { - fontSize: '0.6rem' - }, - children: collectorItems.length - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn btn-link text-decoration-none p-1 d-flex flex-column align-items-center ${mobTab === 'auditor' ? 'text-primary fw-bold' : 'text-slate-400'}`, - onClick: () => setMobTab('auditor'), - style: { - fontSize: '0.72rem', - color: mobTab === 'auditor' ? '#38bdf8' : '#94a3b8' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-sliders2 fs-5" - }), /*#__PURE__*/_jsx("span", { - children: "Shelf Audit" - })] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn btn-link text-decoration-none p-1 d-flex flex-column align-items-center ${mobTab === 'purchase_photo' ? 'text-primary fw-bold' : 'text-slate-400'}`, - onClick: () => setMobTab('purchase_photo'), - style: { - fontSize: '0.72rem', - color: mobTab === 'purchase_photo' ? '#38bdf8' : '#94a3b8' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-camera-fill fs-5" - }), /*#__PURE__*/_jsx("span", { - children: "Bill Camera" - })] - })] - })] - }); + style: { + cursor: 'pointer' + } + }, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-white small" + }, item.item_name), /*#__PURE__*/React.createElement("small", { + className: "text-slate-400", + style: { + fontSize: '0.7rem', + color: '#94a3b8' + } + }, item.generic_name, " • Stock: ", /*#__PURE__*/React.createElement("strong", { + className: "text-success" + }, item.total_stock), " Units"))))), selectedItem && /*#__PURE__*/React.createElement("div", { + className: "p-3 rounded-3 mb-3 border border-primary", + style: { + background: 'rgba(14, 165, 233, 0.12)' + } + }, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-white fs-6 mb-1" + }, selectedItem.item_name), /*#__PURE__*/React.createElement("small", { + className: "text-slate-400 d-block mb-2" + }, selectedItem.generic_name), /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-12" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-slate-300 small mb-1" + }, "Select Batch from Shelf"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm bg-dark text-white border-secondary", + value: selectedBatch?.batch_id || '', + onChange: e => { + const b = selectedItem.batches?.find(bt => bt.batch_id == e.target.value); + setSelectedBatch(b || null); + } + }, (selectedItem.batches || []).map(b => /*#__PURE__*/React.createElement("option", { + key: b.batch_id, + value: b.batch_id + }, "Batch: ", b.batch_no, " | Exp: ", b.expiry_date, " | Stock: ", b.current_qty, " | Sh: ", b.shelf_no || '-')))), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-slate-300 small mb-1" + }, "Sell Unit"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm bg-dark text-white border-secondary", + value: collectUnit, + onChange: e => setCollectUnit(e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "Tablet" + }, "Tablet / Loose"), /*#__PURE__*/React.createElement("option", { + value: "Strip" + }, "Strip / Full Pack"))), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-slate-300 small mb-1" + }, "Quantity"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-secondary text-white", + type: "button", + onClick: () => setCollectQty(Math.max(1, collectQty - 1)) + }, "-"), /*#__PURE__*/React.createElement("input", { + type: "number", + min: "1", + className: "form-control text-center fw-bold bg-dark text-white border-secondary", + value: collectQty, + onChange: e => setCollectQty(Math.max(1, Number(e.target.value))) + }), /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-secondary text-white", + type: "button", + onClick: () => setCollectQty(collectQty + 1) + }, "+")))), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-between pt-2" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-secondary text-white", + onClick: () => setSelectedItem(null) + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-primary fw-bold", + onClick: addItemToDraft + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-plus-circle me-1" + }), " Add to Basket"))), /*#__PURE__*/React.createElement("div", { + className: "card border-0 rounded-3 mb-3", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("div", { + className: "card-header border-bottom border-secondary py-2 px-3 d-flex align-items-center justify-content-between" + }, /*#__PURE__*/React.createElement("span", { + className: "small fw-bold text-white" + }, "Draft Basket Items (", collectorItems.length, ")"), collectorItems.length > 0 && /*#__PURE__*/React.createElement("button", { + className: "btn btn-xs btn-outline-danger", + onClick: () => setCollectorItems([]) + }, "Clear")), /*#__PURE__*/React.createElement("div", { + className: "p-0" + }, collectorItems.length === 0 ? /*#__PURE__*/React.createElement("div", { + className: "p-4 text-center text-slate-400 small" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cart3 fs-3 d-block mb-1 text-slate-600" + }), "No medicines collected yet. Search and pick items above.") : collectorItems.map((it, idx) => /*#__PURE__*/React.createElement("div", { + key: idx, + className: "p-2.5 border-bottom border-slate-700 d-flex align-items-center justify-content-between small" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-white" + }, it.item_name), /*#__PURE__*/React.createElement("div", { + className: "text-slate-400", + style: { + fontSize: '0.7rem' + } + }, "Batch: ", it.batch_no, " • Qty: ", /*#__PURE__*/React.createElement("strong", { + className: "text-cyan-300" + }, it.qty, " ", it.sell_unit), " • Rate: ", /*#__PURE__*/React.createElement("strong", { + className: "text-warning" + }, "₹", it.effective_rate), " • Total: ", /*#__PURE__*/React.createElement("strong", { + className: "text-success" + }, "₹", it.line_gross))), /*#__PURE__*/React.createElement("button", { + className: "btn btn-xs btn-outline-danger p-1", + onClick: () => setCollectorItems(collectorItems.filter((_, i) => i !== idx)) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-trash" + })))))), collectorItems.length > 0 && /*#__PURE__*/React.createElement("div", { + className: "p-3 rounded-3 mb-3 border border-secondary", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-slate-300 small fw-bold text-uppercase mb-2", + style: { + color: '#cbd5e1' + } + }, "Patient / Counter Destination"), /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-dark text-white border-secondary", + placeholder: "Patient Name / Walk-in", + value: patientName, + onChange: e => setPatientName(e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-dark text-white border-secondary", + placeholder: "Mobile Number", + value: patientMobile, + onChange: e => setPatientMobile(e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-dark text-white border-secondary", + placeholder: "Bed / Room No (optional)", + value: bedNo, + onChange: e => setBedNo(e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-dark text-white border-secondary", + placeholder: "Ward Name", + value: wardName, + onChange: e => setWardName(e.target.value) + }))), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-primary w-100 py-2 fw-bold d-flex align-items-center justify-content-center gap-2 shadow", + onClick: handleSaveDraft, + disabled: isSavingDraft + }, isSavingDraft ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm" + }), " Transmitting to Counter Desk...") : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-send-check-fill" + }), " Save Draft to Counter Desk")))), mobTab === 'auditor' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-between mb-2" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold mb-0 text-white d-flex align-items-center gap-1.5" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-sliders2 text-info" + }), " Mobile Shelf Auditor"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-info-subtle text-info border border-info", + style: { + fontSize: '0.65rem' + } + }, "Routine Count")), /*#__PURE__*/React.createElement("p", { + className: "text-slate-400 small mb-3", + style: { + fontSize: '0.75rem', + color: '#94a3b8' + } + }, "During low workload hours, search medicine or rack, check shelf count against system records, and reconcile stock with 1 tap."), /*#__PURE__*/React.createElement("div", { + className: "input-group mb-3" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-dark border-secondary text-slate-400" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-dark text-white border-secondary", + placeholder: "Search medicine, batch, shelf no...", + value: auditSearch, + onChange: e => handleSearchAudit(e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-column gap-2" + }, auditResults.length === 0 ? /*#__PURE__*/React.createElement("div", { + className: "text-center py-4 text-slate-500 small" + }, "Type medicine or batch to verify shelf stock.") : auditResults.map((item, idx) => /*#__PURE__*/React.createElement("div", { + key: idx, + className: "p-3 rounded-3 border border-secondary", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-start justify-content-between gap-2 mb-1" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-white small" + }, item.item_name), /*#__PURE__*/React.createElement("div", { + className: "text-slate-400", + style: { + fontSize: '0.72rem', + color: '#94a3b8' + } + }, "Batch: ", /*#__PURE__*/React.createElement("strong", { + className: "text-cyan-300" + }, item.batch_no), " • Exp: ", item.expiry_display || item.expiry_date)), /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary", + style: { + fontSize: '0.65rem' + } + }, item.shelf_no ? `Shelf: ${item.shelf_no}` : 'Normal')), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-between pt-2 border-top border-slate-700 mt-2" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("small", { + className: "text-slate-400 d-block", + style: { + fontSize: '0.65rem' + } + }, "SYSTEM STOCK"), /*#__PURE__*/React.createElement("span", { + className: "fs-6 fw-bold text-success" + }, item.current_qty, " Units")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-info text-white px-2.5 py-1 rounded-pill d-flex align-items-center gap-1", + onClick: () => { + setAuditModalItem(item); + setAuditCount(item.current_qty); + setAuditReason('PHYSICAL_VARIATION'); + setAuditRemarks(''); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-pencil-square" + }), " Count & Reconcile"))))), auditModalItem && /*#__PURE__*/React.createElement("div", { + className: "modal fade show d-block", + style: { + backgroundColor: 'rgba(15, 23, 42, 0.85)', + zIndex: 10700 + }, + tabIndex: "-1" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content border-0 shadow-2xl rounded-4 overflow-hidden", + style: { + background: '#0f172a', + color: '#f8fafc', + border: '1px solid #334155' + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header border-bottom border-secondary py-2.5 px-3" + }, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold text-white mb-0 small" + }, "Reconcile: ", auditModalItem.item_name), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: () => setAuditModalItem(null) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3" + }, /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("div", { + className: "p-2 rounded-3 border border-secondary text-center", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("small", { + className: "text-slate-400 d-block", + style: { + fontSize: '0.65rem' + } + }, "System Qty"), /*#__PURE__*/React.createElement("span", { + className: "fs-4 fw-bolder text-white" + }, auditModalItem.current_qty))), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("div", { + className: "p-2 rounded-3 border border-primary text-center", + style: { + background: 'rgba(14, 165, 233, 0.15)' + } + }, /*#__PURE__*/React.createElement("small", { + className: "text-cyan-300 d-block", + style: { + fontSize: '0.65rem' + } + }, "Physical Count"), /*#__PURE__*/React.createElement("input", { + type: "number", + min: "0", + className: "form-control form-control-sm text-center fw-bolder text-cyan-300 bg-dark border-primary", + value: auditCount, + onChange: e => setAuditCount(e.target.value), + autoFocus: true + })))), (() => { + const sys = Number(auditModalItem.current_qty); + const phy = Number(auditCount !== '' ? auditCount : sys); + const diff = phy - sys; + const rate = Number(auditModalItem.ptr || auditModalItem.mrp || 0); + const val = Math.abs(diff) * rate; + if (diff === 0) { + return /*#__PURE__*/React.createElement("div", { + className: "alert alert-success py-1.5 px-2 small mb-2" + }, "✓ Counts match (0 diff)."); + } else if (diff < 0) { + return /*#__PURE__*/React.createElement("div", { + className: "alert alert-danger py-1.5 px-2 small mb-2" + }, /*#__PURE__*/React.createElement("strong", null, "Shortage: ", Math.abs(diff), " units"), " (Loss: ₹", val.toFixed(2), ")"); + } else { + return /*#__PURE__*/React.createElement("div", { + className: "alert alert-info py-1.5 px-2 small mb-2" + }, /*#__PURE__*/React.createElement("strong", null, "Surplus: +", diff, " units"), " (Valuation: ₹", val.toFixed(2), ")"); + } + })(), /*#__PURE__*/React.createElement("div", { + className: "mb-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-slate-300 small mb-1" + }, "Reason"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm bg-dark text-white border-secondary", + value: auditReason, + onChange: e => setAuditReason(e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "PHYSICAL_VARIATION" + }, "Physical Shelf Miscount"), /*#__PURE__*/React.createElement("option", { + value: "DAMAGE" + }, "Damaged Foil / Bottle"), /*#__PURE__*/React.createElement("option", { + value: "BREAKAGE" + }, "Breakage / Leakage"), /*#__PURE__*/React.createElement("option", { + value: "EXPIRY_DUMP" + }, "Expired Stock Disposed"), /*#__PURE__*/React.createElement("option", { + value: "SURPLUS_FOUND" + }, "Surplus Found"), /*#__PURE__*/React.createElement("option", { + value: "THEFT_LOSS" + }, "Unaccounted Shortage"))), /*#__PURE__*/React.createElement("div", { + className: "mb-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-slate-300 small mb-1" + }, "Remarks"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm bg-dark text-white border-secondary", + placeholder: "Shelf location / note", + value: auditRemarks, + onChange: e => setAuditRemarks(e.target.value) + }))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer border-top border-secondary py-2 px-3" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-xs btn-outline-secondary", + onClick: () => setAuditModalItem(null) + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-primary fw-bold", + onClick: handleMobileReconcile, + disabled: isSubmittingAudit + }, isSubmittingAudit ? 'Saving...' : 'Commit Adjustment')))))), mobTab === 'purchase_photo' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-between mb-2" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold mb-0 text-white d-flex align-items-center gap-1.5" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-camera-fill text-primary" + }), " Inward Bill Camera Attachment"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary border border-primary", + style: { + fontSize: '0.65rem' + } + }, "Audit Proof")), /*#__PURE__*/React.createElement("p", { + className: "text-slate-400 small mb-3", + style: { + fontSize: '0.75rem', + color: '#94a3b8' + } + }, "Take a direct photo of the distributor's delivery challan or paper tax invoice and attach it to the inward record."), /*#__PURE__*/React.createElement("div", { + className: "p-3 rounded-3 mb-3 border border-secondary", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("label", { + className: "form-label text-slate-300 small fw-bold text-uppercase mb-1", + style: { + color: '#cbd5e1' + } + }, "1. Select Inward Purchase Bill"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm bg-dark text-white border-secondary mb-3", + value: selectedPurchaseId, + onChange: e => setSelectedPurchaseId(e.target.value) + }, recentPurchases.map(p => /*#__PURE__*/React.createElement("option", { + key: p.purchase_id, + value: p.purchase_id + }, "#", p.purchase_id, " | Inv: ", p.supplier_invoice_no, " | ", p.supplier_name || 'Distributor', " (₹", p.net_amount, ")"))), /*#__PURE__*/React.createElement("label", { + className: "form-label text-slate-300 small fw-bold text-uppercase mb-1", + style: { + color: '#cbd5e1' + } + }, "2. Take Paper Invoice Photo"), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "btn btn-outline-primary btn-sm w-100 py-3 d-flex flex-column align-items-center justify-content-center gap-1.5 rounded-3", + style: { + borderStyle: 'dashed', + borderWidth: '2px', + cursor: 'pointer' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-camera fs-3" + }), /*#__PURE__*/React.createElement("span", { + className: "fw-bold small" + }, "Snap Photo with Phone Camera"), /*#__PURE__*/React.createElement("small", { + className: "text-slate-400", + style: { + fontSize: '0.68rem' + } + }, "or choose from device gallery"), /*#__PURE__*/React.createElement("input", { + type: "file", + accept: "image/*", + capture: "environment", + className: "d-none", + onChange: handleCaptureFile + }))), capturedImageBase64 && /*#__PURE__*/React.createElement("div", { + className: "mb-3 text-center" + }, /*#__PURE__*/React.createElement("div", { + className: "small text-slate-400 mb-1 text-start" + }, "Preview of Captured Bill:"), /*#__PURE__*/React.createElement("img", { + src: capturedImageBase64, + alt: "Captured Invoice", + className: "rounded-3 border border-secondary shadow-sm", + style: { + maxWidth: '100%', + maxHeight: 220, + objectFit: 'contain', + background: '#000' + } + })), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-primary w-100 py-2 fw-bold d-flex align-items-center justify-content-center gap-2 shadow", + onClick: handleUploadPhoto, + disabled: isUploadingPhoto || !capturedImageBase64 + }, isUploadingPhoto ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm" + }), " Attaching Image...") : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cloud-arrow-up-fill" + }), " Upload & Attach to Purchase"))), /*#__PURE__*/React.createElement("div", { + className: "card border-0 rounded-3", + style: { + background: '#1e293b' + } + }, /*#__PURE__*/React.createElement("div", { + className: "card-header border-bottom border-secondary py-2 px-3" + }, /*#__PURE__*/React.createElement("span", { + className: "small fw-bold text-white" + }, "Recent Purchases with Photo Status")), /*#__PURE__*/React.createElement("div", { + className: "p-0" + }, recentPurchases.slice(0, 5).map(p => /*#__PURE__*/React.createElement("div", { + key: p.purchase_id, + className: "p-2.5 border-bottom border-slate-700 d-flex align-items-center justify-content-between small" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-white" + }, p.supplier_invoice_no), /*#__PURE__*/React.createElement("div", { + className: "text-slate-400", + style: { + fontSize: '0.7rem' + } + }, p.supplier_name || 'Distributor', " • ₹", p.net_amount)), /*#__PURE__*/React.createElement("div", null, p.invoice_photo ? /*#__PURE__*/React.createElement("a", { + href: p.invoice_photo, + target: "_blank", + rel: "noreferrer", + className: "btn btn-xs btn-outline-success d-flex align-items-center gap-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-image" + }), " View Photo") : /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-secondary", + style: { + fontSize: '0.65rem' + } + }, "No Photo")))))))), /*#__PURE__*/React.createElement("div", { + className: "fixed-bottom border-top border-slate-800 d-flex align-items-center justify-content-around py-2 px-1 shadow-lg", + style: { + background: '#0f172a', + zIndex: 1030 + } + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn btn-link text-decoration-none p-1 d-flex flex-column align-items-center ${mobTab === 'dashboard' ? 'text-primary fw-bold' : 'text-slate-400'}`, + onClick: () => setMobTab('dashboard'), + style: { + fontSize: '0.72rem', + color: mobTab === 'dashboard' ? '#38bdf8' : '#94a3b8' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-speedometer2 fs-5" + }), /*#__PURE__*/React.createElement("span", null, "Dashboard")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn btn-link text-decoration-none p-1 d-flex flex-column align-items-center position-relative ${mobTab === 'collector' ? 'text-primary fw-bold' : 'text-slate-400'}`, + onClick: () => setMobTab('collector'), + style: { + fontSize: '0.72rem', + color: mobTab === 'collector' ? '#38bdf8' : '#94a3b8' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-basket-fill fs-5" + }), /*#__PURE__*/React.createElement("span", null, "Rack Drafts"), collectorItems.length > 0 && /*#__PURE__*/React.createElement("span", { + className: "position-absolute top-0 start-50 translate-middle badge rounded-pill bg-danger", + style: { + fontSize: '0.6rem' + } + }, collectorItems.length)), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn btn-link text-decoration-none p-1 d-flex flex-column align-items-center ${mobTab === 'auditor' ? 'text-primary fw-bold' : 'text-slate-400'}`, + onClick: () => setMobTab('auditor'), + style: { + fontSize: '0.72rem', + color: mobTab === 'auditor' ? '#38bdf8' : '#94a3b8' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-sliders2 fs-5" + }), /*#__PURE__*/React.createElement("span", null, "Shelf Audit")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn btn-link text-decoration-none p-1 d-flex flex-column align-items-center ${mobTab === 'purchase_photo' ? 'text-primary fw-bold' : 'text-slate-400'}`, + onClick: () => setMobTab('purchase_photo'), + style: { + fontSize: '0.72rem', + color: mobTab === 'purchase_photo' ? '#38bdf8' : '#94a3b8' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-camera-fill fs-5" + }), /*#__PURE__*/React.createElement("span", null, "Bill Camera")))); } const root = ReactDOM.createRoot(document.getElementById('root')); -root.render(/*#__PURE__*/_jsx(ErrorBoundary, { - children: /*#__PURE__*/_jsx(App, {}) -})); \ No newline at end of file +root.render(/*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(App, null))); \ No newline at end of file diff --git a/public/App/Nursing/nursing-app.bundle.js b/public/App/Nursing/nursing-app.bundle.js index 3324ba1..683ad3c 100644 --- a/public/App/Nursing/nursing-app.bundle.js +++ b/public/App/Nursing/nursing-app.bundle.js @@ -1,4 +1,3 @@ -import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; const { useState, useEffect @@ -22,201 +21,168 @@ const MobileAppsModal = ({ window.location.href = '/app/nursing'; } }; - return /*#__PURE__*/_jsx("div", { + return /*#__PURE__*/React.createElement("div", { className: "modal fade show d-block", style: { backgroundColor: 'rgba(15, 23, 42, 0.7)', zIndex: 1055, backdropFilter: 'blur(4px)' }, - tabIndex: "-1", - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered px-2", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content border-0 shadow-lg rounded-4 overflow-hidden", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header text-white p-3", - style: { - background: 'linear-gradient(135deg, #0f172a 0%, #1e293b 100%)' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("img", { - src: "/assets/img/logo.png", - alt: "Hospital Logo", - style: { - height: '28px', - width: 'auto', - filter: 'brightness(0) invert(1)' - }, - onError: e => { - e.target.style.display = 'none'; - } - }), /*#__PURE__*/_jsxs("h6", { - className: "modal-title fw-bold mb-0 text-white", - style: { - fontSize: '15px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-grid-fill me-1 text-primary" - }), " HMS Mobile & PWA Apps Launcher"] - })] - }), /*#__PURE__*/_jsx("button", { - type: "button", - className: "btn-close btn-close-white", - onClick: onClose - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-3 bg-light", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label fw-bold small text-secondary mb-2", - style: { - letterSpacing: '0.5px' - }, - children: "1. SELECT APPLICATION" - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "col-4", - children: /*#__PURE__*/_jsxs("div", { - className: `card p-2 text-center h-100 ${currentApp === 'nursing' ? 'border-2 border-primary bg-primary-subtle shadow-sm' : 'border bg-white text-dark'}`, - style: { - cursor: 'pointer', - borderRadius: '12px' - }, - onClick: () => navigateToApp('nursing'), - children: [/*#__PURE__*/_jsx("div", { - className: "my-1", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-heart-pulse-fill fs-3 text-primary" - }) - }), /*#__PURE__*/_jsx("div", { - className: "fw-bold small text-truncate", - style: { - fontSize: '12px' - }, - children: "Nursing Care" - }), currentApp === 'nursing' ? /*#__PURE__*/_jsx("span", { - className: "badge bg-primary mt-1", - style: { - fontSize: '9px' - }, - children: "● Active App" - }) : /*#__PURE__*/_jsx("span", { - className: "badge bg-info-subtle text-info-emphasis border border-info-subtle mt-1", - style: { - fontSize: '9px' - }, - children: "Active PWA" - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-4", - children: /*#__PURE__*/_jsxs("div", { - className: `card p-2 text-center h-100 ${currentApp === 'doctor' ? 'border-2 border-primary bg-primary-subtle shadow-sm' : 'border bg-white text-dark'}`, - style: { - cursor: 'pointer', - borderRadius: '12px' - }, - onClick: () => navigateToApp('doctor'), - children: [/*#__PURE__*/_jsx("div", { - className: "my-1", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-person-badge-fill fs-3 text-primary" - }) - }), /*#__PURE__*/_jsx("div", { - className: "fw-bold small text-truncate", - style: { - fontSize: '12px' - }, - children: "Doctor App" - }), currentApp === 'doctor' ? /*#__PURE__*/_jsx("span", { - className: "badge bg-primary mt-1", - style: { - fontSize: '9px' - }, - children: "● Active App" - }) : /*#__PURE__*/_jsx("span", { - className: "badge bg-success mt-1", - style: { - fontSize: '9px' - }, - children: "Active PWA" - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-4", - children: /*#__PURE__*/_jsxs("div", { - className: "card p-2 text-center border bg-white text-muted opacity-75 h-100", - style: { - borderRadius: '12px', - cursor: 'not-allowed' - }, - children: [/*#__PURE__*/_jsx("div", { - className: "my-1", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-capsule fs-3 text-secondary" - }) - }), /*#__PURE__*/_jsx("div", { - className: "fw-bold small text-truncate", - style: { - fontSize: '12px' - }, - children: "Pharmacy App" - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary mt-1", - style: { - fontSize: '9px' - }, - children: "Coming Soon" - })] - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "p-3 bg-white rounded-3 border text-center shadow-sm", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-center gap-2 mb-2", - children: [/*#__PURE__*/_jsx("img", { - src: "/assets/img/logo.png", - alt: "Logo", - style: { - height: '28px' - }, - onError: e => e.target.style.display = 'none' - }), /*#__PURE__*/_jsxs("div", { - className: "text-start", - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold small text-dark", - children: "HMS Unified Mobile Portal" - }), /*#__PURE__*/_jsxs("div", { - className: "small text-muted", - style: { - fontSize: '10px' - }, - children: ["Domain: ", window.location.host] - })] - })] - }), /*#__PURE__*/_jsx("p", { - className: "small text-muted mb-2", - style: { - fontSize: '11px' - }, - children: "Tap any active app card above to switch between modules in your mobile app." - }), /*#__PURE__*/_jsxs("a", { - href: "/app", - className: "btn btn-outline-primary btn-sm w-100 fw-bold rounded-pill", - style: { - fontSize: '12px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-house-door me-1" - }), " Open Mobile App Hub"] - })] - })] - })] - }) - }) - }); + tabIndex: "-1" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered px-2" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content border-0 shadow-lg rounded-4 overflow-hidden" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header text-white p-3", + style: { + background: 'linear-gradient(135deg, #0f172a 0%, #1e293b 100%)' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("img", { + src: "/assets/img/logo.png", + alt: "Hospital Logo", + style: { + height: '28px', + width: 'auto', + filter: 'brightness(0) invert(1)' + }, + onError: e => { + e.target.style.display = 'none'; + } + }), /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold mb-0 text-white", + style: { + fontSize: '15px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-grid-fill me-1 text-primary" + }), " HMS Mobile & PWA Apps Launcher")), /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn-close btn-close-white", + onClick: onClose + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3 bg-light" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-secondary mb-2", + style: { + letterSpacing: '0.5px' + } + }, "1. SELECT APPLICATION"), /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("div", { + className: `card p-2 text-center h-100 ${currentApp === 'nursing' ? 'border-2 border-primary bg-primary-subtle shadow-sm' : 'border bg-white text-dark'}`, + style: { + cursor: 'pointer', + borderRadius: '12px' + }, + onClick: () => navigateToApp('nursing') + }, /*#__PURE__*/React.createElement("div", { + className: "my-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-heart-pulse-fill fs-3 text-primary" + })), /*#__PURE__*/React.createElement("div", { + className: "fw-bold small text-truncate", + style: { + fontSize: '12px' + } + }, "Nursing Care"), currentApp === 'nursing' ? /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary mt-1", + style: { + fontSize: '9px' + } + }, "● Active App") : /*#__PURE__*/React.createElement("span", { + className: "badge bg-info-subtle text-info-emphasis border border-info-subtle mt-1", + style: { + fontSize: '9px' + } + }, "Active PWA"))), /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("div", { + className: `card p-2 text-center h-100 ${currentApp === 'doctor' ? 'border-2 border-primary bg-primary-subtle shadow-sm' : 'border bg-white text-dark'}`, + style: { + cursor: 'pointer', + borderRadius: '12px' + }, + onClick: () => navigateToApp('doctor') + }, /*#__PURE__*/React.createElement("div", { + className: "my-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-badge-fill fs-3 text-primary" + })), /*#__PURE__*/React.createElement("div", { + className: "fw-bold small text-truncate", + style: { + fontSize: '12px' + } + }, "Doctor App"), currentApp === 'doctor' ? /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary mt-1", + style: { + fontSize: '9px' + } + }, "● Active App") : /*#__PURE__*/React.createElement("span", { + className: "badge bg-success mt-1", + style: { + fontSize: '9px' + } + }, "Active PWA"))), /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("div", { + className: "card p-2 text-center border bg-white text-muted opacity-75 h-100", + style: { + borderRadius: '12px', + cursor: 'not-allowed' + } + }, /*#__PURE__*/React.createElement("div", { + className: "my-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-capsule fs-3 text-secondary" + })), /*#__PURE__*/React.createElement("div", { + className: "fw-bold small text-truncate", + style: { + fontSize: '12px' + } + }, "Pharmacy App"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary mt-1", + style: { + fontSize: '9px' + } + }, "Coming Soon")))), /*#__PURE__*/React.createElement("div", { + className: "p-3 bg-white rounded-3 border text-center shadow-sm" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-center gap-2 mb-2" + }, /*#__PURE__*/React.createElement("img", { + src: "/assets/img/logo.png", + alt: "Logo", + style: { + height: '28px' + }, + onError: e => e.target.style.display = 'none' + }), /*#__PURE__*/React.createElement("div", { + className: "text-start" + }, /*#__PURE__*/React.createElement("div", { + className: "fw-bold small text-dark" + }, "HMS Unified Mobile Portal"), /*#__PURE__*/React.createElement("div", { + className: "small text-muted", + style: { + fontSize: '10px' + } + }, "Domain: ", window.location.host))), /*#__PURE__*/React.createElement("p", { + className: "small text-muted mb-2", + style: { + fontSize: '11px' + } + }, "Tap any active app card above to switch between modules in your mobile app."), /*#__PURE__*/React.createElement("a", { + href: "/app", + className: "btn btn-outline-primary btn-sm w-100 fw-bold rounded-pill", + style: { + fontSize: '12px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-house-door me-1" + }), " Open Mobile App Hub")))))); }; function NursingApp() { const [showAppsModal, setShowAppsModal] = useState(false); @@ -364,32 +330,10 @@ function NursingApp() { general_note: '' }); const [showAllDoctorOrders, setShowAllDoctorOrders] = useState(false); - const nurseFetch = async (url, options = {}) => { - const headers = Object.assign({}, options.headers || {}); - const storedPairing = localStorage.getItem(PAIRED_NURSE_KEY); - if (storedPairing) { - try { - const parsed = JSON.parse(storedPairing); - if (parsed && parsed.device_token && !headers['X-Device-Token']) { - headers['X-Device-Token'] = parsed.device_token; - } - } catch (e) {} - } - const fetchOptions = Object.assign({}, options, { - credentials: 'same-origin', - headers: headers - }); - const res = await fetch(url, fetchOptions); - if (res.status === 401) { - setAuthenticatedNurse(null); - localStorage.removeItem(DEVICE_AUTH_KEY); - } - return res; - }; const fetchBeds = async () => { try { setLoading(true); - const res = await nurseFetch('/api/v1/nursing/beds'); + const res = await fetch('/api/v1/nursing/beds'); const json = await res.json(); if (json.status === 1 && json.data) { setBeds(json.data.beds || []); @@ -402,7 +346,7 @@ function NursingApp() { }; const fetchDoctors = async () => { try { - const res = await nurseFetch('/api/v1/doctor/list'); + const res = await fetch('/api/v1/doctor/list'); const json = await res.json(); if (json.status === 1 && json.data) { setDoctors(json.data); @@ -416,7 +360,7 @@ function NursingApp() { const mode = dateModeOverride !== undefined ? dateModeOverride : opdDateMode; const docId = docIdOverride !== undefined ? docIdOverride : selectedDoctorId; const vFilter = vitalsOverride !== undefined ? vitalsOverride : vitalsFilter; - const res = await nurseFetch(`/api/v1/nursing/opd/list?date_mode=${mode}&doctor_id=${docId}&vitals_status=${vFilter}`); + const res = await fetch(`/api/v1/nursing/opd/list?date_mode=${mode}&doctor_id=${docId}&vitals_status=${vFilter}`); const json = await res.json(); if (json.status === 1) { setOpdAppointments(json.appointments || []); @@ -430,23 +374,19 @@ function NursingApp() { }; useEffect(() => { const savedAuth = localStorage.getItem(DEVICE_AUTH_KEY); - let hasValidAuth = false; if (savedAuth) { try { const parsed = JSON.parse(savedAuth); if (parsed && parsed.nurse && parsed.expires_at > Date.now()) { setAuthenticatedNurse(parsed.nurse); - hasValidAuth = true; } else { localStorage.removeItem(DEVICE_AUTH_KEY); } } catch (e) {} } - if (hasValidAuth) { - fetchBeds(); - fetchDoctors(); - fetchOpdAppointments('today', '0', 'all'); - } + fetchBeds(); + fetchDoctors(); + fetchOpdAppointments('today', '0', 'all'); }, []); const handleVerifyPin = async () => { const isPairing = !pairedNurse || showPairingForm; @@ -501,7 +441,6 @@ function NursingApp() { setPinInput(''); setDeviceCodeInput(''); fetchBeds(); - fetchDoctors(); fetchOpdAppointments(opdDateMode, selectedDoctorId, vitalsFilter); } else if (json.status === 2) { setIsSettingNewPin(true); @@ -1068,36 +1007,30 @@ function NursingApp() { const text = entry.treatment_text || entry.general_note || ''; const match = text.match(/\[IMAGE_ATTACHMENT:(.*?)\]/); const cleanText = text.replace(/\[IMAGE_ATTACHMENT:.*?\]/, '').replace('[Doctor Note] ', ''); - return /*#__PURE__*/_jsxs("div", { - children: [cleanText && /*#__PURE__*/_jsx("div", { - className: "small fw-semibold", - children: cleanText - }), match && match[1] && /*#__PURE__*/_jsxs("div", { - className: "mt-2", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-primary mb-1 d-inline-flex align-items-center gap-1", - style: { - fontSize: '10px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-paperclip" - }), " Attached Document / Photo"] - }), /*#__PURE__*/_jsx("a", { - href: match[1], - target: "_blank", - rel: "noreferrer", - children: /*#__PURE__*/_jsx("img", { - src: match[1], - alt: "Attached Document", - className: "img-fluid rounded-3 border shadow-sm d-block mt-1", - style: { - maxHeight: '220px', - objectFit: 'cover' - } - }) - })] - })] - }); + return /*#__PURE__*/React.createElement("div", null, cleanText && /*#__PURE__*/React.createElement("div", { + className: "small fw-semibold" + }, cleanText), match && match[1] && /*#__PURE__*/React.createElement("div", { + className: "mt-2" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary mb-1 d-inline-flex align-items-center gap-1", + style: { + fontSize: '10px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-paperclip" + }), " Attached Document / Photo"), /*#__PURE__*/React.createElement("a", { + href: match[1], + target: "_blank", + rel: "noreferrer" + }, /*#__PURE__*/React.createElement("img", { + src: match[1], + alt: "Attached Document", + className: "img-fluid rounded-3 border shadow-sm d-block mt-1", + style: { + maxHeight: '220px', + objectFit: 'cover' + } + })))); }; const displayTempF = tempC => { if (tempC === null || tempC === undefined || tempC === '') return '-'; @@ -1146,3395 +1079,2560 @@ function NursingApp() { // ------------------------------------------------------------- if (!authenticatedNurse) { const isQuickUnlock = Boolean(pairedNurse && !showPairingForm); - return /*#__PURE__*/_jsxs("div", { - className: "lock-screen-overlay", - children: [/*#__PURE__*/_jsx(MobileAppsModal, { - show: showAppsModal, - onClose: () => setShowAppsModal(false), - currentApp: "nursing" - }), /*#__PURE__*/_jsxs("div", { - className: "lock-card", - children: [/*#__PURE__*/_jsxs("div", { - className: "p-4 text-center text-white position-relative", - style: { - background: 'linear-gradient(135deg, #0f172a 0%, #1e293b 100%)' - }, - children: [/*#__PURE__*/_jsx("button", { - type: "button", - className: "btn btn-sm btn-outline-light position-absolute top-0 end-0 m-2 rounded-circle", - style: { - width: '32px', - height: '32px', - padding: 0 - }, - onClick: () => setShowAppsModal(true), - title: "HMS Mobile & PWA Apps Launcher", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-grid-3x3-gap-fill", - style: { - fontSize: '12px' - } - }) - }), /*#__PURE__*/_jsx("img", { - src: "/assets/img/logo.png", - alt: "Hospital Logo", - className: "d-block mx-auto mb-2", - style: { - maxHeight: '40px', - filter: 'brightness(0) invert(1)' - }, - onError: e => { - e.target.style.display = 'none'; - } - }), /*#__PURE__*/_jsx("h5", { - className: "fw-bold mb-1", - children: "Nursing Care Mobile App" - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-center gap-1 opacity-75 small", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-check text-success" - }), /*#__PURE__*/_jsx("span", { - children: "Hospital Intranet & Device Protected" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "p-4", - children: [pinError && /*#__PURE__*/_jsx("div", { - className: "alert alert-danger py-2 px-3 small mb-3", - children: pinError - }), !isSettingNewPin ? isQuickUnlock ? - /*#__PURE__*/ - /* ------------------------------------------------------------- - PAIRED DEVICE QUICK UNLOCK - ------------------------------------------------------------- */ - _jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "text-center mb-4", - children: [/*#__PURE__*/_jsx("div", { - className: "avatar-circle mx-auto mb-2", - style: { - width: '54px', - height: '54px', - fontSize: '18px' - }, - children: getInitials(pairedNurse.name || pairedNurse.staff_id) - }), /*#__PURE__*/_jsx("h6", { - className: "fw-bold text-dark mb-0", - children: pairedNurse.name || 'Staff Nurse' - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary-subtle text-dark border font-monospace mt-1", - children: pairedNurse.staff_id - }), /*#__PURE__*/_jsxs("div", { - className: "text-muted small mt-1", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-phone-fill me-1 text-primary" - }), " Trusted Hospital Device"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label fw-bold small text-muted", - children: "Enter PIN or Password to Unlock" - }), /*#__PURE__*/_jsx("input", { - type: "password", - maxLength: "20", - className: "form-control text-center fs-3 letter-spacing-2", - placeholder: "••••", - value: pinInput, - autoFocus: true, - onChange: e => setPinInput(e.target.value), - onKeyUp: e => e.key === 'Enter' && handleVerifyPin() - }), /*#__PURE__*/_jsx("small", { - className: "text-muted text-center d-block mt-1", - style: { - fontSize: '11px' - }, - children: "30-day verified session active" - })] - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-success btn-lg w-100 py-3 fw-bold shadow-sm mb-2", - onClick: handleVerifyPin, - disabled: isVerifying, - children: isVerifying ? /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm me-2" - }), "Verifying..."] - }) : /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-unlock-fill me-2" - }), " Unlock Nursing App"] - }) - }), /*#__PURE__*/_jsx("div", { - className: "text-center mt-3 pt-2 border-top", - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-link btn-sm text-secondary text-decoration-none p-0", - onClick: () => { - setShowPairingForm(true); - setPinError(''); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-repeat me-1" - }), " Switch Account / Re-Pair Device"] - }) - })] - }) : - /*#__PURE__*/ - /* ------------------------------------------------------------- - FIRST-TIME DEVICE REGISTRATION / PAIRING FORM - ------------------------------------------------------------- */ - _jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "alert alert-primary py-2 px-3 small d-flex align-items-center gap-2 mb-3", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-lock-fill fs-5 text-primary" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold", - children: "First-Time Device Pairing" - }), /*#__PURE__*/_jsx("div", { - style: { - fontSize: '11px' - }, - children: "Enter Staff ID and Device Security Code from Nursing Staff Master." - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label fw-bold small text-dark mb-1", - children: ["Staff ID or Username ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "input-group", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-light", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-person-badge" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control", - placeholder: "e.g. NUR-637 or username", - value: staffIdInput, - onChange: e => setStaffIdInput(e.target.value) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label fw-bold small text-dark mb-1", - children: ["Device Security Code ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "input-group", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-light", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-key-fill text-warning" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - maxLength: "10", - className: "form-control font-monospace fw-bold", - placeholder: "6-digit code from Admin", - value: deviceCodeInput, - onChange: e => setDeviceCodeInput(e.target.value) - })] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - style: { - fontSize: '11px' - }, - children: "Displayed on HMS Admin > Nursing Staff Master" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-4", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label fw-bold small text-dark mb-1", - children: ["App PIN or Password ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "input-group", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-light", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-lock-fill" - }) - }), /*#__PURE__*/_jsx("input", { - type: "password", - maxLength: "20", - className: "form-control", - placeholder: "••••", - value: pinInput, - onChange: e => setPinInput(e.target.value), - onKeyUp: e => e.key === 'Enter' && handleVerifyPin() - })] - })] - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-primary btn-lg w-100 py-3 fw-bold shadow-sm", - onClick: handleVerifyPin, - disabled: isVerifying, - children: isVerifying ? /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm me-2" - }), "Pairing Device..."] - }) : /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-check me-2" - }), " Register Device & Unlock"] - }) - }), pairedNurse && /*#__PURE__*/_jsx("div", { - className: "text-center mt-3 pt-2 border-top", - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-link btn-sm text-secondary text-decoration-none p-0", - onClick: () => { - setShowPairingForm(false); - setPinError(''); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-left me-1" - }), " Back to Quick Unlock"] - }) - })] - }) : - /*#__PURE__*/ - /* ------------------------------------------------------------- - INITIAL PIN CREATION (IF NURSE DOES NOT HAVE A PIN YET) - ------------------------------------------------------------- */ - _jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "alert alert-info py-2 small mb-3", - children: "Initial PIN Setup for Nurse Profile. Set a 4-6 digit Security PIN." - }), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label fw-bold small", - children: "New Security PIN" - }), /*#__PURE__*/_jsx("input", { - type: "password", - maxLength: "6", - className: "form-control text-center fs-3", - placeholder: "••••", - value: newPin, - onChange: e => setNewPin(e.target.value) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label fw-bold small", - children: "Confirm New PIN" - }), /*#__PURE__*/_jsx("input", { - type: "password", - maxLength: "6", - className: "form-control text-center fs-3", - placeholder: "••••", - value: confirmPin, - onChange: e => setConfirmPin(e.target.value) - })] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-primary btn-lg w-100 py-3 fw-bold shadow-sm", - onClick: handleSaveNewPin, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle-fill me-2" - }), " Save PIN & Unlock"] - })] - })] - })] - })] - }); + return /*#__PURE__*/React.createElement("div", { + className: "lock-screen-overlay" + }, /*#__PURE__*/React.createElement(MobileAppsModal, { + show: showAppsModal, + onClose: () => setShowAppsModal(false), + currentApp: "nursing" + }), /*#__PURE__*/React.createElement("div", { + className: "lock-card" + }, /*#__PURE__*/React.createElement("div", { + className: "p-4 text-center text-white position-relative", + style: { + background: 'linear-gradient(135deg, #0f172a 0%, #1e293b 100%)' + } + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-outline-light position-absolute top-0 end-0 m-2 rounded-circle", + style: { + width: '32px', + height: '32px', + padding: 0 + }, + onClick: () => setShowAppsModal(true), + title: "HMS Mobile & PWA Apps Launcher" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-grid-3x3-gap-fill", + style: { + fontSize: '12px' + } + })), /*#__PURE__*/React.createElement("img", { + src: "/assets/img/logo.png", + alt: "Hospital Logo", + className: "d-block mx-auto mb-2", + style: { + maxHeight: '40px', + filter: 'brightness(0) invert(1)' + }, + onError: e => { + e.target.style.display = 'none'; + } + }), /*#__PURE__*/React.createElement("h5", { + className: "fw-bold mb-1" + }, "Nursing Care Mobile App"), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-center gap-1 opacity-75 small" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-check text-success" + }), /*#__PURE__*/React.createElement("span", null, "Hospital Intranet & Device Protected"))), /*#__PURE__*/React.createElement("div", { + className: "p-4" + }, pinError && /*#__PURE__*/React.createElement("div", { + className: "alert alert-danger py-2 px-3 small mb-3" + }, pinError), !isSettingNewPin ? isQuickUnlock ? + /*#__PURE__*/ + /* ------------------------------------------------------------- + PAIRED DEVICE QUICK UNLOCK + ------------------------------------------------------------- */ + React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "text-center mb-4" + }, /*#__PURE__*/React.createElement("div", { + className: "avatar-circle mx-auto mb-2", + style: { + width: '54px', + height: '54px', + fontSize: '18px' + } + }, getInitials(pairedNurse.name || pairedNurse.staff_id)), /*#__PURE__*/React.createElement("h6", { + className: "fw-bold text-dark mb-0" + }, pairedNurse.name || 'Staff Nurse'), /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-dark border font-monospace mt-1" + }, pairedNurse.staff_id), /*#__PURE__*/React.createElement("div", { + className: "text-muted small mt-1", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-phone-fill me-1 text-primary" + }), " Trusted Hospital Device")), /*#__PURE__*/React.createElement("div", { + className: "mb-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-muted" + }, "Enter PIN or Password to Unlock"), /*#__PURE__*/React.createElement("input", { + type: "password", + maxLength: "20", + className: "form-control text-center fs-3 letter-spacing-2", + placeholder: "••••", + value: pinInput, + autoFocus: true, + onChange: e => setPinInput(e.target.value), + onKeyUp: e => e.key === 'Enter' && handleVerifyPin() + }), /*#__PURE__*/React.createElement("small", { + className: "text-muted text-center d-block mt-1", + style: { + fontSize: '11px' + } + }, "30-day verified session active")), /*#__PURE__*/React.createElement("button", { + className: "btn btn-success btn-lg w-100 py-3 fw-bold shadow-sm mb-2", + onClick: handleVerifyPin, + disabled: isVerifying + }, isVerifying ? /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm me-2" + }), "Verifying...") : /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-unlock-fill me-2" + }), " Unlock Nursing App")), /*#__PURE__*/React.createElement("div", { + className: "text-center mt-3 pt-2 border-top" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-link btn-sm text-secondary text-decoration-none p-0", + onClick: () => { + setShowPairingForm(true); + setPinError(''); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-repeat me-1" + }), " Switch Account / Re-Pair Device"))) : + /*#__PURE__*/ + /* ------------------------------------------------------------- + FIRST-TIME DEVICE REGISTRATION / PAIRING FORM + ------------------------------------------------------------- */ + React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "alert alert-primary py-2 px-3 small d-flex align-items-center gap-2 mb-3" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-lock-fill fs-5 text-primary" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold" + }, "First-Time Device Pairing"), /*#__PURE__*/React.createElement("div", { + style: { + fontSize: '11px' + } + }, "Enter Staff ID and Device Security Code from Nursing Staff Master."))), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-dark mb-1" + }, "Staff ID or Username ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("div", { + className: "input-group" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-badge" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control", + placeholder: "e.g. NUR-637 or username", + value: staffIdInput, + onChange: e => setStaffIdInput(e.target.value) + }))), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-dark mb-1" + }, "Device Security Code ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("div", { + className: "input-group" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-key-fill text-warning" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + maxLength: "10", + className: "form-control font-monospace fw-bold", + placeholder: "6-digit code from Admin", + value: deviceCodeInput, + onChange: e => setDeviceCodeInput(e.target.value) + })), /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '11px' + } + }, "Displayed on HMS Admin > Nursing Staff Master")), /*#__PURE__*/React.createElement("div", { + className: "mb-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small text-dark mb-1" + }, "App PIN or Password ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("div", { + className: "input-group" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-light" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-lock-fill" + })), /*#__PURE__*/React.createElement("input", { + type: "password", + maxLength: "20", + className: "form-control", + placeholder: "••••", + value: pinInput, + onChange: e => setPinInput(e.target.value), + onKeyUp: e => e.key === 'Enter' && handleVerifyPin() + }))), /*#__PURE__*/React.createElement("button", { + className: "btn btn-primary btn-lg w-100 py-3 fw-bold shadow-sm", + onClick: handleVerifyPin, + disabled: isVerifying + }, isVerifying ? /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm me-2" + }), "Pairing Device...") : /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-check me-2" + }), " Register Device & Unlock")), pairedNurse && /*#__PURE__*/React.createElement("div", { + className: "text-center mt-3 pt-2 border-top" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-link btn-sm text-secondary text-decoration-none p-0", + onClick: () => { + setShowPairingForm(false); + setPinError(''); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-left me-1" + }), " Back to Quick Unlock"))) : + /*#__PURE__*/ + /* ------------------------------------------------------------- + INITIAL PIN CREATION (IF NURSE DOES NOT HAVE A PIN YET) + ------------------------------------------------------------- */ + React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "alert alert-info py-2 small mb-3" + }, "Initial PIN Setup for Nurse Profile. Set a 4-6 digit Security PIN."), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small" + }, "New Security PIN"), /*#__PURE__*/React.createElement("input", { + type: "password", + maxLength: "6", + className: "form-control text-center fs-3", + placeholder: "••••", + value: newPin, + onChange: e => setNewPin(e.target.value) + })), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label fw-bold small" + }, "Confirm New PIN"), /*#__PURE__*/React.createElement("input", { + type: "password", + maxLength: "6", + className: "form-control text-center fs-3", + placeholder: "••••", + value: confirmPin, + onChange: e => setConfirmPin(e.target.value) + })), /*#__PURE__*/React.createElement("button", { + className: "btn btn-primary btn-lg w-100 py-3 fw-bold shadow-sm", + onClick: handleSaveNewPin + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle-fill me-2" + }), " Save PIN & Unlock"))))); } // ------------------------------------------------------------- // UNLOCKED NURSING PWA APP // ------------------------------------------------------------- - return /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx(MobileAppsModal, { - show: showAppsModal, - onClose: () => setShowAppsModal(false), - currentApp: "nursing" - }), /*#__PURE__*/_jsxs("header", { - className: "nursing-header d-flex justify-content-between align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("div", { - className: "avatar-circle", - children: getInitials(authenticatedNurse.name) - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "mb-0 fw-bold", - children: authenticatedNurse.name - }), /*#__PURE__*/_jsxs("small", { - className: "text-light opacity-75", - style: { - fontSize: '11px' - }, - children: [authenticatedNurse.designation || 'Staff Nurse', " ", /*#__PURE__*/_jsx("span", { - className: "badge bg-success ms-1", - style: { - fontSize: '9px' - }, - children: "● Active" - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("button", { - className: "btn btn-sm btn-outline-light rounded-circle p-2", - style: { - width: '36px', - height: '36px' - }, - onClick: () => setShowAppsModal(true), - title: "HMS Mobile & PWA Apps Launcher", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-grid-3x3-gap-fill" - }) - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-sm btn-outline-light rounded-circle p-2", - style: { - width: '36px', - height: '36px' - }, - onClick: () => { - fetchBeds(); - fetchOpdAppointments(opdDateMode, selectedDoctorId, vitalsFilter); - }, - title: "Refresh", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-clockwise" - }) - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-sm btn-outline-danger rounded-circle p-2", - style: { - width: '36px', - height: '36px' - }, - onClick: handleLogout, - title: "Lock Access", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-lock-fill" - }) - })] - })] - }), /*#__PURE__*/_jsxs("main", { - className: "container-fluid py-3 px-2 px-md-3 content-with-bottom-dock", - children: [!activeBed ? /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "segmented-tabs mb-3", - children: [/*#__PURE__*/_jsxs("button", { - className: `segmented-tab ${mainTab === 'ipd' ? 'active' : ''}`, - onClick: () => { - setMainTab('ipd'); - fetchBeds(); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hospital-fill me-2" - }), " Admitted IPDs (", beds.filter(b => b.status === 'occupied' || b.patient_name).length, ")"] - }), /*#__PURE__*/_jsxs("button", { - className: `segmented-tab ${mainTab === 'opd' ? 'active-blue' : ''}`, - onClick: () => { - setMainTab('opd'); - fetchOpdAppointments(opdDateMode, selectedDoctorId, vitalsFilter); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-calendar-check-fill me-2" - }), " OPD Patients (", opdAppointments.length, ")"] - })] - }), mainTab === 'ipd' ? - /*#__PURE__*/ - /* ------------------------------------------------------------- - ADMITTED IPD PATIENTS & BEDS - ------------------------------------------------------------- */ - _jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-3 align-items-center", - children: [/*#__PURE__*/_jsx("div", { - className: "col-12 col-md-6", - children: /*#__PURE__*/_jsxs("div", { - className: "input-group shadow-sm rounded-pill overflow-hidden bg-white border", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-white border-0 ps-3 text-secondary", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-search" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control border-0 py-2 shadow-none", - placeholder: "Search Bed No, Patient Name, UHID...", - value: searchQuery, - onChange: e => setSearchQuery(e.target.value) - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-12 col-md-6", - children: /*#__PURE__*/_jsxs("select", { - className: "form-select rounded-pill shadow-sm py-2", - value: selectedWard, - onChange: e => setSelectedWard(e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "all", - children: "All Wards / Units" - }), Array.from(new Set(beds.map(b => b.ward_name))).filter(Boolean).map(w => /*#__PURE__*/_jsx("option", { - value: w, - children: w - }, w))] - }) - })] - }), /*#__PURE__*/_jsx("div", { - className: "row g-3", - children: filteredBeds.length === 0 ? /*#__PURE__*/_jsxs("div", { - className: "col-12 text-center text-muted py-5 bg-white rounded-4 border shadow-sm", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hospital fs-1 text-secondary opacity-50 d-block mb-2" - }), /*#__PURE__*/_jsx("h6", { - className: "fw-bold text-slate-800 mb-1", - children: "No Admitted Patients Found" - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: "There are currently no admitted IPD patients in the selected ward." - })] - }) : filteredBeds.map(bed => /*#__PURE__*/_jsx("div", { - className: "col-12 col-md-6 col-lg-4", - children: /*#__PURE__*/_jsxs("div", { - className: `bed-card p-3 bed-status-${bed.status}`, - onClick: () => openWorkspace(bed), - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-start mb-2", - children: [/*#__PURE__*/_jsxs("span", { - className: "fw-bold text-dark fs-5", - children: ["Bed ", bed.bed_number] - }), /*#__PURE__*/_jsx("span", { - className: `badge ${bed.status === 'occupied' ? 'bg-primary' : 'bg-success'} text-uppercase`, - style: { - fontSize: '9px' - }, - children: bed.status - })] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted d-block mb-2", - style: { - fontSize: '11px' - }, - children: bed.ward_name || 'General Ward' - }), bed.patient_name ? /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("div", { - className: "fw-bold text-primary text-truncate", - style: { - fontSize: '15px' - }, - children: bed.patient_name - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted d-block", - style: { - fontSize: '11px' - }, - children: ["UHID: ", bed.uhid || 'N/A', " • IPD: ", bed.ipd_code || 'N/A'] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-primary-subtle text-primary border border-primary-subtle px-2 py-1 mt-2 d-inline-block", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-badge me-1" - }), " ", bed.doctor_name || 'Dr. Assigned'] - })] - }) : /*#__PURE__*/_jsx("div", { - className: "text-success small fw-semibold py-2", - children: "Available for Admission" - }), /*#__PURE__*/_jsx("div", { - className: "mt-3 pt-2 border-top d-flex gap-1", - children: /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-primary w-100 py-2 fw-bold rounded-3 shadow-sm", - style: { - fontSize: '12px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-heart-pulse me-1" - }), " Open Bedside Workspace"] - }) - })] - }) - }, bed.id)) - })] - }) : - /*#__PURE__*/ - /* ------------------------------------------------------------- - OPD PATIENTS TAB (VITALS & DOCUMENT SCANNING) - ------------------------------------------------------------- */ - _jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center justify-content-between mb-3 bg-white p-2 rounded-4 border shadow-sm flex-wrap gap-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex gap-1 bg-light p-1 rounded-pill border", - children: [/*#__PURE__*/_jsxs("button", { - className: `btn btn-sm rounded-pill px-3 py-1 fw-bold ${opdDateMode === 'today' ? 'btn-primary shadow-sm' : 'btn-light text-secondary'}`, - onClick: () => { - setOpdDateMode('today'); - fetchOpdAppointments('today', selectedDoctorId, vitalsFilter); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-calendar-event me-1" - }), " Today's OPDs (", opdCounts.today_total || 0, ")"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm rounded-pill px-3 py-1 fw-bold ${opdDateMode === 'all' ? 'btn-primary shadow-sm' : 'btn-light text-secondary'}`, - onClick: () => { - setOpdDateMode('all'); - fetchOpdAppointments('all', selectedDoctorId, vitalsFilter); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-calendar3 me-1" - }), " All Dates (", opdCounts.all_total || 0, ")"] - })] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-primary-subtle text-primary border border-primary-subtle px-2 py-1 rounded-pill small", - style: { - fontSize: '11px' - }, - children: opdDateMode === 'today' ? '● Current Date' : '● All Appointments' - })] - }), /*#__PURE__*/_jsx("div", { - className: "bg-white p-3 mb-3 rounded-4 border shadow-sm", - children: /*#__PURE__*/_jsxs("div", { - className: "row g-2 align-items-center", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-12 col-md-6", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold text-dark mb-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-badge text-primary me-1" - }), " Filter by Doctor"] - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm rounded-pill fw-semibold", - value: selectedDoctorId, - onChange: e => { - const val = e.target.value; - setSelectedDoctorId(val); - fetchOpdAppointments(opdDateMode, val, vitalsFilter); - }, - children: [/*#__PURE__*/_jsx("option", { - value: "0", - children: "-- All Hospital Doctors --" - }), doctors.map(d => /*#__PURE__*/_jsx("option", { - value: d.id, - children: d.name - }, d.id))] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-12 col-md-6", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold text-dark mb-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-heart-pulse-fill text-danger me-1" - }), " Vitals Status Filter"] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-1", - children: [/*#__PURE__*/_jsxs("button", { - className: `btn btn-sm flex-fill rounded-pill py-1 fw-bold ${vitalsFilter === 'all' ? 'btn-primary shadow-sm' : 'btn-light border text-secondary'}`, - onClick: () => { - setVitalsFilter('all'); - fetchOpdAppointments(opdDateMode, selectedDoctorId, 'all'); - }, - children: ["All (", opdCounts.all, ")"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm flex-fill rounded-pill py-1 fw-bold ${vitalsFilter === 'pending' ? 'btn-warning text-dark shadow-sm' : 'btn-light border text-secondary'}`, - onClick: () => { - setVitalsFilter('pending'); - fetchOpdAppointments(opdDateMode, selectedDoctorId, 'pending'); - }, - children: ["⚠️ Pending (", opdCounts.pending_vitals || 0, ")"] - }), /*#__PURE__*/_jsxs("button", { - className: `btn btn-sm flex-fill rounded-pill py-1 fw-bold ${vitalsFilter === 'done' ? 'btn-success text-white shadow-sm' : 'btn-light border text-secondary'}`, - onClick: () => { - setVitalsFilter('done'); - fetchOpdAppointments(opdDateMode, selectedDoctorId, 'done'); - }, - children: ["✅ Filled (", opdCounts.done_vitals || 0, ")"] - })] - })] - })] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2 mb-3 overflow-auto no-scrollbar pb-1", - children: [/*#__PURE__*/_jsx("button", { - className: `btn btn-sm rounded-pill px-3 ${opdFilter === 'all' ? 'btn-primary fw-bold' : 'btn-white bg-white text-secondary border'}`, - onClick: () => setOpdFilter('all'), - children: "All Visits" - }), /*#__PURE__*/_jsx("button", { - className: `btn btn-sm rounded-pill px-3 ${opdFilter === 'waiting' ? 'btn-primary fw-bold' : 'btn-white bg-white text-secondary border'}`, - onClick: () => setOpdFilter('waiting'), - children: "Waiting" - }), /*#__PURE__*/_jsx("button", { - className: `btn btn-sm rounded-pill px-3 ${opdFilter === 'visited' ? 'btn-info text-dark fw-bold' : 'btn-white bg-white text-secondary border'}`, - onClick: () => setOpdFilter('visited'), - children: "Visited" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "input-group mb-3 shadow-sm rounded-pill overflow-hidden bg-white border", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-white border-0 ps-3 text-secondary", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-search" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control border-0 py-2 shadow-none", - placeholder: "Search Patient Name, Doctor Name, UHID, OPD Code...", - value: searchQuery, - onChange: e => setSearchQuery(e.target.value) - })] - }), /*#__PURE__*/_jsx("div", { - children: filteredOpdAppointments.length === 0 ? /*#__PURE__*/_jsxs("div", { - className: "text-center text-muted py-5 bg-white rounded-4 border shadow-sm", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-x fs-1 text-secondary opacity-50 d-block mb-2" - }), "No OPD appointments found for selected filter."] - }) : filteredOpdAppointments.map(app => /*#__PURE__*/_jsxs("div", { - className: "mobile-patient-card", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-2 pb-2 border-bottom", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsxs("span", { - className: "queue-badge", - children: ["Q #", app.queue_no || app.opd_no || '1'] - }), /*#__PURE__*/_jsxs("span", { - className: `status-pill ${app.status_key}`, - children: ["● ", app.status_label] - })] - }), /*#__PURE__*/_jsx("code", { - className: "fw-bold text-dark fs-6", - children: app.opd_code - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-start gap-3 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "patient-avatar-circle", - children: getInitials(app.patient_display_name) - }), /*#__PURE__*/_jsxs("div", { - className: "flex-grow-1", - children: [/*#__PURE__*/_jsx("h5", { - className: "fw-bold text-slate-900 mb-1", - style: { - fontSize: '16px' - }, - children: app.patient_display_name - }), /*#__PURE__*/_jsxs("small", { - className: "text-muted d-block mb-2", - style: { - fontSize: '12px' - }, - children: [app.age_display, " • ", app.gender_label, " | UHID: ", app.uhid] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-primary-subtle text-primary border border-primary-subtle px-2 py-1", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-badge me-1" - }), app.doctor_name || 'Doctor'] - })] - })] - }), app.has_vitals && /*#__PURE__*/_jsxs("div", { - className: "alert alert-success py-1.5 px-3 mb-3 small rounded-3 d-flex align-items-center justify-content-between", - style: { - fontSize: '12px' - }, - children: [/*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-heart-pulse-fill text-danger me-1" - }), " ", /*#__PURE__*/_jsx("strong", { - children: "Vitals:" - }), " BP ", app.bp || '-', "/", app.diastolic || '-', " | Pulse ", app.pulse || '-', " | Temp ", app.temp || '-', "°F"] - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-success", - children: "Vitals ✓" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2", - children: [/*#__PURE__*/_jsxs("button", { - className: `btn ${app.has_vitals ? 'btn-success' : 'btn-outline-success'} w-50 py-2 fw-bold rounded-3 shadow-sm`, - onClick: () => openOpdVitalsModal(app), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-heart-pulse me-1" - }), " ", app.has_vitals ? 'Vitals ✓' : 'Fill Vitals'] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-outline-primary w-50 py-2 fw-bold rounded-3 shadow-sm", - onClick: () => openScanModal(app, 'opd'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-camera me-1" - }), " Scan / Photo"] - })] - })] - }, app.opd_id)) - })] - })] - }) : - /*#__PURE__*/ - /* ------------------------------------------------------------- - IPD BEDSIDE WORKSPACE FOR NURSING STAFF - ------------------------------------------------------------- */ - _jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-3", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-dark rounded-pill px-3", - onClick: () => setActiveBed(null), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-left me-1" - }), " Back to Bed List"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-primary fw-bold rounded-pill px-3", - onClick: () => openScanModal(activeBed, 'ipd'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-camera me-1" - }), " Scan Paper Doc"] - })] - }), /*#__PURE__*/_jsx("div", { - className: "card shadow-sm mb-3 border-0 bg-primary text-white rounded-4", - style: { - background: 'linear-gradient(135deg, #0f172a 0%, #1e293b 100%)' - }, - children: /*#__PURE__*/_jsxs("div", { - className: "card-body p-3", - children: [/*#__PURE__*/_jsx("h5", { - className: "fw-bold mb-1", - children: activeBed.patient_name - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap gap-2 opacity-90 small mt-2", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-white text-dark", - children: ["Bed ", activeBed.bed_number, " (", activeBed.ward_name, ")"] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-white text-danger", - children: ["UHID: ", activeBed.uhid] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-white text-primary", - children: ["IPD: ", activeBed.ipd_code] - })] - })] - }) - }), /*#__PURE__*/_jsxs("ul", { - className: "nav nav-pills mb-3 bg-white p-1 rounded-3 border shadow-sm", - children: [/*#__PURE__*/_jsx("li", { - className: "nav-item flex-fill text-center", - children: /*#__PURE__*/_jsxs("button", { - className: `nav-link w-100 fw-bold ${activeTab === 'vitals' ? 'active' : ''}`, - onClick: () => setActiveTab('vitals'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-heart-pulse me-1" - }), " Vitals (", workspaceData.filter(e => e.entry_type === 'vitals').length, ")"] - }) - }), /*#__PURE__*/_jsx("li", { - className: "nav-item flex-fill text-center", - children: /*#__PURE__*/_jsxs("button", { - className: `nav-link w-100 fw-bold ${activeTab === 'fluid' ? 'active' : ''}`, - onClick: () => setActiveTab('fluid'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-droplet me-1" - }), " Fluid I/O (", workspaceData.filter(e => e.entry_type === 'fluid').length, ")"] - }) - }), /*#__PURE__*/_jsx("li", { - className: "nav-item flex-fill text-center", - children: /*#__PURE__*/_jsxs("button", { - className: `nav-link w-100 fw-bold ${activeTab === 'treatment' ? 'active' : ''}`, - onClick: () => setActiveTab('treatment'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clipboard2-pulse me-1" - }), " Treatment & Orders (", workspaceData.filter(e => e.entry_type === 'treatment').length, ")"] - }) - })] - }), activeTab === 'vitals' && /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "card p-3 shadow-sm border-0 mb-3 rounded-4", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold mb-3 text-dark", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-heart-pulse-fill text-danger me-1" - }), " Record Bedside Vitals"] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "BP Sys/Dia (mmHg)" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control text-center", - placeholder: "120", - value: vitalsForm.bp_systolic, - onChange: e => setVitalsForm({ - ...vitalsForm, - bp_systolic: e.target.value - }) - }), /*#__PURE__*/_jsx("span", { - className: "input-group-text", - children: "/" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control text-center", - placeholder: "80", - value: vitalsForm.bp_diastolic, - onChange: e => setVitalsForm({ - ...vitalsForm, - bp_diastolic: e.target.value - }) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Pulse Rate (bpm)" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm text-center", - placeholder: "72", - value: vitalsForm.pulse_rate, - onChange: e => setVitalsForm({ - ...vitalsForm, - pulse_rate: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "SpO2 %" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm text-center", - placeholder: "98", - value: vitalsForm.spo2, - onChange: e => setVitalsForm({ - ...vitalsForm, - spo2: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Temp °F" - }), /*#__PURE__*/_jsx("input", { - type: "number", - step: "0.1", - className: "form-control form-control-sm text-center", - placeholder: "98.6", - value: vitalsForm.temperature_f, - onChange: e => setVitalsForm({ - ...vitalsForm, - temperature_f: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Resp Rate (/min)" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm text-center", - placeholder: "18", - value: vitalsForm.resp_rate, - onChange: e => setVitalsForm({ - ...vitalsForm, - resp_rate: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Weight (kg)" - }), /*#__PURE__*/_jsx("input", { - type: "number", - step: "0.1", - className: "form-control form-control-sm text-center", - placeholder: "70", - value: vitalsForm.weight_kg, - onChange: e => setVitalsForm({ - ...vitalsForm, - weight_kg: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-12 col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Nursing Remark / Observation" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "e.g. Patient resting, vitals stable", - value: vitalsForm.general_note, - onChange: e => setVitalsForm({ - ...vitalsForm, - general_note: e.target.value - }) - })] - })] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-success fw-bold py-2 w-100 rounded-3 shadow-sm", - onClick: () => handleSaveIpdEntry('vitals', vitalsForm), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle-fill me-1" - }), " Save Bedside Vitals"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card shadow-sm border-0 rounded-4 overflow-hidden mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header py-2 bg-white d-flex justify-content-between align-items-center border-bottom", - children: [/*#__PURE__*/_jsxs("strong", { - className: "text-dark", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clock-history me-1 text-danger" - }), " Vitals History Records"] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-danger-subtle text-danger border border-danger-subtle", - children: [workspaceData.filter(e => e.entry_type === 'vitals').length, " Records"] - })] - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-sm table-striped table-hover align-middle mb-0", - style: { - fontSize: '12px' - }, - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "Date & Time" - }), /*#__PURE__*/_jsx("th", { - children: "BP (mmHg)" - }), /*#__PURE__*/_jsx("th", { - children: "Pulse" - }), /*#__PURE__*/_jsx("th", { - children: "Temp" - }), /*#__PURE__*/_jsx("th", { - children: "Resp" - }), /*#__PURE__*/_jsx("th", { - children: "SpO2" - }), /*#__PURE__*/_jsx("th", { - children: "Weight" - }), /*#__PURE__*/_jsx("th", { - children: "Staff" - }), /*#__PURE__*/_jsx("th", { - children: "Remarks" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: workspaceData.filter(e => e.entry_type === 'vitals').length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsx("td", { - colSpan: "9", - className: "text-center text-muted py-4", - children: "No vitals records entered yet." - }) - }) : workspaceData.filter(e => e.entry_type === 'vitals').map(v => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - className: "fw-semibold text-nowrap", - children: formatDateTime(v.recorded_at) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: "badge bg-light text-dark border", - children: v.bp_systolic ? `${v.bp_systolic}/${v.bp_diastolic}` : '-' - }) - }), /*#__PURE__*/_jsx("td", { - children: v.pulse_rate ? `${v.pulse_rate} bpm` : '-' - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: "badge bg-danger-subtle text-danger", - children: displayTempF(v.temperature_c) - }) - }), /*#__PURE__*/_jsx("td", { - children: v.resp_rate ? `${v.resp_rate}/min` : '-' - }), /*#__PURE__*/_jsx("td", { - children: v.spo2 ? `${v.spo2}%` : '-' - }), /*#__PURE__*/_jsx("td", { - children: v.weight_kg ? `${v.weight_kg} kg` : '-' - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: v.recorded_by || 'Staff' - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("small", { - children: v.general_note || '-' - }) - })] - }, v.id)) - })] - }) - })] - })] - }), activeTab === 'fluid' && (() => { - const fluidList = workspaceData.filter(e => e.entry_type === 'fluid'); - const totalIn = fluidList.filter(e => (e.fluid_direction || '').toLowerCase() === 'intake').reduce((sum, e) => sum + (parseFloat(e.fluid_amount_ml) || 0), 0); - const totalOut = fluidList.filter(e => (e.fluid_direction || '').toLowerCase() === 'output').reduce((sum, e) => sum + (parseFloat(e.fluid_amount_ml) || 0), 0); - const netDiff = totalIn - totalOut; - const intakeRoutes = ['IV (Intravenous)', 'Oral / Water / Juice', 'Ryles Tube / NG Feed', 'Normal Saline (NS)', 'Dextrose (DNS / RL)', 'Blood / Plasma', 'TPN', 'Other Intake']; - const outputRoutes = ['Urine / Foley Catheter', 'Drain / Ryle Tube', 'Vomitus', 'Stool / Loose Motion', 'Chest Tube Drain', 'Wound Drain', 'Other Output']; - return /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "col-4", - children: /*#__PURE__*/_jsxs("div", { - className: "stat-card-intake text-center shadow-sm", - children: [/*#__PURE__*/_jsxs("small", { - className: "text-success fw-bold d-block mb-1", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-down-left-circle-fill me-1" - }), " Total Intake"] - }), /*#__PURE__*/_jsxs("h5", { - className: "fw-bold text-success mb-0", - children: [totalIn.toLocaleString(), " ", /*#__PURE__*/_jsx("span", { - style: { - fontSize: '11px' - }, - children: "ml" - })] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-4", - children: /*#__PURE__*/_jsxs("div", { - className: "stat-card-output text-center shadow-sm", - children: [/*#__PURE__*/_jsxs("small", { - className: "text-warning fw-bold d-block mb-1", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-up-right-circle-fill me-1" - }), " Total Output"] - }), /*#__PURE__*/_jsxs("h5", { - className: "fw-bold text-warning mb-0", - children: [totalOut.toLocaleString(), " ", /*#__PURE__*/_jsx("span", { - style: { - fontSize: '11px' - }, - children: "ml" - })] - })] - }) - }), /*#__PURE__*/_jsx("div", { - className: "col-4", - children: /*#__PURE__*/_jsxs("div", { - className: "stat-card-balance text-center shadow-sm", - children: [/*#__PURE__*/_jsxs("small", { - className: "text-primary fw-bold d-block mb-1", - style: { - fontSize: '11px' - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-calculator me-1" - }), " Difference (In-Out)"] - }), /*#__PURE__*/_jsxs("h5", { - className: `fw-bold mb-0 ${netDiff >= 0 ? 'text-primary' : 'text-danger'}`, - children: [netDiff > 0 ? `+${netDiff.toLocaleString()}` : netDiff.toLocaleString(), " ", /*#__PURE__*/_jsx("span", { - style: { - fontSize: '11px' - }, - children: "ml" - })] - })] - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card p-3 shadow-sm border-0 mb-3 rounded-4", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold mb-3 text-dark", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-droplet-fill text-primary me-1" - }), " Add Fluid Intake / Output Entry"] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Direction" - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn btn-sm flex-fill py-2 fw-bold rounded-3 ${fluidForm.fluid_direction === 'intake' ? 'btn-success text-white shadow-sm' : 'btn-light border text-secondary'}`, - onClick: () => setFluidForm({ - ...fluidForm, - fluid_direction: 'intake', - fluid_route: 'IV (Intravenous)' - }), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-down-left-circle me-1" - }), " Fluid Intake (In)"] - }), /*#__PURE__*/_jsxs("button", { - type: "button", - className: `btn btn-sm flex-fill py-2 fw-bold rounded-3 ${fluidForm.fluid_direction === 'output' ? 'btn-warning text-dark shadow-sm' : 'btn-light border text-secondary'}`, - onClick: () => setFluidForm({ - ...fluidForm, - fluid_direction: 'output', - fluid_route: 'Urine / Foley Catheter' - }), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-up-right-circle me-1" - }), " Fluid Output (Out)"] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-12 col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Route / Site" - }), /*#__PURE__*/_jsx("select", { - className: "form-select form-select-sm", - value: fluidForm.fluid_route, - onChange: e => setFluidForm({ - ...fluidForm, - fluid_route: e.target.value - }), - children: (fluidForm.fluid_direction === 'intake' ? intakeRoutes : outputRoutes).map(r => /*#__PURE__*/_jsx("option", { - value: r, - children: r - }, r)) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-12 col-md-6", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-1", - children: ["Amount (ml) ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm text-center fw-bold fs-6", - placeholder: "e.g. 500", - value: fluidForm.fluid_amount_ml, - onChange: e => setFluidForm({ - ...fluidForm, - fluid_amount_ml: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-12", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Observation / Note" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "e.g. Clear urine, Normal fluid color, IV site intact", - value: fluidForm.general_note, - onChange: e => setFluidForm({ - ...fluidForm, - general_note: e.target.value - }) - })] - })] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-primary fw-bold py-2 w-100 rounded-3 shadow-sm", - onClick: () => { - if (!fluidForm.fluid_amount_ml) { - alert('Please enter fluid amount in ml.'); - return; - } - handleSaveIpdEntry('fluid', fluidForm); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-plus-circle-fill me-1" - }), " Save Fluid Entry"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card shadow-sm border-0 rounded-4 overflow-hidden mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header py-2 bg-white d-flex justify-content-between align-items-center border-bottom", - children: [/*#__PURE__*/_jsxs("strong", { - className: "text-dark", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clock-history me-1 text-primary" - }), " Fluid Intake & Output Log"] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-primary-subtle text-primary border border-primary-subtle", - children: [fluidList.length, " Records"] - })] - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-sm table-striped table-hover align-middle mb-0", - style: { - fontSize: '12px' - }, - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "Date & Time" - }), /*#__PURE__*/_jsx("th", { - children: "Direction" - }), /*#__PURE__*/_jsx("th", { - children: "Route" - }), /*#__PURE__*/_jsx("th", { - children: "Amount (ml)" - }), /*#__PURE__*/_jsx("th", { - children: "Observation / Note" - }), /*#__PURE__*/_jsx("th", { - children: "Staff" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: fluidList.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsx("td", { - colSpan: "6", - className: "text-center text-muted py-4", - children: "No fluid entries recorded yet." - }) - }) : fluidList.map(fl => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - className: "fw-semibold text-nowrap", - children: formatDateTime(fl.recorded_at) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: `badge ${fl.fluid_direction === 'intake' ? 'bg-success' : 'bg-warning text-dark'} text-uppercase`, - children: fl.fluid_direction === 'intake' ? '↓ Intake' : '↑ Output' - }) - }), /*#__PURE__*/_jsx("td", { - className: "fw-semibold", - children: fl.fluid_route || '-' - }), /*#__PURE__*/_jsxs("td", { - className: "fw-bold", - children: [parseFloat(fl.fluid_amount_ml || 0).toLocaleString(), " ml"] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("small", { - children: fl.general_note || '-' - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: fl.recorded_by || 'Staff' - }) - })] - }, fl.id)) - })] - }) - })] - })] - }); - })(), activeTab === 'treatment' && (() => { - const allTreatments = workspaceData.filter(e => e.entry_type === 'treatment'); - const doctorOrders = allTreatments.filter(e => e.recorded_by && e.recorded_by.toLowerCase().startsWith('dr.') || e.treatment_text && e.treatment_text.includes('[Doctor Note]')); - const latestDocOrder = doctorOrders.length > 0 ? doctorOrders[0] : null; - const nurseTreatments = allTreatments.filter(e => !(e.recorded_by && e.recorded_by.toLowerCase().startsWith('dr.')) && !(e.treatment_text && e.treatment_text.includes('[Doctor Note]'))); - return /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "card shadow-sm border-0 mb-3 rounded-4 overflow-hidden", - style: { - border: '1.5px solid #818cf8' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header py-2 text-white d-flex justify-content-between align-items-center", - style: { - background: 'linear-gradient(135deg, #3730a3 0%, #4f46e5 100%)' - }, - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-medical-fill" - }), /*#__PURE__*/_jsx("strong", { - className: "small", - children: "Doctor's Prescribed Treatment & Orders" - })] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-white text-dark small", - children: [doctorOrders.length, " Doctor Orders"] - })] - }), /*#__PURE__*/_jsx("div", { - className: "card-body p-3 bg-light", - children: latestDocOrder ? /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-start mb-2", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-primary px-2 py-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-badge me-1" - }), " ", latestDocOrder.recorded_by] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted fw-semibold", - children: formatDateTime(latestDocOrder.recorded_at) - })] - }), /*#__PURE__*/_jsx("div", { - className: "p-3 bg-white rounded-3 border mb-2 shadow-sm", - children: renderNoteContent(latestDocOrder) - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-primary fw-bold w-100 rounded-pill py-2", - onClick: () => { - const cleanText = (latestDocOrder.treatment_text || '').replace(/\[IMAGE_ATTACHMENT:.*?\]/, '').replace('[Doctor Note] ', '').trim(); - setTreatmentForm({ - ...treatmentForm, - treatment_text: `Administered as prescribed: ${cleanText}` - }); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clipboard-check-fill me-1" - }), " Follow & Administer This Order"] - }), doctorOrders.length > 1 && /*#__PURE__*/_jsxs("div", { - className: "mt-3", - children: [/*#__PURE__*/_jsxs("button", { - type: "button", - className: "btn btn-sm btn-light border w-100 text-secondary", - onClick: () => setShowAllDoctorOrders(!showAllDoctorOrders), - children: [/*#__PURE__*/_jsx("i", { - className: `bi bi-chevron-${showAllDoctorOrders ? 'up' : 'down'} me-1` - }), showAllDoctorOrders ? 'Hide Previous Doctor Notes' : `View All ${doctorOrders.length} Doctor Notes`] - }), showAllDoctorOrders && /*#__PURE__*/_jsx("div", { - className: "mt-2 d-flex flex-column gap-2", - children: doctorOrders.slice(1).map(docOrd => /*#__PURE__*/_jsxs("div", { - className: "p-2.5 bg-white rounded-3 border", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-1", - children: [/*#__PURE__*/_jsx("strong", { - className: "text-primary small", - children: docOrd.recorded_by - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - style: { - fontSize: '11px' - }, - children: formatDateTime(docOrd.recorded_at) - })] - }), renderNoteContent(docOrd)] - }, docOrd.id)) - })] - })] - }) : /*#__PURE__*/_jsxs("div", { - className: "text-center text-muted py-3", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clipboard-x fs-2 text-secondary opacity-50 d-block mb-1" - }), /*#__PURE__*/_jsx("small", { - children: "No doctor orders or clinical prescriptions recorded yet." - })] - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card p-3 shadow-sm border-0 mb-3 rounded-4", - children: [/*#__PURE__*/_jsxs("h6", { - className: "fw-bold mb-3 text-dark", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-capsule text-success me-1" - }), " Log Nursing Treatment Given / Medication Administered"] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small fw-bold mb-1", - children: ["Treatment / Medication Administered ", /*#__PURE__*/_jsx("span", { - className: "text-danger", - children: "*" - })] - }), /*#__PURE__*/_jsx("textarea", { - className: "form-control rounded-3", - rows: "3", - placeholder: "e.g. Inj. Ceftriaxone 1g IV given slowly, Tab Pantop 40mg given orally...", - value: treatmentForm.treatment_text, - onChange: e => setTreatmentForm({ - ...treatmentForm, - treatment_text: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Observation / Patient Response" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "e.g. Tolerated well, No adverse reaction, IV site patent", - value: treatmentForm.general_note, - onChange: e => setTreatmentForm({ - ...treatmentForm, - general_note: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-success fw-bold py-2 w-100 rounded-3 shadow-sm", - onClick: () => { - if (!treatmentForm.treatment_text.trim()) { - alert('Please enter treatment or medication administered.'); - return; - } - handleSaveIpdEntry('treatment', treatmentForm); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-send-check-fill me-1" - }), " Log Treatment Administration"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "card shadow-sm border-0 rounded-4 overflow-hidden mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "card-header py-2 bg-white d-flex justify-content-between align-items-center border-bottom", - children: [/*#__PURE__*/_jsxs("strong", { - className: "text-dark", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clock-history me-1 text-success" - }), " Nursing Treatment Given History"] - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-success-subtle text-success border border-success-subtle", - children: [nurseTreatments.length, " Records"] - })] - }), /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-sm table-striped table-hover align-middle mb-0", - style: { - fontSize: '12px' - }, - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - style: { - width: '140px' - }, - children: "Time Administered" - }), /*#__PURE__*/_jsx("th", { - children: "Treatment / Medication Given" - }), /*#__PURE__*/_jsx("th", { - children: "Observation & Remarks" - }), /*#__PURE__*/_jsx("th", { - style: { - width: '120px' - }, - children: "Staff Nurse" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: nurseTreatments.length === 0 ? /*#__PURE__*/_jsx("tr", { - children: /*#__PURE__*/_jsx("td", { - colSpan: "4", - className: "text-center text-muted py-4", - children: "No nursing treatments logged yet." - }) - }) : nurseTreatments.map(tr => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - className: "fw-semibold text-nowrap", - children: formatDateTime(tr.recorded_at) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("div", { - className: "fw-bold text-dark", - children: renderNoteContent(tr) - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: tr.general_note || '-' - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary-subtle text-secondary border", - children: tr.recorded_by || 'Staff Nurse' - }) - })] - }, tr.id)) - })] - }) - })] - })] - }); - })()] - }), activeOpdForVitals && /*#__PURE__*/_jsx("div", { - className: "modal show d-block", - style: { - backgroundColor: 'rgba(0,0,0,0.5)' - }, - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content rounded-4 border-0 shadow-lg", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-success text-white", - children: [/*#__PURE__*/_jsxs("h6", { - className: "modal-title fw-bold", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-heart-pulse-fill me-2" - }), " Fill OPD Patient Vitals"] - }), /*#__PURE__*/_jsx("button", { - className: "btn-close btn-close-white", - onClick: () => setActiveOpdForVitals(null) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "alert alert-light border py-2 mb-3 small", - children: [/*#__PURE__*/_jsx("strong", { - children: activeOpdForVitals.patient_display_name - }), " (", activeOpdForVitals.age_display, " • ", activeOpdForVitals.gender_label, ")", /*#__PURE__*/_jsx("br", {}), /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: ["UHID: ", activeOpdForVitals.uhid, " | OPD Code: ", activeOpdForVitals.opd_code] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "BP Sys/Dia" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control text-center", - placeholder: "120", - value: opdVitalsForm.bp_systolic, - onChange: e => setOpdVitalsForm({ - ...opdVitalsForm, - bp_systolic: e.target.value - }) - }), /*#__PURE__*/_jsx("span", { - className: "input-group-text", - children: "/" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control text-center", - placeholder: "80", - value: opdVitalsForm.bp_diastolic, - onChange: e => setOpdVitalsForm({ - ...opdVitalsForm, - bp_diastolic: e.target.value - }) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Pulse Rate (bpm)" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm text-center", - placeholder: "72", - value: opdVitalsForm.pulse, - onChange: e => setOpdVitalsForm({ - ...opdVitalsForm, - pulse: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "SpO2 %" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm text-center", - placeholder: "98", - value: opdVitalsForm.spo2, - onChange: e => setOpdVitalsForm({ - ...opdVitalsForm, - spo2: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Temp °F" - }), /*#__PURE__*/_jsx("input", { - type: "number", - step: "0.1", - className: "form-control form-control-sm text-center", - placeholder: "98.6", - value: opdVitalsForm.temp, - onChange: e => setOpdVitalsForm({ - ...opdVitalsForm, - temp: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Weight (kg)" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm text-center", - placeholder: "70", - value: opdVitalsForm.weight, - onChange: e => setOpdVitalsForm({ - ...opdVitalsForm, - weight: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Height (cm)" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm text-center", - placeholder: "165", - value: opdVitalsForm.height, - onChange: e => setOpdVitalsForm({ - ...opdVitalsForm, - height: e.target.value - }) - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer p-2 bg-light", - children: [/*#__PURE__*/_jsx("button", { - className: "btn btn-secondary btn-sm", - onClick: () => setActiveOpdForVitals(null), - children: "Cancel" - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-success btn-sm fw-bold px-3", - onClick: handleSaveOpdVitals, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle-fill me-1" - }), " Save Vitals for Doctor"] - })] - })] - }) - }) - }), scanTarget && /*#__PURE__*/_jsx("div", { - className: "modal show d-block", - style: { - backgroundColor: 'rgba(0,0,0,0.5)' - }, - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content rounded-4 border-0 shadow-lg", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-primary text-white", - children: [/*#__PURE__*/_jsxs("h6", { - className: "modal-title fw-bold", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-camera-fill me-2" - }), " Scan / Photo Paper Document"] - }), /*#__PURE__*/_jsx("button", { - className: "btn-close btn-close-white", - onClick: () => setScanTarget(null) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "mb-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold", - children: "Document Type / Category" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: scanDocCategory, - onChange: e => setScanDocCategory(e.target.value), - children: [/*#__PURE__*/_jsx("option", { - value: "Paper Document", - children: "Paper Document (General)" - }), /*#__PURE__*/_jsx("option", { - value: "Vitals Sheet", - children: "Vitals Sheet / Chart" - }), /*#__PURE__*/_jsx("option", { - value: "Lab Test Report", - children: "Lab / Pathology Report" - }), /*#__PURE__*/_jsx("option", { - value: "Handwritten Doctor Note", - children: "Handwritten Doctor Note" - }), /*#__PURE__*/_jsx("option", { - value: "Consent Form", - children: "Signed Consent Form" - })] - })] - }), /*#__PURE__*/_jsx("div", { - className: "mb-3 text-center", - children: /*#__PURE__*/_jsxs("label", { - className: "btn btn-primary btn-lg w-100 py-3 fw-bold rounded-3 shadow-sm", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-camera me-2" - }), " Take Photo / Choose File", /*#__PURE__*/_jsx("input", { - type: "file", - accept: "image/*", - capture: "environment", - className: "d-none", - onChange: handleScanImageCapture - })] - }) - }), scanImagePreview && /*#__PURE__*/_jsxs("div", { - className: "position-relative p-2 border rounded-3 bg-light text-center", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-success position-absolute top-0 start-0 m-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle me-1" - }), " Document Photo Captured"] - }), /*#__PURE__*/_jsx("img", { - src: scanImagePreview, - alt: "Document Scan Preview", - className: "img-fluid rounded-3 border shadow-sm", - style: { - maxHeight: '220px', - objectFit: 'contain' - } - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer p-2 bg-light", - children: [/*#__PURE__*/_jsx("button", { - className: "btn btn-secondary btn-sm", - onClick: () => setScanTarget(null), - children: "Cancel" - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-success btn-sm fw-bold px-3", - onClick: handleSaveScanDocument, - disabled: !scanImageBase64, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cloud-upload-fill me-1" - }), " Save Document to Chart"] - })] - })] - }) - }) - }), cropSrc && /*#__PURE__*/_jsx("div", { - className: "modal show d-block", - style: { - backgroundColor: 'rgba(0,0,0,0.85)', - zIndex: 10000 - }, - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered modal-lg", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content rounded-4 border-0 shadow-lg overflow-hidden", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2", - children: [/*#__PURE__*/_jsxs("h6", { - className: "modal-title fw-bold mb-0", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-crop me-2 text-success" - }), " Crop Document Photo"] - }), /*#__PURE__*/_jsx("button", { - className: "btn-close btn-close-white", - onClick: cancelCrop - })] - }), /*#__PURE__*/_jsx("div", { - className: "modal-body p-2 text-center bg-black", - style: { - maxHeight: '65vh', - overflow: 'hidden' - }, - children: /*#__PURE__*/_jsx("div", { - style: { - maxHeight: '60vh', - width: '100%' - }, - children: /*#__PURE__*/_jsx("img", { - ref: imageRef, - src: cropSrc, - alt: "Crop Target", - style: { - maxWidth: '100%', - display: 'block' - } - }) - }) - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer p-2 bg-dark d-flex justify-content-between align-items-center flex-wrap gap-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex gap-1", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-light px-2", - onClick: () => cropper && cropper.rotate(-90), - title: "Rotate Left 90°", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-counterclockwise" - }), " 90°"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-light px-2", - onClick: () => cropper && cropper.rotate(90), - title: "Rotate Right 90°", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-clockwise" - }), " 90°"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-outline-light px-2", - onClick: () => cropper && cropper.reset(), - title: "Reset Crop Box", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-aspect-ratio" - }), " Reset"] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2", - children: [/*#__PURE__*/_jsx("button", { - className: "btn btn-sm btn-secondary", - onClick: cancelCrop, - children: "Cancel" - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-success fw-bold px-3", - onClick: applyCrop, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-lg me-1" - }), " Apply Crop & Save Photo"] - })] - })] - })] - }) - }) - }), /*#__PURE__*/_jsxs("div", { - className: "bottom-dock-container", - children: [/*#__PURE__*/_jsxs("button", { - className: "bottom-dock-btn btn-scan", - onClick: () => openPatientSearch('scan'), - title: "Scan Barcode / QR or Search Patient", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-qr-code-scan fs-5" - }), /*#__PURE__*/_jsx("span", { - children: "Scan / Search" - })] - }), /*#__PURE__*/_jsxs("button", { - className: "bottom-dock-btn btn-vitals", - onClick: () => { - if (activeBed) { - openWellnessModal({ - id: activeBed.p_id || activeBed.patient_id, - p_code: activeBed.uhid, - fullName: activeBed.patient_name, - abha_id: activeBed.abha_id, - gender: activeBed.gender - }); - } else { - openPatientSearch('type'); - } - }, - title: "Add ABDM M2 Wellness Vitals", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-heart-pulse-fill fs-5" - }), /*#__PURE__*/_jsx("span", { - children: "ABDM Vitals" - })] - }), /*#__PURE__*/_jsxs("button", { - className: "bottom-dock-btn btn-doc", - onClick: () => { - if (activeBed) { - openDocModal({ - id: activeBed.p_id || activeBed.patient_id, - p_code: activeBed.uhid, - fullName: activeBed.patient_name, - abha_id: activeBed.abha_id - }); - } else { - openPatientSearch('type'); - } - }, - title: "Add ABDM M2 Health Document (Scan/Photo)", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-medical-fill fs-5" - }), /*#__PURE__*/_jsx("span", { - children: "ABDM Health Doc" - })] - })] - }), showPatientSearchModal && /*#__PURE__*/_jsx("div", { - className: "modal show d-block", - style: { - backgroundColor: 'rgba(0,0,0,0.65)', - zIndex: 1050 - }, - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered modal-lg", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content rounded-4 border-0 shadow-lg overflow-hidden", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2.5", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-upc-scan fs-5 text-primary" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "modal-title fw-bold mb-0", - children: "Search Patient by Barcode, QR & Name" - }), /*#__PURE__*/_jsx("small", { - className: "text-white-50", - style: { - fontSize: '11px' - }, - children: "Scan Hospital Card Barcode, ABHA QR, or search registered patients" - })] - })] - }), /*#__PURE__*/_jsx("button", { - className: "btn-close btn-close-white", - onClick: closePatientSearch - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "segmented-tabs mb-3", - children: [/*#__PURE__*/_jsxs("button", { - className: `segmented-tab ${searchModalTab === 'scan' ? 'active-blue' : ''}`, - onClick: () => { - setSearchModalTab('scan'); - startBarcodeQrScanner(); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-camera-video-fill me-1" - }), " Camera Scanner (Barcode & QR)"] - }), /*#__PURE__*/_jsxs("button", { - className: `segmented-tab ${searchModalTab === 'type' ? 'active-blue' : ''}`, - onClick: () => { - setSearchModalTab('type'); - stopBarcodeQrScanner(); - }, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-search me-1" - }), " Manual Search (UHID / Mobile / ABHA)"] - })] - }), searchModalTab === 'scan' && /*#__PURE__*/_jsxs("div", { - className: "text-center mb-3", - children: [/*#__PURE__*/_jsx("div", { - className: "qr-scanner-wrapper mx-auto mb-2", - style: { - maxWidth: '420px' - }, - children: /*#__PURE__*/_jsx("div", { - id: "patient-qr-reader", - style: { - width: '100%' - } - }) - }), scannerError ? /*#__PURE__*/_jsxs("div", { - className: "alert alert-warning py-2 px-3 small d-inline-block", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-exclamation-triangle-fill me-1" - }), " ", scannerError] - }) : /*#__PURE__*/_jsxs("small", { - className: "text-muted d-block", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-info-circle me-1" - }), " Point camera at ", /*#__PURE__*/_jsx("strong", { - children: "Patient Card Barcode" - }), " or ", /*#__PURE__*/_jsx("strong", { - children: "ABHA QR Code" - }), " to scan instantly."] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "input-group mb-3", - children: [/*#__PURE__*/_jsx("span", { - className: "input-group-text bg-white border-end-0", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-search text-muted" - }) - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control border-start-0 ps-0", - placeholder: "Search by UHID (P...), ABHA No, Mobile (98...), Name...", - value: patientSearchQuery, - onChange: e => { - setPatientSearchQuery(e.target.value); - executePatientSearch(e.target.value); - }, - onKeyDown: e => { - if (e.key === 'Enter') executePatientSearch(patientSearchQuery); - } - }), patientSearchQuery && /*#__PURE__*/_jsx("button", { - className: "btn btn-outline-secondary", - onClick: () => { - setPatientSearchQuery(''); - setPatientSearchResults([]); - }, - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-x" - }) - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-primary fw-bold px-3", - onClick: () => executePatientSearch(patientSearchQuery), - children: searchingPatient ? /*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm" - }) : 'Search' - })] - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center mb-2", - children: [/*#__PURE__*/_jsxs("strong", { - className: "small text-secondary text-uppercase", - children: ["Matched Patients (", patientSearchResults.length, ")"] - }), searchingPatient && /*#__PURE__*/_jsx("span", { - className: "badge bg-primary-subtle text-primary", - children: "Searching..." - })] - }), patientSearchResults.length === 0 ? /*#__PURE__*/_jsxs("div", { - className: "text-center py-4 bg-light rounded-3 border", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-badge fs-2 text-muted opacity-50 d-block mb-1" - }), /*#__PURE__*/_jsx("p", { - className: "small text-muted mb-0", - children: patientSearchQuery ? 'No patients found matching this query.' : 'Type patient name, UHID, ABHA number or scan barcode above.' - })] - }) : /*#__PURE__*/_jsx("div", { - className: "d-flex flex-column gap-2", - style: { - maxHeight: '40vh', - overflowY: 'auto' - }, - children: patientSearchResults.map(pat => /*#__PURE__*/_jsx("div", { - className: "patient-search-result-card", - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-start flex-wrap gap-2", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("h6", { - className: "fw-bold mb-0 text-dark", - children: pat.fullName - }), /*#__PURE__*/_jsxs("span", { - className: "badge bg-light text-dark border", - style: { - fontSize: '11px' - }, - children: [pat.gender === '1' || pat.gender === 1 ? 'Male' : pat.gender === '2' || pat.gender === 2 ? 'Female' : 'Other', pat.dob ? ` • DOB: ${pat.dob}` : ''] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap gap-2 mt-1 small", - children: [/*#__PURE__*/_jsxs("span", { - className: "text-danger fw-semibold", - children: ["UHID: ", pat.p_code] - }), pat.mphone1 && /*#__PURE__*/_jsxs("span", { - className: "text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-telephone me-1" - }), pat.mphone1] - }), pat.abha_id && /*#__PURE__*/_jsxs("span", { - className: "badge bg-success-subtle text-success border border-success-subtle", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-check me-1" - }), "ABHA: ", pat.abha_id] - }), pat.abha_address && /*#__PURE__*/_jsx("span", { - className: "badge bg-primary-subtle text-primary border border-primary-subtle", - children: pat.abha_address - })] - }), pat.ipd_admission && /*#__PURE__*/_jsx("div", { - className: "mt-1", - children: /*#__PURE__*/_jsxs("span", { - className: "badge bg-primary", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-hospital me-1" - }), " Admitted IPD: ", pat.ipd_admission.ipd_code, " (Bed ", pat.ipd_admission.bed_number || pat.ipd_admission.bed_no, ")"] - }) - }), pat.opd_today && /*#__PURE__*/_jsx("div", { - className: "mt-1", - children: /*#__PURE__*/_jsxs("span", { - className: "badge bg-success", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-calendar-check me-1" - }), " OPD Today: Token #", pat.opd_today.token_no, " (", pat.opd_today.doctor_name || 'Doctor', ")"] - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap gap-1.5 align-items-center", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-success fw-bold rounded-3 px-2 py-1.5", - onClick: () => openWellnessModal(pat), - title: "Add ABDM M2 Wellness Vitals", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-heart-pulse-fill me-1" - }), " Add Vitals"] - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-primary fw-bold rounded-3 px-2 py-1.5", - onClick: () => openDocModal(pat), - title: "Add ABDM M2 Health Document", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-medical-fill me-1" - }), " Add Doc"] - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-sm btn-outline-secondary rounded-3 px-2 py-1.5", - onClick: () => openWellnessHistory(pat), - title: "View Vitals History", - children: /*#__PURE__*/_jsx("i", { - className: "bi bi-clock-history" - }) - }), pat.ipd_admission && /*#__PURE__*/_jsxs("button", { - className: "btn btn-sm btn-dark rounded-3 px-2 py-1.5", - onClick: () => { - closePatientSearch(); - openWorkspace({ - ipd_id: pat.ipd_admission.ipd_id, - patient_name: pat.fullName, - uhid: pat.p_code, - ipd_code: pat.ipd_admission.ipd_code, - bed_number: pat.ipd_admission.bed_number, - ward_name: pat.ipd_admission.ward_name, - status: 'occupied' - }); - }, - title: "Go to IPD Bedside Care", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-arrow-right-circle" - }), " IPD Bed"] - })] - })] - }) - }, pat.id)) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer p-2 bg-light d-flex justify-content-between", - children: [/*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-lock me-1" - }), " ABDM M2 Standard Compliance"] - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-secondary btn-sm px-3", - onClick: closePatientSearch, - children: "Close" - })] - })] - }) - }) - }), activeWellnessPatient && /*#__PURE__*/_jsx("div", { - className: "modal show d-block", - style: { - backgroundColor: 'rgba(0,0,0,0.65)', - zIndex: 1060 - }, - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered modal-lg", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content rounded-4 border-0 shadow-lg overflow-hidden", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-success text-white py-2.5", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-heart-pulse-fill fs-5" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "modal-title fw-bold mb-0", - children: "Record ABDM M2 Wellness & Vitals" - }), /*#__PURE__*/_jsx("small", { - className: "text-white-50", - style: { - fontSize: '11px' - }, - children: "NRCES FHIR R4 Compliant Comprehensive Health & Wellness Suite" - })] - })] - }), /*#__PURE__*/_jsx("button", { - className: "btn-close btn-close-white", - onClick: () => setActiveWellnessPatient(null) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-3", - children: [/*#__PURE__*/_jsx("div", { - className: "p-2.5 rounded-3 bg-light border mb-3", - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-center flex-wrap gap-2", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("strong", { - className: "fs-6 text-dark me-2", - children: activeWellnessPatient.fullName || activeWellnessPatient.p_fname - }), /*#__PURE__*/_jsx("span", { - className: "badge bg-secondary me-1", - children: activeWellnessPatient.gender ? activeWellnessPatient.gender.toUpperCase() : 'PATIENT' - }), activeWellnessPatient.age && /*#__PURE__*/_jsxs("span", { - className: "badge bg-light text-dark border me-1", - children: [activeWellnessPatient.age, " Yrs"] - }), /*#__PURE__*/_jsxs("div", { - className: "small text-muted mt-0.5", - children: ["UHID: ", /*#__PURE__*/_jsx("span", { - className: "text-danger fw-bold", - children: activeWellnessPatient.p_code || activeWellnessPatient.uhid - }), activeWellnessPatient.mphone1 && ` • Phone: ${activeWellnessPatient.mphone1}`] - })] - }), /*#__PURE__*/_jsx("div", { - children: activeWellnessPatient.abha_id ? /*#__PURE__*/_jsxs("span", { - className: "badge bg-success", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-check me-1" - }), " ABHA: ", activeWellnessPatient.abha_id] - }) : /*#__PURE__*/_jsxs("span", { - className: "badge bg-secondary-subtle text-secondary border", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-exclamation me-1" - }), " ABHA Not Linked"] - }) - })] - }) - }), /*#__PURE__*/_jsxs("ul", { - className: "nav nav-pills nav-fill bg-light p-1 rounded-3 mb-3 border small", - children: [/*#__PURE__*/_jsx("li", { - className: "nav-item", - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: `nav-link py-1.5 px-2 fw-semibold d-flex align-items-center justify-content-center gap-1 ${wellnessModalTab === 'vitals' ? 'active shadow-sm' : 'text-secondary'}`, - onClick: () => setWellnessModalTab('vitals'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-heart-pulse-fill text-danger" - }), /*#__PURE__*/_jsx("span", { - children: "Vitals & Triage" - }), (wellnessForm.bp_systolic || wellnessForm.pulse_rate || wellnessForm.temperature_f) && /*#__PURE__*/_jsx("span", { - className: "badge rounded-pill bg-success p-1 ms-1", - style: { - fontSize: '7px' - }, - children: "✓" - })] - }) - }), /*#__PURE__*/_jsx("li", { - className: "nav-item", - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: `nav-link py-1.5 px-2 fw-semibold d-flex align-items-center justify-content-center gap-1 ${wellnessModalTab === 'sugar' ? 'active shadow-sm' : 'text-secondary'}`, - onClick: () => setWellnessModalTab('sugar'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-droplet-half text-danger" - }), /*#__PURE__*/_jsx("span", { - children: "Sugar & Labs" - }), (wellnessForm.sugar_random || wellnessForm.sugar_fasting || wellnessForm.sugar_pp || wellnessForm.hba1c || wellnessForm.hemoglobin) && /*#__PURE__*/_jsx("span", { - className: "badge rounded-pill bg-success p-1 ms-1", - style: { - fontSize: '7px' - }, - children: "✓" - })] - }) - }), /*#__PURE__*/_jsx("li", { - className: "nav-item", - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: `nav-link py-1.5 px-2 fw-semibold d-flex align-items-center justify-content-center gap-1 ${wellnessModalTab === 'activity' ? 'active shadow-sm' : 'text-secondary'}`, - onClick: () => setWellnessModalTab('activity'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-person-bounding-box text-primary" - }), /*#__PURE__*/_jsx("span", { - children: "Waist & Activity" - }), (wellnessForm.waist_circumference_cm || wellnessForm.hip_circumference_cm || wellnessForm.daily_steps || wellnessForm.sleep_hours) && /*#__PURE__*/_jsx("span", { - className: "badge rounded-pill bg-success p-1 ms-1", - style: { - fontSize: '7px' - }, - children: "✓" - })] - }) - }), /*#__PURE__*/_jsx("li", { - className: "nav-item", - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: `nav-link py-1.5 px-2 fw-semibold d-flex align-items-center justify-content-center gap-1 ${wellnessModalTab === 'lifestyle' ? 'active shadow-sm' : 'text-secondary'}`, - onClick: () => setWellnessModalTab('lifestyle'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-apple text-success" - }), /*#__PURE__*/_jsx("span", { - children: "Lifestyle & Notes" - }), (wellnessForm.diet_type || wellnessForm.tobacco_status || wellnessForm.diet_lifestyle_note || wellnessForm.general_advice) && /*#__PURE__*/_jsx("span", { - className: "badge rounded-pill bg-success p-1 ms-1", - style: { - fontSize: '7px' - }, - children: "✓" - })] - }) - }), String(activeWellnessPatient.gender || '').toLowerCase() !== 'male' && /*#__PURE__*/_jsx("li", { - className: "nav-item", - children: /*#__PURE__*/_jsxs("button", { - type: "button", - className: `nav-link py-1.5 px-2 fw-semibold d-flex align-items-center justify-content-center gap-1 ${wellnessModalTab === 'women' ? 'active shadow-sm' : 'text-secondary'}`, - onClick: () => setWellnessModalTab('women'), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-gender-female text-warning" - }), /*#__PURE__*/_jsx("span", { - children: "Women's Health" - }), (wellnessForm.women_lmp || wellnessForm.women_pregnancy_status) && /*#__PURE__*/_jsx("span", { - className: "badge rounded-pill bg-success p-1 ms-1", - style: { - fontSize: '7px' - }, - children: "✓" - })] - }) - })] - }), wellnessModalTab === 'vitals' && /*#__PURE__*/_jsxs("div", { - className: "row g-2.5 mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "BP Sys/Dia (mmHg)" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control text-center", - placeholder: "120", - value: wellnessForm.bp_systolic, - onChange: e => setWellnessForm({ - ...wellnessForm, - bp_systolic: e.target.value - }) - }), /*#__PURE__*/_jsx("span", { - className: "input-group-text px-1", - children: "/" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control text-center", - placeholder: "80", - value: wellnessForm.bp_diastolic, - onChange: e => setWellnessForm({ - ...wellnessForm, - bp_diastolic: e.target.value - }) - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Pulse Rate (bpm)" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm text-center", - placeholder: "72", - value: wellnessForm.pulse_rate, - onChange: e => setWellnessForm({ - ...wellnessForm, - pulse_rate: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "SpO2 %" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm text-center", - placeholder: "98", - value: wellnessForm.spo2, - onChange: e => setWellnessForm({ - ...wellnessForm, - spo2: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Temp °F" - }), /*#__PURE__*/_jsx("input", { - type: "number", - step: "0.1", - className: "form-control form-control-sm text-center", - placeholder: "98.6", - value: wellnessForm.temperature_f, - onChange: e => setWellnessForm({ - ...wellnessForm, - temperature_f: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Resp Rate (/min)" - }), /*#__PURE__*/_jsx("input", { - type: "number", - className: "form-control form-control-sm text-center", - placeholder: "18", - value: wellnessForm.resp_rate, - onChange: e => setWellnessForm({ - ...wellnessForm, - resp_rate: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Height (cm)" - }), /*#__PURE__*/_jsx("input", { - type: "number", - step: "0.1", - className: "form-control form-control-sm text-center", - placeholder: "165", - value: wellnessForm.height_cm, - onChange: e => setWellnessForm({ - ...wellnessForm, - height_cm: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Weight (kg)" - }), /*#__PURE__*/_jsx("input", { - type: "number", - step: "0.1", - className: "form-control form-control-sm text-center", - placeholder: "70", - value: wellnessForm.weight_kg, - onChange: e => setWellnessForm({ - ...wellnessForm, - weight_kg: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-3", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Calculated BMI" - }), /*#__PURE__*/_jsx("div", { - className: "input-group input-group-sm", - children: /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm text-center bg-light fw-bold", - readOnly: true, - value: wellnessForm.height_cm && wellnessForm.weight_kg && parseFloat(wellnessForm.height_cm) > 0 ? (parseFloat(wellnessForm.weight_kg) / Math.pow(parseFloat(wellnessForm.height_cm) / 100, 2)).toFixed(2) : '-' - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-12 mt-2", - children: [/*#__PURE__*/_jsxs("label", { - className: "form-label small mb-1 fw-bold d-flex justify-content-between", - children: [/*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-emoji-frown me-1 text-warning" - }), " Pain Severity Score (0 - 10 VRS)"] - }), /*#__PURE__*/_jsx("span", { - className: "text-muted fw-normal", - children: wellnessForm.pain_score === '' ? 'Not assessed' : wellnessForm.pain_score == 0 ? '0 - No Pain' : wellnessForm.pain_score <= 3 ? `${wellnessForm.pain_score} - Mild Pain` : wellnessForm.pain_score <= 6 ? `${wellnessForm.pain_score} - Moderate Pain` : `${wellnessForm.pain_score} - Severe Pain` - })] - }), /*#__PURE__*/_jsx("div", { - className: "d-flex gap-1 flex-wrap", - children: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(val => /*#__PURE__*/_jsx("button", { - type: "button", - className: `btn btn-sm flex-fill py-1 px-1.5 ${wellnessForm.pain_score === String(val) ? val === 0 ? 'btn-success text-white' : val <= 3 ? 'btn-info text-white' : val <= 6 ? 'btn-warning text-dark' : 'btn-danger text-white' : 'btn-outline-secondary'}`, - onClick: () => setWellnessForm({ - ...wellnessForm, - pain_score: wellnessForm.pain_score === String(val) ? '' : String(val) - }), - children: val - }, val)) - })] - })] - }), wellnessModalTab === 'sugar' && /*#__PURE__*/_jsxs("div", { - className: "row g-2.5 mb-2", - children: [/*#__PURE__*/_jsx("div", { - className: "col-12", - children: /*#__PURE__*/_jsxs("div", { - className: "alert alert-info py-1.5 px-3 small d-flex align-items-center gap-2 mb-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-info-circle-fill fs-6 text-primary" - }), /*#__PURE__*/_jsxs("span", { - children: ["Point-of-care capillary blood sugar & POC lab values (NRCES ", /*#__PURE__*/_jsx("strong", { - children: "GeneralAssessment" - }), " slice)"] - })] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Random Blood Sugar (RBS)" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "number", - step: "1", - className: "form-control text-center", - placeholder: "110", - value: wellnessForm.sugar_random, - onChange: e => setWellnessForm({ - ...wellnessForm, - sugar_random: e.target.value - }) - }), /*#__PURE__*/_jsx("span", { - className: "input-group-text", - children: "mg/dL" - })] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - style: { - fontSize: '10px' - }, - children: "Normal: < 140 mg/dL" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Fasting Blood Sugar (FBS)" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "number", - step: "1", - className: "form-control text-center", - placeholder: "95", - value: wellnessForm.sugar_fasting, - onChange: e => setWellnessForm({ - ...wellnessForm, - sugar_fasting: e.target.value - }) - }), /*#__PURE__*/_jsx("span", { - className: "input-group-text", - children: "mg/dL" - })] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - style: { - fontSize: '10px' - }, - children: "Normal: 70 - 100 mg/dL" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Post-Prandial (PPBS)" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "number", - step: "1", - className: "form-control text-center", - placeholder: "130", - value: wellnessForm.sugar_pp, - onChange: e => setWellnessForm({ - ...wellnessForm, - sugar_pp: e.target.value - }) - }), /*#__PURE__*/_jsx("span", { - className: "input-group-text", - children: "mg/dL" - })] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - style: { - fontSize: '10px' - }, - children: "Normal: < 140 mg/dL (2h post meal)" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "HbA1c (Glycated Hemoglobin)" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "number", - step: "0.1", - className: "form-control text-center", - placeholder: "5.6", - value: wellnessForm.hba1c, - onChange: e => setWellnessForm({ - ...wellnessForm, - hba1c: e.target.value - }) - }), /*#__PURE__*/_jsx("span", { - className: "input-group-text", - children: "%" - })] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - style: { - fontSize: '10px' - }, - children: "Normal: < 5.7% | Prediabetes: 5.7-6.4% | Diabetes: ≥ 6.5%" - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "POC Hemoglobin (Hb)" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "number", - step: "0.1", - className: "form-control text-center", - placeholder: "13.5", - value: wellnessForm.hemoglobin, - onChange: e => setWellnessForm({ - ...wellnessForm, - hemoglobin: e.target.value - }) - }), /*#__PURE__*/_jsx("span", { - className: "input-group-text", - children: "g/dL" - })] - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - style: { - fontSize: '10px' - }, - children: "Normal: 12.0 - 17.5 g/dL" - })] - })] - }), wellnessModalTab === 'activity' && /*#__PURE__*/_jsxs("div", { - className: "row g-2.5 mb-2", - children: [/*#__PURE__*/_jsx("div", { - className: "col-12", - children: /*#__PURE__*/_jsxs("h6", { - className: "fw-bold small text-primary mb-1 border-bottom pb-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-rulers me-1" - }), " Body Circumferences (NRCES BodyMeasurement)"] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Waist Circumference" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "number", - step: "0.1", - className: "form-control text-center", - placeholder: "85", - value: wellnessForm.waist_circumference_cm, - onChange: e => setWellnessForm({ - ...wellnessForm, - waist_circumference_cm: e.target.value - }) - }), /*#__PURE__*/_jsx("span", { - className: "input-group-text", - children: "cm" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Hip Circumference" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "number", - step: "0.1", - className: "form-control text-center", - placeholder: "95", - value: wellnessForm.hip_circumference_cm, - onChange: e => setWellnessForm({ - ...wellnessForm, - hip_circumference_cm: e.target.value - }) - }), /*#__PURE__*/_jsx("span", { - className: "input-group-text", - children: "cm" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-12 col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Waist-to-Hip Ratio (WHR)" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm text-center bg-light fw-bold", - readOnly: true, - value: wellnessForm.waist_circumference_cm && wellnessForm.hip_circumference_cm && parseFloat(wellnessForm.hip_circumference_cm) > 0 ? (parseFloat(wellnessForm.waist_circumference_cm) / parseFloat(wellnessForm.hip_circumference_cm)).toFixed(2) : '-' - }), /*#__PURE__*/_jsx("small", { - className: "text-muted", - style: { - fontSize: '10px' - }, - children: "Normal: Men < 0.90 | Women < 0.85" - })] - }), /*#__PURE__*/_jsx("div", { - className: "col-12 mt-2", - children: /*#__PURE__*/_jsxs("h6", { - className: "fw-bold small text-success mb-1 border-bottom pb-1", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-activity me-1" - }), " Physical Activity & Sleep (NRCES PhysicalActivity)"] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Daily Steps (24h)" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "number", - step: "100", - className: "form-control text-center", - placeholder: "8000", - value: wellnessForm.daily_steps, - onChange: e => setWellnessForm({ - ...wellnessForm, - daily_steps: e.target.value - }) - }), /*#__PURE__*/_jsx("span", { - className: "input-group-text", - children: "steps" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Sleep Duration" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "number", - step: "0.5", - className: "form-control text-center", - placeholder: "7.5", - value: wellnessForm.sleep_hours, - onChange: e => setWellnessForm({ - ...wellnessForm, - sleep_hours: e.target.value - }) - }), /*#__PURE__*/_jsx("span", { - className: "input-group-text", - children: "hours" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-12 col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Exercise Duration" - }), /*#__PURE__*/_jsxs("div", { - className: "input-group input-group-sm", - children: [/*#__PURE__*/_jsx("input", { - type: "number", - step: "5", - className: "form-control text-center", - placeholder: "30", - value: wellnessForm.exercise_min_per_day, - onChange: e => setWellnessForm({ - ...wellnessForm, - exercise_min_per_day: e.target.value - }) - }), /*#__PURE__*/_jsx("span", { - className: "input-group-text", - children: "min/day" - })] - })] - })] - }), wellnessModalTab === 'lifestyle' && /*#__PURE__*/_jsxs("div", { - className: "row g-2.5 mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-12 col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Diet Pattern (ABDM)" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: wellnessForm.diet_type, - onChange: e => setWellnessForm({ - ...wellnessForm, - diet_type: e.target.value - }), - children: [/*#__PURE__*/_jsx("option", { - value: "", - children: "Select diet..." - }), /*#__PURE__*/_jsx("option", { - value: "Balanced Diet", - children: "Balanced Diet" - }), /*#__PURE__*/_jsx("option", { - value: "Vegetarian", - children: "Vegetarian" - }), /*#__PURE__*/_jsx("option", { - value: "Lacto-Vegetarian", - children: "Lacto-Vegetarian" - }), /*#__PURE__*/_jsx("option", { - value: "Non-Vegetarian", - children: "Non-Vegetarian" - }), /*#__PURE__*/_jsx("option", { - value: "Vegan", - children: "Vegan" - }), /*#__PURE__*/_jsx("option", { - value: "Diabetic Diet", - children: "Diabetic Diet (Low GI)" - }), /*#__PURE__*/_jsx("option", { - value: "Low Sodium / DASH Diet", - children: "Low Sodium / DASH Diet" - }), /*#__PURE__*/_jsx("option", { - value: "Renal Diet", - children: "Renal Diet" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Tobacco / Smoking" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: wellnessForm.tobacco_status, - onChange: e => setWellnessForm({ - ...wellnessForm, - tobacco_status: e.target.value - }), - children: [/*#__PURE__*/_jsx("option", { - value: "", - children: "Select status..." - }), /*#__PURE__*/_jsx("option", { - value: "Never Smoked", - children: "Never Smoked" - }), /*#__PURE__*/_jsx("option", { - value: "Former / Ex-Smoker", - children: "Former / Ex-Smoker" - }), /*#__PURE__*/_jsx("option", { - value: "Current Smoker (Occasional)", - children: "Current Smoker (Occasional)" - }), /*#__PURE__*/_jsx("option", { - value: "Current Smoker (Daily)", - children: "Current Smoker (Daily)" - }), /*#__PURE__*/_jsx("option", { - value: "Tobacco Chewer", - children: "Tobacco Chewer" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-6 col-md-4", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Alcohol Consumption" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: wellnessForm.alcohol_status, - onChange: e => setWellnessForm({ - ...wellnessForm, - alcohol_status: e.target.value - }), - children: [/*#__PURE__*/_jsx("option", { - value: "", - children: "Select status..." - }), /*#__PURE__*/_jsx("option", { - value: "Lifetime Non-Drinker", - children: "Lifetime Non-Drinker" - }), /*#__PURE__*/_jsx("option", { - value: "Former Drinker", - children: "Former Drinker" - }), /*#__PURE__*/_jsx("option", { - value: "Occasional / Social Drinker", - children: "Occasional / Social Drinker" - }), /*#__PURE__*/_jsx("option", { - value: "Regular Drinker", - children: "Regular Drinker" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-12", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Diet & Lifestyle Guidance (ABDM)" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "e.g. Low sodium diet, 30 min daily brisk walking, adequate hydration", - value: wellnessForm.diet_lifestyle_note, - onChange: e => setWellnessForm({ - ...wellnessForm, - diet_lifestyle_note: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-12", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "General Nursing Observations" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "e.g. Patient conscious, oriented to time/place, vitals within acceptable limits", - value: wellnessForm.general_advice, - onChange: e => setWellnessForm({ - ...wellnessForm, - general_advice: e.target.value - }) - })] - })] - }), wellnessModalTab === 'women' && /*#__PURE__*/_jsxs("div", { - className: "row g-2.5 mb-2", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-12 col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Last Menstrual Period (LMP Date)" - }), /*#__PURE__*/_jsx("input", { - type: "date", - className: "form-control form-control-sm", - value: wellnessForm.women_lmp, - onChange: e => setWellnessForm({ - ...wellnessForm, - women_lmp: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-12 col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small mb-1 fw-bold", - children: "Pregnancy / Reproductive Status" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: wellnessForm.women_pregnancy_status, - onChange: e => setWellnessForm({ - ...wellnessForm, - women_pregnancy_status: e.target.value - }), - children: [/*#__PURE__*/_jsx("option", { - value: "", - children: "Select reproductive status..." - }), /*#__PURE__*/_jsx("option", { - value: "Not Pregnant", - children: "Not Pregnant" - }), /*#__PURE__*/_jsx("option", { - value: "Pregnant - 1st Trimester (1 - 12 wks)", - children: "Pregnant - 1st Trimester (1 - 12 wks)" - }), /*#__PURE__*/_jsx("option", { - value: "Pregnant - 2nd Trimester (13 - 26 wks)", - children: "Pregnant - 2nd Trimester (13 - 26 wks)" - }), /*#__PURE__*/_jsx("option", { - value: "Pregnant - 3rd Trimester (27 - 40+ wks)", - children: "Pregnant - 3rd Trimester (27 - 40+ wks)" - }), /*#__PURE__*/_jsx("option", { - value: "Postpartum (< 6 weeks post delivery)", - children: "Postpartum (< 6 weeks post delivery)" - }), /*#__PURE__*/_jsx("option", { - value: "Lactating / Breastfeeding", - children: "Lactating / Breastfeeding" - }), /*#__PURE__*/_jsx("option", { - value: "Perimenopausal", - children: "Perimenopausal" - }), /*#__PURE__*/_jsx("option", { - value: "Postmenopausal", - children: "Postmenopausal" - })] - })] - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer p-2 bg-light d-flex justify-content-between", - children: [/*#__PURE__*/_jsxs("button", { - className: "btn btn-outline-secondary btn-sm", - onClick: () => openWellnessHistory(activeWellnessPatient), - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clock-history me-1" - }), " Past History"] - }), /*#__PURE__*/_jsxs("div", { - className: "d-flex gap-2", - children: [/*#__PURE__*/_jsx("button", { - className: "btn btn-secondary btn-sm", - onClick: () => setActiveWellnessPatient(null), - children: "Cancel" - }), /*#__PURE__*/_jsxs("button", { - className: "btn btn-success btn-sm fw-bold px-3 shadow-sm", - onClick: handleSaveWellness, - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle-fill me-1" - }), " Save ABDM Wellness Vitals"] - })] - })] - })] - }) - }) - }), activeDocPatient && /*#__PURE__*/_jsx("div", { - className: "modal show d-block", - style: { - backgroundColor: 'rgba(0,0,0,0.65)', - zIndex: 1060 - }, - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered modal-lg", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content rounded-4 border-0 shadow-lg overflow-hidden", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-primary text-white py-2.5", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-file-earmark-medical-fill fs-5" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "modal-title fw-bold mb-0", - children: "Add ABDM M2 Health Document" - }), /*#__PURE__*/_jsx("small", { - className: "text-white-50", - style: { - fontSize: '11px' - }, - children: "Scan paper prescriptions, lab reports or clinical documents" - })] - })] - }), /*#__PURE__*/_jsx("button", { - className: "btn-close btn-close-white", - onClick: () => setActiveDocPatient(null) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-body p-3", - children: [/*#__PURE__*/_jsx("div", { - className: "p-2.5 rounded-3 bg-light border mb-3", - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex justify-content-between align-items-start flex-wrap gap-1", - children: [/*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("strong", { - className: "fs-6 text-dark", - children: activeDocPatient.fullName || activeDocPatient.p_fname - }), /*#__PURE__*/_jsxs("div", { - className: "small text-muted", - children: ["UHID: ", /*#__PURE__*/_jsx("span", { - className: "text-danger fw-bold", - children: activeDocPatient.p_code || activeDocPatient.uhid - })] - })] - }), activeDocPatient.abha_id && /*#__PURE__*/_jsxs("span", { - className: "badge bg-success", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-shield-check me-1" - }), " ABHA: ", activeDocPatient.abha_id] - })] - }) - }), /*#__PURE__*/_jsxs("div", { - className: "row g-2 mb-3", - children: [/*#__PURE__*/_jsxs("div", { - className: "col-12 col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Document Category (ABDM HI Type)" - }), /*#__PURE__*/_jsxs("select", { - className: "form-select form-select-sm", - value: patientDocForm.document_type, - onChange: e => setPatientDocForm({ - ...patientDocForm, - document_type: e.target.value - }), - children: [/*#__PURE__*/_jsx("option", { - value: "Prescription", - children: "Prescription Record (PrescriptionRecord)" - }), /*#__PURE__*/_jsx("option", { - value: "Diagnostic Report / Lab", - children: "Diagnostic / Lab Report (DiagnosticReport)" - }), /*#__PURE__*/_jsx("option", { - value: "Discharge Summary", - children: "Discharge Summary (DischargeSummary)" - }), /*#__PURE__*/_jsx("option", { - value: "Scan / Radiology (X-Ray/CT/MRI)", - children: "Radiology / Scan (HealthDocumentRecord)" - }), /*#__PURE__*/_jsx("option", { - value: "Paper Medical Record", - children: "Paper Medical Record (HealthDocumentRecord)" - }), /*#__PURE__*/_jsx("option", { - value: "Immunization Record", - children: "Immunization Record (ImmunizationRecord)" - }), /*#__PURE__*/_jsx("option", { - value: "Health Document", - children: "Other Health Document (HealthDocumentRecord)" - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-12 col-md-6", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Document Date" - }), /*#__PURE__*/_jsx("input", { - type: "date", - className: "form-control form-control-sm", - value: patientDocForm.document_date, - onChange: e => setPatientDocForm({ - ...patientDocForm, - document_date: e.target.value - }) - })] - }), /*#__PURE__*/_jsxs("div", { - className: "col-12", - children: [/*#__PURE__*/_jsx("label", { - className: "form-label small fw-bold mb-1", - children: "Remarks / Document Title" - }), /*#__PURE__*/_jsx("input", { - type: "text", - className: "form-control form-control-sm", - placeholder: "e.g. Chest X-Ray Report, Blood CBC Test, Consultation Note", - value: patientDocForm.remarks, - onChange: e => setPatientDocForm({ - ...patientDocForm, - remarks: e.target.value - }) - })] - })] - }), /*#__PURE__*/_jsx("div", { - className: "mb-3 text-center", - children: /*#__PURE__*/_jsxs("label", { - className: "btn btn-primary btn-lg w-100 py-3 fw-bold rounded-3 shadow-sm", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-camera me-2" - }), " Take Document Photo / Choose Image", /*#__PURE__*/_jsx("input", { - type: "file", - accept: "image/*", - capture: "environment", - className: "d-none", - onChange: handleScanImageCapture - })] - }) - }), scanImagePreview && /*#__PURE__*/_jsxs("div", { - className: "position-relative p-2 border rounded-3 bg-light text-center", - children: [/*#__PURE__*/_jsxs("span", { - className: "badge bg-success position-absolute top-0 start-0 m-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-check-circle me-1" - }), " Document Photo Captured"] - }), /*#__PURE__*/_jsx("img", { - src: scanImagePreview, - alt: "Document Scan Preview", - className: "img-fluid rounded-3 border shadow-sm", - style: { - maxHeight: '200px', - objectFit: 'contain' - } - })] - })] - }), /*#__PURE__*/_jsxs("div", { - className: "modal-footer p-2 bg-light", - children: [/*#__PURE__*/_jsx("button", { - className: "btn btn-secondary btn-sm", - onClick: () => setActiveDocPatient(null), - disabled: isSavingDoc, - children: "Cancel" - }), /*#__PURE__*/_jsx("button", { - className: "btn btn-primary btn-sm fw-bold px-3", - onClick: handleSavePatientDocument, - disabled: !scanImageBase64 || isSavingDoc, - children: isSavingDoc ? /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("span", { - className: "spinner-border spinner-border-sm me-1", - role: "status", - "aria-hidden": "true" - }), "Uploading..."] - }) : /*#__PURE__*/_jsxs("span", { - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-cloud-upload-fill me-1" - }), " Upload ABDM Health Document"] - }) - })] - })] - }) - }) - }), wellnessHistoryPatient && /*#__PURE__*/_jsx("div", { - className: "modal show d-block", - style: { - backgroundColor: 'rgba(0,0,0,0.65)', - zIndex: 1070 - }, - children: /*#__PURE__*/_jsx("div", { - className: "modal-dialog modal-dialog-centered modal-xl", - children: /*#__PURE__*/_jsxs("div", { - className: "modal-content rounded-4 border-0 shadow-lg overflow-hidden", - children: [/*#__PURE__*/_jsxs("div", { - className: "modal-header bg-dark text-white py-2.5", - children: [/*#__PURE__*/_jsxs("div", { - className: "d-flex align-items-center gap-2", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-clock-history fs-5 text-warning" - }), /*#__PURE__*/_jsxs("div", { - children: [/*#__PURE__*/_jsx("h6", { - className: "modal-title fw-bold mb-0", - children: "Vitals & Wellness History" - }), /*#__PURE__*/_jsxs("small", { - className: "text-white-50", - style: { - fontSize: '11px' - }, - children: [wellnessHistoryPatient.fullName || wellnessHistoryPatient.p_fname, " (UHID: ", wellnessHistoryPatient.p_code || wellnessHistoryPatient.uhid, ")"] - })] - })] - }), /*#__PURE__*/_jsx("button", { - className: "btn-close btn-close-white", - onClick: () => setWellnessHistoryPatient(null) - })] - }), /*#__PURE__*/_jsx("div", { - className: "modal-body p-3", - children: loadingHistory ? /*#__PURE__*/_jsxs("div", { - className: "text-center py-4", - children: [/*#__PURE__*/_jsx("div", { - className: "spinner-border text-primary", - role: "status" - }), /*#__PURE__*/_jsx("p", { - className: "small text-muted mt-2", - children: "Loading historical vitals..." - })] - }) : wellnessHistoryList.length === 0 ? /*#__PURE__*/_jsxs("div", { - className: "text-center py-4 bg-light rounded-3", - children: [/*#__PURE__*/_jsx("i", { - className: "bi bi-heart-pulse fs-2 text-muted opacity-50 d-block mb-1" - }), /*#__PURE__*/_jsx("p", { - className: "small text-muted mb-0", - children: "No past vitals or wellness entries recorded yet for this patient." - })] - }) : /*#__PURE__*/_jsx("div", { - className: "table-responsive", - children: /*#__PURE__*/_jsxs("table", { - className: "table table-sm table-striped table-hover align-middle mb-0", - style: { - fontSize: '12px' - }, - children: [/*#__PURE__*/_jsx("thead", { - className: "table-light", - children: /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("th", { - children: "Date & Time" - }), /*#__PURE__*/_jsx("th", { - children: "Vitals (BP / Pulse / SpO2 / Temp)" - }), /*#__PURE__*/_jsx("th", { - children: "Body / BMI" - }), /*#__PURE__*/_jsx("th", { - children: "Blood Glucose (mg/dL)" - }), /*#__PURE__*/_jsx("th", { - children: "POC Labs" - }), /*#__PURE__*/_jsx("th", { - children: "Activity / Lifestyle" - }), /*#__PURE__*/_jsx("th", { - children: "Staff" - }), /*#__PURE__*/_jsx("th", { - children: "Advice / Remarks" - })] - }) - }), /*#__PURE__*/_jsx("tbody", { - children: wellnessHistoryList.map(rec => /*#__PURE__*/_jsxs("tr", { - children: [/*#__PURE__*/_jsx("td", { - className: "fw-semibold text-nowrap", - children: formatDateTime(rec.recorded_at) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap gap-1 align-items-center", - children: [rec.bp_systolic && /*#__PURE__*/_jsxs("span", { - className: "badge bg-light text-dark border", - children: ["BP ", rec.bp_systolic, "/", rec.bp_diastolic] - }), rec.pulse_rate && /*#__PURE__*/_jsxs("span", { - className: "badge bg-light text-dark border", - children: [rec.pulse_rate, " bpm"] - }), rec.spo2 && /*#__PURE__*/_jsxs("span", { - className: "badge bg-info-subtle text-info border border-info-subtle", - children: [rec.spo2, "% O2"] - }), rec.temperature_f && /*#__PURE__*/_jsxs("span", { - className: "badge bg-danger-subtle text-danger border border-danger-subtle", - children: [rec.temperature_f, "°F"] - }), rec.pain_score !== null && rec.pain_score !== undefined && rec.pain_score !== '' && /*#__PURE__*/_jsxs("span", { - className: `badge ${rec.pain_score == 0 ? 'bg-success-subtle text-success' : rec.pain_score <= 3 ? 'bg-info-subtle text-info' : 'bg-warning-subtle text-warning-emphasis'}`, - children: ["Pain: ", rec.pain_score, "/10"] - })] - }) - }), /*#__PURE__*/_jsxs("td", { - children: [/*#__PURE__*/_jsxs("div", { - children: [rec.bmi && /*#__PURE__*/_jsxs("span", { - className: "badge bg-secondary-subtle text-secondary me-1", - children: ["BMI ", rec.bmi] - }), rec.weight_kg && /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [rec.weight_kg, "kg "] - }), rec.height_cm && /*#__PURE__*/_jsxs("small", { - className: "text-muted", - children: [rec.height_cm, "cm"] - })] - }), (rec.waist_circumference_cm || rec.waist_hip_ratio) && /*#__PURE__*/_jsxs("small", { - className: "text-muted d-block", - style: { - fontSize: '11px' - }, - children: [rec.waist_circumference_cm ? `Waist: ${rec.waist_circumference_cm}cm` : '', rec.waist_hip_ratio ? ` • WHR: ${rec.waist_hip_ratio}` : ''] - })] - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap gap-1", - children: [rec.sugar_random && /*#__PURE__*/_jsxs("span", { - className: "badge bg-warning-subtle text-warning-emphasis border", - children: ["RBS: ", rec.sugar_random] - }), rec.sugar_fasting && /*#__PURE__*/_jsxs("span", { - className: "badge bg-primary-subtle text-primary border", - children: ["FBS: ", rec.sugar_fasting] - }), rec.sugar_pp && /*#__PURE__*/_jsxs("span", { - className: "badge bg-secondary-subtle text-secondary border", - children: ["PP: ", rec.sugar_pp] - }), !rec.sugar_random && !rec.sugar_fasting && !rec.sugar_pp && /*#__PURE__*/_jsx("span", { - className: "text-muted", - children: "-" - })] - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("div", { - className: "d-flex flex-wrap gap-1", - children: [rec.hemoglobin && /*#__PURE__*/_jsxs("span", { - className: "badge bg-danger-subtle text-danger border", - children: ["Hb: ", rec.hemoglobin, " g/dL"] - }), rec.hba1c && /*#__PURE__*/_jsxs("span", { - className: "badge bg-success-subtle text-success border", - children: ["A1c: ", rec.hba1c, "%"] - }), !rec.hemoglobin && !rec.hba1c && /*#__PURE__*/_jsx("span", { - className: "text-muted", - children: "-" - })] - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsxs("div", { - className: "small", - children: [rec.diet_type && /*#__PURE__*/_jsx("span", { - className: "badge bg-light text-dark border me-1", - children: rec.diet_type - }), rec.daily_steps && /*#__PURE__*/_jsxs("span", { - className: "text-muted me-1", - children: [rec.daily_steps, " steps"] - }), rec.sleep_hours && /*#__PURE__*/_jsxs("span", { - className: "text-muted", - children: [rec.sleep_hours, "h sleep"] - }), !rec.diet_type && !rec.daily_steps && !rec.sleep_hours && /*#__PURE__*/_jsx("span", { - className: "text-muted", - children: "-" - })] - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("small", { - className: "text-muted", - children: rec.recorded_by || 'Staff' - }) - }), /*#__PURE__*/_jsx("td", { - children: /*#__PURE__*/_jsx("small", { - className: "text-truncate d-inline-block", - style: { - maxWidth: '180px' - }, - title: rec.general_advice || rec.diet_lifestyle_note, - children: rec.general_advice || rec.diet_lifestyle_note || '-' - }) - })] - }, rec.id)) - })] - }) - }) - }), /*#__PURE__*/_jsx("div", { - className: "modal-footer p-2 bg-light", - children: /*#__PURE__*/_jsx("button", { - className: "btn btn-secondary btn-sm px-3", - onClick: () => setWellnessHistoryPatient(null), - children: "Close" - }) - })] - }) - }) - })] - })] - }); + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(MobileAppsModal, { + show: showAppsModal, + onClose: () => setShowAppsModal(false), + currentApp: "nursing" + }), /*#__PURE__*/React.createElement("header", { + className: "nursing-header d-flex justify-content-between align-items-center" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "avatar-circle" + }, getInitials(authenticatedNurse.name)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "mb-0 fw-bold" + }, authenticatedNurse.name), /*#__PURE__*/React.createElement("small", { + className: "text-light opacity-75", + style: { + fontSize: '11px' + } + }, authenticatedNurse.designation || 'Staff Nurse', " ", /*#__PURE__*/React.createElement("span", { + className: "badge bg-success ms-1", + style: { + fontSize: '9px' + } + }, "● Active")))), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-light rounded-circle p-2", + style: { + width: '36px', + height: '36px' + }, + onClick: () => setShowAppsModal(true), + title: "HMS Mobile & PWA Apps Launcher" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-grid-3x3-gap-fill" + })), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-light rounded-circle p-2", + style: { + width: '36px', + height: '36px' + }, + onClick: () => { + fetchBeds(); + fetchOpdAppointments(opdDateMode, selectedDoctorId, vitalsFilter); + }, + title: "Refresh" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-clockwise" + })), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-danger rounded-circle p-2", + style: { + width: '36px', + height: '36px' + }, + onClick: handleLogout, + title: "Lock Access" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-lock-fill" + })))), /*#__PURE__*/React.createElement("main", { + className: "container-fluid py-3 px-2 px-md-3 content-with-bottom-dock" + }, !activeBed ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "segmented-tabs mb-3" + }, /*#__PURE__*/React.createElement("button", { + className: `segmented-tab ${mainTab === 'ipd' ? 'active' : ''}`, + onClick: () => { + setMainTab('ipd'); + fetchBeds(); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hospital-fill me-2" + }), " Admitted IPDs (", beds.filter(b => b.status === 'occupied' || b.patient_name).length, ")"), /*#__PURE__*/React.createElement("button", { + className: `segmented-tab ${mainTab === 'opd' ? 'active-blue' : ''}`, + onClick: () => { + setMainTab('opd'); + fetchOpdAppointments(opdDateMode, selectedDoctorId, vitalsFilter); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-calendar-check-fill me-2" + }), " OPD Patients (", opdAppointments.length, ")")), mainTab === 'ipd' ? + /*#__PURE__*/ + /* ------------------------------------------------------------- + ADMITTED IPD PATIENTS & BEDS + ------------------------------------------------------------- */ + React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-3 align-items-center" + }, /*#__PURE__*/React.createElement("div", { + className: "col-12 col-md-6" + }, /*#__PURE__*/React.createElement("div", { + className: "input-group shadow-sm rounded-pill overflow-hidden bg-white border" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-white border-0 ps-3 text-secondary" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control border-0 py-2 shadow-none", + placeholder: "Search Bed No, Patient Name, UHID...", + value: searchQuery, + onChange: e => setSearchQuery(e.target.value) + }))), /*#__PURE__*/React.createElement("div", { + className: "col-12 col-md-6" + }, /*#__PURE__*/React.createElement("select", { + className: "form-select rounded-pill shadow-sm py-2", + value: selectedWard, + onChange: e => setSelectedWard(e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "all" + }, "All Wards / Units"), Array.from(new Set(beds.map(b => b.ward_name))).filter(Boolean).map(w => /*#__PURE__*/React.createElement("option", { + key: w, + value: w + }, w))))), /*#__PURE__*/React.createElement("div", { + className: "row g-3" + }, filteredBeds.length === 0 ? /*#__PURE__*/React.createElement("div", { + className: "col-12 text-center text-muted py-5 bg-white rounded-4 border shadow-sm" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hospital fs-1 text-secondary opacity-50 d-block mb-2" + }), /*#__PURE__*/React.createElement("h6", { + className: "fw-bold text-slate-800 mb-1" + }, "No Admitted Patients Found"), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "There are currently no admitted IPD patients in the selected ward.")) : filteredBeds.map(bed => /*#__PURE__*/React.createElement("div", { + key: bed.id, + className: "col-12 col-md-6 col-lg-4" + }, /*#__PURE__*/React.createElement("div", { + className: `bed-card p-3 bed-status-${bed.status}`, + onClick: () => openWorkspace(bed) + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-start mb-2" + }, /*#__PURE__*/React.createElement("span", { + className: "fw-bold text-dark fs-5" + }, "Bed ", bed.bed_number), /*#__PURE__*/React.createElement("span", { + className: `badge ${bed.status === 'occupied' ? 'bg-primary' : 'bg-success'} text-uppercase`, + style: { + fontSize: '9px' + } + }, bed.status)), /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block mb-2", + style: { + fontSize: '11px' + } + }, bed.ward_name || 'General Ward'), bed.patient_name ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-primary text-truncate", + style: { + fontSize: '15px' + } + }, bed.patient_name), /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block", + style: { + fontSize: '11px' + } + }, "UHID: ", bed.uhid || 'N/A', " • IPD: ", bed.ipd_code || 'N/A'), /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary border border-primary-subtle px-2 py-1 mt-2 d-inline-block", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-badge me-1" + }), " ", bed.doctor_name || 'Dr. Assigned')) : /*#__PURE__*/React.createElement("div", { + className: "text-success small fw-semibold py-2" + }, "Available for Admission"), /*#__PURE__*/React.createElement("div", { + className: "mt-3 pt-2 border-top d-flex gap-1" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-primary w-100 py-2 fw-bold rounded-3 shadow-sm", + style: { + fontSize: '12px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-heart-pulse me-1" + }), " Open Bedside Workspace"))))))) : + /*#__PURE__*/ + /* ------------------------------------------------------------- + OPD PATIENTS TAB (VITALS & DOCUMENT SCANNING) + ------------------------------------------------------------- */ + React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center justify-content-between mb-3 bg-white p-2 rounded-4 border shadow-sm flex-wrap gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1 bg-light p-1 rounded-pill border" + }, /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm rounded-pill px-3 py-1 fw-bold ${opdDateMode === 'today' ? 'btn-primary shadow-sm' : 'btn-light text-secondary'}`, + onClick: () => { + setOpdDateMode('today'); + fetchOpdAppointments('today', selectedDoctorId, vitalsFilter); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-calendar-event me-1" + }), " Today's OPDs (", opdCounts.today_total || 0, ")"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm rounded-pill px-3 py-1 fw-bold ${opdDateMode === 'all' ? 'btn-primary shadow-sm' : 'btn-light text-secondary'}`, + onClick: () => { + setOpdDateMode('all'); + fetchOpdAppointments('all', selectedDoctorId, vitalsFilter); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-calendar3 me-1" + }), " All Dates (", opdCounts.all_total || 0, ")")), /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary border border-primary-subtle px-2 py-1 rounded-pill small", + style: { + fontSize: '11px' + } + }, opdDateMode === 'today' ? '● Current Date' : '● All Appointments')), /*#__PURE__*/React.createElement("div", { + className: "bg-white p-3 mb-3 rounded-4 border shadow-sm" + }, /*#__PURE__*/React.createElement("div", { + className: "row g-2 align-items-center" + }, /*#__PURE__*/React.createElement("div", { + className: "col-12 col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-dark mb-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-badge text-primary me-1" + }), " Filter by Doctor"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm rounded-pill fw-semibold", + value: selectedDoctorId, + onChange: e => { + const val = e.target.value; + setSelectedDoctorId(val); + fetchOpdAppointments(opdDateMode, val, vitalsFilter); + } + }, /*#__PURE__*/React.createElement("option", { + value: "0" + }, "-- All Hospital Doctors --"), doctors.map(d => /*#__PURE__*/React.createElement("option", { + key: d.id, + value: d.id + }, d.name)))), /*#__PURE__*/React.createElement("div", { + className: "col-12 col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold text-dark mb-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-heart-pulse-fill text-danger me-1" + }), " Vitals Status Filter"), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1" + }, /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm flex-fill rounded-pill py-1 fw-bold ${vitalsFilter === 'all' ? 'btn-primary shadow-sm' : 'btn-light border text-secondary'}`, + onClick: () => { + setVitalsFilter('all'); + fetchOpdAppointments(opdDateMode, selectedDoctorId, 'all'); + } + }, "All (", opdCounts.all, ")"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm flex-fill rounded-pill py-1 fw-bold ${vitalsFilter === 'pending' ? 'btn-warning text-dark shadow-sm' : 'btn-light border text-secondary'}`, + onClick: () => { + setVitalsFilter('pending'); + fetchOpdAppointments(opdDateMode, selectedDoctorId, 'pending'); + } + }, "⚠️ Pending (", opdCounts.pending_vitals || 0, ")"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm flex-fill rounded-pill py-1 fw-bold ${vitalsFilter === 'done' ? 'btn-success text-white shadow-sm' : 'btn-light border text-secondary'}`, + onClick: () => { + setVitalsFilter('done'); + fetchOpdAppointments(opdDateMode, selectedDoctorId, 'done'); + } + }, "✅ Filled (", opdCounts.done_vitals || 0, ")"))))), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2 mb-3 overflow-auto no-scrollbar pb-1" + }, /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm rounded-pill px-3 ${opdFilter === 'all' ? 'btn-primary fw-bold' : 'btn-white bg-white text-secondary border'}`, + onClick: () => setOpdFilter('all') + }, "All Visits"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm rounded-pill px-3 ${opdFilter === 'waiting' ? 'btn-primary fw-bold' : 'btn-white bg-white text-secondary border'}`, + onClick: () => setOpdFilter('waiting') + }, "Waiting"), /*#__PURE__*/React.createElement("button", { + className: `btn btn-sm rounded-pill px-3 ${opdFilter === 'visited' ? 'btn-info text-dark fw-bold' : 'btn-white bg-white text-secondary border'}`, + onClick: () => setOpdFilter('visited') + }, "Visited")), /*#__PURE__*/React.createElement("div", { + className: "input-group mb-3 shadow-sm rounded-pill overflow-hidden bg-white border" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-white border-0 ps-3 text-secondary" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control border-0 py-2 shadow-none", + placeholder: "Search Patient Name, Doctor Name, UHID, OPD Code...", + value: searchQuery, + onChange: e => setSearchQuery(e.target.value) + })), /*#__PURE__*/React.createElement("div", null, filteredOpdAppointments.length === 0 ? /*#__PURE__*/React.createElement("div", { + className: "text-center text-muted py-5 bg-white rounded-4 border shadow-sm" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-x fs-1 text-secondary opacity-50 d-block mb-2" + }), "No OPD appointments found for selected filter.") : filteredOpdAppointments.map(app => /*#__PURE__*/React.createElement("div", { + key: app.opd_id, + className: "mobile-patient-card" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-2 pb-2 border-bottom" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("span", { + className: "queue-badge" + }, "Q #", app.queue_no || app.opd_no || '1'), /*#__PURE__*/React.createElement("span", { + className: `status-pill ${app.status_key}` + }, "● ", app.status_label)), /*#__PURE__*/React.createElement("code", { + className: "fw-bold text-dark fs-6" + }, app.opd_code)), /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-start gap-3 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "patient-avatar-circle" + }, getInitials(app.patient_display_name)), /*#__PURE__*/React.createElement("div", { + className: "flex-grow-1" + }, /*#__PURE__*/React.createElement("h5", { + className: "fw-bold text-slate-900 mb-1", + style: { + fontSize: '16px' + } + }, app.patient_display_name), /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block mb-2", + style: { + fontSize: '12px' + } + }, app.age_display, " • ", app.gender_label, " | UHID: ", app.uhid), /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary border border-primary-subtle px-2 py-1", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-badge me-1" + }), app.doctor_name || 'Doctor'))), app.has_vitals && /*#__PURE__*/React.createElement("div", { + className: "alert alert-success py-1.5 px-3 mb-3 small rounded-3 d-flex align-items-center justify-content-between", + style: { + fontSize: '12px' + } + }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-heart-pulse-fill text-danger me-1" + }), " ", /*#__PURE__*/React.createElement("strong", null, "Vitals:"), " BP ", app.bp || '-', "/", app.diastolic || '-', " | Pulse ", app.pulse || '-', " | Temp ", app.temp || '-', "°F"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-success" + }, "Vitals ✓")), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2" + }, /*#__PURE__*/React.createElement("button", { + className: `btn ${app.has_vitals ? 'btn-success' : 'btn-outline-success'} w-50 py-2 fw-bold rounded-3 shadow-sm`, + onClick: () => openOpdVitalsModal(app) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-heart-pulse me-1" + }), " ", app.has_vitals ? 'Vitals ✓' : 'Fill Vitals'), /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-primary w-50 py-2 fw-bold rounded-3 shadow-sm", + onClick: () => openScanModal(app, 'opd') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-camera me-1" + }), " Scan / Photo"))))))) : + /*#__PURE__*/ + /* ------------------------------------------------------------- + IPD BEDSIDE WORKSPACE FOR NURSING STAFF + ------------------------------------------------------------- */ + React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-3" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-dark rounded-pill px-3", + onClick: () => setActiveBed(null) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-left me-1" + }), " Back to Bed List"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-primary fw-bold rounded-pill px-3", + onClick: () => openScanModal(activeBed, 'ipd') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-camera me-1" + }), " Scan Paper Doc")), /*#__PURE__*/React.createElement("div", { + className: "card shadow-sm mb-3 border-0 bg-primary text-white rounded-4", + style: { + background: 'linear-gradient(135deg, #0f172a 0%, #1e293b 100%)' + } + }, /*#__PURE__*/React.createElement("div", { + className: "card-body p-3" + }, /*#__PURE__*/React.createElement("h5", { + className: "fw-bold mb-1" + }, activeBed.patient_name), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap gap-2 opacity-90 small mt-2" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-white text-dark" + }, "Bed ", activeBed.bed_number, " (", activeBed.ward_name, ")"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-white text-danger" + }, "UHID: ", activeBed.uhid), /*#__PURE__*/React.createElement("span", { + className: "badge bg-white text-primary" + }, "IPD: ", activeBed.ipd_code)))), /*#__PURE__*/React.createElement("ul", { + className: "nav nav-pills mb-3 bg-white p-1 rounded-3 border shadow-sm" + }, /*#__PURE__*/React.createElement("li", { + className: "nav-item flex-fill text-center" + }, /*#__PURE__*/React.createElement("button", { + className: `nav-link w-100 fw-bold ${activeTab === 'vitals' ? 'active' : ''}`, + onClick: () => setActiveTab('vitals') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-heart-pulse me-1" + }), " Vitals (", workspaceData.filter(e => e.entry_type === 'vitals').length, ")")), /*#__PURE__*/React.createElement("li", { + className: "nav-item flex-fill text-center" + }, /*#__PURE__*/React.createElement("button", { + className: `nav-link w-100 fw-bold ${activeTab === 'fluid' ? 'active' : ''}`, + onClick: () => setActiveTab('fluid') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-droplet me-1" + }), " Fluid I/O (", workspaceData.filter(e => e.entry_type === 'fluid').length, ")")), /*#__PURE__*/React.createElement("li", { + className: "nav-item flex-fill text-center" + }, /*#__PURE__*/React.createElement("button", { + className: `nav-link w-100 fw-bold ${activeTab === 'treatment' ? 'active' : ''}`, + onClick: () => setActiveTab('treatment') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clipboard2-pulse me-1" + }), " Treatment & Orders (", workspaceData.filter(e => e.entry_type === 'treatment').length, ")"))), activeTab === 'vitals' && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "card p-3 shadow-sm border-0 mb-3 rounded-4" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold mb-3 text-dark" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-heart-pulse-fill text-danger me-1" + }), " Record Bedside Vitals"), /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "BP Sys/Dia (mmHg)"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control text-center", + placeholder: "120", + value: vitalsForm.bp_systolic, + onChange: e => setVitalsForm({ + ...vitalsForm, + bp_systolic: e.target.value + }) + }), /*#__PURE__*/React.createElement("span", { + className: "input-group-text" + }, "/"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control text-center", + placeholder: "80", + value: vitalsForm.bp_diastolic, + onChange: e => setVitalsForm({ + ...vitalsForm, + bp_diastolic: e.target.value + }) + }))), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Pulse Rate (bpm)"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm text-center", + placeholder: "72", + value: vitalsForm.pulse_rate, + onChange: e => setVitalsForm({ + ...vitalsForm, + pulse_rate: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "SpO2 %"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm text-center", + placeholder: "98", + value: vitalsForm.spo2, + onChange: e => setVitalsForm({ + ...vitalsForm, + spo2: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Temp °F"), /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.1", + className: "form-control form-control-sm text-center", + placeholder: "98.6", + value: vitalsForm.temperature_f, + onChange: e => setVitalsForm({ + ...vitalsForm, + temperature_f: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Resp Rate (/min)"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm text-center", + placeholder: "18", + value: vitalsForm.resp_rate, + onChange: e => setVitalsForm({ + ...vitalsForm, + resp_rate: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Weight (kg)"), /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.1", + className: "form-control form-control-sm text-center", + placeholder: "70", + value: vitalsForm.weight_kg, + onChange: e => setVitalsForm({ + ...vitalsForm, + weight_kg: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-12 col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Nursing Remark / Observation"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "e.g. Patient resting, vitals stable", + value: vitalsForm.general_note, + onChange: e => setVitalsForm({ + ...vitalsForm, + general_note: e.target.value + }) + }))), /*#__PURE__*/React.createElement("button", { + className: "btn btn-success fw-bold py-2 w-100 rounded-3 shadow-sm", + onClick: () => handleSaveIpdEntry('vitals', vitalsForm) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle-fill me-1" + }), " Save Bedside Vitals")), /*#__PURE__*/React.createElement("div", { + className: "card shadow-sm border-0 rounded-4 overflow-hidden mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "card-header py-2 bg-white d-flex justify-content-between align-items-center border-bottom" + }, /*#__PURE__*/React.createElement("strong", { + className: "text-dark" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clock-history me-1 text-danger" + }), " Vitals History Records"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger-subtle text-danger border border-danger-subtle" + }, workspaceData.filter(e => e.entry_type === 'vitals').length, " Records")), /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-sm table-striped table-hover align-middle mb-0", + style: { + fontSize: '12px' + } + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "Date & Time"), /*#__PURE__*/React.createElement("th", null, "BP (mmHg)"), /*#__PURE__*/React.createElement("th", null, "Pulse"), /*#__PURE__*/React.createElement("th", null, "Temp"), /*#__PURE__*/React.createElement("th", null, "Resp"), /*#__PURE__*/React.createElement("th", null, "SpO2"), /*#__PURE__*/React.createElement("th", null, "Weight"), /*#__PURE__*/React.createElement("th", null, "Staff"), /*#__PURE__*/React.createElement("th", null, "Remarks"))), /*#__PURE__*/React.createElement("tbody", null, workspaceData.filter(e => e.entry_type === 'vitals').length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "9", + className: "text-center text-muted py-4" + }, "No vitals records entered yet.")) : workspaceData.filter(e => e.entry_type === 'vitals').map(v => /*#__PURE__*/React.createElement("tr", { + key: v.id + }, /*#__PURE__*/React.createElement("td", { + className: "fw-semibold text-nowrap" + }, formatDateTime(v.recorded_at)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border" + }, v.bp_systolic ? `${v.bp_systolic}/${v.bp_diastolic}` : '-')), /*#__PURE__*/React.createElement("td", null, v.pulse_rate ? `${v.pulse_rate} bpm` : '-'), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger-subtle text-danger" + }, displayTempF(v.temperature_c))), /*#__PURE__*/React.createElement("td", null, v.resp_rate ? `${v.resp_rate}/min` : '-'), /*#__PURE__*/React.createElement("td", null, v.spo2 ? `${v.spo2}%` : '-'), /*#__PURE__*/React.createElement("td", null, v.weight_kg ? `${v.weight_kg} kg` : '-'), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, v.recorded_by || 'Staff')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("small", null, v.general_note || '-'))))))))), activeTab === 'fluid' && (() => { + const fluidList = workspaceData.filter(e => e.entry_type === 'fluid'); + const totalIn = fluidList.filter(e => (e.fluid_direction || '').toLowerCase() === 'intake').reduce((sum, e) => sum + (parseFloat(e.fluid_amount_ml) || 0), 0); + const totalOut = fluidList.filter(e => (e.fluid_direction || '').toLowerCase() === 'output').reduce((sum, e) => sum + (parseFloat(e.fluid_amount_ml) || 0), 0); + const netDiff = totalIn - totalOut; + const intakeRoutes = ['IV (Intravenous)', 'Oral / Water / Juice', 'Ryles Tube / NG Feed', 'Normal Saline (NS)', 'Dextrose (DNS / RL)', 'Blood / Plasma', 'TPN', 'Other Intake']; + const outputRoutes = ['Urine / Foley Catheter', 'Drain / Ryle Tube', 'Vomitus', 'Stool / Loose Motion', 'Chest Tube Drain', 'Wound Drain', 'Other Output']; + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("div", { + className: "stat-card-intake text-center shadow-sm" + }, /*#__PURE__*/React.createElement("small", { + className: "text-success fw-bold d-block mb-1", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-down-left-circle-fill me-1" + }), " Total Intake"), /*#__PURE__*/React.createElement("h5", { + className: "fw-bold text-success mb-0" + }, totalIn.toLocaleString(), " ", /*#__PURE__*/React.createElement("span", { + style: { + fontSize: '11px' + } + }, "ml")))), /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("div", { + className: "stat-card-output text-center shadow-sm" + }, /*#__PURE__*/React.createElement("small", { + className: "text-warning fw-bold d-block mb-1", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-up-right-circle-fill me-1" + }), " Total Output"), /*#__PURE__*/React.createElement("h5", { + className: "fw-bold text-warning mb-0" + }, totalOut.toLocaleString(), " ", /*#__PURE__*/React.createElement("span", { + style: { + fontSize: '11px' + } + }, "ml")))), /*#__PURE__*/React.createElement("div", { + className: "col-4" + }, /*#__PURE__*/React.createElement("div", { + className: "stat-card-balance text-center shadow-sm" + }, /*#__PURE__*/React.createElement("small", { + className: "text-primary fw-bold d-block mb-1", + style: { + fontSize: '11px' + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-calculator me-1" + }), " Difference (In-Out)"), /*#__PURE__*/React.createElement("h5", { + className: `fw-bold mb-0 ${netDiff >= 0 ? 'text-primary' : 'text-danger'}` + }, netDiff > 0 ? `+${netDiff.toLocaleString()}` : netDiff.toLocaleString(), " ", /*#__PURE__*/React.createElement("span", { + style: { + fontSize: '11px' + } + }, "ml"))))), /*#__PURE__*/React.createElement("div", { + className: "card p-3 shadow-sm border-0 mb-3 rounded-4" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold mb-3 text-dark" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-droplet-fill text-primary me-1" + }), " Add Fluid Intake / Output Entry"), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Direction"), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn btn-sm flex-fill py-2 fw-bold rounded-3 ${fluidForm.fluid_direction === 'intake' ? 'btn-success text-white shadow-sm' : 'btn-light border text-secondary'}`, + onClick: () => setFluidForm({ + ...fluidForm, + fluid_direction: 'intake', + fluid_route: 'IV (Intravenous)' + }) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-down-left-circle me-1" + }), " Fluid Intake (In)"), /*#__PURE__*/React.createElement("button", { + type: "button", + className: `btn btn-sm flex-fill py-2 fw-bold rounded-3 ${fluidForm.fluid_direction === 'output' ? 'btn-warning text-dark shadow-sm' : 'btn-light border text-secondary'}`, + onClick: () => setFluidForm({ + ...fluidForm, + fluid_direction: 'output', + fluid_route: 'Urine / Foley Catheter' + }) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-up-right-circle me-1" + }), " Fluid Output (Out)"))), /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-12 col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Route / Site"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: fluidForm.fluid_route, + onChange: e => setFluidForm({ + ...fluidForm, + fluid_route: e.target.value + }) + }, (fluidForm.fluid_direction === 'intake' ? intakeRoutes : outputRoutes).map(r => /*#__PURE__*/React.createElement("option", { + key: r, + value: r + }, r)))), /*#__PURE__*/React.createElement("div", { + className: "col-12 col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Amount (ml) ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm text-center fw-bold fs-6", + placeholder: "e.g. 500", + value: fluidForm.fluid_amount_ml, + onChange: e => setFluidForm({ + ...fluidForm, + fluid_amount_ml: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-12" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Observation / Note"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "e.g. Clear urine, Normal fluid color, IV site intact", + value: fluidForm.general_note, + onChange: e => setFluidForm({ + ...fluidForm, + general_note: e.target.value + }) + }))), /*#__PURE__*/React.createElement("button", { + className: "btn btn-primary fw-bold py-2 w-100 rounded-3 shadow-sm", + onClick: () => { + if (!fluidForm.fluid_amount_ml) { + alert('Please enter fluid amount in ml.'); + return; + } + handleSaveIpdEntry('fluid', fluidForm); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-plus-circle-fill me-1" + }), " Save Fluid Entry")), /*#__PURE__*/React.createElement("div", { + className: "card shadow-sm border-0 rounded-4 overflow-hidden mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "card-header py-2 bg-white d-flex justify-content-between align-items-center border-bottom" + }, /*#__PURE__*/React.createElement("strong", { + className: "text-dark" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clock-history me-1 text-primary" + }), " Fluid Intake & Output Log"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary border border-primary-subtle" + }, fluidList.length, " Records")), /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-sm table-striped table-hover align-middle mb-0", + style: { + fontSize: '12px' + } + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "Date & Time"), /*#__PURE__*/React.createElement("th", null, "Direction"), /*#__PURE__*/React.createElement("th", null, "Route"), /*#__PURE__*/React.createElement("th", null, "Amount (ml)"), /*#__PURE__*/React.createElement("th", null, "Observation / Note"), /*#__PURE__*/React.createElement("th", null, "Staff"))), /*#__PURE__*/React.createElement("tbody", null, fluidList.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "6", + className: "text-center text-muted py-4" + }, "No fluid entries recorded yet.")) : fluidList.map(fl => /*#__PURE__*/React.createElement("tr", { + key: fl.id + }, /*#__PURE__*/React.createElement("td", { + className: "fw-semibold text-nowrap" + }, formatDateTime(fl.recorded_at)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: `badge ${fl.fluid_direction === 'intake' ? 'bg-success' : 'bg-warning text-dark'} text-uppercase` + }, fl.fluid_direction === 'intake' ? '↓ Intake' : '↑ Output')), /*#__PURE__*/React.createElement("td", { + className: "fw-semibold" + }, fl.fluid_route || '-'), /*#__PURE__*/React.createElement("td", { + className: "fw-bold" + }, parseFloat(fl.fluid_amount_ml || 0).toLocaleString(), " ml"), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("small", null, fl.general_note || '-')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, fl.recorded_by || 'Staff'))))))))); + })(), activeTab === 'treatment' && (() => { + const allTreatments = workspaceData.filter(e => e.entry_type === 'treatment'); + const doctorOrders = allTreatments.filter(e => e.recorded_by && e.recorded_by.toLowerCase().startsWith('dr.') || e.treatment_text && e.treatment_text.includes('[Doctor Note]')); + const latestDocOrder = doctorOrders.length > 0 ? doctorOrders[0] : null; + const nurseTreatments = allTreatments.filter(e => !(e.recorded_by && e.recorded_by.toLowerCase().startsWith('dr.')) && !(e.treatment_text && e.treatment_text.includes('[Doctor Note]'))); + return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "card shadow-sm border-0 mb-3 rounded-4 overflow-hidden", + style: { + border: '1.5px solid #818cf8' + } + }, /*#__PURE__*/React.createElement("div", { + className: "card-header py-2 text-white d-flex justify-content-between align-items-center", + style: { + background: 'linear-gradient(135deg, #3730a3 0%, #4f46e5 100%)' + } + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-medical-fill" + }), /*#__PURE__*/React.createElement("strong", { + className: "small" + }, "Doctor's Prescribed Treatment & Orders")), /*#__PURE__*/React.createElement("span", { + className: "badge bg-white text-dark small" + }, doctorOrders.length, " Doctor Orders")), /*#__PURE__*/React.createElement("div", { + className: "card-body p-3 bg-light" + }, latestDocOrder ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-start mb-2" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary px-2 py-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-badge me-1" + }), " ", latestDocOrder.recorded_by), /*#__PURE__*/React.createElement("small", { + className: "text-muted fw-semibold" + }, formatDateTime(latestDocOrder.recorded_at))), /*#__PURE__*/React.createElement("div", { + className: "p-3 bg-white rounded-3 border mb-2 shadow-sm" + }, renderNoteContent(latestDocOrder)), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-primary fw-bold w-100 rounded-pill py-2", + onClick: () => { + const cleanText = (latestDocOrder.treatment_text || '').replace(/\[IMAGE_ATTACHMENT:.*?\]/, '').replace('[Doctor Note] ', '').trim(); + setTreatmentForm({ + ...treatmentForm, + treatment_text: `Administered as prescribed: ${cleanText}` + }); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clipboard-check-fill me-1" + }), " Follow & Administer This Order"), doctorOrders.length > 1 && /*#__PURE__*/React.createElement("div", { + className: "mt-3" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: "btn btn-sm btn-light border w-100 text-secondary", + onClick: () => setShowAllDoctorOrders(!showAllDoctorOrders) + }, /*#__PURE__*/React.createElement("i", { + className: `bi bi-chevron-${showAllDoctorOrders ? 'up' : 'down'} me-1` + }), showAllDoctorOrders ? 'Hide Previous Doctor Notes' : `View All ${doctorOrders.length} Doctor Notes`), showAllDoctorOrders && /*#__PURE__*/React.createElement("div", { + className: "mt-2 d-flex flex-column gap-2" + }, doctorOrders.slice(1).map(docOrd => /*#__PURE__*/React.createElement("div", { + key: docOrd.id, + className: "p-2.5 bg-white rounded-3 border" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-1" + }, /*#__PURE__*/React.createElement("strong", { + className: "text-primary small" + }, docOrd.recorded_by), /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '11px' + } + }, formatDateTime(docOrd.recorded_at))), renderNoteContent(docOrd)))))) : /*#__PURE__*/React.createElement("div", { + className: "text-center text-muted py-3" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clipboard-x fs-2 text-secondary opacity-50 d-block mb-1" + }), /*#__PURE__*/React.createElement("small", null, "No doctor orders or clinical prescriptions recorded yet.")))), /*#__PURE__*/React.createElement("div", { + className: "card p-3 shadow-sm border-0 mb-3 rounded-4" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold mb-3 text-dark" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-capsule text-success me-1" + }), " Log Nursing Treatment Given / Medication Administered"), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Treatment / Medication Administered ", /*#__PURE__*/React.createElement("span", { + className: "text-danger" + }, "*")), /*#__PURE__*/React.createElement("textarea", { + className: "form-control rounded-3", + rows: "3", + placeholder: "e.g. Inj. Ceftriaxone 1g IV given slowly, Tab Pantop 40mg given orally...", + value: treatmentForm.treatment_text, + onChange: e => setTreatmentForm({ + ...treatmentForm, + treatment_text: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Observation / Patient Response"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "e.g. Tolerated well, No adverse reaction, IV site patent", + value: treatmentForm.general_note, + onChange: e => setTreatmentForm({ + ...treatmentForm, + general_note: e.target.value + }) + })), /*#__PURE__*/React.createElement("button", { + className: "btn btn-success fw-bold py-2 w-100 rounded-3 shadow-sm", + onClick: () => { + if (!treatmentForm.treatment_text.trim()) { + alert('Please enter treatment or medication administered.'); + return; + } + handleSaveIpdEntry('treatment', treatmentForm); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-send-check-fill me-1" + }), " Log Treatment Administration")), /*#__PURE__*/React.createElement("div", { + className: "card shadow-sm border-0 rounded-4 overflow-hidden mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "card-header py-2 bg-white d-flex justify-content-between align-items-center border-bottom" + }, /*#__PURE__*/React.createElement("strong", { + className: "text-dark" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clock-history me-1 text-success" + }), " Nursing Treatment Given History"), /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success border border-success-subtle" + }, nurseTreatments.length, " Records")), /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-sm table-striped table-hover align-middle mb-0", + style: { + fontSize: '12px' + } + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", { + style: { + width: '140px' + } + }, "Time Administered"), /*#__PURE__*/React.createElement("th", null, "Treatment / Medication Given"), /*#__PURE__*/React.createElement("th", null, "Observation & Remarks"), /*#__PURE__*/React.createElement("th", { + style: { + width: '120px' + } + }, "Staff Nurse"))), /*#__PURE__*/React.createElement("tbody", null, nurseTreatments.length === 0 ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", { + colSpan: "4", + className: "text-center text-muted py-4" + }, "No nursing treatments logged yet.")) : nurseTreatments.map(tr => /*#__PURE__*/React.createElement("tr", { + key: tr.id + }, /*#__PURE__*/React.createElement("td", { + className: "fw-semibold text-nowrap" + }, formatDateTime(tr.recorded_at)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "fw-bold text-dark" + }, renderNoteContent(tr))), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, tr.general_note || '-')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-secondary border" + }, tr.recorded_by || 'Staff Nurse'))))))))); + })()), activeOpdForVitals && /*#__PURE__*/React.createElement("div", { + className: "modal show d-block", + style: { + backgroundColor: 'rgba(0,0,0,0.5)' + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content rounded-4 border-0 shadow-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-success text-white" + }, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-heart-pulse-fill me-2" + }), " Fill OPD Patient Vitals"), /*#__PURE__*/React.createElement("button", { + className: "btn-close btn-close-white", + onClick: () => setActiveOpdForVitals(null) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3" + }, /*#__PURE__*/React.createElement("div", { + className: "alert alert-light border py-2 mb-3 small" + }, /*#__PURE__*/React.createElement("strong", null, activeOpdForVitals.patient_display_name), " (", activeOpdForVitals.age_display, " • ", activeOpdForVitals.gender_label, ")", /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, "UHID: ", activeOpdForVitals.uhid, " | OPD Code: ", activeOpdForVitals.opd_code)), /*#__PURE__*/React.createElement("div", { + className: "row g-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "BP Sys/Dia"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control text-center", + placeholder: "120", + value: opdVitalsForm.bp_systolic, + onChange: e => setOpdVitalsForm({ + ...opdVitalsForm, + bp_systolic: e.target.value + }) + }), /*#__PURE__*/React.createElement("span", { + className: "input-group-text" + }, "/"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control text-center", + placeholder: "80", + value: opdVitalsForm.bp_diastolic, + onChange: e => setOpdVitalsForm({ + ...opdVitalsForm, + bp_diastolic: e.target.value + }) + }))), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Pulse Rate (bpm)"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm text-center", + placeholder: "72", + value: opdVitalsForm.pulse, + onChange: e => setOpdVitalsForm({ + ...opdVitalsForm, + pulse: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "SpO2 %"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm text-center", + placeholder: "98", + value: opdVitalsForm.spo2, + onChange: e => setOpdVitalsForm({ + ...opdVitalsForm, + spo2: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Temp °F"), /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.1", + className: "form-control form-control-sm text-center", + placeholder: "98.6", + value: opdVitalsForm.temp, + onChange: e => setOpdVitalsForm({ + ...opdVitalsForm, + temp: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Weight (kg)"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm text-center", + placeholder: "70", + value: opdVitalsForm.weight, + onChange: e => setOpdVitalsForm({ + ...opdVitalsForm, + weight: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Height (cm)"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm text-center", + placeholder: "165", + value: opdVitalsForm.height, + onChange: e => setOpdVitalsForm({ + ...opdVitalsForm, + height: e.target.value + }) + })))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer p-2 bg-light" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-secondary btn-sm", + onClick: () => setActiveOpdForVitals(null) + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-success btn-sm fw-bold px-3", + onClick: handleSaveOpdVitals + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle-fill me-1" + }), " Save Vitals for Doctor"))))), scanTarget && /*#__PURE__*/React.createElement("div", { + className: "modal show d-block", + style: { + backgroundColor: 'rgba(0,0,0,0.5)' + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content rounded-4 border-0 shadow-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-primary text-white" + }, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-camera-fill me-2" + }), " Scan / Photo Paper Document"), /*#__PURE__*/React.createElement("button", { + className: "btn-close btn-close-white", + onClick: () => setScanTarget(null) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3" + }, /*#__PURE__*/React.createElement("div", { + className: "mb-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold" + }, "Document Type / Category"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: scanDocCategory, + onChange: e => setScanDocCategory(e.target.value) + }, /*#__PURE__*/React.createElement("option", { + value: "Paper Document" + }, "Paper Document (General)"), /*#__PURE__*/React.createElement("option", { + value: "Vitals Sheet" + }, "Vitals Sheet / Chart"), /*#__PURE__*/React.createElement("option", { + value: "Lab Test Report" + }, "Lab / Pathology Report"), /*#__PURE__*/React.createElement("option", { + value: "Handwritten Doctor Note" + }, "Handwritten Doctor Note"), /*#__PURE__*/React.createElement("option", { + value: "Consent Form" + }, "Signed Consent Form"))), /*#__PURE__*/React.createElement("div", { + className: "mb-3 text-center" + }, /*#__PURE__*/React.createElement("label", { + className: "btn btn-primary btn-lg w-100 py-3 fw-bold rounded-3 shadow-sm" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-camera me-2" + }), " Take Photo / Choose File", /*#__PURE__*/React.createElement("input", { + type: "file", + accept: "image/*", + capture: "environment", + className: "d-none", + onChange: handleScanImageCapture + }))), scanImagePreview && /*#__PURE__*/React.createElement("div", { + className: "position-relative p-2 border rounded-3 bg-light text-center" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-success position-absolute top-0 start-0 m-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle me-1" + }), " Document Photo Captured"), /*#__PURE__*/React.createElement("img", { + src: scanImagePreview, + alt: "Document Scan Preview", + className: "img-fluid rounded-3 border shadow-sm", + style: { + maxHeight: '220px', + objectFit: 'contain' + } + }))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer p-2 bg-light" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-secondary btn-sm", + onClick: () => setScanTarget(null) + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-success btn-sm fw-bold px-3", + onClick: handleSaveScanDocument, + disabled: !scanImageBase64 + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cloud-upload-fill me-1" + }), " Save Document to Chart"))))), cropSrc && /*#__PURE__*/React.createElement("div", { + className: "modal show d-block", + style: { + backgroundColor: 'rgba(0,0,0,0.85)', + zIndex: 10000 + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered modal-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content rounded-4 border-0 shadow-lg overflow-hidden" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2" + }, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold mb-0" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-crop me-2 text-success" + }), " Crop Document Photo"), /*#__PURE__*/React.createElement("button", { + className: "btn-close btn-close-white", + onClick: cancelCrop + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-2 text-center bg-black", + style: { + maxHeight: '65vh', + overflow: 'hidden' + } + }, /*#__PURE__*/React.createElement("div", { + style: { + maxHeight: '60vh', + width: '100%' + } + }, /*#__PURE__*/React.createElement("img", { + ref: imageRef, + src: cropSrc, + alt: "Crop Target", + style: { + maxWidth: '100%', + display: 'block' + } + }))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer p-2 bg-dark d-flex justify-content-between align-items-center flex-wrap gap-2" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-light px-2", + onClick: () => cropper && cropper.rotate(-90), + title: "Rotate Left 90°" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-counterclockwise" + }), " 90°"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-light px-2", + onClick: () => cropper && cropper.rotate(90), + title: "Rotate Right 90°" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-clockwise" + }), " 90°"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-light px-2", + onClick: () => cropper && cropper.reset(), + title: "Reset Crop Box" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-aspect-ratio" + }), " Reset")), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-secondary", + onClick: cancelCrop + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-success fw-bold px-3", + onClick: applyCrop + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-lg me-1" + }), " Apply Crop & Save Photo")))))), /*#__PURE__*/React.createElement("div", { + className: "bottom-dock-container" + }, /*#__PURE__*/React.createElement("button", { + className: "bottom-dock-btn btn-scan", + onClick: () => openPatientSearch('scan'), + title: "Scan Barcode / QR or Search Patient" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-qr-code-scan fs-5" + }), /*#__PURE__*/React.createElement("span", null, "Scan / Search")), /*#__PURE__*/React.createElement("button", { + className: "bottom-dock-btn btn-vitals", + onClick: () => { + if (activeBed) { + openWellnessModal({ + id: activeBed.p_id || activeBed.patient_id, + p_code: activeBed.uhid, + fullName: activeBed.patient_name, + abha_id: activeBed.abha_id, + gender: activeBed.gender + }); + } else { + openPatientSearch('type'); + } + }, + title: "Add ABDM M2 Wellness Vitals" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-heart-pulse-fill fs-5" + }), /*#__PURE__*/React.createElement("span", null, "ABDM Vitals")), /*#__PURE__*/React.createElement("button", { + className: "bottom-dock-btn btn-doc", + onClick: () => { + if (activeBed) { + openDocModal({ + id: activeBed.p_id || activeBed.patient_id, + p_code: activeBed.uhid, + fullName: activeBed.patient_name, + abha_id: activeBed.abha_id + }); + } else { + openPatientSearch('type'); + } + }, + title: "Add ABDM M2 Health Document (Scan/Photo)" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-medical-fill fs-5" + }), /*#__PURE__*/React.createElement("span", null, "ABDM Health Doc"))), showPatientSearchModal && /*#__PURE__*/React.createElement("div", { + className: "modal show d-block", + style: { + backgroundColor: 'rgba(0,0,0,0.65)', + zIndex: 1050 + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered modal-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content rounded-4 border-0 shadow-lg overflow-hidden" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2.5" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-upc-scan fs-5 text-primary" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold mb-0" + }, "Search Patient by Barcode, QR & Name"), /*#__PURE__*/React.createElement("small", { + className: "text-white-50", + style: { + fontSize: '11px' + } + }, "Scan Hospital Card Barcode, ABHA QR, or search registered patients"))), /*#__PURE__*/React.createElement("button", { + className: "btn-close btn-close-white", + onClick: closePatientSearch + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3" + }, /*#__PURE__*/React.createElement("div", { + className: "segmented-tabs mb-3" + }, /*#__PURE__*/React.createElement("button", { + className: `segmented-tab ${searchModalTab === 'scan' ? 'active-blue' : ''}`, + onClick: () => { + setSearchModalTab('scan'); + startBarcodeQrScanner(); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-camera-video-fill me-1" + }), " Camera Scanner (Barcode & QR)"), /*#__PURE__*/React.createElement("button", { + className: `segmented-tab ${searchModalTab === 'type' ? 'active-blue' : ''}`, + onClick: () => { + setSearchModalTab('type'); + stopBarcodeQrScanner(); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search me-1" + }), " Manual Search (UHID / Mobile / ABHA)")), searchModalTab === 'scan' && /*#__PURE__*/React.createElement("div", { + className: "text-center mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "qr-scanner-wrapper mx-auto mb-2", + style: { + maxWidth: '420px' + } + }, /*#__PURE__*/React.createElement("div", { + id: "patient-qr-reader", + style: { + width: '100%' + } + })), scannerError ? /*#__PURE__*/React.createElement("div", { + className: "alert alert-warning py-2 px-3 small d-inline-block" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-exclamation-triangle-fill me-1" + }), " ", scannerError) : /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-info-circle me-1" + }), " Point camera at ", /*#__PURE__*/React.createElement("strong", null, "Patient Card Barcode"), " or ", /*#__PURE__*/React.createElement("strong", null, "ABHA QR Code"), " to scan instantly.")), /*#__PURE__*/React.createElement("div", { + className: "input-group mb-3" + }, /*#__PURE__*/React.createElement("span", { + className: "input-group-text bg-white border-end-0" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-search text-muted" + })), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control border-start-0 ps-0", + placeholder: "Search by UHID (P...), ABHA No, Mobile (98...), Name...", + value: patientSearchQuery, + onChange: e => { + setPatientSearchQuery(e.target.value); + executePatientSearch(e.target.value); + }, + onKeyDown: e => { + if (e.key === 'Enter') executePatientSearch(patientSearchQuery); + } + }), patientSearchQuery && /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-secondary", + onClick: () => { + setPatientSearchQuery(''); + setPatientSearchResults([]); + } + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-x" + })), /*#__PURE__*/React.createElement("button", { + className: "btn btn-primary fw-bold px-3", + onClick: () => executePatientSearch(patientSearchQuery) + }, searchingPatient ? /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm" + }) : 'Search')), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center mb-2" + }, /*#__PURE__*/React.createElement("strong", { + className: "small text-secondary text-uppercase" + }, "Matched Patients (", patientSearchResults.length, ")"), searchingPatient && /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary" + }, "Searching...")), patientSearchResults.length === 0 ? /*#__PURE__*/React.createElement("div", { + className: "text-center py-4 bg-light rounded-3 border" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-badge fs-2 text-muted opacity-50 d-block mb-1" + }), /*#__PURE__*/React.createElement("p", { + className: "small text-muted mb-0" + }, patientSearchQuery ? 'No patients found matching this query.' : 'Type patient name, UHID, ABHA number or scan barcode above.')) : /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-column gap-2", + style: { + maxHeight: '40vh', + overflowY: 'auto' + } + }, patientSearchResults.map(pat => /*#__PURE__*/React.createElement("div", { + key: pat.id, + className: "patient-search-result-card" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-start flex-wrap gap-2" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold mb-0 text-dark" + }, pat.fullName), /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border", + style: { + fontSize: '11px' + } + }, pat.gender === '1' || pat.gender === 1 ? 'Male' : pat.gender === '2' || pat.gender === 2 ? 'Female' : 'Other', pat.dob ? ` • DOB: ${pat.dob}` : '')), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap gap-2 mt-1 small" + }, /*#__PURE__*/React.createElement("span", { + className: "text-danger fw-semibold" + }, "UHID: ", pat.p_code), pat.mphone1 && /*#__PURE__*/React.createElement("span", { + className: "text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-telephone me-1" + }), pat.mphone1), pat.abha_id && /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success border border-success-subtle" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-check me-1" + }), "ABHA: ", pat.abha_id), pat.abha_address && /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary border border-primary-subtle" + }, pat.abha_address)), pat.ipd_admission && /*#__PURE__*/React.createElement("div", { + className: "mt-1" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-hospital me-1" + }), " Admitted IPD: ", pat.ipd_admission.ipd_code, " (Bed ", pat.ipd_admission.bed_number || pat.ipd_admission.bed_no, ")")), pat.opd_today && /*#__PURE__*/React.createElement("div", { + className: "mt-1" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-success" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-calendar-check me-1" + }), " OPD Today: Token #", pat.opd_today.token_no, " (", pat.opd_today.doctor_name || 'Doctor', ")"))), /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap gap-1.5 align-items-center" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-success fw-bold rounded-3 px-2 py-1.5", + onClick: () => openWellnessModal(pat), + title: "Add ABDM M2 Wellness Vitals" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-heart-pulse-fill me-1" + }), " Add Vitals"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-primary fw-bold rounded-3 px-2 py-1.5", + onClick: () => openDocModal(pat), + title: "Add ABDM M2 Health Document" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-medical-fill me-1" + }), " Add Doc"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-outline-secondary rounded-3 px-2 py-1.5", + onClick: () => openWellnessHistory(pat), + title: "View Vitals History" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clock-history" + })), pat.ipd_admission && /*#__PURE__*/React.createElement("button", { + className: "btn btn-sm btn-dark rounded-3 px-2 py-1.5", + onClick: () => { + closePatientSearch(); + openWorkspace({ + ipd_id: pat.ipd_admission.ipd_id, + patient_name: pat.fullName, + uhid: pat.p_code, + ipd_code: pat.ipd_admission.ipd_code, + bed_number: pat.ipd_admission.bed_number, + ward_name: pat.ipd_admission.ward_name, + status: 'occupied' + }); + }, + title: "Go to IPD Bedside Care" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-arrow-right-circle" + }), " IPD Bed")))))))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer p-2 bg-light d-flex justify-content-between" + }, /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-lock me-1" + }), " ABDM M2 Standard Compliance"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-secondary btn-sm px-3", + onClick: closePatientSearch + }, "Close"))))), activeWellnessPatient && /*#__PURE__*/React.createElement("div", { + className: "modal show d-block", + style: { + backgroundColor: 'rgba(0,0,0,0.65)', + zIndex: 1060 + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered modal-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content rounded-4 border-0 shadow-lg overflow-hidden" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-success text-white py-2.5" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-heart-pulse-fill fs-5" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold mb-0" + }, "Record ABDM M2 Wellness & Vitals"), /*#__PURE__*/React.createElement("small", { + className: "text-white-50", + style: { + fontSize: '11px' + } + }, "NRCES FHIR R4 Compliant Comprehensive Health & Wellness Suite"))), /*#__PURE__*/React.createElement("button", { + className: "btn-close btn-close-white", + onClick: () => setActiveWellnessPatient(null) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3" + }, /*#__PURE__*/React.createElement("div", { + className: "p-2.5 rounded-3 bg-light border mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-center flex-wrap gap-2" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", { + className: "fs-6 text-dark me-2" + }, activeWellnessPatient.fullName || activeWellnessPatient.p_fname), /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary me-1" + }, activeWellnessPatient.gender ? activeWellnessPatient.gender.toUpperCase() : 'PATIENT'), activeWellnessPatient.age && /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border me-1" + }, activeWellnessPatient.age, " Yrs"), /*#__PURE__*/React.createElement("div", { + className: "small text-muted mt-0.5" + }, "UHID: ", /*#__PURE__*/React.createElement("span", { + className: "text-danger fw-bold" + }, activeWellnessPatient.p_code || activeWellnessPatient.uhid), activeWellnessPatient.mphone1 && ` • Phone: ${activeWellnessPatient.mphone1}`)), /*#__PURE__*/React.createElement("div", null, activeWellnessPatient.abha_id ? /*#__PURE__*/React.createElement("span", { + className: "badge bg-success" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-check me-1" + }), " ABHA: ", activeWellnessPatient.abha_id) : /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-secondary border" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-exclamation me-1" + }), " ABHA Not Linked")))), /*#__PURE__*/React.createElement("ul", { + className: "nav nav-pills nav-fill bg-light p-1 rounded-3 mb-3 border small" + }, /*#__PURE__*/React.createElement("li", { + className: "nav-item" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: `nav-link py-1.5 px-2 fw-semibold d-flex align-items-center justify-content-center gap-1 ${wellnessModalTab === 'vitals' ? 'active shadow-sm' : 'text-secondary'}`, + onClick: () => setWellnessModalTab('vitals') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-heart-pulse-fill text-danger" + }), /*#__PURE__*/React.createElement("span", null, "Vitals & Triage"), (wellnessForm.bp_systolic || wellnessForm.pulse_rate || wellnessForm.temperature_f) && /*#__PURE__*/React.createElement("span", { + className: "badge rounded-pill bg-success p-1 ms-1", + style: { + fontSize: '7px' + } + }, "✓"))), /*#__PURE__*/React.createElement("li", { + className: "nav-item" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: `nav-link py-1.5 px-2 fw-semibold d-flex align-items-center justify-content-center gap-1 ${wellnessModalTab === 'sugar' ? 'active shadow-sm' : 'text-secondary'}`, + onClick: () => setWellnessModalTab('sugar') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-droplet-half text-danger" + }), /*#__PURE__*/React.createElement("span", null, "Sugar & Labs"), (wellnessForm.sugar_random || wellnessForm.sugar_fasting || wellnessForm.sugar_pp || wellnessForm.hba1c || wellnessForm.hemoglobin) && /*#__PURE__*/React.createElement("span", { + className: "badge rounded-pill bg-success p-1 ms-1", + style: { + fontSize: '7px' + } + }, "✓"))), /*#__PURE__*/React.createElement("li", { + className: "nav-item" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: `nav-link py-1.5 px-2 fw-semibold d-flex align-items-center justify-content-center gap-1 ${wellnessModalTab === 'activity' ? 'active shadow-sm' : 'text-secondary'}`, + onClick: () => setWellnessModalTab('activity') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-person-bounding-box text-primary" + }), /*#__PURE__*/React.createElement("span", null, "Waist & Activity"), (wellnessForm.waist_circumference_cm || wellnessForm.hip_circumference_cm || wellnessForm.daily_steps || wellnessForm.sleep_hours) && /*#__PURE__*/React.createElement("span", { + className: "badge rounded-pill bg-success p-1 ms-1", + style: { + fontSize: '7px' + } + }, "✓"))), /*#__PURE__*/React.createElement("li", { + className: "nav-item" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: `nav-link py-1.5 px-2 fw-semibold d-flex align-items-center justify-content-center gap-1 ${wellnessModalTab === 'lifestyle' ? 'active shadow-sm' : 'text-secondary'}`, + onClick: () => setWellnessModalTab('lifestyle') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-apple text-success" + }), /*#__PURE__*/React.createElement("span", null, "Lifestyle & Notes"), (wellnessForm.diet_type || wellnessForm.tobacco_status || wellnessForm.diet_lifestyle_note || wellnessForm.general_advice) && /*#__PURE__*/React.createElement("span", { + className: "badge rounded-pill bg-success p-1 ms-1", + style: { + fontSize: '7px' + } + }, "✓"))), String(activeWellnessPatient.gender || '').toLowerCase() !== 'male' && /*#__PURE__*/React.createElement("li", { + className: "nav-item" + }, /*#__PURE__*/React.createElement("button", { + type: "button", + className: `nav-link py-1.5 px-2 fw-semibold d-flex align-items-center justify-content-center gap-1 ${wellnessModalTab === 'women' ? 'active shadow-sm' : 'text-secondary'}`, + onClick: () => setWellnessModalTab('women') + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-gender-female text-warning" + }), /*#__PURE__*/React.createElement("span", null, "Women's Health"), (wellnessForm.women_lmp || wellnessForm.women_pregnancy_status) && /*#__PURE__*/React.createElement("span", { + className: "badge rounded-pill bg-success p-1 ms-1", + style: { + fontSize: '7px' + } + }, "✓")))), wellnessModalTab === 'vitals' && /*#__PURE__*/React.createElement("div", { + className: "row g-2.5 mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "BP Sys/Dia (mmHg)"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control text-center", + placeholder: "120", + value: wellnessForm.bp_systolic, + onChange: e => setWellnessForm({ + ...wellnessForm, + bp_systolic: e.target.value + }) + }), /*#__PURE__*/React.createElement("span", { + className: "input-group-text px-1" + }, "/"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control text-center", + placeholder: "80", + value: wellnessForm.bp_diastolic, + onChange: e => setWellnessForm({ + ...wellnessForm, + bp_diastolic: e.target.value + }) + }))), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Pulse Rate (bpm)"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm text-center", + placeholder: "72", + value: wellnessForm.pulse_rate, + onChange: e => setWellnessForm({ + ...wellnessForm, + pulse_rate: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "SpO2 %"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm text-center", + placeholder: "98", + value: wellnessForm.spo2, + onChange: e => setWellnessForm({ + ...wellnessForm, + spo2: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Temp °F"), /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.1", + className: "form-control form-control-sm text-center", + placeholder: "98.6", + value: wellnessForm.temperature_f, + onChange: e => setWellnessForm({ + ...wellnessForm, + temperature_f: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Resp Rate (/min)"), /*#__PURE__*/React.createElement("input", { + type: "number", + className: "form-control form-control-sm text-center", + placeholder: "18", + value: wellnessForm.resp_rate, + onChange: e => setWellnessForm({ + ...wellnessForm, + resp_rate: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Height (cm)"), /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.1", + className: "form-control form-control-sm text-center", + placeholder: "165", + value: wellnessForm.height_cm, + onChange: e => setWellnessForm({ + ...wellnessForm, + height_cm: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Weight (kg)"), /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.1", + className: "form-control form-control-sm text-center", + placeholder: "70", + value: wellnessForm.weight_kg, + onChange: e => setWellnessForm({ + ...wellnessForm, + weight_kg: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-3" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Calculated BMI"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm text-center bg-light fw-bold", + readOnly: true, + value: wellnessForm.height_cm && wellnessForm.weight_kg && parseFloat(wellnessForm.height_cm) > 0 ? (parseFloat(wellnessForm.weight_kg) / Math.pow(parseFloat(wellnessForm.height_cm) / 100, 2)).toFixed(2) : '-' + }))), /*#__PURE__*/React.createElement("div", { + className: "col-12 mt-2" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold d-flex justify-content-between" + }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-emoji-frown me-1 text-warning" + }), " Pain Severity Score (0 - 10 VRS)"), /*#__PURE__*/React.createElement("span", { + className: "text-muted fw-normal" + }, wellnessForm.pain_score === '' ? 'Not assessed' : wellnessForm.pain_score == 0 ? '0 - No Pain' : wellnessForm.pain_score <= 3 ? `${wellnessForm.pain_score} - Mild Pain` : wellnessForm.pain_score <= 6 ? `${wellnessForm.pain_score} - Moderate Pain` : `${wellnessForm.pain_score} - Severe Pain`)), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-1 flex-wrap" + }, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(val => /*#__PURE__*/React.createElement("button", { + key: val, + type: "button", + className: `btn btn-sm flex-fill py-1 px-1.5 ${wellnessForm.pain_score === String(val) ? val === 0 ? 'btn-success text-white' : val <= 3 ? 'btn-info text-white' : val <= 6 ? 'btn-warning text-dark' : 'btn-danger text-white' : 'btn-outline-secondary'}`, + onClick: () => setWellnessForm({ + ...wellnessForm, + pain_score: wellnessForm.pain_score === String(val) ? '' : String(val) + }) + }, val))))), wellnessModalTab === 'sugar' && /*#__PURE__*/React.createElement("div", { + className: "row g-2.5 mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-12" + }, /*#__PURE__*/React.createElement("div", { + className: "alert alert-info py-1.5 px-3 small d-flex align-items-center gap-2 mb-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-info-circle-fill fs-6 text-primary" + }), /*#__PURE__*/React.createElement("span", null, "Point-of-care capillary blood sugar & POC lab values (NRCES ", /*#__PURE__*/React.createElement("strong", null, "GeneralAssessment"), " slice)"))), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Random Blood Sugar (RBS)"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + step: "1", + className: "form-control text-center", + placeholder: "110", + value: wellnessForm.sugar_random, + onChange: e => setWellnessForm({ + ...wellnessForm, + sugar_random: e.target.value + }) + }), /*#__PURE__*/React.createElement("span", { + className: "input-group-text" + }, "mg/dL")), /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '10px' + } + }, "Normal: < 140 mg/dL")), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Fasting Blood Sugar (FBS)"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + step: "1", + className: "form-control text-center", + placeholder: "95", + value: wellnessForm.sugar_fasting, + onChange: e => setWellnessForm({ + ...wellnessForm, + sugar_fasting: e.target.value + }) + }), /*#__PURE__*/React.createElement("span", { + className: "input-group-text" + }, "mg/dL")), /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '10px' + } + }, "Normal: 70 - 100 mg/dL")), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Post-Prandial (PPBS)"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + step: "1", + className: "form-control text-center", + placeholder: "130", + value: wellnessForm.sugar_pp, + onChange: e => setWellnessForm({ + ...wellnessForm, + sugar_pp: e.target.value + }) + }), /*#__PURE__*/React.createElement("span", { + className: "input-group-text" + }, "mg/dL")), /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '10px' + } + }, "Normal: < 140 mg/dL (2h post meal)")), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "HbA1c (Glycated Hemoglobin)"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.1", + className: "form-control text-center", + placeholder: "5.6", + value: wellnessForm.hba1c, + onChange: e => setWellnessForm({ + ...wellnessForm, + hba1c: e.target.value + }) + }), /*#__PURE__*/React.createElement("span", { + className: "input-group-text" + }, "%")), /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '10px' + } + }, "Normal: < 5.7% | Prediabetes: 5.7-6.4% | Diabetes: ≥ 6.5%")), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "POC Hemoglobin (Hb)"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.1", + className: "form-control text-center", + placeholder: "13.5", + value: wellnessForm.hemoglobin, + onChange: e => setWellnessForm({ + ...wellnessForm, + hemoglobin: e.target.value + }) + }), /*#__PURE__*/React.createElement("span", { + className: "input-group-text" + }, "g/dL")), /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '10px' + } + }, "Normal: 12.0 - 17.5 g/dL"))), wellnessModalTab === 'activity' && /*#__PURE__*/React.createElement("div", { + className: "row g-2.5 mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-12" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold small text-primary mb-1 border-bottom pb-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-rulers me-1" + }), " Body Circumferences (NRCES BodyMeasurement)")), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Waist Circumference"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.1", + className: "form-control text-center", + placeholder: "85", + value: wellnessForm.waist_circumference_cm, + onChange: e => setWellnessForm({ + ...wellnessForm, + waist_circumference_cm: e.target.value + }) + }), /*#__PURE__*/React.createElement("span", { + className: "input-group-text" + }, "cm"))), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Hip Circumference"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.1", + className: "form-control text-center", + placeholder: "95", + value: wellnessForm.hip_circumference_cm, + onChange: e => setWellnessForm({ + ...wellnessForm, + hip_circumference_cm: e.target.value + }) + }), /*#__PURE__*/React.createElement("span", { + className: "input-group-text" + }, "cm"))), /*#__PURE__*/React.createElement("div", { + className: "col-12 col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Waist-to-Hip Ratio (WHR)"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm text-center bg-light fw-bold", + readOnly: true, + value: wellnessForm.waist_circumference_cm && wellnessForm.hip_circumference_cm && parseFloat(wellnessForm.hip_circumference_cm) > 0 ? (parseFloat(wellnessForm.waist_circumference_cm) / parseFloat(wellnessForm.hip_circumference_cm)).toFixed(2) : '-' + }), /*#__PURE__*/React.createElement("small", { + className: "text-muted", + style: { + fontSize: '10px' + } + }, "Normal: Men < 0.90 | Women < 0.85")), /*#__PURE__*/React.createElement("div", { + className: "col-12 mt-2" + }, /*#__PURE__*/React.createElement("h6", { + className: "fw-bold small text-success mb-1 border-bottom pb-1" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-activity me-1" + }), " Physical Activity & Sleep (NRCES PhysicalActivity)")), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Daily Steps (24h)"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + step: "100", + className: "form-control text-center", + placeholder: "8000", + value: wellnessForm.daily_steps, + onChange: e => setWellnessForm({ + ...wellnessForm, + daily_steps: e.target.value + }) + }), /*#__PURE__*/React.createElement("span", { + className: "input-group-text" + }, "steps"))), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Sleep Duration"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + step: "0.5", + className: "form-control text-center", + placeholder: "7.5", + value: wellnessForm.sleep_hours, + onChange: e => setWellnessForm({ + ...wellnessForm, + sleep_hours: e.target.value + }) + }), /*#__PURE__*/React.createElement("span", { + className: "input-group-text" + }, "hours"))), /*#__PURE__*/React.createElement("div", { + className: "col-12 col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Exercise Duration"), /*#__PURE__*/React.createElement("div", { + className: "input-group input-group-sm" + }, /*#__PURE__*/React.createElement("input", { + type: "number", + step: "5", + className: "form-control text-center", + placeholder: "30", + value: wellnessForm.exercise_min_per_day, + onChange: e => setWellnessForm({ + ...wellnessForm, + exercise_min_per_day: e.target.value + }) + }), /*#__PURE__*/React.createElement("span", { + className: "input-group-text" + }, "min/day")))), wellnessModalTab === 'lifestyle' && /*#__PURE__*/React.createElement("div", { + className: "row g-2.5 mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-12 col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Diet Pattern (ABDM)"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: wellnessForm.diet_type, + onChange: e => setWellnessForm({ + ...wellnessForm, + diet_type: e.target.value + }) + }, /*#__PURE__*/React.createElement("option", { + value: "" + }, "Select diet..."), /*#__PURE__*/React.createElement("option", { + value: "Balanced Diet" + }, "Balanced Diet"), /*#__PURE__*/React.createElement("option", { + value: "Vegetarian" + }, "Vegetarian"), /*#__PURE__*/React.createElement("option", { + value: "Lacto-Vegetarian" + }, "Lacto-Vegetarian"), /*#__PURE__*/React.createElement("option", { + value: "Non-Vegetarian" + }, "Non-Vegetarian"), /*#__PURE__*/React.createElement("option", { + value: "Vegan" + }, "Vegan"), /*#__PURE__*/React.createElement("option", { + value: "Diabetic Diet" + }, "Diabetic Diet (Low GI)"), /*#__PURE__*/React.createElement("option", { + value: "Low Sodium / DASH Diet" + }, "Low Sodium / DASH Diet"), /*#__PURE__*/React.createElement("option", { + value: "Renal Diet" + }, "Renal Diet"))), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Tobacco / Smoking"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: wellnessForm.tobacco_status, + onChange: e => setWellnessForm({ + ...wellnessForm, + tobacco_status: e.target.value + }) + }, /*#__PURE__*/React.createElement("option", { + value: "" + }, "Select status..."), /*#__PURE__*/React.createElement("option", { + value: "Never Smoked" + }, "Never Smoked"), /*#__PURE__*/React.createElement("option", { + value: "Former / Ex-Smoker" + }, "Former / Ex-Smoker"), /*#__PURE__*/React.createElement("option", { + value: "Current Smoker (Occasional)" + }, "Current Smoker (Occasional)"), /*#__PURE__*/React.createElement("option", { + value: "Current Smoker (Daily)" + }, "Current Smoker (Daily)"), /*#__PURE__*/React.createElement("option", { + value: "Tobacco Chewer" + }, "Tobacco Chewer"))), /*#__PURE__*/React.createElement("div", { + className: "col-6 col-md-4" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Alcohol Consumption"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: wellnessForm.alcohol_status, + onChange: e => setWellnessForm({ + ...wellnessForm, + alcohol_status: e.target.value + }) + }, /*#__PURE__*/React.createElement("option", { + value: "" + }, "Select status..."), /*#__PURE__*/React.createElement("option", { + value: "Lifetime Non-Drinker" + }, "Lifetime Non-Drinker"), /*#__PURE__*/React.createElement("option", { + value: "Former Drinker" + }, "Former Drinker"), /*#__PURE__*/React.createElement("option", { + value: "Occasional / Social Drinker" + }, "Occasional / Social Drinker"), /*#__PURE__*/React.createElement("option", { + value: "Regular Drinker" + }, "Regular Drinker"))), /*#__PURE__*/React.createElement("div", { + className: "col-12" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Diet & Lifestyle Guidance (ABDM)"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "e.g. Low sodium diet, 30 min daily brisk walking, adequate hydration", + value: wellnessForm.diet_lifestyle_note, + onChange: e => setWellnessForm({ + ...wellnessForm, + diet_lifestyle_note: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-12" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "General Nursing Observations"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "e.g. Patient conscious, oriented to time/place, vitals within acceptable limits", + value: wellnessForm.general_advice, + onChange: e => setWellnessForm({ + ...wellnessForm, + general_advice: e.target.value + }) + }))), wellnessModalTab === 'women' && /*#__PURE__*/React.createElement("div", { + className: "row g-2.5 mb-2" + }, /*#__PURE__*/React.createElement("div", { + className: "col-12 col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Last Menstrual Period (LMP Date)"), /*#__PURE__*/React.createElement("input", { + type: "date", + className: "form-control form-control-sm", + value: wellnessForm.women_lmp, + onChange: e => setWellnessForm({ + ...wellnessForm, + women_lmp: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-12 col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small mb-1 fw-bold" + }, "Pregnancy / Reproductive Status"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: wellnessForm.women_pregnancy_status, + onChange: e => setWellnessForm({ + ...wellnessForm, + women_pregnancy_status: e.target.value + }) + }, /*#__PURE__*/React.createElement("option", { + value: "" + }, "Select reproductive status..."), /*#__PURE__*/React.createElement("option", { + value: "Not Pregnant" + }, "Not Pregnant"), /*#__PURE__*/React.createElement("option", { + value: "Pregnant - 1st Trimester (1 - 12 wks)" + }, "Pregnant - 1st Trimester (1 - 12 wks)"), /*#__PURE__*/React.createElement("option", { + value: "Pregnant - 2nd Trimester (13 - 26 wks)" + }, "Pregnant - 2nd Trimester (13 - 26 wks)"), /*#__PURE__*/React.createElement("option", { + value: "Pregnant - 3rd Trimester (27 - 40+ wks)" + }, "Pregnant - 3rd Trimester (27 - 40+ wks)"), /*#__PURE__*/React.createElement("option", { + value: "Postpartum (< 6 weeks post delivery)" + }, "Postpartum (< 6 weeks post delivery)"), /*#__PURE__*/React.createElement("option", { + value: "Lactating / Breastfeeding" + }, "Lactating / Breastfeeding"), /*#__PURE__*/React.createElement("option", { + value: "Perimenopausal" + }, "Perimenopausal"), /*#__PURE__*/React.createElement("option", { + value: "Postmenopausal" + }, "Postmenopausal"))))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer p-2 bg-light d-flex justify-content-between" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-outline-secondary btn-sm", + onClick: () => openWellnessHistory(activeWellnessPatient) + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clock-history me-1" + }), " Past History"), /*#__PURE__*/React.createElement("div", { + className: "d-flex gap-2" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-secondary btn-sm", + onClick: () => setActiveWellnessPatient(null) + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-success btn-sm fw-bold px-3 shadow-sm", + onClick: handleSaveWellness + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle-fill me-1" + }), " Save ABDM Wellness Vitals")))))), activeDocPatient && /*#__PURE__*/React.createElement("div", { + className: "modal show d-block", + style: { + backgroundColor: 'rgba(0,0,0,0.65)', + zIndex: 1060 + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered modal-lg" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content rounded-4 border-0 shadow-lg overflow-hidden" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-primary text-white py-2.5" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-file-earmark-medical-fill fs-5" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold mb-0" + }, "Add ABDM M2 Health Document"), /*#__PURE__*/React.createElement("small", { + className: "text-white-50", + style: { + fontSize: '11px' + } + }, "Scan paper prescriptions, lab reports or clinical documents"))), /*#__PURE__*/React.createElement("button", { + className: "btn-close btn-close-white", + onClick: () => setActiveDocPatient(null) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3" + }, /*#__PURE__*/React.createElement("div", { + className: "p-2.5 rounded-3 bg-light border mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex justify-content-between align-items-start flex-wrap gap-1" + }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("strong", { + className: "fs-6 text-dark" + }, activeDocPatient.fullName || activeDocPatient.p_fname), /*#__PURE__*/React.createElement("div", { + className: "small text-muted" + }, "UHID: ", /*#__PURE__*/React.createElement("span", { + className: "text-danger fw-bold" + }, activeDocPatient.p_code || activeDocPatient.uhid))), activeDocPatient.abha_id && /*#__PURE__*/React.createElement("span", { + className: "badge bg-success" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-shield-check me-1" + }), " ABHA: ", activeDocPatient.abha_id))), /*#__PURE__*/React.createElement("div", { + className: "row g-2 mb-3" + }, /*#__PURE__*/React.createElement("div", { + className: "col-12 col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Document Category (ABDM HI Type)"), /*#__PURE__*/React.createElement("select", { + className: "form-select form-select-sm", + value: patientDocForm.document_type, + onChange: e => setPatientDocForm({ + ...patientDocForm, + document_type: e.target.value + }) + }, /*#__PURE__*/React.createElement("option", { + value: "Prescription" + }, "Prescription Record (PrescriptionRecord)"), /*#__PURE__*/React.createElement("option", { + value: "Diagnostic Report / Lab" + }, "Diagnostic / Lab Report (DiagnosticReport)"), /*#__PURE__*/React.createElement("option", { + value: "Discharge Summary" + }, "Discharge Summary (DischargeSummary)"), /*#__PURE__*/React.createElement("option", { + value: "Scan / Radiology (X-Ray/CT/MRI)" + }, "Radiology / Scan (HealthDocumentRecord)"), /*#__PURE__*/React.createElement("option", { + value: "Paper Medical Record" + }, "Paper Medical Record (HealthDocumentRecord)"), /*#__PURE__*/React.createElement("option", { + value: "Immunization Record" + }, "Immunization Record (ImmunizationRecord)"), /*#__PURE__*/React.createElement("option", { + value: "Health Document" + }, "Other Health Document (HealthDocumentRecord)"))), /*#__PURE__*/React.createElement("div", { + className: "col-12 col-md-6" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Document Date"), /*#__PURE__*/React.createElement("input", { + type: "date", + className: "form-control form-control-sm", + value: patientDocForm.document_date, + onChange: e => setPatientDocForm({ + ...patientDocForm, + document_date: e.target.value + }) + })), /*#__PURE__*/React.createElement("div", { + className: "col-12" + }, /*#__PURE__*/React.createElement("label", { + className: "form-label small fw-bold mb-1" + }, "Remarks / Document Title"), /*#__PURE__*/React.createElement("input", { + type: "text", + className: "form-control form-control-sm", + placeholder: "e.g. Chest X-Ray Report, Blood CBC Test, Consultation Note", + value: patientDocForm.remarks, + onChange: e => setPatientDocForm({ + ...patientDocForm, + remarks: e.target.value + }) + }))), /*#__PURE__*/React.createElement("div", { + className: "mb-3 text-center" + }, /*#__PURE__*/React.createElement("label", { + className: "btn btn-primary btn-lg w-100 py-3 fw-bold rounded-3 shadow-sm" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-camera me-2" + }), " Take Document Photo / Choose Image", /*#__PURE__*/React.createElement("input", { + type: "file", + accept: "image/*", + capture: "environment", + className: "d-none", + onChange: handleScanImageCapture + }))), scanImagePreview && /*#__PURE__*/React.createElement("div", { + className: "position-relative p-2 border rounded-3 bg-light text-center" + }, /*#__PURE__*/React.createElement("span", { + className: "badge bg-success position-absolute top-0 start-0 m-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-check-circle me-1" + }), " Document Photo Captured"), /*#__PURE__*/React.createElement("img", { + src: scanImagePreview, + alt: "Document Scan Preview", + className: "img-fluid rounded-3 border shadow-sm", + style: { + maxHeight: '200px', + objectFit: 'contain' + } + }))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer p-2 bg-light" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-secondary btn-sm", + onClick: () => setActiveDocPatient(null), + disabled: isSavingDoc + }, "Cancel"), /*#__PURE__*/React.createElement("button", { + className: "btn btn-primary btn-sm fw-bold px-3", + onClick: handleSavePatientDocument, + disabled: !scanImageBase64 || isSavingDoc + }, isSavingDoc ? /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("span", { + className: "spinner-border spinner-border-sm me-1", + role: "status", + "aria-hidden": "true" + }), "Uploading...") : /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("i", { + className: "bi bi-cloud-upload-fill me-1" + }), " Upload ABDM Health Document")))))), wellnessHistoryPatient && /*#__PURE__*/React.createElement("div", { + className: "modal show d-block", + style: { + backgroundColor: 'rgba(0,0,0,0.65)', + zIndex: 1070 + } + }, /*#__PURE__*/React.createElement("div", { + className: "modal-dialog modal-dialog-centered modal-xl" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-content rounded-4 border-0 shadow-lg overflow-hidden" + }, /*#__PURE__*/React.createElement("div", { + className: "modal-header bg-dark text-white py-2.5" + }, /*#__PURE__*/React.createElement("div", { + className: "d-flex align-items-center gap-2" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-clock-history fs-5 text-warning" + }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h6", { + className: "modal-title fw-bold mb-0" + }, "Vitals & Wellness History"), /*#__PURE__*/React.createElement("small", { + className: "text-white-50", + style: { + fontSize: '11px' + } + }, wellnessHistoryPatient.fullName || wellnessHistoryPatient.p_fname, " (UHID: ", wellnessHistoryPatient.p_code || wellnessHistoryPatient.uhid, ")"))), /*#__PURE__*/React.createElement("button", { + className: "btn-close btn-close-white", + onClick: () => setWellnessHistoryPatient(null) + })), /*#__PURE__*/React.createElement("div", { + className: "modal-body p-3" + }, loadingHistory ? /*#__PURE__*/React.createElement("div", { + className: "text-center py-4" + }, /*#__PURE__*/React.createElement("div", { + className: "spinner-border text-primary", + role: "status" + }), /*#__PURE__*/React.createElement("p", { + className: "small text-muted mt-2" + }, "Loading historical vitals...")) : wellnessHistoryList.length === 0 ? /*#__PURE__*/React.createElement("div", { + className: "text-center py-4 bg-light rounded-3" + }, /*#__PURE__*/React.createElement("i", { + className: "bi bi-heart-pulse fs-2 text-muted opacity-50 d-block mb-1" + }), /*#__PURE__*/React.createElement("p", { + className: "small text-muted mb-0" + }, "No past vitals or wellness entries recorded yet for this patient.")) : /*#__PURE__*/React.createElement("div", { + className: "table-responsive" + }, /*#__PURE__*/React.createElement("table", { + className: "table table-sm table-striped table-hover align-middle mb-0", + style: { + fontSize: '12px' + } + }, /*#__PURE__*/React.createElement("thead", { + className: "table-light" + }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, "Date & Time"), /*#__PURE__*/React.createElement("th", null, "Vitals (BP / Pulse / SpO2 / Temp)"), /*#__PURE__*/React.createElement("th", null, "Body / BMI"), /*#__PURE__*/React.createElement("th", null, "Blood Glucose (mg/dL)"), /*#__PURE__*/React.createElement("th", null, "POC Labs"), /*#__PURE__*/React.createElement("th", null, "Activity / Lifestyle"), /*#__PURE__*/React.createElement("th", null, "Staff"), /*#__PURE__*/React.createElement("th", null, "Advice / Remarks"))), /*#__PURE__*/React.createElement("tbody", null, wellnessHistoryList.map(rec => /*#__PURE__*/React.createElement("tr", { + key: rec.id + }, /*#__PURE__*/React.createElement("td", { + className: "fw-semibold text-nowrap" + }, formatDateTime(rec.recorded_at)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap gap-1 align-items-center" + }, rec.bp_systolic && /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border" + }, "BP ", rec.bp_systolic, "/", rec.bp_diastolic), rec.pulse_rate && /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border" + }, rec.pulse_rate, " bpm"), rec.spo2 && /*#__PURE__*/React.createElement("span", { + className: "badge bg-info-subtle text-info border border-info-subtle" + }, rec.spo2, "% O2"), rec.temperature_f && /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger-subtle text-danger border border-danger-subtle" + }, rec.temperature_f, "°F"), rec.pain_score !== null && rec.pain_score !== undefined && rec.pain_score !== '' && /*#__PURE__*/React.createElement("span", { + className: `badge ${rec.pain_score == 0 ? 'bg-success-subtle text-success' : rec.pain_score <= 3 ? 'bg-info-subtle text-info' : 'bg-warning-subtle text-warning-emphasis'}` + }, "Pain: ", rec.pain_score, "/10"))), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", null, rec.bmi && /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-secondary me-1" + }, "BMI ", rec.bmi), rec.weight_kg && /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, rec.weight_kg, "kg "), rec.height_cm && /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, rec.height_cm, "cm")), (rec.waist_circumference_cm || rec.waist_hip_ratio) && /*#__PURE__*/React.createElement("small", { + className: "text-muted d-block", + style: { + fontSize: '11px' + } + }, rec.waist_circumference_cm ? `Waist: ${rec.waist_circumference_cm}cm` : '', rec.waist_hip_ratio ? ` • WHR: ${rec.waist_hip_ratio}` : '')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap gap-1" + }, rec.sugar_random && /*#__PURE__*/React.createElement("span", { + className: "badge bg-warning-subtle text-warning-emphasis border" + }, "RBS: ", rec.sugar_random), rec.sugar_fasting && /*#__PURE__*/React.createElement("span", { + className: "badge bg-primary-subtle text-primary border" + }, "FBS: ", rec.sugar_fasting), rec.sugar_pp && /*#__PURE__*/React.createElement("span", { + className: "badge bg-secondary-subtle text-secondary border" + }, "PP: ", rec.sugar_pp), !rec.sugar_random && !rec.sugar_fasting && !rec.sugar_pp && /*#__PURE__*/React.createElement("span", { + className: "text-muted" + }, "-"))), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "d-flex flex-wrap gap-1" + }, rec.hemoglobin && /*#__PURE__*/React.createElement("span", { + className: "badge bg-danger-subtle text-danger border" + }, "Hb: ", rec.hemoglobin, " g/dL"), rec.hba1c && /*#__PURE__*/React.createElement("span", { + className: "badge bg-success-subtle text-success border" + }, "A1c: ", rec.hba1c, "%"), !rec.hemoglobin && !rec.hba1c && /*#__PURE__*/React.createElement("span", { + className: "text-muted" + }, "-"))), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("div", { + className: "small" + }, rec.diet_type && /*#__PURE__*/React.createElement("span", { + className: "badge bg-light text-dark border me-1" + }, rec.diet_type), rec.daily_steps && /*#__PURE__*/React.createElement("span", { + className: "text-muted me-1" + }, rec.daily_steps, " steps"), rec.sleep_hours && /*#__PURE__*/React.createElement("span", { + className: "text-muted" + }, rec.sleep_hours, "h sleep"), !rec.diet_type && !rec.daily_steps && !rec.sleep_hours && /*#__PURE__*/React.createElement("span", { + className: "text-muted" + }, "-"))), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("small", { + className: "text-muted" + }, rec.recorded_by || 'Staff')), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("small", { + className: "text-truncate d-inline-block", + style: { + maxWidth: '180px' + }, + title: rec.general_advice || rec.diet_lifestyle_note + }, rec.general_advice || rec.diet_lifestyle_note || '-')))))))), /*#__PURE__*/React.createElement("div", { + className: "modal-footer p-2 bg-light" + }, /*#__PURE__*/React.createElement("button", { + className: "btn btn-secondary btn-sm px-3", + onClick: () => setWellnessHistoryPatient(null) + }, "Close"))))))); } const root = ReactDOM.createRoot(document.getElementById('root')); -root.render(/*#__PURE__*/_jsx(NursingApp, {})); \ No newline at end of file +root.render(/*#__PURE__*/React.createElement(NursingApp, null)); \ No newline at end of file diff --git a/scripts/build_pwas.js b/scripts/build_pwas.js index 2bc9290..a8f27fe 100644 --- a/scripts/build_pwas.js +++ b/scripts/build_pwas.js @@ -52,18 +52,35 @@ for (const app of apps) { console.log(`\n--- Processing ${app.name} ---`); const htmlContent = fs.readFileSync(htmlPath, 'utf8'); const match = htmlContent.match(/