PageSourceSearch

https://www.n4researchgroup.se/assets/PublicationEditor-DgYLUo-F.js

js n4researchgroup.se collected 2026-10-08 11:57:11 UTC 4,833 bytes, 2 lines download raw bytes

1import{r as C,j as e,c as F,h as E,o as L,H as T,B as j,a as _,C as k,q as D,s as S,b as q,x as p}from"./index-B7eNje79.js";import{u as J,t as O,F as U,a as n,b as o,c as l,d as c,f as b,e as d}from"./form-VZHjG0sa.js";import{u as B}from"./useAuth-0SwQWQDf.js";import{A as H}from"./AuthGuard-GYOB9I9n.js";import{A as I}from"./AdminNav-DPgl35CB.js";import{I as f}from"./input-b4SOZsWx.js";import{c as M,d as Y,e as R}from"./usePublications-CXMdt3su.js";import{A as W}from"./arrow-left-irBG8RfV.js";import{L as w}from"./loader-circle-CtTXJrLX.js";import{o as z,c as G,s as m}from"./types-DSeofJGI.js";import"./label-CmVjVsh6.js";import"./file-text-BddWyqAL.js";import"./useMutation-ByEjuL9J.js";const g=C.forwardRef(({className:i,...u},x)=>e.jsx("textarea",{className:F("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",i),ref:x,...u}));g.displayName="Textarea";const V=z({year:G.number().int().min(0,"Year must be 0 or greater"),authors:m().min(1,"Authors are required"),title:m().min(1,"Title is required"),journal:m().min(1,"Journal citation is required"),sort_date:m().optional()});function le(){const{id:i}=E(),u=L(),{signOut:x}=B(),r=!!i,{data:a,isLoading:v}=M(i),y=Y(),P=R(),t=J({resolver:O(V),defaultValues:{year:new Date().getFullYear(),authors:"",title:"",journal:"",sort_date:""}});C.useEffect(()=>{a&&t.reset({year:a.year,authors:a.authors,title:a.title,journal:a.journal,sort_date:a.sort_date||""})},[a,t]);const A=async s=>{try{const h={year:s.year,authors:s.authors,title:s.title,journal:s.journal,sort_date:s.sort_date||null};r?(await P.mutateAsync({id:i,...h}),p.success("Publication updated")):(await y.mutateAsync(h),p.success("Publication created")),u("/n4-manage/publications")}catch{p.error(r?"Failed to update publication":"Failed to create publication")}},N=y.isPending||P.isPending;return e.jsxs(H,{children:[e.jsxs(T,{children:[e.jsx("meta",{name:"robots",content:"noindex, nofollow"}),e.jsxs("title",{children:[r?"Edit Publication":"New Publication"," | Admin"]})]}),e.jsxs("div",{className:"min-h-screen bg-muted/30",children:[e.jsx(I,{onSignOut:x}),e.jsxs("main",{className:"container py-8",children:[e.jsx("div",{className:"mb-6",children:e.jsx(j,{asChild:!0,variant:"ghost",size:"sm",children:e.jsxs(_,{to:"/n4-manage/publications",children:[e.jsx(W,{className:"h-4 w-4 mr-2"}),"Back to Publications"]})})}),e.jsxs(k,{className:"max-w-2xl",children:[e.jsx(D,{children:e.jsx(S,{children:r?"Edit Publication":"New Publication"})}),e.jsx(q,{children:v&&r?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(w,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx(U,{...t,children:e.jsxs("form",{onSubmit:t.handleSubmit(A),className:"space-y-6",children:[e.jsx(n,{control:t.control,name:"year",render:({field:s})=>e.jsxs(o,{children:[e.jsx(l,{children:"Year"}),e.jsx(c,{children:e.jsx(f,{type:"number",min:0,placeholder:"e.g., 2025",...s})}),e.jsx(b,{children:'Use 0 for "Other Publications" category'}),e.jsx(d,{})]})}),e.jsx(n,{control:t.control,name:"authors",render:({field:s})=>e.jsxs(o,{children:[e.jsx(l,{children:"Authors"}),e.jsx(c,{children:e.jsx(g,{placeholder:"e.g., **Domellöf M**, Smith J, **West CE**",className:"min-h-[100px]",...s})}),e.jsxs(b,{children:["Wrap N4 member names in double asterisks to highlight them in teal, e.g., ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"**Magnus Domellöf**"})]}),e.jsx(d,{})]})}),e.jsx(n,{control:t.control,name:"title",render:({field:s})=>e.jsxs(o,{children:[e.jsx(l,{children:"Title"}),e.jsx(c,{children:e.jsx(g,{placeholder:"Publication title",className:"min-h-[80px]",...s})}),e.jsx(d,{})]})}),e.jsx(n,{control:t.control,name:"journal",render:({field:s})=>e.jsxs(o,{children:[e.jsx(l,{children:"Journal Citation"}),e.jsx(c,{children:e.jsx(f,{placeholder:"e.g., Acta Paediatr. 2025 Jun;114(6):1096-1097",...s})}),e.jsx(d,{})]})}),e.jsx(n,{control:t.control,name:"sort_date",render:({field:s})=>e.jsxs(o,{children:[e.jsx(l,{children:"Publication Date (for sorting)"}),e.jsx(c,{children:e.jsx(f,{type:"date",...s})}),e.jsx(b,{children:"Optional. Used to sort publications chronologically within each year. Latest date appears first."}),e.jsx(d,{})]})}),e.jsxs("div",{className:"flex gap-4 pt-4",children:[e.jsxs(j,{type:"submit",disabled:N,children:[N&&e.jsx(w,{className:"h-4 w-4 mr-2 animate-spin"}),r?"Update Publication":"Create Publication"]}),e.jsx(j,{type:"button",variant:"outline",onClick:()=>u("/n4-manage/publications"),children:"Cancel"})]})]})})})]})]})]})]})}export{le as default};
2//# sourceMappingURL=PublicationEditor-DgYLUo-F.js.map

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.