1 line
6.8 KiB
JavaScript
1 line
6.8 KiB
JavaScript
import{A as e,C as t,D as n,E as ee,I as r,J as i,K as te,L as a,M as o,N as s,R as c,S as ne,St as l,Tt as u,X as d,_ as re,et as ie,g as ae,j as oe,k as f,n as p,pt as m,rt as h,wt as se,xt as g}from"./BasicIcon-B6lR-mG3.js";import{o as _}from"./format-BHJptHdF.js";import{i as ce,s as le,y as ue}from"./index-B20WsQhf.js";import{t as de}from"./IconChevronBack-BXRfc2bX.js";import{t as fe}from"./IconMoreVertical-Dw3RBXp5.js";import{t as pe}from"./PageSkeleton-BImjuI6S.js";import{t as me}from"./crm-DbcoqKAF.js";import{t as he}from"./useGoBack-yePcdjuj.js";var ge={class:`page reminders-page`},_e={class:`top`},v={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`],L={class:`reminder-card__body`},ve={class:`reminder-card__top`},ye={class:`customer`},be={class:`contact`},xe={class:`desc`},R=p(c({__name:`RemindersView`,setup(c){let p=ae(),R=re(),{goBack:z}=he(`/`),B=me(),V=f(()=>String(p.query.filter??`today`)),H=m([]),U=m([]),W=m(!0),G=m(null),K=m(!1),q=m(!1),J=m({customerId:``,title:``,date:``,time:`10:00`,note:``}),Se=[{id:`all`,label:`همه`},{id:`today`,label:`امروز`},{id:`week`,label:`هفته آینده`},{id:`past`,label:`گذشته`}],Y=f(()=>H.value.filter(e=>!e.completed)),X=f(()=>H.value.filter(e=>e.completed)),Ce=f(()=>Y.value.length),Z=f(()=>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}}te(Q),ie(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=f(()=>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(te,c)=>(i(),s(`div`,ge,[e(`header`,_e,[e(`button`,{type:`button`,class:`icon-btn`,"aria-label":`بازگشت`,onClick:c[0]||=(...e)=>g(z)&&g(z)(...e)},[a(de,{size:20})]),c[9]||=e(`h1`,null,`یادآورها`,-1),e(`div`,v,[a(ce,{variant:`inline`}),e(`button`,{type:`button`,class:`icon-btn`,"aria-label":`اعلانها`,onClick:c[1]||=e=>g(R).push(`/profile/notifications`)},[a(le,{size:18})])])]),e(`div`,y,[e(`div`,b,[(i(),s(n,null,d(Se,t=>e(`button`,{key:t.id,type:`button`,class:l([`filter`,{"filter--active":V.value===t.id}]),onClick:e=>$(t.id)},[r(u(t.label)+` `,1),t.id===`past`&&Z.value?(i(),s(`span`,S,u(Z.value.toLocaleString(`fa-IR`)),1)):o(``,!0)],10,x)),64))]),W.value?(i(),oe(pe,{key:0,variant:`list`})):G.value&&!K.value?(i(),s(`p`,C,u(G.value),1)):o(``,!0),K.value?(i(),s(`section`,w,[c[16]||=e(`h3`,null,`یادآور جدید`,-1),G.value?(i(),s(`p`,T,u(G.value),1)):o(``,!0),e(`label`,null,[c[11]||=r(` مشتری `,-1),h(e(`select`,{"onUpdate:modelValue":c[2]||=e=>J.value.customerId=e},[c[10]||=e(`option`,{disabled:``,value:``},`انتخاب مشتری`,-1),(i(!0),s(n,null,d(U.value,e=>(i(),s(`option`,{key:e.id,value:e.id},u(e.name||e.contactName),9,E))),128))],512),[[ne,J.value.customerId]])]),e(`label`,null,[c[12]||=r(` عنوان `,-1),h(e(`input`,{"onUpdate:modelValue":c[3]||=e=>J.value.title=e,type:`text`,placeholder:`مثلاً پیگیری نمونه`},null,512),[[t,J.value.title]])]),e(`div`,D,[e(`label`,null,[c[13]||=r(` تاریخ `,-1),h(e(`input`,{"onUpdate:modelValue":c[4]||=e=>J.value.date=e,type:`date`},null,512),[[t,J.value.date]])]),e(`label`,null,[c[14]||=r(` ساعت `,-1),h(e(`input`,{"onUpdate:modelValue":c[5]||=e=>J.value.time=e,type:`time`},null,512),[[t,J.value.time]])])]),e(`label`,null,[c[15]||=r(` یادداشت `,-1),h(e(`textarea`,{"onUpdate:modelValue":c[6]||=e=>J.value.note=e,rows:`2`,placeholder:`اختیاری`},null,512),[[t,J.value.note]])]),e(`div`,O,[e(`button`,{type:`button`,class:`btn-cancel`,onClick:c[7]||=e=>K.value=!1},`انصراف`),e(`button`,{type:`button`,class:`btn-save`,disabled:q.value,onClick:ke},u(q.value?`در حال ثبت...`:`ثبت یادآور`),9,k)])])):!W.value&&!G.value?(i(),s(`section`,A,[e(`div`,j,[e(`span`,M,u(De.value),1)]),e(`div`,N,[e(`strong`,null,u(g(_)(Ce.value)),1),c[17]||=e(`span`,null,`مورد`,-1)]),c[18]||=e(`p`,{class:`summary__sub`},`یادآورهای شما برای پیگیری مشتریان`,-1)])):o(``,!0),(i(!0),s(n,null,d(Y.value,t=>(i(),s(`article`,{key:t.id,class:`reminder-card`,onClick:e=>g(R).push({path:`/reminder`,query:{id:t.id}})},[e(`span`,F,u(t.time),1),e(`button`,{type:`button`,class:`check`,"aria-label":`تکمیل`,onClick:ee(e=>we(t.id),[`stop`])},null,8,I),e(`div`,L,[e(`div`,ve,[e(`strong`,null,u(t.title),1),a(fe,{size:16})]),e(`span`,{class:l([`tag`,Ee(t.interactionType)])},u(Te(t.interactionType)),3),e(`p`,ye,u(t.customerName),1),e(`p`,be,u(t.contactName),1),e(`p`,xe,u(t.description),1)]),e(`div`,{class:`avatar`,style:se({background:t.avatarColor})},u(t.avatarLetter),5)],8,P))),128)),e(`button`,{type:`button`,class:`completed-bar`,onClick:c[8]||=e=>$(`past`)},[c[19]||=r(` یادآورهای تکمیلشده `,-1),e(`span`,null,u(g(_)(X.value.length)),1)]),e(`button`,{type:`button`,class:`new-btn`,onClick:Oe},[a(ue,{size:20,color:`#fff`}),c[20]||=r(` یادآور جدید `,-1)])])]))}}),[[`__scopeId`,`data-v-89857cb4`]]);export{R as default}; |