PageSourceSearch

https://caremetric.ai/assets/IntegrationHub-Dep9YADR.js

js caremetric.ai collected 2026-10-05 15:02:16 UTC 8,221 bytes, 1 lines download raw bytes

1import{a as z}from"./rolldown-runtime-DS2seoW7.js";import{En as c,It as C,L,Nt as d,On as o,Vn as q,_t as k,an as A,j as E,xn as n,xt as $,z as D}from"./chunk-admin-DnJxlFde.js";import{g as x}from"./chunk-admin-subscription-CQfvBNB9.js";var i=z(q(),1),e=A();function P(){const{profile:r}=C(),[m,p]=(0,i.useState)([]),[a,N]=(0,i.useState)(null),[g,v]=(0,i.useState)([]),[M,h]=(0,i.useState)(!1),[f,y]=(0,i.useState)(!0),l=(0,i.useCallback)(async()=>{if(r?.organization_id)try{const{data:s,error:t}=await n.from("integrations").select("*").eq("organization_id",r.organization_id).order("created_at",{ascending:!1});if(t)throw t;p(s||[])}catch(s){c.error("Error loading integrations:",o(s))}finally{y(!1)}},[r]);(0,i.useEffect)(()=>{r?.organization_id&&queueMicrotask(()=>l())},[r?.organization_id,l]);const u=async s=>{try{const{data:t,error:j}=await n.from("integration_logs").select("*").eq("integration_id",s).order("created_at",{ascending:!1}).limit(50);if(j)throw j;v(t||[])}catch(t){c.error("Error loading logs:",o(t))}},_=s=>{N(s),u(s.id)},w=async s=>{try{const{error:t}=await n.from("integrations").update({is_active:!s.is_active}).eq("id",s.id);if(t)throw t;l()}catch(t){c.error("Error toggling integration:",o(t))}},S=async s=>{if(r?.organization_id)try{const{error:t}=await n.from("integration_logs").insert({organization_id:r.organization_id,integration_id:s,action:"sync",status:"success",records_processed:null,metadata:{synced_at:new Date().toISOString()}});if(t)throw t;await n.from("integrations").update({last_sync_at:new Date().toISOString()}).eq("id",s),l(),a?.id===s&&u(s)}catch(t){c.error("Error syncing integration:",o(t))}},b=s=>{const t="w-10 h-10";switch(s){case"lab":return(0,e.jsx)(d,{className:`${t} text-blue-600`});case"imaging":return(0,e.jsx)(d,{className:`${t} text-blue-600`});case"pharmacy":return(0,e.jsx)(d,{className:`${t} text-green-600`});case"insurance":return(0,e.jsx)(d,{className:`${t} text-yellow-600`});default:return(0,e.jsx)(x,{className:`${t} text-slate-600`})}},I=s=>s?(0,e.jsxs)("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800",children:[(0,e.jsx)($,{className:"w-3 h-3 mr-1"}),"Active"]}):(0,e.jsxs)("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-slate-100 text-slate-800",children:[(0,e.jsx)(k,{className:"w-3 h-3 mr-1"}),"Inactive"]});return f?(0,e.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,e.jsx)("div",{className:"text-slate-500",children:"Loading integrations..."})}):(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{className:"text-2xl font-bold text-slate-900",children:"Integration Hub"}),(0,e.jsx)("p",{className:"text-sm text-slate-600 mt-1",children:"Connect and manage third-party integrations"})]}),(0,e.jsxs)("button",{onClick:()=>h(!0),className:"flex items-center space-x-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700",children:[(0,e.jsx)(D,{className:"w-5 h-5"}),(0,e.jsx)("span",{children:"Add Integration"})]})]}),(0,e.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[(0,e.jsxs)("div",{className:"lg:col-span-1 space-y-4",children:[m.map(s=>(0,e.jsxs)("div",{onClick:()=>_(s),className:`bg-white rounded-lg shadow-xs border-2 p-4 cursor-pointer transition-colors ${a?.id===s.id?"border-blue-500 bg-blue-50":"border-slate-200 hover:border-slate-300"}`,children:[(0,e.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[b(s.integration_type),I(s.is_active)]}),(0,e.jsx)("h3",{className:"font-semibold text-slate-900 mb-1",children:s.provider_name}),(0,e.jsx)("p",{className:"text-sm text-slate-600 mb-2 capitalize",children:s.integration_type}),(0,e.jsxs)("div",{className:"flex items-center justify-between text-xs text-slate-500",children:[(0,e.jsxs)("span",{children:["Sync: ",s.sync_frequency]}),s.last_sync_at&&(0,e.jsx)("span",{children:new Date(s.last_sync_at).toLocaleDateString()})]})]},s.id)),m.length===0&&(0,e.jsxs)("div",{className:"bg-white rounded-lg shadow-xs border border-slate-200 p-8 text-center",children:[(0,e.jsx)(x,{className:"w-12 h-12 text-slate-400 mx-auto mb-4"}),(0,e.jsx)("p",{className:"text-slate-600 mb-4",children:"No integrations configured"}),(0,e.jsx)("button",{onClick:()=>h(!0),className:"text-blue-600 hover:text-blue-700 font-medium",children:"Add your first integration"})]})]}),(0,e.jsx)("div",{className:"lg:col-span-2",children:a?(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("div",{className:"bg-white rounded-lg shadow-xs border border-slate-200 p-6",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,e.jsxs)("div",{className:"flex items-center space-x-4",children:[b(a.integration_type),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-xl font-semibold text-slate-900",children:a.provider_name}),(0,e.jsxs)("p",{className:"text-sm text-slate-600 capitalize",children:[a.integration_type," Integration"]})]})]}),(0,e.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,e.jsx)("button",{onClick:()=>S(a.id),className:"p-2 text-blue-600 hover:bg-blue-50 rounded-lg",children:(0,e.jsx)(L,{className:"w-5 h-5"})}),(0,e.jsx)("button",{onClick:()=>w(a),className:`px-4 py-2 rounded-lg ${a.is_active?"bg-red-100 text-red-700 hover:bg-red-200":"bg-green-100 text-green-700 hover:bg-green-200"}`,children:a.is_active?"Disable":"Enable"}),(0,e.jsx)("button",{className:"p-2 text-slate-600 hover:bg-slate-100 rounded-lg",children:(0,e.jsx)(E,{className:"w-5 h-5"})})]})]}),(0,e.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,e.jsxs)("div",{className:"bg-slate-50 rounded-lg p-4",children:[(0,e.jsx)("div",{className:"text-sm text-slate-600 mb-1",children:"Status"}),(0,e.jsx)("div",{className:"font-semibold text-slate-900",children:a.is_active?"Active":"Inactive"})]}),(0,e.jsxs)("div",{className:"bg-slate-50 rounded-lg p-4",children:[(0,e.jsx)("div",{className:"text-sm text-slate-600 mb-1",children:"Sync Frequency"}),(0,e.jsx)("div",{className:"font-semibold text-slate-900 capitalize",children:a.sync_frequency})]}),(0,e.jsxs)("div",{className:"bg-slate-50 rounded-lg p-4",children:[(0,e.jsx)("div",{className:"text-sm text-slate-600 mb-1",children:"Last Sync"}),(0,e.jsx)("div",{className:"font-semibold text-slate-900",children:a.last_sync_at?new Date(a.last_sync_at).toLocaleStr
1ing():"Never"})]})]})]}),(0,e.jsxs)("div",{className:"bg-white rounded-lg shadow-xs border border-slate-200",children:[(0,e.jsx)("div",{className:"p-4 border-b border-slate-200",children:(0,e.jsx)("h3",{className:"font-semibold text-slate-900",children:"Activity Log"})}),(0,e.jsxs)("div",{className:"divide-y divide-slate-200 max-h-[400px] overflow-y-auto",children:[g.map(s=>(0,e.jsx)("div",{className:"p-4",children:(0,e.jsxs)("div",{className:"flex items-start justify-between",children:[(0,e.jsxs)("div",{className:"flex-1",children:[(0,e.jsxs)("div",{className:"flex items-center space-x-2 mb-1",children:[(0,e.jsx)("span",{className:`inline-flex items-center px-2 py-1 rounded text-xs font-medium ${s.status==="success"?"bg-green-100 text-green-800":s.status==="failed"?"bg-red-100 text-red-800":"bg-yellow-100 text-yellow-800"}`,children:s.status}),(0,e.jsx)("span",{className:"text-sm text-slate-600 capitalize",children:s.action})]}),(0,e.jsxs)("div",{className:"text-sm text-slate-600",children:["Processed ",s.records_processed," records"]}),s.error_message&&(0,e.jsx)("div",{className:"text-sm text-red-600 mt-1",children:s.error_message})]}),(0,e.jsx)("div",{className:"text-xs text-slate-500",children:new Date(s.created_at).toLocaleString()})]})},s.id)),g.length===0&&(0,e.jsx)("div",{className:"p-8 text-center text-slate-500",children:"No activity logs yet"})]})]})]}):(0,e.jsxs)("div",{className:"bg-white rounded-lg shadow-xs border border-slate-200 p-12 text-center",children:[(0,e.jsx)(x,{className:"w-12 h-12 text-slate-400 mx-auto mb-4"}),(0,e.jsx)("p",{className:"text-slate-600",children:"Select an integration to view details and activity"})]})})]})]})}export{P as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.