1import{r,Z as e,a3 as a,az as _,aA as h,ag as f,aB as g,$ as D}from"./vendor-mui-D5pLRgDb.js";import{U as E,r as M,d as j,e as P,T as I,v as L,H as R,I as U,M as l,A as k,o as H,a as Y}from"./index-BSFWpFMK.js";import{M as q}from"./ManageAlertsContainer-Ct_atg1l.js";import{S as v}from"./InputFields-BJUL-RVv.js";import{C as z}from"./DateTimePicker-avwAFAEf.js";import{T as B}from"./TextEditor-gGDzAoaG.js";import"./__commonjsHelpers__-BosuxZz1.js";import"./vendor-sweetalert2-CokzRhbv.js";import"./TwoColumnLayout-CEOrMY6p.js";import"./TopBanner-C3LORJp2.js";import"./vendor-react-csv-Uy1MYOCL.js";import"./BreadCrumbs-Ce1rw5PH.js";import"./TopBanner.module--qQpYJq9.js";import"./TwoColumnBox-gHXb3Blm.js";import"./CheckBox-Dkb41L1G.js";const F=()=>[{link:"/",name:"Home"},{link:"/alerts",name:"Alerts"},{link:null,name:"Create Alert"}],O="_form_e1psc_1",Z="_formGroup_e1psc_7",$="_inputGroup_e1psc_13",J="_description_e1psc_19",t={form:O,formGroup:Z,inputGroup:$,description:J};function pe(){const n=r.useContext(E),{dispatch:o}=n,{user:C}=n.state.userData,[c,y]=r.useState(""),[p,b]=r.useState(""),[u,A]=r.useState(null),[i,T]=r.useState("all"),[d,w]=r.useState(""),x=M();r.useEffect(()=>{C.isAdmin?o(j("Create Alert")):o(P(R)),o(I(!1))},[]);const S=async s=>{s.preventDefault();try{if((await U("Are you sure you want to post this alert? This cannot be reversed")).isConfirmed){await o(l(!0,"ajax"));const N={title:c,message:p,validTill:u,targetAudience:{type:i,contestCode:d}},G=await k.post("api/alerts",N);await o(l(!1,"ajax")),await H(G),x("/alerts")}}catch(m){Y(m)}finally{await o(l(!1,""))}};return e(q,{breadCrumbData:F(),rightColumnData:a("form",{className:t.form,onSubmit:S,children:[a("div",{className:t.formGroup,children:[e("label",{className:t.inputGroup,children:"Title"}),e(v,{props:{maxLength:500},type:"text",handleChange:y,value:c,required:!0}),a("div",{className:t.description,children:["This will only be used for internal reference, and will",e("b",{children:" never "}),"be shown to the public."]})]}),a("div",{className:t.formGroup,children:[e("label",{className:t.inputGroup,children:"Target Audience"}),a(_,{name:"target-audience",value:i,onChange:s=>T(s.target.value),children:[e(h,{value:"all",control:e(g,{color:"primary"}),label:e(f,{style:{fontSize:"14px"},children:"All users on CodeChef"})}),e(h,{value:"contest",control:e(g,{color:"primary"}),label:e(f,{style:{fontSize:"14px"},children:"Users from a particular contest"})}),i==="contest"&&a("div",{style:{paddingLeft:"30px"},children:[e(v,{props:{maxLength:500},type:"text",handleChange:w,value:d,placeholder:"Enter contest code",required:!0}),a("div",{className:t.description,children:[e("strong",{children:"Note: "}),"Users who have visited any page of the contest in the past, as well as users who will visit any page of the contest in the future, will get alert."]})]})]})]}),a("div",{className:t.formGroup,children:[e("label",{className:t.inputGroup,children:"Valid till Time (IST/ +05:30)"}),e(z,{value:u,handleChange:s=>{D.isDayjs(s)&&(s=s.format("YYYY-MM-DD HH:mm:ss")),A(s)},required:!0}),e("div",{className:t.description,children:"Time till which the specified set of users will get the alert."})]}),a("div",{className:t.formGroup,children:[e("label",{className:t.inputGroup,children:"Message"}),e(B,{data:p,height:200,handleChange:b}),e("div",{className:t.description,children:"Alert content that is supposed to be sent to the users."})]}),e(L,{title:"Publish Alert",type:"primary"})]})})}export{pe 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.