PageSourceSearch

https://polarizationresearchlab.org/assets/TeamAdmin-CAkVfFyg.js

js polarizationresearchlab.org collected 2026-09-25 04:28:06 UTC 14,095 bytes, 1 lines download raw bytes

1import{r as u,j as e}from"./vendor-chartjs-DAQApR3A.js";import{u as te,a as q,D as J,c as K,S as Y,v as z,p as re,d as H,s as ae,K as le,P as oe,b as Q,C as V,F as ne}from"./publishToS3-6mao7I8F.js";import{u as de}from"./AdminToastContext-CgqwTXQu.js";import"./vendor-recharts-KyLwo51t.js";import"./vendor-maps-DjSiDsVE.js";import"./adminAuth-CHjczaih.js";import"./index-VXtZNIH-.js";const N="admin-team",W={faculty:"Faculty",staff:"Staff",postdocs:"Postdocs",gradStudents:"Graduate Students",advisoryBoard:"Advisory Board",globalAdvisors:"Global Advisors"},ie={faculty:[],staff:[],postdocs:[],gradStudents:[],undergrads:[],advisoryBoard:[],globalAdvisors:[]},T={name:"",title:"",institution:"",photo:"",website:"",profileLink:""};function ce(r,a){const g=JSON.stringify(r,null,2),b=new Blob([g],{type:"application/json"}),m=URL.createObjectURL(b),d=document.createElement("a");d.href=m,d.download=a,d.click(),URL.revokeObjectURL(m)}function ue({id:r,member:a,onEdit:g,onDelete:b}){const{attributes:m,listeners:d,setNodeRef:i,transform:y,transition:j,isDragging:h}=Q({id:r}),c={transform:V.Transform.toString(y),transition:j,opacity:h?.5:1};return e.jsxs("div",{ref:i,style:{...c,background:"var(--bg-tertiary)",border:"1px solid var(--border)"},className:"flex items-center gap-3 p-3 rounded-lg",children:[e.jsx("div",{...m,...d,className:"cursor-grab active:cursor-grabbing p-1",style:{color:"var(--text-muted)"},children:e.jsx("i",{className:"bi bi-grip-vertical text-lg"})}),a.photo&&e.jsx("img",{src:a.photo,alt:a.name,className:"w-12 h-12 rounded-full object-cover flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium",style:{color:"var(--text-primary)"},children:[a.name,a.profileLink&&e.jsx("a",{href:a.profileLink,className:"ml-2 text-xs",style:{color:"var(--accent)"},children:"(profile)"})]}),e.jsx("div",{className:"text-sm",style:{color:"var(--text-secondary)"},children:a.title}),e.jsxs("div",{className:"text-xs",style:{color:"var(--text-muted)"},children:[a.institution,a.website&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("a",{href:a.website,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)"},children:"website"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("button",{onClick:g,className:"p-1 hover:opacity-70",style:{color:"var(--text-secondary)"},title:"Edit",children:e.jsx("i",{className:"bi bi-pencil"})}),e.jsx("button",{onClick:b,className:"p-1 hover:opacity-70",style:{color:"#ef4444"},title:"Delete",children:e.jsx("i",{className:"bi bi-trash"})})]})]})}function me({id:r,name:a,onEdit:g,onDelete:b}){const{attributes:m,listeners:d,setNodeRef:i,transform:y,transition:j,isDragging:h}=Q({id:r}),c={transform:V.Transform.toString(y),transition:j,opacity:h?.5:1};return e.jsxs("div",{ref:i,style:{...c,background:"var(--bg-tertiary)",border:"1px solid var(--border)"},className:"flex items-center gap-3 p-3 rounded-lg",children:[e.jsx("div",{...m,...d,className:"cursor-grab active:cursor-grabbing p-1",style:{color:"var(--text-muted)"},children:e.jsx("i",{className:"bi bi-grip-vertical text-lg"})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("div",{className:"font-medium",style:{color:"var(--text-primary)"},children:a})}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("button",{onClick:g,className:"p-1 hover:opacity-70",style:{color:"var(--text-secondary)"},children:e.jsx("i",{className:"bi bi-pencil"})}),e.jsx("button",{onClick:b,className:"p-1 hover:opacity-70",style:{color:"#ef4444"},children:e.jsx("i",{className:"bi bi-trash"})})]})]})}function ye(){const[r,a]=u.useState(ie),[g,b]=u.useState(!0),[m,d]=u.useState(!1),[i,y]=u.useState(new Set(["faculty","staff"])),[j,h]=u.useState(!1),[c,C]=u.useState(null),[f,E]=u.useState(null),[o,x]=u.useState(T),[D,k]=u.useState(""),[w,P]=u.useState(!1),{showError:S,showSuccess:R}=de(),F=te(q(oe),q(le,{coordinateGetter:ae}));u.useEffect(()=>{async function s(){const t=localStorage.getItem(N);if(t)try{a(JSON.parse(t)),d(!0),b(!1);return}catch{localStorage.removeItem(N)}try{const p=await(await fetch("/data/team.json")).json();a(p)}catch(l){S("Failed to load team data",l)}b(!1)}s()},[S]);const I=s=>{localStorage.setItem(N,JSON.stringify(s)),d(!0)},_=s=>{const t=new Set(i);t.has(s)?t.delete(s):t.add(s),y(t)},U=(s,t)=>{const{active:l,over:p}=s;if(p&&l.id!==p.id){const n={...r};if(t==="undergrads"){const $=n.undergrads.findIndex((L,v)=>`undergrad-${v}`===l.id),A=n.undergrads.findIndex((L,v)=>`undergrad-${v}`===p.id);n.undergrads=H(n.undergrads,$,A)}else{const $=n[t].findIndex((L,v)=>`${t}-${v}`===l.id),A=n[t].findIndex((L,v)=>`${t}-${v}`===p.id);n[t]=H(n[t],$,A)}a(n),I(n)}},O=s=>{C(s),E(null),s==="undergrads"?k(""):x({...T}),h(!0)},M=(s,t)=>{C(s),E(t),s==="undergrads"?k(r.undergrads[t]):x({...r[s][t]}),h(!0)},B=(s,t)=>{if(!confirm("Are you sure you want to delete this member?"))return;const l={...r};s==="undergrads"?l.undergrads=l.undergrads.filter((p,n)=>n!==t):l[s]=l[s].filter((p,n)=>n!==t),a(l),I(l)},X=s=>{if(s.preventDefault(),!c)return;const t={...r};c==="undergrads"?f!==null?t.undergrads[f]=D:t.undergrads=[...t.undergrads,D]:f!==null?t[c][f]={...o}:t[c]=[...t[c],{...o}],a(t),I(t),G()},G=()=>{h(!1),C(null),E(null),x({...T}),k("")},Z=()=>{ce(r,"team.json")},ee=async()=>{P(!0);const s=await re(ne.team,r);s.success?(R("Published to live site!"),localStorage.removeItem(N),d(!1)):S("Failed to publish team data",s.error),P(!1)},se=async()=>
1{if(confirm("This will discard all local changes. Continue?")){localStorage.removeItem(N);try{const t=await(await fetch("/data/team.json")).json();a(t),d(!1),R("Reset to source data")}catch(s){S("Failed to reload data",s)}}};return g?e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-8 w-48 rounded mb-4",style:{background:"var(--bg-secondary)"}}),e.jsx("div",{className:"h-64 rounded",style:{background:"var(--bg-secondary)"}})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:"Team"}),e.jsxs("p",{className:"text-sm mt-1",style:{color:"var(--text-secondary)"},children:["Manage team members across all categories",m&&e.jsx("span",{style:{color:"#f59e0b"},children:" (unsaved changes)"})]})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[m&&e.jsx("button",{onClick:se,className:"px-4 py-2 rounded-lg text-sm font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)",border:"1px solid var(--border)"},children:"Reset"}),e.jsxs("button",{onClick:Z,className:"px-4 py-2 rounded-lg text-sm font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)",border:"1px solid var(--border)"},children:[e.jsx("i",{className:"bi bi-download mr-2"}),"Export"]}),m&&e.jsxs("button",{onClick:ee,disabled:w,className:"px-4 py-2 rounded-lg text-sm font-medium",style:{background:"#10b981",color:"#fff",opacity:w?.7:1},children:[e.jsx("i",{className:`bi ${w?"bi-arrow-repeat animate-spin":"bi-cloud-upload"} mr-2`}),w?"Publishing...":"Publish to Site"]})]})]}),e.jsxs("div",{className:"space-y-4",children:[Object.keys(W).map(s=>e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:[e.jsxs("button",{onClick:()=>_(s),className:"w-full flex items-center justify-between px-4 py-3 text-left",style:{borderBottom:i.has(s)?"1px solid var(--border)":"none"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("i",{className:`bi bi-chevron-${i.has(s)?"down":"right"}`,style:{color:"var(--text-muted)"}}),e.jsx("span",{className:"font-medium",style:{color:"var(--text-primary)"},children:W[s]}),e.jsxs("span",{className:"text-sm",style:{color:"var(--text-muted)"},children:["(",r[s].length,")"]})]}),e.jsxs("button",{onClick:t=>{t.stopPropagation(),O(s)},className:"px-3 py-1 rounded text-sm font-medium",style:{background:"var(--accent)",color:"#fff"},children:[e.jsx("i",{className:"bi bi-plus-lg mr-1"}),"Add"]})]}),i.has(s)&&e.jsx("div",{className:"p-4 space-y-2",children:r[s].length===0?e.jsx("div",{className:"text-center py-4",style:{color:"var(--text-muted)"},children:"No members in this category"}):e.jsx(J,{sensors:F,collisionDetection:K,onDragEnd:t=>U(t,s),children:e.jsx(Y,{items:r[s].map((t,l)=>`${s}-${l}`),strategy:z,children:r[s].map((t,l)=>e.jsx(ue,{id:`${s}-${l}`,member:t,onEdit:()=>M(s,l),onDelete:()=>B(s,l)},`${s}-${l}`))})})})]},s)),e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:[e.jsxs("button",{onClick:()=>_("undergrads"),className:"w-full flex items-center justify-between px-4 py-3 text-left",style:{borderBottom:i.has("undergrads")?"1px solid var(--border)":"none"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("i",{className:`bi bi-chevron-${i.has("undergrads")?"down":"right"}`,style:{color:"var(--text-muted)"}}),e.jsx("span",{className:"font-medium",style:{color:"var(--text-primary)"},children:"Undergraduates"}),e.jsxs("span",{className:"text-sm",style:{color:"var(--text-muted)"},children:["(",r.undergrads.length,")"]})]}),e.jsxs("button",{onClick:s=>{s.stopPropagation(),O("undergrads")},className:"px-3 py-1 rounded text-sm font-medium",style:{background:"var(--accent)",color:"#fff"},children:[e.jsx("i",{className:"bi bi-plus-lg mr-1"}),"Add"]})]}),i.has("undergrads")&&e.jsx("div",{className:"p-4 space-y-2",children:r.undergrads.length===0?e.jsx("div",{className:"text-center py-4",style:{color:"var(--text-muted)"},children:"No undergraduates listed"}):e.jsx(J,{sensors:F,collisionDetection:K,onDragEnd:s=>
1U(s,"undergrads"),children:e.jsx(Y,{items:r.undergrads.map((s,t)=>`undergrad-${t}`),strategy:z,children:r.undergrads.map((s,t)=>e.jsx(me,{id:`undergrad-${t}`,name:s,onEdit:()=>M("undergrads",t),onDelete:()=>B("undergrads",t)},`undergrad-${t}`))})})})]})]}),j&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"w-full max-w-lg p-6 rounded-xl max-h-[90vh] overflow-y-auto",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:[e.jsxs("h2",{className:"text-lg font-bold mb-4",style:{color:"var(--text-primary)"},children:[f!==null?"Edit":"Add"," ",c==="undergrads"?"Undergraduate":"Team Member"]}),e.jsxs("form",{onSubmit:X,children:[c==="undergrads"?e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm mb-1",style:{color:"var(--text-secondary)"},children:"Name *"}),e.jsx("input",{type:"text",value:D,onChange:s=>k(s.target.value),className:"w-full px-3 py-2 rounded-lg",style:{background:"var(--bg-tertiary)",border:"1px solid var(--border)",color:"var(--text-primary)"},required:!0,placeholder:"Full name"})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm mb-1",style:{color:"var(--text-secondary)"},children:"Name *"}),e.jsx("input",{type:"text",value:o.name,onChange:s=>x({...o,name:s.target.value}),className:"w-full px-3 py-2 rounded-lg",style:{background:"var(--bg-tertiary)",border:"1px solid var(--border)",color:"var(--text-primary)"},required:!0,placeholder:"Full name"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm mb-1",style:{color:"var(--text-secondary)"},children:"Title *"}),e.jsx("input",{type:"text",value:o.title,onChange:s=>x({...o,title:s.target.value}),className:"w-full px-3 py-2 rounded-lg",style:{background:"var(--bg-tertiary)",border:"1px solid var(--border)",color:"var(--text-primary)"},required:!0,placeholder:"e.g., Associate Professor of Government"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm mb-1",style:{color:"var(--text-secondary)"},children:"Institution *"}),e.jsx("input",{type:"text",value:o.institution,onChange:s=>x({...o,institution:s.target.value}),className:"w-full px-3 py-2 rounded-lg",style:{background:"var(--bg-tertiary)",border:"1px solid var(--border)",color:"var(--text-primary)"},required:!0,placeholder:"e.g., Dartmouth College"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm mb-1",style:{color:"var(--text-secondary)"},children:"Photo URL"}),e.jsx("input",{type:"url",value:o.photo||"",onChange:s=>x({...o,photo:s.target.value}),className:"w-full px-3 py-2 rounded-lg",style:{background:"var(--bg-tertiary)",border:"1px solid var(--border)",color:"var(--text-primary)"},placeholder:"https://..."}),o.photo&&e.jsx("div",{className:"mt-2",children:e.jsx("img",{src:o.photo,alt:"Preview",className:"w-16 h-16 rounded-full object-cover",onError:s=>{s.target.style.display="none"}})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm mb-1",style:{color:"var(--text-secondary)"},children:"Website URL"}),e.jsx("input",{type:"url",value:o.website||"",onChange:s=>x({...o,website:s.target.value}),className:"w-full px-3 py-2 rounded-lg",style:{background:"var(--bg-tertiary)",border:"1px solid var(--border)",color:"var(--text-primary)"},placeholder:"https://..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm mb-1",style:{color:"var(--text-secondary)"},children:"Profile Link (internal)"}),e.jsx("input",{type:"text",value:o.profileLink||"",onChange:s=>x({...o,profileLink:s.target.value}),className:"w-full px-3 py-2 rounded-lg",style:{background:"var(--bg-tertiary)",border:"1px solid var(--border)",color:"var(--text-primary)"},placeholder:"/about/name"})]})]}),e.jsxs("div",{className:"flex gap-2 mt-6",children:[e.jsx("button",{type:"button",onClick:G,className:"flex-1 py-2 rounded-lg font-medium",style:{background:"var(--bg-tertiary)",color:"var(--text-secondary)",border:"1px solid var(--border)"},children:"Cancel"}),e.jsx("button",{type:"submit",className:"flex-1 py-2 rounded-lg font-medium",style:{background:"var(--accent)",color:"#fff"},children:f!==null?"Update":"Add"})]})]})]})})]})}export{ye as TeamAdmin};

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.