1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2940],{66660:function(e,l,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/settings/announcements",function(){return t(27196)}])},27196:function(e,l,t){"use strict";t.r(l),t.d(l,{default:function(){return u}});var a=t(85893),r=t(67294),i=t(41664),s=t.n(i),n=t(44389),d=t(49759),o=t(84858),c=t(32474);let x={ALL:"ÙÙ
٠کاربراÙ",HOSTS:"ÙÙØ· Ù
ÛØ²Ø¨Ø§ÙâÙØ§",GUESTS:"ÙÙØ· Ù
ÙÙ
اÙâÙØ§"},g={BANNER:"ÙÙØ§Ø± در Ù¾ÛØ´Ø®ÙاÙ",MODAL:"Ù¾ÙØ¬Ø±ÙâÛ Ø¨Ø§Ø²Ø´Ù"},m={title:"",body:"",imageUrl:"",linkUrl:"",linkLabel:"",audience:"ALL",style:"BANNER",isActive:!0,startsAt:"",endsAt:"",sortOrder:0,maxViews:"",backgroundColor:"",textColor:"",titleBold:!0,dashedBorder:!1,imageUrlMobile:""};function u(){let[e,l]=(0,r.useState)(null),[t,i]=(0,r.useState)(!1),{data:m,isLoading:u,mutate:b}=(0,n.u)("/api/admin/announcements",e=>(0,o.SC)(e));async function j(e){await (0,o.SC)(`/api/admin/announcements/${e.id}`,{method:"PATCH",body:JSON.stringify({isActive:!e.isActive})}),b()}return(0,a.jsxs)(d.Z,{title:"Ø§Ø·ÙØ§Ø¹ÛÙâÙØ§",breadcrumb:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s(),{href:"/admin",children:"Ø¯Ø§Ø´Ø¨ÙØ±Ø¯"})," / ",(0,a.jsx)(s(),{href:"/admin/settings",children:"ØªÙØ¸ÛÙ
ات"})]}),actions:(0,a.jsx)(c.zx,{onClick:()=>i(!0),children:"Ø§Ø·ÙØ§Ø¹ÛÙ Ø¬Ø¯ÛØ¯"}),children:[u?(0,a.jsx)(c.Od,{className:"h-[300px]"}):(null==m?void 0:m.length)?(0,a.jsx)("div",{className:"flex flex-col gap-y-12",children:m.map(e=>{var t;return(0,a.jsx)(c.Zb,{className:"p-16",children:(0,a.jsxs)("div",{className:"flex items-start justify-between gap-x-12 flex-wrap gap-y-10",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-x-8 flex-wrap gap-y-6 mb-6",children:[(0,a.jsx)("span",{className:"text-15 leading-24 font-m text-black",children:e.title}),e.isLive?(0,a.jsx)(c.Ct,{tone:"green",children:"در ØØ§Ù ÙÙ
Ø§ÛØ´"}):e.isActive?(0,a.jsx)(c.Ct,{tone:"yellow",children:"خارج از بازÙâÛ Ø²Ù
اÙÛ"}):(0,a.jsx)(c.Ct,{tone:"gray",children:"خاÙ
ÙØ´"}),(0,a.jsx)(c.Ct,{tone:"purple",children:x[e.audience]}),(0,a.jsx)(c.Ct,{tone:"gray",children:g[e.style]})]}),!!e.body&&(0,a.jsx)("p",{className:"text-13 leading-22 text-gray-6C6A7D whitespace-pre-line",children:e.body}),(0,a.jsxs)("p",{className:"text-11 leading-18 text-gray-9B9BAA mt-6",children:[e.startsAt||e.endsAt?`از ${e.startsAt?(0,c.IY)(e.startsAt):"ÙÙ
ÛØ´Ù"} تا ${e.endsAt?(0,c.IY)(e.endsAt):"ÙÙ
ÛØ´Ù"}`:"بدÙÙ Ù
ØØ¯ÙØ¯ÛØª زÙ
اÙÛ",(null===(t=e.createdBy)||void 0===t?void 0:t.name)?` \xb7 ${e.createdBy.name}`:""]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-x-8 shrink-0",children:[(0,a.jsx)(c.ZD,{checked:e.isActive,onChange:()=>j(e)}),(0,a.jsx)(c.zx,{variant:"secondary",onClick:()=>l(e),children:"ÙÛØ±Ø§ÛØ´"})]})]})},e.id)})}):(0,a.jsxs)(c.Zb,{className:"p-20",children:[(0,a.jsx)(c.ub,{text:"Ø§Ø·ÙØ§Ø¹ÛÙâØ§Û Ø³Ø§Ø®ØªÙ ÙØ´Ø¯Ù"}),(0,a.jsx)("p",{className:"text-12 leading-20 text-gray-9B9BAA text-center mt-8",children:"Ø§Ø·ÙØ§Ø¹ÛÙâÙØ§ در Ù¾ÛØ´Ø®Ùا٠Ù
ÙÙ
اÙâÙØ§ Ù Ù
ÛØ²Ø¨Ø§ÙâÙØ§ ÙÙ
Ø§ÛØ´ داد٠Ù
ÛâØ´ÙÙØ¯."})]}),(0,a.jsx)(h,{open:t||!!e,announcement:e,onClose:()=>{i(!1),l(null)},onSaved:b})]})}function h(e){let{open:l,announcement:t,onClose:i,onSaved:s}=e,[n,d]=(0,r.useState)(m),[x,g]=(0,r.useState)(!1),[u,h]=(0,r.useState)(null),[j,p]=(0,r.useState)(null),v=(null==t?void 0:t.id)??"new";if(l&&j!==v){var C,y;d(t?{title:t.title,body:t.body??"",imageUrl:t.imageUrl??"",linkUrl:t.linkUrl??"",linkLabel:t.linkLabel??"",audience:t.audience,style:t.style,isActive:t.isActive,startsAt:(null===(C=t.startsAt)||void 0===C?void 0:C.slice(0,10))??"",endsAt:(null===(y=t.endsAt)||void 0===y?void 0:y.slice(0,10))??"",sortOrder:t.sortOrder,maxViews:null!=t.maxViews?String(t.maxViews):"",backgroundColor:t.backgroundColor??"",textColor:t.textColor??"",titleBold:t.titleBold,dashedBorder:t.dashedBorder,imageUrlMobile:t.imageUrlMobile??""}:m),h(null),p(v)}l||null===j||p(null);let N=(e,l)=>d(t=>({...t,[e]:l}));async function f(){if(!n.title.trim()){h("عÙÙØ§Ù Ø§Ø·ÙØ§Ø¹ÛÙ Ø§ÙØ²Ø§Ù
Û Ø§Ø³Øª");return}g(!0),h(null);try{let e=JSON.stringify({title:n.title.trim(),body:n.body.trim()||null,imageUrl:n.imageUrl.trim()||null,linkUrl:n.linkUrl.trim()||null,linkLabel:n.linkLabel.trim()||null,audie
1nce:n.audience,style:n.style,isActive:n.isActive,startsAt:n.startsAt||null,endsAt:n.endsAt||null,sortOrder:Number(n.sortOrder)||0,maxViews:n.maxViews.trim()?Number(n.maxViews):null,backgroundColor:n.backgroundColor.trim()||null,textColor:n.textColor.trim()||null,titleBold:n.titleBold,dashedBorder:n.dashedBorder,imageUrlMobile:n.imageUrlMobile.trim()||null});t?await (0,o.SC)(`/api/admin/announcements/${t.id}`,{method:"PATCH",body:e}):await (0,o.SC)("/api/admin/announcements",{method:"POST",body:e}),s(),i()}catch(e){h(e instanceof Error?e.message:"Ø°Ø®ÛØ±Ù ÙØ´Ø¯")}finally{g(!1)}}async function A(){if(t){g(!0);try{await (0,o.SC)(`/api/admin/announcements/${t.id}`,{method:"DELETE"}),s(),i()}catch(e){h(e instanceof Error?e.message:"ØØ°Ù ÙØ´Ø¯")}finally{g(!1)}}}return(0,a.jsxs)(c.u_,{open:l,onClose:i,title:t?"ÙÛØ±Ø§ÛØ´ Ø§Ø·ÙØ§Ø¹ÛÙ":"Ø§Ø·ÙØ§Ø¹ÛÙ Ø¬Ø¯ÛØ¯",width:"max-w-[880px]",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-20",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-y-12",children:[(0,a.jsx)(c.gN,{label:"عÙÙØ§Ù",children:(0,a.jsx)(c.II,{value:n.title,onChange:e=>N("title",e.target.value),placeholder:"Ù
Ø«ÙØ§Ù تغÛÛØ± Ø±ÙØ´ پرداخت"})}),(0,a.jsx)(c.gN,{label:"Ù
ت٠(Ø§Ø®ØªÛØ§Ø±Û)",children:(0,a.jsx)("textarea",{value:n.body,onChange:e=>N("body",e.target.value),rows:3,className:"w-full rounded-8 border border-gray-E3E3E8 px-12 py-10 text-14 leading-24 outline-none focus:border-primary resize-none"})}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-10",children:[(0,a.jsx)(c.gN,{label:"تصÙÛØ± دسکتاپ",hint:"خاÙÛ = بدÙ٠تصÙÛØ±",children:(0,a.jsx)(c.II,{value:n.imageUrl,onChange:e=>N("imageUrl",e.target.value),placeholder:"https://â¦",dir:"ltr"})}),(0,a.jsx)(c.gN,{label:"تصÙÛØ± Ù
ÙØ¨Ø§ÛÙ",hint:"خاÙÛ = ÙÙ
ا٠تصÙÛØ± دسکتاپ",children:(0,a.jsx)(c.II,{value:n.imageUrlMobile,onChange:e=>N("imageUrlMobile",e.target.value),placeholder:"https://â¦",dir:"ltr"})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-10",children:[(0,a.jsx)(c.gN,{label:"ÙÛÙÚ© (Ø§Ø®ØªÛØ§Ø±Û)",children:(0,a.jsx)(c.II,{value:n.linkUrl,onChange:e=>N("linkUrl",e.target.value),placeholder:"/residences/list",dir:"ltr"})}),(0,a.jsx)(c.gN,{label:"Ù
ت٠دکÙ
Ù",children:(0,a.jsx)(c.II,{value:n.linkLabel,onChange:e=>N("linkLabel",e.target.value),placeholder:"Ù
Ø´Ø§ÙØ¯Ù"})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-10",children:[(0,a.jsx)(c.gN,{label:"Ù
خاطب",children:(0,a.jsxs)(c.Ph,{value:n.audience,onChange:e=>N("audience",e.target.value),className:"w-full",children:[(0,a.jsx)("option",{value:"ALL",children:"ÙÙ
٠کاربراÙ"}),(0,a.jsx)("option",{value:"HOSTS",children:"ÙÙØ· Ù
ÛØ²Ø¨Ø§ÙâÙØ§"}),(0,a.jsx)("option",{value:"GUESTS",children:"ÙÙØ· Ù
ÙÙ
اÙâÙØ§"})]})}),(0,a.jsx)(c.gN,{label:"ÙØÙÙ ÙÙ
Ø§ÛØ´",children:(0,a.jsxs)(c.Ph,{value:n.style,onChange:e=>N("style",e.target.value),className:"w-full",children:[(0,a.jsx)("option",{value:"BANNER",children:"ÙÙØ§Ø± در Ù¾ÛØ´Ø®ÙاÙ"}),(0,a.jsx)("option",{value:"MODAL",children:"Ù¾ÙØ¬Ø±ÙâÛ Ø¨Ø§Ø²Ø´Ù"})]})})]}),"MODAL"===n.style&&(0,a.jsx)("p",{className:"text-11 leading-18 text-[#B26A00] -mt-6",children:"Ù¾ÙØ¬Ø±ÙâÛ Ø¨Ø§Ø²Ø´Ù Ø¬ÙÙÛ Ú©Ø§Ø± کاربر را Ù
ÛâÚ¯ÛØ±Ø¯. اگر Ø²ÛØ§Ø¯ Ø§Ø³ØªÙØ§Ø¯Ù Ø´ÙØ¯Ø کاربر ÛØ§Ø¯ Ù
ÛâÚ¯ÛØ±Ø¯ بدÙÙ Ø®ÙØ§ÙØ¯Ù Ø¨Ø¨ÙØ¯Ø¯ â Ø¨Ø±Ø§Û Ù
ÙØ§Ø±Ø¯ ÙØ§Ùعا٠Ù
ÙÙ
ÙÚ¯ÙØ´ Ø¯Ø§Ø±ÛØ¯."}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-10",children:[(0,a.jsx)(c.gN,{label:"Ø´Ø±ÙØ¹ ÙÙ
Ø§ÛØ´ (Ø§Ø®ØªÛØ§Ø±Û)",children:(0,a.jsx)(c.II,{type:"date",value:n.startsAt,onChange:e=>N("startsAt",e.target.value),dir:"ltr"})}),(0,a.jsx)(c.gN,{label:"Ù¾Ø§ÛØ§Ù ÙÙ
Ø§ÛØ´ (Ø§Ø®ØªÛØ§Ø±Û)",children:(0,a.jsx)(c.II,{type:"date",value:n.endsAt,onChange:e=>N("endsAt",e.target.value),dir:"ltr"})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-10",children:[(0,a.jsx)(c.gN,{label:"Ø¯ÙØ¹Ø§Øª ÙÙ
Ø§ÛØ´",hint:"خاÙÛ = ÙØ± بار \xb7 Û± = ÙÙØ· ÛÚ© بار",children:(0,a.jsx)(c.II,{value:n.maxViews,onChange:e=>N("maxViews",e.target.value.replace(/[^0-9]/g,"")),inputMode:"numeric",placeholder:"ÙØ± بار"})}),(0,a.jsx)(c.gN,{label:"ØªØ±ØªÛØ¨",hint:"Ú©ÙÚکتر Ø¨Ø§ÙØ§ØªØ±",children:(0,a.jsx)(c.II,{value:String(n.sortOrder),onChange:e=>N("sortOrder",Number(e.target.value.replace(/[^0-9]/g,""))||0),inputMode:"numeric"})})]}),(0,a.jsxs)("div",{className:"rounded-10 border border-gray-E5E5E6 p-12",children:[(0,a.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D mb-10",children:"Ø¸Ø§ÙØ±"}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-10 mb-10",children:[(0,a.jsx)(c.gN,{label:"رÙÚ¯ Ù¾Ø³âØ²Ù
ÛÙÙ",children:(0,a.jsxs)("div",{className:"flex items-center gap-x-8",children:[(0,a.jsx)("input",{type:"color",value:n.backgroundColor||"#E6FBF8",onChange:e=>N("backgroundColor",e.target.value),className:"w-40 h-40 rounded-8 border border-gray-E5E5E6 shrink-0"}),(0,a.jsx)(c.II,{value:n.backgroundColor,onChange:e=>N("backgroundColor",e.target.value),placeholder:"Ù¾ÛØ´âÙØ±Ø¶",dir:"ltr"})]})}),(0,a.jsx)(c.gN,{label:"رÙÚ¯ Ù
تÙ",children:(0,a.jsxs)("div",{className:"flex items-center gap-x-8",children:[(0,a.jsx)("input",{type:"color",value:n.textColor||"#000000",onChange:e=>N("textColor",e.target.value),className:"w-40 h-40 rounded-8 border border-gray-E5E5E6 shrink-0"}),(0,a.jsx)(c.II,{value:n.textColor,onChange:e=>N("textColor",e.target.value),placeholder:"Ù¾ÛØ´âÙØ±Ø¶",dir:"ltr"})]})})]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-6 mb-10",children:[{name:"Ù¾ÛØ´âÙØ±Ø¶",bg:"",fg:""},{name:"ÙØ´Ø¯Ø§Ø±",bg:"#FFF8EC",fg:"#7A4B00"},{name:"خطر",bg:"#FDECEC",fg:"#8A1C1C"},{name:"Ù
ÙÙÙ",bg:"#EAF7EA",fg:"#14600F"},{name:"Ø®ÙØ«Û",bg:"#F4F5F6",fg:"#2B3A55"}].map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>{N("backgroundColor",e.bg),N("textColor",e.fg)},className:"rounded-full border border-gray-E5E5E6 px-10 py-4 text-12 leading-18",style:{backgroundColor:e.bg||void 0,color:e.fg||void 0},children:e.name},e.name))}),(0,a.jsxs)("div",{className:"flex items-center gap-x-20 flex-wrap gap-y-8",children:[(0,a.jsxs)("label",{className:"flex items-center gap-x-8 text-13 text-gray-6C6A7D",children:[(0,a.jsx)(c.ZD,{checked:n.titleBold,onChange:e=>N("titleBold",e)}),"عÙÙØ§Ù پررÙÚ¯"]}),(0,a.jsxs)("label",{className:"flex items-center gap-x-8 text-13 text-gray-6C6A7D",children:[(0,a.jsx)(c.ZD,{checked:n.dashedBorder,onChange:e=>N("dashedBorder",e)}),"کادر خطâÚÛÙ"]})]})]}),(0,a.jsxs)("label",{className:"flex items-center gap-x-8 text-13 text-gray-6C6A7D",children:[(0,a.jsx)(c.ZD,{checked:n.isActive,onChange:e=>N("isActive",e)}),"ÙØ¹Ø§Ù"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-12 leading-20 text-gray-6C6A7D mb-8",children:"Ù¾ÛØ´âÙÙ
Ø§ÛØ´ â Ø¯ÙÛÙØ§Ù ÙÙ
ا٠ÚÛØ²Û ک٠کاربر Ù
ÛâØ¨ÛÙØ¯"}),(0,a.jsx)("div",{className:"rounded-12 bg-gray-F7F7F7 p-16",children:(0,a.jsx)(b,{draft:n})}),(0,a.jsxs)("p",{className:"text-11 leading-18 text-gray-9B9BAA mt-8",children:["MODAL"===n.style?"Ø¨Ù ØµÙØ±Øª Ù¾ÙØ¬Ø±ÙâÛ Ø¨Ø§Ø²Ø´Ù Ø±ÙÛ ØµÙØÙ Ø¨Ø§Ø² Ù
ÛâØ´ÙØ¯.":"Ø¨Ù ØµÙØ±Øª ÙÙØ§Ø±Ø Ø¨Ø§ÙØ§Û Ù¾ÛØ´Ø®ÙاÙ."," ",n.maxViews.trim()?`ØØ¯Ø§Ú©Ø«Ø± ${Number(n.maxViews).toLocaleStr
1ing("fa-IR")} بار Ø¨Ø±Ø§Û ÙØ± کاربر.`:"ÙØ± بار Ú©Ù Ù¾ÛØ´Ø®Ùا٠باز Ø´ÙØ¯."]}),(0,a.jsx)("p",{className:"text-11 leading-18 text-gray-9B9BAA mt-4",children:"ALL"===n.audience?"Ø¨Ø±Ø§Û ÙÙ
ÙâÛ Ú©Ø§Ø±Ø¨Ø±Ø§Ù ÙØ§Ø±Ø¯Ø´Ø¯Ù ÙÙ
Ø§ÛØ´ داد٠Ù
ÛâØ´ÙØ¯.":"HOSTS"===n.audience?"ÙÙØ· در Ù¾ÛØ´Ø®Ùا٠Ù
ÛØ²Ø¨Ø§ÙâÙØ§.":"ÙÙØ· در Ù¾ÛØ´Ø®Ùا٠Ù
ÙÙ
اÙâÙØ§."})]})]}),!!u&&(0,a.jsx)("p",{className:"mt-14 text-13 text-[#C62828]",children:u}),(0,a.jsxs)("div",{className:"mt-20 flex items-center justify-between gap-x-10",children:[(0,a.jsx)("div",{children:!!t&&(0,a.jsx)(c.zx,{variant:"danger",onClick:A,disabled:x,children:"ØØ°Ù"})}),(0,a.jsxs)("div",{className:"flex items-center gap-x-10",children:[(0,a.jsx)(c.zx,{variant:"secondary",onClick:i,disabled:x,children:"Ø§ÙØµØ±Ø§Ù"}),(0,a.jsx)(c.zx,{onClick:f,disabled:x||!n.title.trim(),children:x?"در ØØ§Ù Ø°Ø®ÛØ±Ùâ¦":"Ø°Ø®ÛØ±Ù"})]})]})]})}function b(e){let{draft:l}=e;if(!l.title.trim()&&!l.body.trim())return(0,a.jsx)("p",{className:"text-12 text-gray-9B9BAA text-center py-20",children:"عÙÙØ§Ù را بÙÙÛØ³Ûدâ¦"});let t=l.imageUrl.trim()||l.imageUrlMobile.trim();return(0,a.jsxs)("div",{className:`rounded-12 border-1 border-solid overflow-hidden ${l.backgroundColor?"":"bg-primary-light"} border-gray-CACFD3`,style:{backgroundColor:l.backgroundColor||void 0,borderStyle:l.dashedBorder?"dashed":void 0},children:[!!t&&(0,a.jsx)("img",{src:t,alt:"",className:"w-full max-h-[140px] object-cover"}),(0,a.jsxs)("div",{className:"p-14",children:[(0,a.jsx)("p",{className:`text-16 leading-26 ${l.titleBold?"font-b":"font-r"} text-black`,style:{color:l.textColor||void 0},children:l.title||"عÙÙØ§Ù Ø§Ø·ÙØ§Ø¹ÛÙ"}),!!l.body.trim()&&(0,a.jsx)("p",{className:"text-13 leading-22 text-gray-6C6A7D mt-4 whitespace-pre-line",style:{color:l.textColor||void 0},children:l.body}),!!l.linkUrl.trim()&&(0,a.jsx)("span",{className:"inline-block mt-12 rounded-8 bg-primary-main text-white text-13 leading-22 px-16 py-8",children:l.linkLabel.trim()||"Ù
Ø´Ø§ÙØ¯Ù"})]})]})}}},function(e){e.O(0,[4389,9759,9774,2888,179],function(){return e(e.s=66660)}),_N_E=e.O()}]);
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.