PageSourceSearch

https://lidomatrip.com/_next/static/chunks/pages/admin/messages-2db786ffca4df5c4.js

js lidomatrip.com collected 2026-09-25 07:11:02 UTC 16,963 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1060],{51554:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/messages",function(){return n(73298)}])},73298:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return F}});var a=n(10253),s=n(85893),r=n(67294),l=n(49759),i=n(44389),c=n(84858),o="/api/admin/sms",d=function(e){var t,n=new URLSearchParams;return e.phone&&n.set("phone",e.phone),e.cursor&&n.set("cursor",String(e.cursor)),n.set("take",String(null!==(t=e.take)&&void 0!==t?t:30)),(0,c.SC)("".concat(o,"/messages?").concat(n))},x=function(){return(0,c.SC)("".concat(o,"/templates"))},u=n(32474);function h(e){var t,n,a=e.details;return(null==a?void 0:a.staffEvent)?"اطلاع کارشناس — ".concat(null!==(t=a.recipientName)&&void 0!==t?t:""):null!==(n=null==a?void 0:a.template)&&void 0!==n?n:e.summary}function p(e){var t,n,a,r,l=e.row,i=null===(t=l.details)||void 0===t?void 0:t.sent,c=null===(n=l.details)||void 0===n?void 0:n.simulated;return!1===i?(0,s.jsx)(u.Ct,{tone:"red",children:null!==(r=null===(a=l.details)||void 0===a?void 0:a.reason)&&void 0!==r?r:"ارسال نشد"}):c?(0,s.jsx)(u.Ct,{tone:"yellow",children:"شبیه‌سازی (بدون کلید پروایدر)"}):(0,s.jsx)(u.Ct,{tone:"green",children:"ارسال شد"})}function m(e){var t,n,r,l,i,c,o,d,x,m=e.row,f=e.onClose;if(!m)return null;var v=(0,a.Z)((0,u.A1)(m.created_at),2),j=v[0],y=v[1],g=null!==(o=null!==(c=null===(t=m.details)||void 0===t?void 0:t.phone)&&void 0!==c?c:null===(n=m.user)||void 0===n?void 0:n.phone)&&void 0!==o?o:"-",N=null!==(x=null!==(d=null===(r=m.details)||void 0===r?void 0:r.recipientName)&&void 0!==d?d:null===(l=m.user)||void 0===l?void 0:l.name)&&void 0!==x?x:"";return(0,s.jsx)(u.u_,{open:!!m,onClose:f,title:"متن پیامک",children:(0,s.jsxs)("div",{className:"flex flex-col gap-y-16",children:[(0,s.jsx)("div",{className:"rounded-10 bg-gray-F5F5F7 p-14 text-14 leading-24 text-black whitespace-pre-wrap",children:(null===(i=m.details)||void 0===i?void 0:i.text)||"متن این پیامک ثبت نشده."}),(0,s.jsxs)("div",{className:"flex flex-col gap-y-8 text-13 leading-22",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-gray-6C6A7D",children:"گیرنده"}),(0,s.jsxs)("span",{dir:"ltr",className:"font-m-en",children:[g," ",!!N&&"— ".concat(N)]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-gray-6C6A7D",children:"زمان"}),(0,s.jsxs)("span",{children:[j," — ",y]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-gray-6C6A7D",children:"وضعیت"}),(0,s.jsx)(p,{row:m})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-gray-6C6A7D",children:"قالب / رویداد"}),(0,s.jsx)("span",{children:h(m)})]}),!!m.actor_name&&(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-gray-6C6A7D",children:"فرستنده"}),(0,s.jsx)("span",{children:m.actor_name})]}),!!m.reservation&&(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-gray-6C6A7D",children:"رزرو"}),(0,s.jsx)("a",{href:"/admin/reservations/".concat(m.reservation.id),className:"text-primary-dark",children:m.reservation.reference})]})]})]})})}function f(){var e,t=(0,a.Z)((0,r.useState)(""),2),n=t[0],l=t[1],c=(0,a.Z)((0,r.useState)(void 0),2),o=c[0],x=c[1],f=(0,a.Z)((0,r.useState)([]),2),v=f[0],j=f[1],y=(0,a.Z)((0,r.useState)(null),2),g=y[0],N=y[1],b="messages:".concat(n,":").concat(null!=o?o:""),w=(0,i.u)(b,function(){return d({phone:n||void 0,cursor:o,take:30})}),C=w.data,E=w.isLoading,A=w.error,k=v.length?v.flat():null!==(e=null==C?void 0:C.items)&&void 0!==e?e:[];return(0,s.jsxs)("div",{className:"flex flex-col gap-y-16",children:[(0,s.jsx)(u.Hf,{value:n,onChange:function(e){l(e),x(void 0),j([])},placeholder:"جستجو با شماره موبایل"}),(0,s.jsx)(u.Zb,{className:"overflow-x-auto",children:E&&!k.length?(0,s.jsx)("div",{className:"p-16 flex flex-col gap-y-8",children:Array.from({length:6}).map(function(e,t){return(0,s.jsx)(u.Od,{className:"h-[44px]"},t)})}):A?(0,s.jsx)("p",{className:"p-16 text-14 text-[#C62828]",children:"خطا در دریافت لاگ پیام‌ها"}):k.length?(0,s.jsxs)("table",{className:"w-full min-w-[860px] text-right border-collapse",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"bg-gray-F5F5F7 text-12 leading-18 text-gray-6C6A7D",children:[(0,s.jsx)("th",{className:"px-12 py-12 font-m whitespace-nowrap",children:"زمان"}),(0,s.jsx)("th",{className:"px-12 py-12 font-m whitespace-nowrap",children:"گیرنده"}),(0,s.jsx)("th",{className:"px-12 py-12 font-m",children:"قالب / رویداد"}),(0,s.jsx)("th",{className:"px-12 py-12 font-m whitespace-nowrap",children:"وضعیت"}),(0,s.jsx)("th",{className:"px-12 py-12 font-m whitespace-nowrap",children:"رزرو"})]})}),(0,s.jsx)("tbody",{className:"divide-y divide-gray-F0F0F0",children:k.map(function(e){var t,n,r,l,i,c,o,d,x,m=(0,a.Z)((0,u.A1)(e.created_at),2),f=m[0],v=m[1],j=null!==(o=null!==(c=null===(t=e.details)||void 0===t?void 0:t.phone)&&void 0!==c?c:null===(n=e.user)||void 0===n?void 0:n.phone)&&void 0!==o?o:"-",y=null!==(x=null!==(d=null===(r=e.details)||void 0===r?void 0:r.recipientName)&&void 0!==d?d:null===(l=e.user)||void 0===l?void 0:l.name)&&void 0!==x?x:"";return(0,s.jsxs)("tr",{onClick:function(){return N(e)},className:"hover:bg-gray-F5F5F7 transition align-top cursor-pointer",children:[(0,s.jsxs)("td",{className:"px-12 py-12 whitespace-nowrap text-13 text-gray-6C6A7D",children:[f,(0,s.jsx)("div",{className:"text-11 text-gray-9B9BAA",children:v})]}),(0,s.jsxs)("td",{className:"px-12 py-12 whitespace-nowrap text-13",children:[(0,s.jsx)("div",{dir:"ltr",className:"font-m-en",children:j}),!!y&&(0,s.jsx)("div",{className:"text-11 text-gray-9B9BAA",children:y})]}),(0,s.jsxs)("td",{className:"px-12 py-12 text-13 max-w-[280px]",children:[(0,s.jsx)("div",{className:"font-m",children:h(e)}),!!(null===(i=e.details)||void 0===i?void 0:i.text)&&(0,s.jsx)("div",{className:"text-11 text-gray-9B9BAA truncate",children:e.details.text})]}),(0,s.jsx)("td",{className:"px-12 py-12 whitespace-nowrap",children:(0,s.jsx)(p,{row:e})}),(0,s.jsx)("td",{className:"px-12 py-12 whitespace-nowrap text-13",children:e.reservation?(0,s.jsx)("a",{href:"/admin/reservations/".concat(e.reservation.id),className:"text-primary-dark",children:e.reservation.reference}):"-"})]},e.id)})})]}):(0,s.jsx)(u.ub,{text:"هیچ پیامکی ثبت نشده"})}),!!(null==C?void 0:C.next_cursor)&&(0,s.jsx)("button",{onClick:function(){(null==C?void 0:C.next_cursor)&&(j(function(e){return e.length?e:[C.items]}),x(C.next_cursor))},className:"self-center px-20 py-10 rounded-10 border border-gray-E5E5E6 text-13 text-gray-6C6A7D hover:bg-gray-F5F5F7 transition",children:"بیشتر"}),(0,s.jsx)(m,{row:g,onClose:function(){return N(null)}})]})}var v=n(47568),j=n(26042),y=n(69396),g=n(70655),N={guest:"مهمان",host:"میزبان",any:"هر دو"};function b(){var e=(0,i.u)("sms-templates",x),t=e.data,n=e.isLoading,a=e.error,r=e.mutate;function l(){return(l=(0,v.Z)(function(e){return(0,g.__generator)(this,function(n){switch(n.label){case 0:r((null!=t?t:[]).map(function(t){return t.name===e.name?(0,y.Z)((0,j.Z)({},t),{disabled:!e.disabled,overriddenInPanel:!0}):t}),!1),n.label=1;case 1:var a,s;return n.trys.push([1,3,,4]),[4,(a=e.name,s=!e.disabled,(0,c.SC)("".concat(o,"/templates/").concat(encodeURIComponent(a),"/toggle"),{method:"POST",body:JSON.stringify({disabled:s})}))];case 2:case 3:return n.sent(),r(),[3,4];case 4:return[2]}})})).apply(this,arguments)}return n?(0,s.jsx)("div",{className:"flex flex-col gap-y-8",children:Array.from({length:6}).map(function(e,t){return(0,s.jsx)(u.Od,{className:"h-[64px]"},t)})}):a||!t?(0,s.jsx)("p",{className:"text-14 text-[#C62828]",children:"خطا در دریافت قالب‌ها"}):t.length?(0,s.jsx)("div",{className:"flex flex-col gap-y-8",children:t.map(function(e){return(0,s.jsxs)(u.Zb,{className:"p-16 flex flex-col gap-y-8",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-x-12 flex-wrap",children:[(0,s.jsxs)("div",{className:"flex items-center gap-x-8 flex-wrap",children:[(0,s.jsx)("strong",{className:"text-14 leading-22 font-m text-black",children:e.label}),(0,s.jsx)(u.Ct,{tone:"blue",children:N[e.audience]}),e.voice&&(0,s.jsx)(u.Ct,{tone:"purple",children:"تماس صوتی"}),e.disabled&&(0,s.jsx)(u.Ct,{tone:"red",children:"غیرفعال"})]}),(0,s.jsx)(u.ZD,{checked:!e.disabled,onChange:function(){return function(e){return l.apply(this,arguments)}(e)},label:e.disabled?"غیرفعال":"فعال"})]}),(0,s.jsx)("p",{className:"text-13 leading-22 text-gray-6C6A7D",children:e.text}),(0,s.jsx)("p",{className:"text-11 leading-18 text-gray-9B9BAA",children:e.trigger})]},e.name)})}):(0,s.jsx)(u.ub,{text:"قالبی تعریف نشده"})}var w=n(14924),C="/api/admin/staff-notify",E=function(){return(0,c.SC)("".concat(C,"/recipients"))},A=[{key:"RESERVATION_CREATED",label:"ثبت درخواست"}
1,{key:"PENDING_PAYMENT",label:"در انتظار پرداخت"},{key:"FINALIZED",label:"قطعی شد"},{key:"EXPIRED",label:"منقضی شد"}];function k(e,t){var n,a;return null!==(a=null===(n=e.rules.find(function(e){return e.event===t}))||void 0===n?void 0:n.active)&&void 0!==a&&a}function D(e){var t=e.open,n=e.onClose,l=e.onSaved,i=e.recipient,o=(0,a.Z)((0,r.useState)(""),2),d=o[0],x=o[1],h=(0,a.Z)((0,r.useState)(""),2),p=h[0],m=h[1],f=(0,a.Z)((0,r.useState)(!0),2),N=f[0],b=f[1],E=(0,a.Z)((0,r.useState)({RESERVATION_CREATED:!1,PENDING_PAYMENT:!1,FINALIZED:!1,EXPIRED:!1}),2),D=E[0],_=E[1],S=(0,a.Z)((0,r.useState)(!1),2),F=S[0],Z=S[1];function I(){return(I=(0,v.Z)(function(){var e,t;return(0,g.__generator)(this,function(a){var s,r,o;switch(a.label){case 0:if(!d.trim()||!p.trim())return[2];Z(!0),a.label=1;case 1:if(a.trys.push([1,,7,8]),!i)return[3,3];return[4,(s=i.id,r={name:d.trim(),phone:p.trim(),active:N},(0,c.SC)("".concat(C,"/recipients/").concat(s),{method:"PATCH",body:JSON.stringify(r)}))];case 2:return t=a.sent().id,[3,5];case 3:return[4,(o={name:d.trim(),phone:p.trim()},(0,c.SC)("".concat(C,"/recipients"),{method:"POST",body:JSON.stringify(o)}))];case 4:t=a.sent().id,a.label=5;case 5:return e=t,[4,Promise.all(A.map(function(t){var n,a;return n=t.key,a=D[t.key],(0,c.SC)("".concat(C,"/recipients/").concat(e,"/rules/").concat(n),{method:"PUT",body:JSON.stringify({active:a})})}))];case 6:return a.sent(),l(),n(),[3,8];case 7:return Z(!1),[7];case 8:return[2]}})})).apply(this,arguments)}return(0,r.useEffect)(function(){var e,n,a;t&&(x(null!==(e=null==i?void 0:i.name)&&void 0!==e?e:""),m(null!==(n=null==i?void 0:i.phone)&&void 0!==n?n:""),b(null===(a=null==i?void 0:i.active)||void 0===a||a),_({RESERVATION_CREATED:!!i&&k(i,"RESERVATION_CREATED"),PENDING_PAYMENT:!!i&&k(i,"PENDING_PAYMENT"),FINALIZED:!!i&&k(i,"FINALIZED"),EXPIRED:!!i&&k(i,"EXPIRED")}))},[t,i]),(0,s.jsx)(u.u_,{open:t,onClose:n,title:i?"ویرایش کارشناس":"افزودن کارشناس",children:(0,s.jsxs)("div",{className:"flex flex-col gap-y-16",children:[(0,s.jsx)(u.gN,{label:"نام",children:(0,s.jsx)(u.II,{value:d,onChange:function(e){return x(e.target.value)},placeholder:"مثلا مریم — مدیر فروش"})}),(0,s.jsx)(u.gN,{label:"شماره موبایل",children:(0,s.jsx)(u.II,{value:p,onChange:function(e){return m(e.target.value)},placeholder:"09xxxxxxxxx",dir:"ltr"})}),(0,s.jsx)(u.ZD,{checked:N,onChange:b,label:N?"فعال":"غیرفعال — پیامکی برایش نمی‌رود"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"block mb-8 text-12 leading-18 text-gray-6C6A7D font-m",children:"برای کدام مرحله‌ی رزرو پیامک بگیرد؟"}),(0,s.jsx)("div",{className:"flex flex-col gap-y-8",children:A.map(function(e){var t=D[e.key];return(0,s.jsxs)("button",{type:"button","aria-pressed":t,onClick:function(){return _(function(t){return(0,y.Z)((0,j.Z)({},t),(0,w.Z)({},e.key,!t[e.key]))})},className:"flex items-center justify-between px-14 py-10 rounded-10 border transition text-right ".concat(t?"border-primary-main bg-primary-light":"border-gray-E5E5E6 hover:bg-gray-F5F5F7"),children:[(0,s.jsx)("span",{className:"text-13 ".concat(t?"text-primary-dark font-m":"text-black"),children:e.label}),(0,s.jsx)("span",{className:"w-20 h-20 rounded-6 flex items-center justify-center border transition ".concat(t?"bg-primary-main border-primary-main text-white":"border-gray-D2D2D7 bg-white"),children:t&&(0,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:(0,s.jsx)("path",{d:"M2 6L5 9L10 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},e.key)})})]}),(0,s.jsx)(u.zx,{onClick:function(){return I.apply(this,arguments)},disabled:F||!d.trim()||!p.trim(),className:"self-start",children:i?"ذخیره":"افزودن"})]})})}function _(){var e=(0,i.u)("staff-notify-recipients",E),t=e.data,n=e.isLoading,l=e.error,o=e.mutate,d=(0,a.Z)((0,r.useState)(null),2),x=d[0],h=d[1];function p(){return(p=(0,v.Z)(function(e){return(0,g.__generator)(this,function(t){switch(t.label){case 0:var n;if(!window.confirm("\xab".concat(e.name,"\xbb حذف شود؟")))return[2];return[4,(n=e.id,(0,c.SC)("".concat(C,"/recipients/").concat(n),{method:"DELETE"}))];case 1:return t.sent(),o(),[2]}})})).apply(this,arguments)}return(0,s.jsxs)("div",{className:"flex flex-col gap-y-16",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsx)("p",{className:"text-13 leading-22 text-gray-6C6A7D",children:"برای Ù
1‡Ø± کارشناس مشخص کن برای کدام مرحله از رزرو پیامک بگیرد."}),(0,s.jsx)(u.zx,{onClick:function(){return h("new")},children:"+ افزودن کارشناس"})]}),(0,s.jsx)(u.Zb,{className:"overflow-x-auto",children:n?(0,s.jsx)("div",{className:"p-16 flex flex-col gap-y-8",children:Array.from({length:3}).map(function(e,t){return(0,s.jsx)(u.Od,{className:"h-[48px]"},t)})}):l||!t?(0,s.jsx)("p",{className:"p-16 text-14 text-[#C62828]",children:"خطا در دریافت کارشناسان"}):t.length?(0,s.jsxs)("table",{className:"w-full min-w-[560px] text-right border-collapse",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"bg-gray-F5F5F7 text-12 leading-18 text-gray-6C6A7D",children:[(0,s.jsx)("th",{className:"px-12 py-12 font-m whitespace-nowrap",children:"کارشناس"}),(0,s.jsx)("th",{className:"px-12 py-12 font-m",children:"مراحل فعال"}),(0,s.jsx)("th",{className:"px-12 py-12 font-m whitespace-nowrap"})]})}),(0,s.jsx)("tbody",{className:"divide-y divide-gray-F0F0F0",children:t.map(function(e){return(0,s.jsxs)("tr",{className:"hover:bg-gray-F5F5F7 transition",children:[(0,s.jsxs)("td",{className:"px-12 py-12 whitespace-nowrap align-top",children:[(0,s.jsx)("div",{className:"text-13 font-m ".concat(e.active?"text-black":"text-gray-9B9BAA line-through"),children:e.name}),(0,s.jsx)("div",{dir:"ltr",className:"text-11 text-gray-9B9BAA",children:e.phone})]}),(0,s.jsx)("td",{className:"px-12 py-12 align-top",children:(0,s.jsxs)("div",{className:"flex flex-wrap gap-6",children:[A.filter(function(t){return k(e,t.key)}).map(function(e){return(0,s.jsx)(u.Ct,{tone:"green",children:e.label},e.key)}),!A.some(function(t){return k(e,t.key)})&&(0,s.jsx)("span",{className:"text-12 text-gray-9B9BAA",children:"هیچ مرحله‌ای انتخاب نشده"})]})}),(0,s.jsx)("td",{className:"px-12 py-12 whitespace-nowrap align-top",children:(0,s.jsxs)("div",{className:"flex items-center gap-x-12",children:[(0,s.jsx)("button",{onClick:function(){return h(e)},className:"text-12 text-primary-dark hover:underline",children:"ویرایش"}),(0,s.jsx)("button",{onClick:function(){return function(e){return p.apply(this,arguments)}(e)},className:"text-12 text-[#C62828] hover:underline",children:"حذف"})]})})]},e.id)})})]}):(0,s.jsx)(u.ub,{text:"هنوز کارشناسی اضافه نشده"})}),(0,s.jsx)(D,{open:null!==x,onClose:function(){return h(null)},onSaved:function(){return o()},recipient:x&&"new"!==x?x:null})]})}var S=[{key:"log",label:"پیام‌های ارسالی"},{key:"templates",label:"قالب‌های پیامکی"},{key:"staff",label:"اطلاع‌رسانی کارشناسان"}];function F(){var e=(0,a.Z)((0,r.useState)("log"),2),t=e[0],n=e[1];return(0,s.jsxs)(l.Z,{title:"مدیریت پیام‌ها",children:[(0,s.jsx)("div",{className:"mb-16",children:(0,s.jsx)(u.Qm,{tabs:S,value:t,onChange:n})}),"log"===t&&(0,s.jsx)(f,{}),"templates"===t&&(0,s.jsx)(b,{}),"staff"===t&&(0,s.jsx)(_,{})]})}}},function(e){e.O(0,[9791,9759,9774,2888,179],function(){return e(e.s=51554)}),_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.