(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9521],{7099:function(e,t,l){(window.__NEXT_P=window.__NEXT_P||[]).push(["/Manager/Notifications/Create",function(){return l(2539)}])},9413:function(e,t,l){"use strict";var a=l(5893),r=l(1664),s=l.n(r),n=l(1163);let i=e=>{let{title:t,children:l,create:r}=e,i=(0,n.useRouter)();return(0,a.jsxs)("div",{className:"m-5 shadow rounded-3xl hover:shadow-2xl",children:[(0,a.jsxs)("div",{className:"border-b border-gray-200 py-3 px-4 flex justify-between",children:[(0,a.jsx)("h1",{className:"font-bold text-gray-900",children:t}),r&&(0,a.jsx)(s(),{href:i.route+"/Create",passHref:!0,legacyBehavior:!0,children:(0,a.jsx)("a",{className:"hover:text-green-600",children:(0,a.jsx)("span",{children:"افزودن"})})})]}),(0,a.jsx)("div",{className:"p-4 lg:h-[80vh] overflow-y-auto",children:l})]})};t.Z=i},5911:function(e,t,l){"use strict";var a=l(5893);let r=e=>{let{type:t,label:l,className:r,onClick:s,icon:n,id:i}=e;return(0,a.jsxs)("button",{className:"bg-theme-main text-white py-2 px-5 rounded-lg min-w-[80px] inline-flex items-center justify-center"+(r?" "+r:""),type:t,onClick:s,id:i,children:[n,l]})};t.Z=r},7474:function(e,t,l){"use strict";var a=l(5893),r=l(7038),s=l(7294);let n=e=>{let{options:t,defaultValue:l,label:n,id:i,dataSet:o,isMulti:d,className:u,style:c}=e,[h,p]=(0,s.useState)(null),[m,f]=(0,s.useState)(!1),x={div:"mb-2 relative"+(u?" "+u:""),label:1===c?"absolute -top-4 right-2 bg-theme-gray z-10 px-4":"mb-2 block",input:"!bg-transparent !border-theme-dark-gray !rounded-2xl py-2"};return(0,s.useEffect)(()=>{l&&!m?(p(t.find(e=>e.value===l)),f(!0)):l||f(!0)},[]),(0,a.jsxs)("div",{className:x.div,children:[(0,a.jsx)("label",{className:x.label,children:n}),m?(0,a.jsx)(r.ZP,{id:i,defaultValue:h,onChange:e=>{p(e),o(e)},isMulti:!!d&&d,options:t,classNames:{control:()=>1===c?x.input:null,indicatorSeparator:()=>"!hidden",dropdownIndicator:()=>"!text-black"},noOptionsMessage:()=>"-----",placeholder:"انتخاب کنید"}):(0,a.jsx)("div",{className:"w-full h-full bg-gray-200 rounded-lg animate-pulse"})]})};t.Z=n},9821:function(e,t,l){"use strict";var a=l(5893);let r=e=>{let{label:t,type:l,placeholder:r,onChange:s,onClick:n,defaultValue:i,value:o,name:d,id:u,onFocus:c,disabled:h}=e,p={div:"flex flex-col mb-2",label:"mb-2",input:"border border-gray-500 rounded-lg px-3 py-2"},m=e=>{let t=e.target.value;e.target.value=t.replace(/[^-a-zA-Z0-9-آ-ی\s+]+/gi,"").replace(/\s+/gi,"-").toLowerCase()};return(0,a.jsxs)("div",{className:p.div,children:[(0,a.jsx)("label",{className:p.label,htmlFor:d,children:t}),(0,a.jsx)("input",{type:l,placeholder:r,className:p.input,onChange:s,onClick:n,onFocus:c,name:d,id:u,disabled:!!h&&h,readOnly:!!h&&h,autoComplete:"off",onKeyUp:"slug"===l?m:void 0,defaultValue:i||o||void 0})]})};t.Z=r},1734:function(e,t,l){"use strict";var a=l(5893);let r=e=>{let{label:t,placeholder:l,onChange:r,defaultValue:s,name:n,disabled:i,id:o}=e,d={div:"flex flex-col mb-2",label:"mb-2",input:"border border-gray-500 rounded-lg px-3 py-2"};return(0,a.jsxs)("div",{className:d.div,children:[(0,a.jsx)("label",{className:d.label,htmlFor:n,children:t}),(0,a.jsx)("textarea",{placeholder:l,className:d.input,onChange:r,name:n,id:o,disabled:!!i&&i,readOnly:!!i&&i,autoComplete:"off",defaultValue:s})]})};t.Z=r},2539:function(e,t,l){"use strict";l.r(t),l.d(t,{__N_SSP:function(){return x}});var a=l(5893),r=l(4184),s=l(9413),n=l(5911),i=l(9821),o=l(2920),d=l(9552),u=l.n(d),c=l(7294),h=l(1163),p=l(1734),m=l(7474);let f=e=>{let{users:t,selected_receivers:l}=e,[d,f]=(0,c.useState)(l),x=(0,h.useRouter)(),b=async e=>{e.preventDefault();let t={title:e.target.title.value,content:e.target.content.value,receiver_id:JSON.stringify(d)},l=u().get("token");fetch("/api/notification/create",{body:JSON.stringify(t),method:"POST",headers:{Authorization:"bearer "+l}}).then(async e=>{if(200===e.status){let t=await e.json();o.Am.success("با موفقیت افزوده شد."),x.push("/Manager/Notifications/Edit/"+t.id)}else o.Am.error("خطا!")})},v=e=>{f(e.map(e=>e.value))};return(0,a.jsx)(r.Z,{title:"اعلانات - افزودن",children:(0,a.jsx)(s.Z,{title:"افزودن",children:(0,a.jsxs)("form",{onSubmit:b,children:[(0,a.jsx)(i.Z,{type:"text",label:"عنوان",id:"title",name:"title"}),(0,a.jsx)(p.Z,{type:"text",label:"محتوا",id:"content",name:"content"}),(0,a.jsx)(m.Z,{id:"receivers",dataSet:v,label:"دریافت کنندگان",isMulti:!0,options:t.map(e=>({value:e.id,label:e.userDetail.first_name+" "+e.userDetail.last_name}))}),(0,a.jsx)("div",{className:"text-left mt-3",children:(0,a.jsx)(n.Z,{type:"submit",label:"افزودن"})})]})})})};var x=!0;t.default=f}},function(e){e.O(0,[4617,1057,3874,699,7038,4184,9774,2888,179],function(){return e(e.s=7099)}),_N_E=e.O()}]);