1import{r as a,j as s}from"./vendor-react-BDlPBQ8H.js";import{t as x}from"./vendor-interactions-B-90v6Vt.js";import{B as f,h as $}from"./index-C9I8CK0-.js";import{g as H,u as M,a as z}from"./sisAdmin-CE3C7dSh.js";import{E as J,a as y}from"./EnterpriseSurface-CxYSrS8g.js";import{I as P}from"./input-DdZnLe1O.js";import"./textarea-K_ft2Dhe.js";import"./switch-C-gCwL2u.js";import{S as V}from"./native-select-Bt4YFc9A.js";import{T as W,a as q,b as i,c as T,d as G,e as c}from"./table-CtOFJGeh.js";import{D as K,b as Q,c as X,d as Y,f as Z}from"./dialog-D6B-UUdu.js";import"./vendor-radix-CoZ84gME.js";import"./vendor-misc-BcNut0Sq.js";import"./vendor-nhost-yQ8TKvUP.js";import"./vendor-ui-helpers-BA9Ou6yF.js";import"./vendor-sentry-B_mZGnMZ.js";import"./EnterpriseStatCard-Wl26IFB0.js";const C=$("AdminSISDataManager"),l=z();var I;const ee=((I=l[0])==null?void 0:I.name)??"sis_roster_students",E=t=>typeof t=="object"&&t!==null,se=t=>E(t)&&typeof t.id=="string",R=t=>typeof t=="string"||typeof t=="number"||typeof t=="boolean"?String(t):t==null?"":JSON.stringify(t);function ge(){var b;const[t,w]=a.useState(ee),[j,D]=a.useState([]),[v,A]=a.useState(null),[F,m]=a.useState("loading"),[o,S]=a.useState(null),[L,d]=a.useState(!1),h=a.useRef(t);h.current=t;const g=async e=>{m("loading");try{if(!l.find(_=>_.name===e))throw new Error("Unsupported SIS table");const r=await H(e);if(h.current!==e)return;const U=E(r)&&Array.isArray(r[e])?r[e].filter(se):[];D(U),A(e),m("ready")}catch(n){if(C.error("Failed to fetch records",n),h.current!==e)return;x.error("Failed to load records"),m("error")}};a.useEffect(()=>{g(t)},[t]);const N=e=>{S(e),d(!0)},B=async()=>{if(o)try{const e=l.find(r=>r.name===t);if(!e)throw new Error("Unsupported SIS table");const n={};e.columns.forEach(r=>{r!=="id"&&(n[r]=o[r])}),await M(t,o.id,n),x.success("Record updated"),d(!1),await g(t)}catch(e){C.error("Failed to update record",e),x.error("Update failed")}},O=(e,n)=>{S(r=>r&&{...r,[e]:n})},p=((b=l.find(e=>e.name===t))==null?void 0:b.columns)??[],u=p.length+1,k=v===t;return s.jsxs(J,{eyebrow:"Integrations",title:"SIS Data Manager",description:"Inspect and edit records in synced SIS tables.",children:[s.jsx(y,{title:"Select Table",children:s.jsxs("div",{className:"max-w-sm space-y-2",children:[s.jsx("label",{htmlFor:"sis-table",className:"text-sm font-medium",children:"Table"}),s.jsx(V,{id:"sis-table",value:t,onChange:e=>w(e.target.value),children:l.map(e=>s.jsx("option",{value:e.name,children:e.name},e.name))})]})}),s.jsx(y,{title:"Records",children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs(W,{children:[s.jsx(q,{children:s.jsxs(i,{children:[p.map(e=>s.jsx(T,{children:e},e)),s.jsx(T,{children:s.jsx("span",{className:"sr-only",children:"Actions"})})]})}),s.jsx(G,{children:k?j.length===0?s.jsx(i,{children:s.jsx(c,{colSpan:u,className:"py-6 text-center text-[var(--enterprise-muted)]",children:"No records in this table."})}):j.map(e=>s.jsxs(i,{children:[p.map(n=>s.jsx(c,{children:R(e[n])},`${e.id}-${n}`)),s.jsx(c,{children:s.jsx(f,{size:"sm",onClick:()=>N(e),children:"Edit"})})]},e.id)):F==="error"?s.jsx(i,{children:s.jsx(c,{colSpan:u,className:"py-6 text-center text-[var(--enterprise-danger)]",children:s.jsx("span",{role:"alert",children:"We couldnât load records. Check your connection and try again."})})}):s.jsx(i,{children:s.jsx(c,{colSpan:u,className:"py-6 text-center text-[var(--enterprise-muted)]",children:s.jsx("span",{role:"status",children:"Loading recordsâ¦"})})})})]})})}),s.jsx(K,{open:L,onOpenChange:d,children:s.jsxs(Q,{children:[s.jsx(X,{children:s.jsx(Y,{children:"Edit Record"})}),s.jsx("div",{className:"space-y-3",children:o&&p.filter(e=>e!=="id").map(e=>s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:`sis-field-${e}`,className:"text-sm font-medium",children:e}),s.jsx(P,{id:`sis-field-${e}`,value:R(o[e]),onChange:n=>O(e,n.target.value)})]},e))}),s.jsxs(Z,{children:[s.jsx(f,{type:"button",onClick:B,children:"Save"}),s.jsx(f,{type:"button",variant:"outline",onClick:()=>d(!1),children:"Cancel"})]})]})})]})}export{ge 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.