PageSourceSearch

https://edgemxtiming.com/assets/RaceFeedPage-Ckx6Whjx.js

js edgemxtiming.com collected 2026-09-24 14:42:55 UTC 13,429 bytes, 10 lines download raw bytes

1import{r as m,j as e,b as P,S as I,n as F,o as z,q as L,t as A,I as Z,B as x,s as $,u as h,m as B,X as ee,P as se}from"./index-BCH4IFx8.js";import{B as w}from"./BpSpinner-Bqvfph1h.js";import{u as ae,a as te,b as ne,c as ie}from"./useRaceFeed-CLeEh0wE.js";import{b as re}from"./useEvents-Ck6r64Ep.js";import{C as W,b as le,c as ce,a as O}from"./card-DaE3Hwfn.js";import{T as q}from"./textarea-C9Po2OuC.js";import{S as de}from"./switch-D8RIYbw7.js";import{R as G,u as oe,E as me,M as he,a as xe,b as ue,c as ge}from"./useRaceFeedComments-UpmC3DGR.js";import{P as D}from"./pin-DJNsHPuq.js";import{I as pe}from"./image-plus-Da7jXNUn.js";import{S as je}from"./send-CJD-Z0Nl.js";import{A as fe,a as Ne,b as be,c as ve,d as ye,e as we,f as Ce,g as Se,h as Pe}from"./alert-dialog-CJdQZTQ5.js";import{S as _e,a as ke,b as Ae,c as De,d as Te,e as Ue}from"./sheet-CPIBZrRk.js";import{P as Re}from"./pin-off-DHvP-aDj.js";import{P as Ee}from"./pen-DnmiT5dx.js";import{T as Ie}from"./trash-2-CrxPrdNf.js";import{S as Fe}from"./save-C6KbuPF0.js";import{T as ze}from"./thumbs-up-lKUbd0LV.js";import{T as Le}from"./thumbs-down-Bw1mgNVr.js";import{f as $e}from"./formatDistanceToNow-nzxXZqmT.js";import{g as Be}from"./baseUrl-1OnSOMcw.js";import{M}from"./megaphone-DSpUXlnT.js";import{C as H}from"./copy-CIGjrFWu.js";import"./chevron-left-BfsUvDbz.js";import"./sanitized-html-DPAQvfI8.js";import"./purify.es-C5KSVp3G.js";import"./en-US-CGO0aXMi.js";import"./differenceInCalendarMonths-D2gXU8RP.js";import"./endOfMonth--R-WtYph.js";import"./differenceInMilliseconds-CVPzdaho.js";const Me=[{value:"update",label:"Update"},{value:"weather",label:"Weather"},{value:"schedule_change",label:"Schedule Change"},{value:"cancellation",label:"Cancellation"},{value:"info",label:"Info"}];function He({organizationId:s,events:l=[]}){const[t,c]=m.useState(""),[p,n]=m.useState(""),[u,g]=m.useState("update"),[j,f]=m.useState("none"),[i,r]=m.useState(!1),[b,C]=m.useState(null),[d,T]=m.useState(!1),U=m.useRef(null),_=ae(),V=a=>{const o=U.current;if(!o){c(k=>`${k}${k.endsWith(`
2`)||k===""?"":`
3
4`}${a}`);return}const N=o.selectionStart??t.length,S=o.selectionEnd??t.length,v=t.slice(0,N),y=t.slice(S),J=v.length>0&&!v.endsWith(`
5`),K=y.length>0&&!y.startsWith(`
6`),R=(J?`
7
8`:"")+a+(K?`
9
10`:""),Q=v+R+y;c(Q);const E=v.length+R.length;requestAnimationFrame(()=>{o.focus();try{o.setSelectionRange(E,E)}catch{}})},Y=async a=>{T(!0);try{const o=a.name.split(".").pop(),N=`${s}/race-feed/${Date.now()}.${o}`,{error:S}=await $.storage.from("org-assets").upload(N,a,{upsert:!1});if(S)throw S;const{data:v}=$.storage.from("org-assets").getPublicUrl(N),y=v.publicUrl;V(`![](${y})`),b||C(y)}catch(o){h.error(o.message||"Image upload failed")}finally{T(!1)}},X=async()=>{if(!t.trim()){h.error("Post content is required");return}try{await _.mutateAsync({organization_id:s,content:t.trim(),link_url:p.trim()||null,image_url:b,category:u,event_id:j==="none"?null:j,is_pinned:i,is_published:!0}),h.success("Post published"),c(""),n(""),C(null),r(!1),g("update"),f("none")}catch(a){h.error(a.message||"Failed to publish post")}};return e.jsxs(W,{children:[e.jsx(le,{children:e.jsx(ce,{className:"text-lg",children:"New Post"})}),e.jsxs(O,{className:"space-y-4",children:[e.jsx(q,{ref:U,placeholder:"What's happening at the race? (e.g., 'Practice delayed 30 min due to weather')",value:t,onChange:a=>c(a.target.value),rows:5,maxLength:4e3}),e.jsxs("p",{className:"text-xs text-muted-foreground -mt-2",children:["Click ",e.jsx("em",{children:"Add image"})," to drop a photo at the cursor — it'll appear right where you placed it."]}),t.trim()&&e.jsxs("div",{className:"border rounded-md p-3 bg-muted/30",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Preview"}),e.jsx(G,{content:t})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Category"}),e.jsxs(I,{value:u,onValueChange:a=>g(a),children:[e.jsx(F,{children:e.jsx(z,{})}),e.jsx(L,{children:Me.map(a=>e.jsx(A,{value:a.value,children:a.label},a.value))})]})]}),l.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Tag to event (optional)"}),e.jsxs(I,{value:j,onValueChange:f,children:[e.jsx(F,{children:e.jsx(z,{})}),e.jsxs(L,{children:[e.jsx(A,{value:"none",children:"None"}),l.map(a=>e.jsx(A,{value:a.id,children:a.name},a.id))]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{children:"Link (optional)"}),e.jsx(Z,{type:"url",placeholder:"https://...",value:p,onChange:a=>n(a.target.value)})]}),e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{id:"pin",checked:i,onCheckedChange:r}),e.jsxs(P,{htmlFor:"pin",className:"cursor-pointer flex items-center gap-1",children:[e.jsx(D,{className:"h-3.5 w-3.5"})," Pin to top"]}
10)]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{variant:"outline",size:"sm",asChild:!0,disabled:d,children:e.jsxs("label",{className:"cursor-pointer",children:[d?e.jsx(w,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(pe,{className:"h-4 w-4 mr-1"}),"Add image",e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:a=>{var N;const o=(N=a.target.files)==null?void 0:N[0];o&&Y(o),a.currentTarget.value=""}})]})}),e.jsxs(x,{onClick:X,disabled:_.isPending||!t.trim(),children:[_.isPending?e.jsx(w,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(je,{className:"h-4 w-4 mr-1"}),"Publish"]})]})]})]})]})}const We={update:"bg-primary/10 text-primary",weather:"bg-blue-500/10 text-blue-700 dark:text-blue-300",schedule_change:"bg-amber-500/10 text-amber-700 dark:text-amber-300",cancellation:"bg-destructive/10 text-destructive",info:"bg-muted text-muted-foreground"},Oe={update:"Update",weather:"Weather",schedule_change:"Schedule Change",cancellation:"Cancellation",info:"Info"};function qe({post:s}){const[l,t]=m.useState(!1),[c,p]=m.useState(s.content),[n,u]=m.useState(!1),g=te(),j=ne(),{data:f={}}=oe(s.organization_id),i=f[s.id],r=async()=>{try{await g.mutateAsync({id:s.id,is_pinned:!s.is_pinned}),h.success(s.is_pinned?"Unpinned":"Pinned")}catch(d){h.error(d.message)}},b=async()=>{if(c.trim())try{await g.mutateAsync({id:s.id,content:c.trim()}),t(!1),h.success("Updated")}catch(d){h.error(d.message)}},C=async()=>{try{await j.mutateAsync({id:s.id,organization_id:s.organization_id}),h.success("Post deleted")}catch(d){h.error(d.message)}};return e.jsx(W,{className:s.is_pinned?"border-primary/40":"",children:e.jsxs(O,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(B,{variant:"secondary",className:We[s.category]||"",children:Oe[s.category]||s.category}),s.is_pinned&&e.jsxs(B,{variant:"outline",className:"gap-1",children:[e.jsx(D,{className:"h-3 w-3"})," Pinned"]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[new Date(s.published_at).toLocaleString(),s.author_name&&` · ${s.author_name}`]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(x,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:r,disabled:g.isPending,children:s.is_pinned?e.jsx(Re,{className:"h-4 w-4"}):e.jsx(D,{className:"h-4 w-4"})}),e.jsx(x,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>t(d=>!d),children:l?e.jsx(ee,{className:"h-4 w-4"}):e.jsx(Ee,{className:"h-4 w-4"})}),e.jsxs(fe,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx(x,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",children:e.jsx(Ie,{className:"h-4 w-4"})})}),e.jsxs(be,{children:[e.jsxs(ve,{children:[e.jsx(ye,{children:"Delete this post?"}),e.jsx(we,{children:"This cannot be undone."})]}),e.jsxs(Ce,{children:[e.jsx(Se,{children:"Cancel"}),e.jsx(Pe,{onClick:C,className:"bg-destructive text-destructive-foreground",children:j.isPending?e.jsx(w,{className:"h-4 w-4 animate-spin"}):"Delete"})]})]})]})]})]}),l?e.jsxs("div",{className:"space-y-2",children:[e.jsx(q,{value:c,onChange:d=>p(d.target.value),rows:4}),e.jsxs(x,{size:"sm",onClick:b,disabled:g.isPending,children:[e.jsx(Fe,{className:"h-4 w-4 mr-1"})," Save"]})]}):e.jsxs(e.Fragment,{children:[s.content_format==="html"&&s.body_html?e.jsxs("div",{className:"space-y-2",children:[s.title&&e.jsx("h2",{className:"text-base font-semibold",children:s.title}),e.jsx(me,{html:s.body_html,clamped:!0})]}):e.jsx(G,{content:s.content,fallbackImageUrl:s.image_url,imageClassName:"rounded-md max-h-80 border my-2"}),s.link_url&&e.jsx("a",{href:s.link_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary underline break-all",children:s.link_url})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t text-xs text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ze,{className:"h-3.5 w-3.5"})," ",(i==null?void 0:i.like_count)??0]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Le,{className:"h-3.5 w-3.5"})," ",(i==null?void 0:i.dislike_count)??0]}),e.jsxs(_e,{open:n,onOpenChange:u,children:[e.jsx(ke,{asChild:!0,children:e.jsxs(x,{variant:"ghost",size:"sm",className:"h-7 px-2 gap-1 ml-auto",children:[e.jsx(he,{className:"h-3.5 w-3.5"}),(i==null?void 0:i.comment_count)??0," Moderate"]})}),e.jsxs(Ae,{side:"right",className:"w-full sm:max-w-md overflow-y-auto",children:[e.jsxs(De,{children:[e.jsx(Te,{children:"Moderate comments"}),e.jsx(Ue,{children:"Hide or delete comments on this post."})]}),e.jsx(Ge,{postId:s.id})]})]})]})]})})}function Ge({postId:s}
10){const{data:l=[],isLoading:t}=xe(s,!0),c=ue(),p=ge();return t?e.jsx("div",{className:"flex justify-center py-6",children:e.jsx(w,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):l.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No comments yet."}):e.jsx("ul",{className:"space-y-3 mt-4",children:l.map(n=>e.jsxs("li",{className:`border rounded-md p-3 space-y-1 ${n.is_hidden?"opacity-60 bg-muted/40":""}`,children:[e.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium text-xs",children:n.author_name}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:$e(new Date(n.created_at),{addSuffix:!0})}),n.is_hidden&&e.jsx("span",{className:"text-[10px] text-destructive font-medium",children:"Hidden"})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap break-words",children:n.content}),e.jsxs("div",{className:"flex gap-1 pt-1",children:[e.jsx(x,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>c.mutate({id:n.id,postId:s,hide:!n.is_hidden}),disabled:c.isPending,children:n.is_hidden?"Unhide":"Hide"}),e.jsx(x,{size:"sm",variant:"ghost",className:"h-7 text-xs text-destructive",onClick:()=>p.mutate({id:n.id,postId:s}),disabled:p.isPending,children:"Delete"})]})]},n.id))})}const ws=()=>{const{currentOrganization:s}=se(),l=s==null?void 0:s.id,{data:t=[],isLoading:c}=ie(l),{data:p=[]}=re(),n=p.filter(r=>r.organization_id===l).map(r=>({id:r.id,name:r.name})),u=s==null?void 0:s.slug,g=Be(),j=u?`${g}/embed/feed/${u}`:"",f=u?`${g}/org/${u}/feed`:"",i=(r,b)=>{navigator.clipboard.writeText(r),h.success(`${b} copied`)};return l?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"container mx-auto p-4 md:p-8 max-w-3xl space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(M,{className:"h-7 w-7 text-primary"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Race Feed"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Post live updates visible on your branded site and embeds."})]})]}),u&&e.jsxs("div",{className:"rounded-lg border bg-muted/30 p-3 space-y-2 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Public feed URL"}),e.jsx("p",{className:"truncate font-mono text-xs",children:f})]}),e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>i(f,"Public URL"),children:e.jsx(H,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Embed URL (for edgemxtiming.com)"}),e.jsx("p",{className:"truncate font-mono text-xs",children:j})]}),e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>i(`<iframe src="${j}" style="width:100%;height:600px;border:0" loading="lazy" allowfullscreen></iframe>`,"Iframe snippet"),children:e.jsx(H,{className:"h-3.5 w-3.5"})})]})]}),e.jsx(He,{organizationId:l,events:n}),e.jsx("div",{className:"space-y-3",children:c?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(w,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(M,{className:"h-10 w-10 mx-auto mb-2 opacity-30"}),e.jsx("p",{children:"No posts yet. Publish your first update above."})]}):t.map(r=>e.jsx(qe,{post:r},r.id))})]})}):e.jsx(e.Fragment,{children:e.jsx("div",{className:"container mx-auto p-8",children:e.jsx("p",{className:"text-muted-foreground",children:"Select an organization to manage the race feed."})})})};export{ws 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.