PageSourceSearch

https://sorareinside.com/assets/EditSystemPostView-Bv-K8QBA.js

js sorareinside.com collected 2026-10-02 02:01:01 UTC 7,133 bytes, 2 lines download raw bytes

1import{o as re,x as ie,y as oe,e as l,U as ce,p as le,f as de,z as me,k as x,m as y,j as e,t as ue,v as pe,S as w,g as j,w as ge,E as he,G as p,a as I,F as H,H as fe,I as $,J as K,K as Q,M as xe,N as ye}from"./index-B7swmYTL.js";import{u as je,S as Se,U as Ee,L as we,I as Ie,P as be,C as Ce,R as a,T as Te}from"./TagSelector-COyjhUNs.js";import{I as _e}from"./IconArrowLeft-BjOPIHH3.js";import{S as b}from"./Switch-CYo6oQoZ.js";import{F as ve}from"./FileButton-zYKSSbvk.js";import"./use-move-CNjnwfFk.js";import"./clamp-BzB_x7IF.js";import"./LineupPosition-CjCqBXw_.js";import"./LazyNScoresPopoverDropdown-D362tX6A.js";import"./use-in-viewport-B7UyCjQI.js";import"./use-toggle-B6bl_c5G.js";import"./CartesianChart-DisticR2.js";import"./with-selector-D_dUv-BM.js";import"./ProjectedScoreReliabilityTooltip-D8U7Et4u.js";import"./moment-hm5YbRet.js";import"./Autocomplete-B9ErIGwa.js";(function(){try{var c=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};c.SENTRY_RELEASE={id:"2ca73fcccbc42b52d2e324a0d85c875e9ada24e2"};var d=new c.Error().stack;d&&(c._sentryDebugIds=c._sentryDebugIds||{},c._sentryDebugIds[d]="11b46d40-6ef4-426b-b860-d59398fe2059",c._sentryDebugIdIdentifier="sentry-dbid-11b46d40-6ef4-426b-b860-d59398fe2059")}catch{}})();const W=1e4,X=4,S=5*1024*1024,$e=()=>{const{postId:c}=re(),d=ie(),C=oe(),{currentUserIsSysAdmin:T}=l.useContext(ce),Y=le("(max-width: 50em)"),J=l.useRef(null),V=l.useRef(null),[_,v]=l.useState(!1),[P,A]=l.useState(!0),[M,k]=l.useState(!1),[R,D]=l.useState(""),[U,z]=l.useState(""),[L,N]=l.useState([]),[g,G]=l.useState([]),[h,F]=l.useState([]),n=je({extensions:[Se,Ee,we,Ie,be.configure({placeholder:"Edit announcement content..."}),Ce.configure({limit:W})],content:""}),{data:f,isLoading:Z}=de({queryKey:["posts",c],queryFn:async()=>await x().get(y.POSTS,{params:{postId:c}}),enabled:!!c}),r=l.useMemo(()=>{var t;return(t=f==null?void 0:f.data)==null?void 0:t[0]},[f]);l.useEffect(()=>{if(r){if(!T||r.type!=="SYSTEM_GENERATED"){d("/feed");return}v(!!r.is_pinned),A(r.is_featured),k(!!r.share_with_partners),D(r.title??""),z(r.excerpt??""),N((r.post_tags||[]).filter(t=>t.tag_type==="PLAYER"||t.tag_type==="TEAM").map(t=>({type:t.tag_type,id:t.tag_id,displayName:t.display_name}))),G((r.post_images||[]).map(t=>({storagePath:t.storage_path,imageUrl:t.image_url}))),n&&n.commands.setContent(r.content)}},[r,n,T,d]);const B=W-((n==null?void 0:n.storage.characterCount.characters())??0),ee=t=>{G(i=>i.filter(s=>s.storagePath!==t))},te=t=>{F(i=>i.filter(s=>s.id!==t))},se=t=>{g.length+h.length+t.length>X||t.forEach(s=>{if(s.size>S)return;const o=new FileReader;o.onload=m=>{F(E=>{var q;return[...E,{id:Math.random().toString(36).substring(7),file:s,preview:(q=m.target)==null?void 0:q.result}]})},o.readAsDataURL(s)})},O=async t=>{if(t.size>S){ye.show({title:"Image too large",message:`Images must be less than ${S/(1024*1024)}MB`,color:"red"});return}const i=new FormData;i.append("file",t);const s=await x().post(y.POST_IMAGES,i,{headers:{"Content-Type":"multipart/form-data"}});n==null||n.chain().focus().setImage({src:s.data.imageUrl}).run()},ae=async t=>{const i=t.clipboardData.items;for(let s=0;s<i.length;s++){const o=i[s];if(o.type.startsWith("image")){const m=o.getAsFile();m&&await O(m)}}},ne=async t=>{t.preventDefault();const i=Array.from(t.dataTransfer.files);for(const s of i)s.type.startsWith("image")&&await O(s)},u=me({mutationFn:async()=>{if(!c)throw new Error("Missing post id");const t=[];for(const o of h){const m=new FormData;m.append("file",o.file);const E=await x().post(y.POST_IMAGES,m,{headers:{"Content-Type":"multipart/form-data"}});t.push(E.data)}const i=[...g.map(o=>({imageUrl:o.imageUrl,storagePath:o.storagePath})),...t];return(await x().post(y.POSTS,{id:c,type:"SYSTEM_GENERATED",content:(n==null?void 0:n.getHTML())??"",title:R,excerpt:U,isPinned:_,isFeatured:P,shareWithPartners:M,tags:L.map(o=>({tag_type:o.type,tag_id:o.id,display_name:o.displayName})),images:i})).data},onSuccess:()=>{C.invalidateQueries({queryKey:["posts"]}),d(`/feed/${c}/${(r==null?void 0:r.slug)||""}`)}});return Z||!r?e.jsx(ue,{py:"xl",children:e.jsx(pe,{size:"sm"})}):e.jsxs(w,{maw:720,children:[e.jsx(j,{component:ge,to:"/feed",variant:"subtle",leftSection:e.jsx(_e,{size:16}),w:"fit-content",children:"Back to Feed"}),e.jsx(he,{withBorder:!0,children:e.jsxs(w,{gap:"sm",children:[e.jsxs(p,{justify:"space-between",align:"center",children:[e.jsx(I,{size:"sm",fw:600,children:"Edit System Announcement"}),e.jsxs(p,{gap:"md",children:[e.jsx(b,{checked:P,onChange:t=>A(t.currentTarget.checked),label:"On carousel"}),e.jsx(b,{checked:_,onChange:t=>v(t.currentTarget.checked),label:"Pin to feed top"}),e.jsx(b,{checked:M,onChange:t=>k(t.currentTarget.checked),label:"Share with partners"})]})]}),e.jsx(H,{placeholder:"Enter announcement title",value:R,onChange:t=>D(t.target.value)}),e.jsxs(w,{gap:"xs",children:[e.jsxs(a,{editor:n,children:[e.jsxs(a.Toolbar,{sticky:!0,stickyOffset:0,children:[e.jsxs(a.ControlsGroup,{children:[e.jsx(a.H1,{}),e.jsx(a.H2,{})]}),e.jsxs(a.ControlsGroup,{children:[e.jsx(a.Bold,{}),e.jsx(a.Italic,{}),e.jsx(a.Underline,{})]}),e.jsxs(a.ControlsGroup,{children:[e.jsx(a.BulletList,{}),e.jsx(a.OrderedList,{}),!Y&&e.jsx(a.Blockquote,{})]}),e.jsx(a.ControlsGroup,{children:e.jsx(a.Link,{})})]}),e.jsx(a.Content,{ref:J,onPaste:ae,onDrop:ne})]}),e.jsxs(I,{ta:"right",size:"xs",c:B>0?"dimmed":"red",children:[B," characters remaining"]})]}),e.jsx(H,{label:"Announcement excerpt",description:"A one-liner summary (max 120 characters)",mb:"md",maxLength:120,placeholder:"Enter announcement excerpt",value:U,onChange:t=>z(t.currentTarget.value)}),(g.length>0||h.length>0)&&e.jsxs(fe,{cols:2,spacing:"xs",children:[g.map(t=>e.jsxs("div",{style:{position:"relative"},children:[e.jsx($,{src:t.imageUrl,alt:"Existing image",radius:"md",height:120,fit:"cover"}),e.jsx(K,{color:"gray",variant:"filled",size:"sm",style:{position:"absolute",top:8,right:8},onClick:()=>ee(t.storagePath),children:e.jsx(Q,{size:14})})]},t.storagePath)),h.map(t=>e.jsxs("div",{style:{position:"relative"},children:[e.jsx($,{src:t.preview,alt:"New image",radius:"md",height:120,fit:"cover"}),e.jsx(K,{color:"gray",variant:"filled",size:"sm",style:{position:"absolute",top:8,right:8},onClick:()=>te(t.id),children:e.jsx(Q,{size:14})})]},t.id))]}),e.jsxs(p,{align:"flex-end",justify:"space-between",children:[e.jsx(Te,{ref:V,selectedTags:L,onTagsChange:N}),e.jsxs(p,{children:[e.jsx(ve,{onChange:se,accept:"image/*",multiple:!0,children:t=>e.jsx(j,{...t,size:"xs",variant:"light",leftSection:e.jsx(xe,{size:16}),children:"Add images"})}),e.jsxs(I,{size:"xs",c:"dimmed",children:["Up to ",X," images, first one will be thumbnail. Max ",S/(1024*1024),"MB each"]})]}),e.jsxs(p,{gap:"xs",children:[e.jsx(j,{onClick:()=>d(-1),color:"gray",variant:"outline",disabled:u.isPending,loading:u.isPending,children:"Cancel"}),e.jsx(j,{onClick:()=>u.mutate(),disabled:!n||n.isEmpty||u.isPending,loading:u.isPending,w:"fit-content",ml:"auto",children:"Save"})]})]})]})})]})};export{$e as default};
2//# sourceMappingURL=EditSystemPostView-Bv-K8QBA.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.