1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[742],{5305:(e,s,a)=>{"use strict";a.r(s),a.d(s,{default:()=>x});var t=a(85485),l=a(80290),r=a(38263),d=a(64476),n=a(5776),i=a(95581),c=a(85964),o=a(92995),m={new:"ÐовÑе",contacted:"ÐонÑакÑ",qualified:"ÐвалиÑиÑиÑован",proposal:"ÐÑедложение",negotiation:"ÐеÑеговоÑÑ",closed_won:"УÑпеÑ
",closed_lost:"ÐÑовал",spam:"Спам"};function x(){var e=(0,i.useRouter)(),[s,a]=(0,n.useState)(!0),[x,g]=(0,n.useState)(null),[h,u]=(0,n.useState)([]),[f,v]=(0,n.useState)(null),[p,j]=(0,n.useState)(null),[b,y]=(0,n.useState)(!1),[N,_]=(0,n.useState)(null),w=()=>(0,t._)(function*(){a(!0),g(null);try{var s=yield(0,o.RQ)("/api/v1/admin/crm/funnel"),l=yield Promise.all(s.map(e=>(0,t._)(function*(){try{var s=yield(0,o.RQ)("/api/v1/admin/crm/kanban?stage=".concat(e.stage_key));return{stage_id:0,stage_key:e.stage_key,stage_name:e.stage_name,stage_color:e.stage_color,leads:s||[]}}catch(s){return{stage_id:0,stage_key:e.stage_key,stage_name:e.stage_name,stage_color:e.stage_color,leads:[]}}})()));u(l)}catch(s){if(s instanceof o.ge&&"UNAUTHORIZED"===s.code)return void e.replace("/admin/login");g((null==s?void 0:s.message)||"Ðе ÑдалоÑÑ Ð·Ð°Ð³ÑÑзиÑÑ Ð´Ð°Ð½Ð½Ñе")}finally{a(!1)}})();(0,n.useEffect)(()=>{w()},[]);var k=e=>{e.preventDefault(),e.dataTransfer.dropEffect="move"};return(0,d.jsxs)(c.A,{title:"CRM - Ðанбан доÑка",children:[(0,d.jsxs)("div",{className:"h-full flex flex-col bg-gray-50",children:[(0,d.jsxs)("div",{className:"bg-white border-b px-6 py-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h1",{className:"text-2xl font-bold",children:"ÐоÑонка пÑодаж"}),(0,d.jsx)("p",{className:"text-gray-500 text-sm mt-1",children:"ÐеÑеÑаÑкивайÑе каÑÑоÑки Ð´Ð»Ñ Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ ÑÑапа"})]}),(0,d.jsxs)("div",{className:"flex gap-3",children:[(0,d.jsxs)("button",{onClick:w,className:"px-4 py-2 border rounded-lg hover:bg-gray-50 flex items-center gap-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"ÐбновиÑÑ"]}),(0,d.jsx)("button",{onClick:()=>e.push("/admin/leads"),className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700",children:"ÐÑе лидÑ"})]})]}),(0,d.jsx)("div",{className:"flex gap-6 mt-6",children:h.map(e=>(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:e.stage_color}}),(0,d.jsx)("span",{className:"text-sm",children:e.stage_name}),(0,d.jsx)("span",{className:"bg-gray-100 px-2 py-0.5 rounded text-xs font-medium",children:e.leads.length})]},e.stage_key))})]}),x&&(0,d.jsx)("div",{className:"bg-red-50 border border-red-200 text-red-600 px-4 py-3 mx-6 mt-4 rounded-lg",children:x}),s?(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,d.jsx)("div",{className:"animate-spin w-8 h-8 border-4 border-current border-t-transparent rounded-full"})}):(0,d.jsx)("div",{className:"flex-1 overflow-x-auto p-6",children:(0,d.jsx)("div",{className:"flex gap-4 h-full min-w-max",children:h.map(e=>(0,d.jsxs)("div",{className:"w-80 flex-shrink-0 rounded-lg border-2 ".concat(p===e.stage_key?"border-blue-400":"border-gray-200"," bg-gray-100 flex flex-col"),onDragOver:k,onDrop:s=>{let a;return a=e.stage_key,(0,t._)(function*(){if((s.preventDefault(),f)&&(v(null),Object.keys(m).find(e=>{var s;return null==(s=h.find(s=>s.stage_key===e))?void 0:s.leads.some(e=>e.id===f.id)})!==a)){u(e=>e.map(e=>(0,r._)((0,l._)({},e),{leads:e.leads.filter(e=>e.id!==f.id)})));try{yield(0,o.RQ)("/api/v1/admin/crm/leads/".concat(f.id,"/stage"),{method:"PUT",body:JSON.stringify({toStage:a})}),yield w()}catch(e){g((null==e?void 0:e.message)||"Ðе ÑдалоÑÑ Ð¿ÐµÑемеÑÑиÑÑ Ð»Ð¸Ð´"),yield w()}}})()},children:[(0,d.jsxs)("div",{className:"p-3 rounded-t-lg flex items-center justify-between",style:{backgroundColor:e.stage_color+"20"},children:[(0,d.jsx)("div",{className:"font-medium text-sm",children:e.stage_name}),(0,d.jsx)("div",{className:"bg-white px-2 py-0.5 rounded text-xs font-medium",children:e.leads.length})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-2 space-y-2",children:[e.leads.map((e,s)=>(0,d.jsxs)("div",{draggable:!0,onDragStart:s=>{v(e),s.dataTransfer.effectAllowed="move"},onClick:()=>{_(e),y(!0)},className:"bg-white rounded-lg p-3 shadow-sm cursor-move hover:shadow-md transition border border-gray-200",children:[(0,d.jsx)("div",{className:"font-medium text-sm truncate",children:e.name||"Ðез имени"}),e.phone&&(0,d.jsx)("div",{className:"text-xs text-gray-500 mt-1",children:e.phone}),e.message&&(0,d.jsx)("div",{className:"text-xs text-gray-600 mt-1 truncate",children:e.message}),(0,d.jsxs)("div",{className:"flex items-center justify-between mt-2",children:[(0,d.jsx)("span",{className:"text-xs text-gray-400",children:new Date(e.created_at).toLocaleDateString("ru-RU",{day:"numeric",month:"short"})}),e.score&&(0,d.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded ".concat(e.score>=70?"bg-green-100 text-green-700":e.score>=40?"bg-yellow-100 text-yellow-700":"bg-red-100 text-red-700"),children:[e.score,"%"]})]})]},e.id)),0===e.leads.length&&(0,d.jsx)("div",{className:"text-center py-8 text-gray-400 text-sm",children:"ÐеÑеÑаÑиÑе ÑÑда лидÑ"})]})]},e.stage_key))})})]}),b&&N&&(0,d.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",onClick:()=>y(!1),children:(0,d.jsxs)("div",{className:"bg-white rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,d.jsx)("div",{className:"p-6 border-b",children:(0,d.jsx)("h2",{className:"text-xl font-semibold",children:N.name||"Ðид без имени"})}),(0,d.jsxs)("div",{className:"p-6 space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-sm text-gray-500",children:"ТелеÑон"}),(0,d.jsx)("div",{className:"font-medium",children:N.phone||"â"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-sm text-gray-500",children:"Email"}),(0,d.jsx)("div",{className:"font-medium",children:N.email||"â"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-sm text-gray-500",children:"СообÑение"}),(0,d.jsx)("div",{className:"font-medium",children:N.message||"â"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-sm text-gray-500",children:"ÐÑенка"}),(0,d.jsxs)("div",{className:"font-medium",children:[N.score||0,"%"]})]}),N.service&&(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-sm text-gray-500",children:"УÑлÑга"}),(0,d.jsx)("div",{className:"font-medium",children:N.service.title})]})]}),(0,d.jsxs)("div",{className:"p-6 border-t bg-gray-50 flex justify-end gap-3",children:[(0,d.jsx)("button",{onClick:()=>{e.push("/admin/leads/".concat(N.id)),y(!1)},className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700",children:"ÐÑкÑÑÑÑ ÐºÐ°ÑÑоÑкÑ"}),(0,d.jsx)("button",{onClick:()=>y(!1),className:"px-4 py-2 border rounded-lg",children:"ÐакÑÑÑÑ"})]})]})})]})}},18718:(e,s,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/crm/kanban",function(){return a(5305)}])}},e=>{e.O(0,[7972,2480,5964,636,6593,8792],()=>e(e.s=18718)),_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.