PageSourceSearch

https://lidomatrip.com/_next/static/chunks/pages/admin/settings/announcements-d594e4d5e06f228b.js

js lidomatrip.com collected 2026-10-02 20:26:14 UTC 13,886 bytes, 1 lines download raw bytes

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.