PageSourceSearch

https://lidomatrip.com/_next/static/chunks/pages/admin/conversations-f87df199783f9369.js

js lidomatrip.com collected 2026-10-02 20:25:44 UTC 8,505 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4846],{73795:function(e,a,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/conversations",function(){return s(64625)}])},64625:function(e,a,s){"use strict";s.r(a);var t=s(85893),n=s(67294),i=s(11163),r=s(44389),l=s(49759),d=s(84858),c=s(32474);let o={OPEN:"yellow",PENDING:"blue",CLOSED:"gray"},x={OPEN:"باز",PENDING:"منتظر کاربر",CLOSED:"بسته"},u={GUEST:"مهمان",HOST:"میزبان",ADMIN:"پشتیبانی"},m=[{key:"all",label:"همه"},{key:"SUPPORT",label:"پشتیبانی"},{key:"BOOKING",label:"میزبان و مهمان"},{key:"unassigned",label:"واگذارنشده"},{key:"flagged",label:"علامت‌خورده"}];a.default=function(){var e,a;let s=(0,i.useRouter)(),[g,p]=(0,n.useState)("all"),[h,b]=(0,n.useState)(""),[y,j]=(0,n.useState)(null),[f,N]=(0,n.useState)(""),[v,w]=(0,n.useState)(!1),[E,S]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if(!s.isReady)return;let e=s.query.c,a=Number(Array.isArray(e)?e[0]:e);Number.isFinite(a)&&a>0&&j(a)},[s.isReady,s.query.c]);let{data:C}=(0,r.u)("/api/admin/conversations/stats",e=>(0,d.SC)(e).then(e=>e.data??e)),{data:_,isLoading:k,mutate:O}=(0,r.u)(function(e,a){let s=new URLSearchParams;("SUPPORT"===e||"BOOKING"===e)&&s.set("type",e),"flagged"===e&&s.set("flagged","1"),"unassigned"===e&&s.set("unassigned","1"),a.trim()&&s.set("q",a.trim()),s.set("pageSize","40");let t=s.toString();return`/api/admin/conversations${t?`?${t}`:""}`}(g,h),e=>(0,d.SC)(e).then(e=>e.data??e)),{data:P,mutate:F}=(0,r.u)(y?`/api/admin/conversations/${y}`:null,e=>(0,d.SC)(e).then(e=>e.data??e)),D=async()=>{let e=f.trim();if(e&&y&&!E){S(!0);try{await (0,d.SC)(`/api/admin/conversations/${y}/messages`,{method:"POST",body:JSON.stringify({body:e,internal:v})}),N(""),await Promise.all([F(),O()])}finally{S(!1)}}},T=async e=>{y&&(await (0,d.SC)(`/api/admin/conversations/${y}`,{method:"PATCH",body:JSON.stringify(e)}),await Promise.all([F(),O()]))},$=async e=>{await (0,d.SC)(`/api/admin/conversations/messages/${e}`,{method:"DELETE"}),await F()},A=(null==_?void 0:_.items)??[];return(0,t.jsxs)(l.Z,{title:"گفتگوها",breadcrumb:"مدیریت",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-16 md:grid-cols-3",children:[(0,t.jsx)(c.bB,{label:"پشتیبانی باز",value:(0,c.N)(null==C?void 0:C.open_support),icon:(0,t.jsx)("i",{"aria-hidden":"true",className:"icon-Information text-18"})}),(0,t.jsx)(c.bB,{label:"واگذارنشده",value:(0,c.N)(null==C?void 0:C.unassigned),icon:(0,t.jsx)("i",{"aria-hidden":"true",className:"icon-Timer text-18"})}),(0,t.jsx)(c.bB,{label:"علامت‌خورده",value:(0,c.N)(null==C?void 0:C.flagged),icon:(0,t.jsx)("i",{"aria-hidden":"true",className:"icon-Warning text-18"})})]}),(0,t.jsxs)("div",{className:"mt-16 flex flex-wrap items-center justify-between gap-12",children:[(0,t.jsx)(c.Qm,{tabs:m,value:g,onChange:p}),(0,t.jsx)(c.Hf,{value:h,onChange:b,placeholder:"نام، شماره، کد رزرو یا موضوع"})]}),(0,t.jsxs)("div",{className:"mt-16 grid grid-cols-1 gap-16 md:grid-cols-[380px_1fr]",children:[(0,t.jsx)("div",{className:"max-h-[70vh] overflow-y-auto rounded-12 border border-gray-E5E5E6 bg-white",children:k?(0,t.jsx)("div",{className:"space-y-8 p-12",children:[0,1,2,3].map(e=>(0,t.jsx)(c.Od,{className:"h-56 w-full rounded-10"},e))}):0===A.length?(0,t.jsx)(c.ub,{text:"گفتگویی با این فیلترها نیست"}):(0,t.jsx)("ul",{className:"divide-y divide-gray-F0F0F0",children:A.map(e=>{let a=e.participants.find(e=>"GUEST"===e.role),s=e.participants.find(e=>"HOST"===e.role);return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button",onClick:()=>j(e.id),className:`w-full px-14 py-12 text-right transition ${y===e.id?"bg-primary-main bg-opacity-[6%]":"hover:bg-gray-F7F7F7"}`,children:[(0,t.jsxs)("span",{className:"flex items-center justify-between gap-x-8",children:[(0,t.jsx)("span",{className:"truncate text-13 leading-20 font-m text-black",children:"SUPPORT"===e.type?e.subject||"پشتیبانی":`${(null==a?void 0:a.name)||"مهمان"} ← ${(null==s?void 0:s.name)||"میزبان"}`}),(0,t.jsx)(c.Ct,{tone:o[e.status],children:x[e.status]})]}),(0,t.jsx)("span",{className:"mt-4 block truncate text-12 leading-18 text-gray-6C6A7D",children:e.last_message||"…"}),(0,t.jsxs)("span",{className:"mt-6 flex flex-wrap items-center gap-x-8 gap-y-4 text-11 leading-16 text-gray-B0AFBC",children:[(0,t.jsx)("span",{children:(0,c.IY)(e.last_message_at)}),e.booking&&(0,t.jsx)("span",{children:e.booking.reference}),e.flagged_count>0&&(0,t.jsxs)(c.Ct,{tone:"red",children:[(0,c.N)(e.flagged_count)," علامت"]}),!e.assigned_admin&&"SUPPORT"===e.type&&(0,t.jsx)(c.Ct,{tone:"yellow",children:"واگذارنشده"})]})]})},e.id)})})}),(0,t.jsx)("div",{className:"flex max-h-[70vh] flex-col overflow-hidden rounded-12 border border-gray-E5E5E6 bg-white",children:y?P?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-8 border-b border-gray-F0F0F0 p-14",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"truncate text-14 leading-22 font-m text-black",children:"SUPPORT"===P.type?P.subject||"پشتیبانی":null===(e=P.residence)||void 0===e?void 0:e.name}),(0,t.jsxs)("p",{className:"mt-2 truncate text-12 leading-18 text-gray-6C6A7D",children:[null===(a=P.participants)||void 0===a?void 0:a.map(e=>{var a;return`${u[e.role]??e.role}: ${(null===(a=e.user)||void 0===a?void 0:a.name)||"—"}`}).join(" \xb7 "),P.booking?` \xb7 ${P.booking.reference}`:""]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-x-6",children:[!P.assignedAdmin&&(0,t.jsx)(c.zx,{variant:"secondary",onClick:()=>T({assign_to_me:!0}),children:"واگذاری به من"}),"CLOSED"!==P.status?(0,t.jsx)(c.zx,{variant:"secondary",onClick:()=>T({status:"CLOSED"}),children:"بستن"}):(0,t.jsx)(c.zx,{variant:"secondary",onClick:()=>T({status:"OPEN"}),children:"بازکردن"})]})]}),(0,t.jsx)("div",{className:"flex-1 space-y-10 overflow-y-auto bg-gray-F7F7F7 p-14",children:P.messages.map(e=>{if("SYSTEM"===e.type)return(0,t.jsx)("p",{className:"mx-auto max-w-[440px] rounded-10 bg-white px-12 py-8 text-center text-12 leading-20 text-gray-6C6A7D",children:e.body},e.id);let a="INTERNAL_NOTE"===e.type;return(0,t.jsxs)("div",{className:`rounded-10 border p-10 ${a?"border-dashed border-[#
1E0B978] bg-[#FDF8EE]":"border-gray-E5E5E6 bg-white"}`,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-x-8 text-11 leading-16 text-gray-6C6A7D",children:[(0,t.jsxs)("span",{className:"font-m",children:[a&&"\uD83D\uDD12 یادداشت داخلی — ",e.sender_name||"—",e.sender_role?` (${u[e.sender_role]??e.sender_role})`:""]}),(0,t.jsxs)("span",{className:"flex items-center gap-x-8",children:[(0,t.jsx)("span",{children:(0,c.IY)(e.created_at)}),!e.deleted&&(0,t.jsx)("button",{type:"button",onClick:()=>$(e.id),className:"text-[#E53935] hover:underline",children:"حذف"})]})]}),(0,t.jsx)("p",{className:"mt-6 whitespace-pre-wrap break-words text-13 leading-22 text-black",children:e.deleted?"— حذف شده —":e.body})]},e.id)})}),(0,t.jsxs)("div",{className:"border-t border-gray-F0F0F0 p-12",children:[(0,t.jsx)("textarea",{rows:3,value:f,onChange:e=>N(e.target.value),placeholder:v?"یادداشتی که فقط تیم پشتیبانی می‌بیند…":"پاسخ شما — با نام \xabپشتیبانی لیدوماتریپ\xbb در گفتگو دیده می‌شود.",className:"w-full resize-y rounded-10 border border-gray-E5E5E6 px-12 py-10 text-14 leading-22 outline-none transition focus:border-primary-main"}),(0,t.jsxs)("div",{className:"mt-8 flex items-center justify-between gap-x-8",children:[(0,t.jsxs)("label",{className:"flex cursor-pointer items-center gap-x-6 text-12 leading-18 text-gray-6C6A7D",children:[(0,t.jsx)("input",{type:"checkbox",checked:v,onChange:e=>w(e.target.checked)}),"یادداشت داخلی (کاربر نمی‌بیند)"]}),(0,t.jsx)(c.zx,{onClick:D,disabled:!f.trim()||E,children:E?"در حال ارسال…":"ارسال"})]})]})]}):(0,t.jsx)("div",{className:"space-y-8 p-16",children:[0,1,2].map(e=>(0,t.jsx)(c.Od,{className:"h-40 w-full rounded-10"},e))}):(0,t.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,t.jsx)(c.ub,{text:"یک گفتگو را انتخاب کنید"})})})]})]})}}},function(e){e.O(0,[4389,9759,9774,2888,179],function(){return e(e.s=73795)}),_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.