1 line
6.8 KiB
JavaScript
1 line
6.8 KiB
JavaScript
import{$ as e,A as ee,Ct as te,E as t,F as n,G as r,I as i,L as ne,M as a,O as o,S as s,T as re,Y as c,_ as ie,bt as l,ft as u,g as ae,j as d,k as f,n as p,nt as m,q as h,wt as g,x as oe,xt as _}from"./BasicIcon-CjTTsi6o.js";import{o as v}from"./format-BHJptHdF.js";import{i as se,s as ce,v as le}from"./index-D3Z8WOeX.js";import{t as ue}from"./IconChevronBack-B10eZjCQ.js";import{t as de}from"./IconMoreVertical-CoEoZgQs.js";import{t as fe}from"./PageSkeleton-CyATkHE1.js";import{t as pe}from"./crm-l0KpZ2AN.js";import{t as me}from"./useGoBack-D3aJ73Q-.js";var he={class:`page reminders-page`},ge={class:`top`},_e={class:`top__actions`},y={class:`page__scroll page__scroll--with-nav reminders-scroll`},b={class:`filters`},x=[`onClick`],S={key:0,class:`count-badge`},C={key:1},w={key:2,class:`create-panel`},T={key:0,class:`create-error`},E=[`value`],D={class:`create-row`},O={class:`create-actions`},k=[`disabled`],A={key:3,class:`summary`},j={class:`summary__head`},M={class:`summary__label`},N={class:`summary__count`},P=[`onClick`],F={class:`time`},I=[`onClick`],ve={class:`reminder-card__body`},L={class:`reminder-card__top`},ye={class:`customer`},be={class:`contact`},xe={class:`desc`},R=p(ne({__name:`RemindersView`,setup(ne){let p=ae(),R=ie(),{goBack:z}=me(`/`),B=pe(),V=o(()=>String(p.query.filter??`today`)),H=u([]),U=u([]),W=u(!0),G=u(null),K=u(!1),q=u(!1),J=u({customerId:``,title:``,date:``,time:`10:00`,note:``}),Se=[{id:`all`,label:`همه`},{id:`today`,label:`امروز`},{id:`week`,label:`هفته آینده`},{id:`past`,label:`گذشته`}],Y=o(()=>H.value.filter(e=>!e.completed)),X=o(()=>H.value.filter(e=>e.completed)),Ce=o(()=>Y.value.length),Z=o(()=>X.value.length);async function Q(){W.value=!0,G.value=null;try{H.value=await B.loadReminders(V.value)}catch(e){G.value=e instanceof Error?e.message:`بارگذاری یادآورها ناموفق بود.`,H.value=[]}finally{W.value=!1}}r(Q),e(V,Q);function $(e){R.replace({path:`/reminders`,query:{filter:e}})}async function we(e){try{await B.markReminderComplete(e),await Q()}catch(e){G.value=e instanceof Error?e.message:`تکمیل یادآور ناموفق بود.`}}function Te(e){return e===`in_person`?`ملاقات حضوری`:e===`call`?`تماس تلفنی`:e===`message`?`پیام`:`یادداشت`}function Ee(e){return e===`in_person`?`tag--green`:e===`call`?`tag--blue`:`tag--purple`}let De=o(()=>V.value===`today`?`پیگیریهای امروز`:V.value===`week`?`پیگیریهای هفته آینده`:V.value===`past`?`پیگیریهای گذشته`:`پیگیریهای باز`);async function Oe(){K.value=!0,G.value=null;try{if(U.value=await B.loadCustomers(),!J.value.customerId&&U.value[0]&&(J.value.customerId=U.value[0].id),!J.value.date){let e=new Date;J.value.date=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}}catch(e){G.value=e instanceof Error?e.message:`بارگذاری مشتریان ناموفق بود.`}}async function ke(){if(!J.value.customerId||!J.value.title.trim()||!J.value.date||!J.value.time){G.value=`مشتری، عنوان، تاریخ و ساعت الزامی است.`;return}q.value=!0,G.value=null;try{await B.createReminder({customerId:J.value.customerId,title:J.value.title.trim(),date:J.value.date,time:J.value.time,note:J.value.note.trim()||void 0,description:J.value.note.trim()||void 0}),K.value=!1,J.value.title=``,J.value.note=``,await Q()}catch(e){G.value=e instanceof Error?e.message:`ثبت یادآور ناموفق بود.`}finally{q.value=!1}}return(e,r)=>(h(),a(`div`,he,[f(`header`,ge,[f(`button`,{type:`button`,class:`icon-btn`,"aria-label":`بازگشت`,onClick:r[0]||=(...e)=>l(z)&&l(z)(...e)},[i(ue,{size:20})]),r[9]||=f(`h1`,null,`یادآورها`,-1),f(`div`,_e,[i(se,{variant:`inline`}),f(`button`,{type:`button`,class:`icon-btn`,"aria-label":`اعلانها`,onClick:r[1]||=e=>l(R).push(`/profile/notifications`)},[i(ce,{size:18})])])]),f(`div`,y,[f(`div`,b,[(h(),a(t,null,c(Se,e=>f(`button`,{key:e.id,type:`button`,class:_([`filter`,{"filter--active":V.value===e.id}]),onClick:ee=>$(e.id)},[n(g(e.label)+` `,1),e.id===`past`&&Z.value?(h(),a(`span`,S,g(Z.value.toLocaleString(`fa-IR`)),1)):d(``,!0)],10,x)),64))]),W.value?(h(),ee(fe,{key:0,variant:`list`})):G.value&&!K.value?(h(),a(`p`,C,g(G.value),1)):d(``,!0),K.value?(h(),a(`section`,w,[r[16]||=f(`h3`,null,`یادآور جدید`,-1),G.value?(h(),a(`p`,T,g(G.value),1)):d(``,!0),f(`label`,null,[r[11]||=n(` مشتری `,-1),m(f(`select`,{"onUpdate:modelValue":r[2]||=e=>J.value.customerId=e},[r[10]||=f(`option`,{disabled:``,value:``},`انتخاب مشتری`,-1),(h(!0),a(t,null,c(U.value,e=>(h(),a(`option`,{key:e.id,value:e.id},g(e.name||e.contactName),9,E))),128))],512),[[oe,J.value.customerId]])]),f(`label`,null,[r[12]||=n(` عنوان `,-1),m(f(`input`,{"onUpdate:modelValue":r[3]||=e=>J.value.title=e,type:`text`,placeholder:`مثلاً پیگیری نمونه`},null,512),[[s,J.value.title]])]),f(`div`,D,[f(`label`,null,[r[13]||=n(` تاریخ `,-1),m(f(`input`,{"onUpdate:modelValue":r[4]||=e=>J.value.date=e,type:`date`},null,512),[[s,J.value.date]])]),f(`label`,null,[r[14]||=n(` ساعت `,-1),m(f(`input`,{"onUpdate:modelValue":r[5]||=e=>J.value.time=e,type:`time`},null,512),[[s,J.value.time]])])]),f(`label`,null,[r[15]||=n(` یادداشت `,-1),m(f(`textarea`,{"onUpdate:modelValue":r[6]||=e=>J.value.note=e,rows:`2`,placeholder:`اختیاری`},null,512),[[s,J.value.note]])]),f(`div`,O,[f(`button`,{type:`button`,class:`btn-cancel`,onClick:r[7]||=e=>K.value=!1},`انصراف`),f(`button`,{type:`button`,class:`btn-save`,disabled:q.value,onClick:ke},g(q.value?`در حال ثبت...`:`ثبت یادآور`),9,k)])])):!W.value&&!G.value?(h(),a(`section`,A,[f(`div`,j,[f(`span`,M,g(De.value),1)]),f(`div`,N,[f(`strong`,null,g(l(v)(Ce.value)),1),r[17]||=f(`span`,null,`مورد`,-1)]),r[18]||=f(`p`,{class:`summary__sub`},`یادآورهای شما برای پیگیری مشتریان`,-1)])):d(``,!0),(h(!0),a(t,null,c(Y.value,e=>(h(),a(`article`,{key:e.id,class:`reminder-card`,onClick:ee=>l(R).push({path:`/reminder`,query:{id:e.id}})},[f(`span`,F,g(e.time),1),f(`button`,{type:`button`,class:`check`,"aria-label":`تکمیل`,onClick:re(ee=>we(e.id),[`stop`])},null,8,I),f(`div`,ve,[f(`div`,L,[f(`strong`,null,g(e.title),1),i(de,{size:16})]),f(`span`,{class:_([`tag`,Ee(e.interactionType)])},g(Te(e.interactionType)),3),f(`p`,ye,g(e.customerName),1),f(`p`,be,g(e.contactName),1),f(`p`,xe,g(e.description),1)]),f(`div`,{class:`avatar`,style:te({background:e.avatarColor})},g(e.avatarLetter),5)],8,P))),128)),f(`button`,{type:`button`,class:`completed-bar`,onClick:r[8]||=e=>$(`past`)},[r[19]||=n(` یادآورهای تکمیلشده `,-1),f(`span`,null,g(l(v)(X.value.length)),1)]),f(`button`,{type:`button`,class:`new-btn`,onClick:Oe},[i(le,{size:20,color:`#fff`}),r[20]||=n(` یادآور جدید `,-1)])])]))}}),[[`__scopeId`,`data-v-89857cb4`]]);export{R as default}; |