PageSourceSearch

https://simveckan.se/assets/AppInteraction-ChAUg8KX.js

js simveckan.se collected 2026-10-08 11:15:31 UTC 13,473 bytes, 1 lines download raw bytes

1import{j as e,u as Q}from"./query-DaV6vLBd.js";import{u as K}from"./ConferenceContext-BaGgsci-.js";import{T as O,a as Z,b as E,c as F}from"./tabs-BvbKqmBC.js";import{r as d}from"./react-vendor-Dn2D-9Bs.js";import{a as P,e as R,L as w,I as q,S as G,i as H,j as W,k as I,l as D,B as g,u as c,s as x,b as J,c as X,d as Y,a2 as ee,aC as se,aw as ae}from"./index-qd8DFCfM.js";import{S as U}from"./switch-CiyKetCG.js";import{S as re}from"./shield-check-CPZ-Iimv.js";import{L as te}from"./link-2-ocqwip64.js";import{P as $}from"./plus-CY81bHpV.js";import{C as ie}from"./copy-B4Czcf89.js";import{T as B}from"./trash-2-D8cUU1TU.js";import{B as ne}from"./badge-BTiiB7bq.js";import{u as le,o as oe,s as L,t as de}from"./types-CrlNp_AA.js";import{D as ce,a as me,b as xe,c as ue,e as he}from"./dialog-C9I3-qiU.js";import{r as fe,t as M,f as V}from"./datetime-BddWg1m_.js";import{A as pe,a as ge}from"./arrow-up-CvVrSug1.js";import{P as je}from"./pencil-1q8dmxZP.js";import"./ui-radix-CEI8UHvd.js";import"./supabase-D_2IiIQD.js";import"./pdf-bz0EImIo.js";import"./charts-CO9wFpST.js";import"./format-DDlkRu2C.js";import"./en-US-CuBlLU8A.js";function ve(){const s=new Uint8Array(18);return crypto.getRandomValues(s),Array.from(s).map(n=>n.toString(16).padStart(2,"0")).join("")}function be({conferenceId:s}){const[n,h]=d.useState([]),[t,v]=d.useState(""),[i,j]=d.useState("all"),[f,N]=d.useState([]),[o,k]=d.useState(!0),[u,C]=d.useState(!1),[a,l]=d.useState(!1),m=async()=>{var z;const[r,y,A]=await Promise.all([x.from("moderator_tokens").select("*").eq("conference_id",s).order("created_at",{ascending:!1}),x.from("conferences").select("qa_require_approval").eq("id",s).maybeSingle(),x.from("sessions").select("location").eq("conference_id",s)]);h(r.data??[]),C(!!((z=y.data)!=null&&z.qa_require_approval)),N(Array.from(new Set((A.data??[]).map(T=>T.location).filter(T=>!!T))).sort()),k(!1)};d.useEffect(()=>{m()},[s]);const p=async r=>{l(!0);const y=u;C(r);const{error:A}=await x.from("conferences").update({qa_require_approval:r}).eq("id",s);if(l(!1),A){C(y),c.error(A.message);return}c.success(r?"Godkännande aktiverat":"Godkännande avaktiverat")},_=async()=>{const r=ve(),{error:y}=await x.from("moderator_tokens").insert({conference_id:s,token:r,label:t||null,room:i==="all"?null:i});if(y){c.error(y.message);return}v(""),j("all"),c.success("Moderator-länk skapad"),m()},b=async r=>{await x.from("moderator_tokens").update({revoked_at:new Date().toISOString()}).eq("id",r),m()},S=r=>`${window.location.origin}/moderate/qa/${r}`;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(P,{children:e.jsx(R,{className:"p-4 space-y-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(re,{className:"h-5 w-5 text-primary flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(w,{htmlFor:"qa-approval",className:"font-semibold cursor-pointer",children:"Kräv godkännande innan frågor visas publikt"}),e.jsx(U,{id:"qa-approval",checked:u,onCheckedChange:p,disabled:a})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:'När påslaget: nya frågor visas först för moderator. Frågeställaren ser sin egen som "Väntar på godkännande". När avslaget: alla frågor blir direkt synliga för alla deltagare.'})]})]})})}),e.jsx(P,{children:e.jsxs(R,{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[e.jsx(te,{className:"h-4 w-4"})," Moderator-länkar"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Skapa en delbar länk som låter tekniker/moderatorer hantera publikens frågor utan inloggning — perfekt att öppna på laptop eller padda i salen."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-[180px]",children:[e.jsx(w,{htmlFor:"ml",className:"text-xs",children:"Etikett (valfritt)"}),e.jsx(q,{id:"ml",value:t,onChange:r=>v(r.target.value),placeholder:"t.ex. Moderator Sal A"})]}),e.jsxs("div",{className:"w-[200px]",children:[e.jsx(w,{className:"text-xs",children:"Lokal"}),e.jsxs(G,{value:i,onValueChange:j,children:[e.jsx(H,{children:e.jsx(W,{})}),e.jsxs(I,{children:[e.jsx(D,{value:"all",children:"Alla lokaler"}),f.map(r=>e.jsx(D,{value:r,children:r},r))]})]})]}),e.jsxs(g,{onClick:_,className:"self-end",children:[e.jsx($,{className:"h-4 w-4 mr-1"})," Skapa länk"]})]}),o?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Laddar..."}):e.jsxs("div",{className:"space-y-2",children:[n.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Inga länkar ännu"}),n.map(r=>e.jsxs("div",{className:`flex items-center gap-2 border rounded p-2 ${r.revoked_at?"opacity-50":""}`,children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-sm font-medium truncate",children:[r.label||"Moderator",r.room?` · ${r.room}`:" · Alla lokaler",r.revoked_at&&" (återkallad)"]}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:S(r.token)})]}),e.jsx(g,{size:"sm",variant:"ghost",onClick:()=>{navigator.clipboard.writeText(S(r.token)),c.success("Länk kopierad")},children:e.jsx(ie,{className:"h-4 w-4"})}),!r.revoked_at&&e.jsx(g,{size:"sm",variant:"ghost",onClick:()=>b(r.id),children:e.jsx(B,{className:"h-4 w-4 text-destructive"})})]},r.id))]})]})})]})}const Ne=oe({name:L().trim().min(1,"Namn krävs").max(100),embed_url:L().trim().url("Ogiltig URL").refine(s=>s.startsWith("https://"),"URL måste börja med https://"),visible_from:L().optional(),visible_until:L().optional()}).refine(s=>!s.visible_from||!s.visible_until||s.visible_from<s.visible_until,{message:"Sluttiden måste vara efter starttiden",path:["visible_until"]});function ke({open:s,onOpenChange:n,conferenceId:h,poll:t,onSaved:v}){const i=le({resolver:de(Ne),defaultValues:{name:"",embed_url:"",visible_from:"",visible_until:""}}),{data:j}=Q({queryKey:["conf-tz",h],queryFn:async()=>{var o;return(o=(await x.from("conferences").select("timezone").eq("id",h).maybeSingle()).data)==null?void 0:o.timezone},enabled:!!h}),f=fe(j);d.useEffect(()=>{s&&i.reset({name:(t==null?void 0:t.name)??"",embed_url:(t==null?void 0:t.embed_url)??"",visible_from:M(t==null?void 0:t.visible_from,f),visible_until:M(t==null?void 0:t.visible_until,f)})},[s,t,i,f]);const N=async o=>{const k={visible_from:V(o.visible_from,f),visible_until:V(o.visible_until,f)};if(t){const{error:u}=await x.from("polls").update({name:o.name,embed_url:o.embed_url,...k}).eq("id",t.id);if(u)return c.error(u.message);c.success("Poll uppdaterad")}else{const{error:u}=await x.from("polls").insert({conference_id:h,name:o.name,embed_url:o.embed_url,sort_order:9999,...k});if(u)return c.error(u.message);c.success("Poll skapad")}n(!1),v()};return e.jsx(ce,{open:s,onOpenChange:n,children:e.jsxs(me,{children:[e.jsx(xe,{children:e.jsx(ue,{children:t?"Redigera poll":"Ny poll"})}),e.jsxs("form",{onSubmit:i.handleSubmit(N),className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(w,{htmlFor:"poll-name",children:"Namn"}),e.jsx(q,{id:"poll-name",...i.register("name"),placeholder:"t.ex. Öppningsfråga"}),i.formState.errors.name&&e.jsx("p",{className:"text-xs text-destructive",children:i.formState.errors.name.message})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(w,{htmlFor:"poll-url",children:"Embed-URL"}),e.jsx(q,{id:"poll-url",...i.register("embed_url"),placeholder:"https://app.sli.do/event/... eller https://www.menti.com/..."}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Använd Slido/Menti share- eller embed-länk (https://)."}),i.formState.errors.embed_url&&e.jsx("p",{className:"text-xs text-destructive",children:i.formState.errors.embed_url.message})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(w,{children:"Visas i appen (valfritt)"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Från"}),e.jsx(q,{type:"datetime-local",...i.register("visible_from")})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Till"}),e.jsx(q,{type:"datetime-local",...i.register("visible_until")})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Lämna tomt för att visa så l
1änge pollen är aktiv. Tider i eventets tidszon (",f,")."]}),i.formState.errors.visible_until&&e.jsx("p",{className:"text-xs text-destructive",children:i.formState.errors.visible_until.message})]}),e.jsxs(he,{children:[e.jsx(g,{type:"button",variant:"ghost",onClick:()=>n(!1),children:"Avbryt"}),e.jsx(g,{type:"submit",disabled:i.formState.isSubmitting,children:t?"Spara":"Skapa"})]})]})]})})}function _e(s){try{const n=new URL(s).hostname.toLowerCase();return n.includes("sli.do")||n.includes("slido")?"Slido":n.includes("menti")?"Mentimeter":"Annan"}catch{return"Annan"}}function Se({conferenceId:s}){const[n,h]=d.useState([]),[t,v]=d.useState(!0),[i,j]=d.useState(!1),[f,N]=d.useState(null),o=async()=>{v(!0);const{data:a,error:l}=await x.from("polls").select("id,name,embed_url,is_active,sort_order,visible_from,visible_until").eq("conference_id",s).order("sort_order",{ascending:!0}).order("created_at",{ascending:!0});l&&c.error(l.message),h(a??[]),v(!1)};d.useEffect(()=>{s&&o()},[s]);const k=async(a,l)=>{h(p=>p.map(_=>_.id===a.id?{..._,is_active:l}:_));const{error:m}=await x.from("polls").update({is_active:l}).eq("id",a.id);m&&(c.error(m.message),o())},u=async(a,l)=>{const m=a+l;if(m<0||m>=n.length)return;const p=[...n];[p[a],p[m]]=[p[m],p[a]],h(p.map((b,S)=>({...b,sort_order:S}))),(await Promise.all(p.map((b,S)=>x.from("polls").update({sort_order:S}).eq("id",b.id)))).some(b=>b.error)&&(c.error("Kunde inte spara ordningen"),o())},C=async a=>{if(!confirm(`Ta bort pollen "${a.name}"?`))return;const{error:l}=await x.from("polls").delete().eq("id",a.id);if(l)return c.error(l.message);c.success("Poll borttagen"),o()};return e.jsxs(P,{children:[e.jsxs(J,{className:"flex flex-row items-start justify-between gap-4 space-y-0",children:[e.jsxs("div",{children:[e.jsx(X,{className:"text-lg",children:"Polls"}),e.jsx(Y,{children:"Skapa polls och länka till din Slido- eller Menti-session. Aktivera när den ska visas i appen."})]}),e.jsxs(g,{size:"sm",onClick:()=>{N(null),j(!0)},children:[e.jsx($,{className:"h-4 w-4 mr-1"})," Ny poll"]})]}),e.jsx(R,{children:t?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Laddar…"}):n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Inga polls skapade ännu."}):e.jsx("ul",{className:"divide-y border rounded-md",children:n.map((a,l)=>e.jsxs("li",{className:"flex items-center gap-4 p-3",children:[e.jsxs("div",{className:"flex flex-col shrink-0",children:[e.jsx(g,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:l===0,onClick:()=>u(l,-1),"aria-label":"Flytta upp",children:e.jsx(pe,{className:"h-3.5 w-3.5"})}),e.jsx(g,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:l===n.length-1,onClick:()=>u(l,1),"aria-label":"Flytta ned",children:e.jsx(ge,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium truncate",children:a.name}),e.jsx(ne,{variant:"secondary",className:"text-xs",children:_e(a.embed_url)})]}),e.jsxs("a",{href:a.embed_url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:underline inline-flex items-center gap-1 truncate max-w-full",children:[e.jsx(ee,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:a.embed_url})]}),(a.visible_from||a.visible_until)&&e.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5",children:["Visas ",a.visible_from?new Date(a.visible_from).toLocaleString("sv-SE",{dateStyle:"short",timeStyle:"short"}):"nu"," – ",a.visible_until?new Date(a.visible_until).toLocaleString("sv-SE",{dateStyle:"short",timeStyle:"short"}):"tills vidare"]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Aktiv"}),e.jsx(U,{checked:a.is_active,onCheckedChange:m=>k(a,m)})]}),e.jsx(g,{variant:"ghost",size:"icon",onClick:()=>{N(a),j(!0)},children:e.jsx(je,{className:"h-4 w-4"})}),e.jsx(g,{variant:"ghost",size:"icon",onClick:()=>C(a),children:e.jsx(B,{className:"h-4 w-4 text-destructive"})})]})]},a.id))})}),e.jsx(ke,{open:i,onOpenChange:j,conferenceId:s,poll:f,onSaved:o})]})}function He(){const{conferenceId:s}=K();return e.jsxs("div",{className:"max-w-4xl animate-fade-in space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-3xl font-bold",children:"Interaktion"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Realtidsverktyg under konferensen — Q&A och Polls."})]}),e.jsxs(O,{defaultValue:"qa",children:[e.jsxs(Z,{children:[e.jsxs(E,{value:"qa",className:"gap-1.5",children:[e.jsx(se,{className:"h-4 w-4"})," Q&A"]}),e.jsxs(E,{value:"polls",className:"gap-1.5",children:[e.jsx(ae,{className:"h-4 w-4"})," Polls"]})]}),e.jsx(F,{value:"qa",className:"mt-4",children:s&&e.jsx(be,{conferenceId:s})}),e.jsx(F,{value:"polls",className:"mt-4",children:s&&e.jsx(Se,{conferenceId:s})})]})]})}export{He 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.