PageSourceSearch

https://digitalbehandling.se/assets/TreatmentSubmissionsView-BqYpq7Ka.js

js digitalbehandling.se collected 2026-09-30 08:27:11 UTC 3,023 bytes, 1 lines download raw bytes

1import{g as C,r,s as A,j as t,B as M,A as E,aH as k,aI as I,aJ as h,aK as L,C as j,aY as P,k as B}from"./index-CobRY8C4.js";import{S as R}from"./types-Cu78f2DN.js";import{l as H}from"./index-BLzEcbIU.js";import"./aiResponseSchema-Dr5w6DAb.js";import"./vfs_fonts-BwDagwDl.js";import"./fordjupningCategories-C-7LBH-e.js";import{f as U,a as Y}from"./submissionCategorization-CA1-mOns.js";function $(){const d=C(),[i,b]=r.useState([]),[v,w]=r.useState([]),[o,T]=r.useState(new Map),[c,u]=r.useState(!0),[l,S]=r.useState("all");r.useEffect(()=>{let e=!1;return(async()=>{try{u(!0);const[a,n]=await Promise.all([H(),U()]);if(e)return;const s=a.filter(m=>n.has(m.template_id));b(s);const y=Array.from(new Set(s.map(m=>m.template_id))),g=await Y(y);if(e)return;T(g);const x=Array.from(new Set([...g.values()].flat()));if(x.length>0){const{data:m}=await A.from("treatment_programs").select("id, name").in("id",x);if(e)return;w((m??[]).sort((N,_)=>N.name.localeCompare(_.name)))}}finally{e||u(!1)}})(),()=>{e=!0}},[]);const p=r.useMemo(()=>l==="all"?i:i.filter(e=>{var a;return(a=o.get(e.template_id))==null?void 0:a.includes(l)}),[i,l,o]),f=r.useMemo(()=>[...p].sort((e,a)=>{const n=s=>s.status==="submitted"?0:s.status==="draft"?2:1;return n(e)-n(a)||a.updated_at.localeCompare(e.updated_at)}),[p]);return t.jsxs("div",{className:"container mx-auto py-6 max-w-5xl space-y-4",children:[t.jsxs("div",{children:[t.jsxs(M,{variant:"ghost",size:"sm",onClick:()=>d("/form-submissions"),children:[t.jsx(E,{className:"h-4 w-4 mr-1"})," Tillbaka till skrivbord"]}),t.jsx("h1",{className:"text-2xl font-semibold mt-2",children:"Behandlingsuppgifter"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Klienternas inlämnade uppgifter från behandlingsprogrammen"})]}),c&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Laddar..."}),!c&&t.jsxs(k,{value:l,onValueChange:S,children:[t.jsxs(I,{className:"flex-wrap h-auto",children:[t.jsxs(h,{value:"all",children:["Alla program (",i.length,")"]}),v.map(e=>{const a=i.filter(n=>{var s;return(s=o.get(n.template_id))==null?void 0:s.includes(e.id)}).length;return t.jsxs(h,{value:e.id,children:[e.name," (",a,")"]},e.id)})]}),t.jsx(L,{value:l,className:"mt-4",children:f.length===0?t.jsx(j,{className:"p-8 text-center text-muted-foreground",children:"Inga inlämnade behandlingsuppgifter i denna vy ännu."}):t.jsx("div",{className:"grid gap-2",children:f.map(e=>{var a;return t.jsxs(j,{className:"p-4 flex items-center justify-between gap-3 cursor-pointer hover:bg-accent/40",onClick:()=>d(`/form-submissions/fill?submission=${e.id}`),children:[t.jsxs("div",{children:[t.jsx("div",{className:"font-medium",children:((a=e.template)==null?void 0:a.name)??"Okänd mall"}),t.jsxs("div",{className:"text-xs text-muted-foreground",children:["Uppdaterad ",P(new Date(e.updated_at),"yyyy-MM-dd HH:mm")]})]}),t.jsx(B,{variant:e.status==="submitted"?"destructive":"outline",children:R[e.status]})]},e.id)})})})]})]})}const q=null;export{q as _USED_CATEGORY_TYPE,$ 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.