Files
nademitex_user/dist/assets/RemindersView-CP53npYK.js
T
mohmdsdgandCopilot adb6ca47cd fix(auth): secure sessions and app routing
Validate sessions against the API, honor configurable base paths, and route unknown pages to 404. Keep development ports stable so user and admin apps cannot be confused.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-24 20:14:11 +03:30

1 line
11 KiB
JavaScript

import{D as e,E as t,Et as n,G as ee,J as r,Kt as i,M as a,N as o,O as s,P as c,T as l,Xt as u,Yt as d,Z as f,at as te,b as p,ct as m,g as ne,h as re,t as h,vt as g,w as _}from"./_plugin-vue_export-helper-Bo3WtfwJ.js";import{s as v,u as ie}from"./BasicIcon-BXxbbWA_.js";import{t as ae}from"./dist-2yEcZq4e.js";import{o as y}from"./format-C72AoJ2H.js";import{s as b,w as x}from"./index-BAQfYU-Q.js";import{t as oe}from"./IconChevronBack-DfGoZJJk.js";import{t as S}from"./IconMoreVertical-zeD1VV0e.js";import{t as se}from"./PageSkeleton-DHtB6RUa.js";import{i as ce,t as le}from"./crm-CooNUbmr.js";import{t as ue}from"./useGoBack-TJZZv7or.js";import{t as de}from"./PersianDateInput-CTe_lYug.js";var fe={class:`page reminders-page`},pe={class:`top mobile-only`},me={class:`desktop-page__head desktop-only reminders-desk-head`},he={class:`reminders-desk-head__actions`},ge={class:`page__scroll page__scroll--with-nav reminders-scroll`},_e={class:`tabs`,role:`tablist`,"aria-label":`فیلتر یادآورها`},ve=[`aria-selected`,`onClick`],ye={class:`tab__text`},be={key:0,class:`tab__badge`},xe={key:1,class:`error-text`},Se={key:2,class:`create-panel`},Ce={key:0,class:`create-error`},C=[`aria-expanded`],w={key:0,class:`field-select__menu`,role:`listbox`},T=[`aria-selected`,`onClick`],E={class:`create-row`},D={class:`create-actions`},O=[`disabled`],k={class:`summary`},A={class:`summary__top`},we={class:`summary__label`},Te={class:`summary__calendar`,"aria-hidden":`true`},Ee={class:`summary__count`},De={key:0,class:`empty-state`},Oe=[`onClick`],ke=[`onClick`],Ae={class:`reminder-card__header`},je={class:`reminder-card__time`},Me={class:`reminder-card__title-row`},Ne={class:`reminder-card__body`},Pe={class:`reminder-card__customer`},Fe={class:`reminder-card__customer-text`},Ie={class:`reminder-card__name`},Le={class:`reminder-card__contact`},Re={key:0,class:`reminder-card__desc`},ze={class:`completed-section`},Be={class:`completed-bar__count`},Ve={key:0,class:`completed-list`},He=[`onClick`],Ue={class:`reminder-card__header`},We={class:`reminder-card__time`},Ge={class:`reminder-card__title-row`},Ke={class:`reminder-card__body`},qe={class:`reminder-card__customer`},j={class:`reminder-card__customer-text`},Je={class:`reminder-card__name`},Ye={class:`reminder-card__contact`},Xe={key:0,class:`reminder-card__desc`},Ze={key:0,class:`completed-empty`},M=h(c({__name:`RemindersView`,setup(c){let h=re(),M=ne(),{goBack:N}=ue(`/`),P=le(),F=_(()=>String(h.query.filter??`today`)),I=g([]),L=g([]),R=g(!0),z=g(null),B=g(!1),V=g(!1),H=g(0),U=g(!1),W=g({customerId:``,title:``,date:``,time:`10:00`,note:``}),G=g(!1),K=g(null),Qe=_(()=>{if(!W.value.customerId)return`انتخاب مشتری`;let e=L.value.find(e=>e.id===W.value.customerId);return e?.name||e?.contactName||`انتخاب مشتری`});ae(K,()=>{G.value=!1});function $e(e){W.value.customerId=e,G.value=!1}let et=[{id:`all`,label:`همه`},{id:`today`,label:`امروز`},{id:`week`,label:`هفته آینده`},{id:`past`,label:`گذشته`}],q=_(()=>I.value.filter(e=>!e.completed)),J=_(()=>{let e=new Date().toISOString().slice(0,10);return I.value.filter(t=>t.completed&&t.date===e)}),tt=_(()=>q.value.length),nt=_(()=>F.value===`today`?`پیگیری‌های امروز`:F.value===`week`?`پیگیری‌های هفته آینده`:F.value===`past`?`پیگیری‌های گذشته`:`پیگیری‌های باز`),rt=_(()=>new Date().getDate().toLocaleString(`fa-IR`));async function Y(){try{let e=await ce(`past`);H.value=e.length}catch{H.value=0}}async function X(){R.value=!0,z.value=null;try{I.value=await P.loadReminders(F.value)}catch(e){z.value=e instanceof Error?e.message:`بارگذاری یادآورها ناموفق بود.`,I.value=[]}finally{R.value=!1}}ee(async()=>{await Promise.all([X(),Y()])}),te(F,X);function it(e){M.replace({path:`/reminders`,query:{filter:e}})}async function at(e){try{await P.markReminderComplete(e),await X(),await Y()}catch(e){z.value=e instanceof Error?e.message:`تکمیل یادآور ناموفق بود.`}}function Z(e){return e===`in_person`?`ملاقات حضوری`:e===`call`?`تماس تلفنی`:e===`message`?`پیام`:`یادداشت`}function Q(e){return e===`in_person`?`tag--green`:e===`call`?`tag--blue`:`tag--purple`}async function $(){B.value=!0,U.value=!1,G.value=!1,z.value=null;try{if(L.value=await P.loadCustomers(),!W.value.customerId&&L.value[0]&&(W.value.customerId=L.value[0].id),!W.value.date){let e=new Date;W.value.date=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}}catch(e){z.value=e instanceof Error?e.message:`بارگذاری مشتریان ناموفق بود.`}}async function ot(){if(!W.value.customerId||!W.value.title.trim()||!W.value.date||!W.value.time){z.value=`مشتری، عنوان، تاریخ و ساعت الزامی است.`;return}V.value=!0,z.value=null;try{await P.createReminder({customerId:W.value.customerId,title:W.value.title.trim(),date:W.value.date,time:W.value.time,note:W.value.note.trim()||void 0,description:W.value.note.trim()||void 0}),B.value=!1,W.value.title=``,W.value.note=``,await X(),await Y()}catch(e){z.value=e instanceof Error?e.message:`ثبت یادآور ناموفق بود.`}finally{V.value=!1}}function st(){U.value=!U.value}return(ee,c)=>(r(),s(`div`,fe,[l(`header`,pe,[l(`button`,{type:`button`,class:`icon-btn`,"aria-label":`بازگشت`,onClick:c[0]||=(...e)=>n(N)&&n(N)(...e)},[o(oe,{size:20})]),c[9]||=l(`h1`,null,`یادآورها`,-1),l(`button`,{type:`button`,class:`icon-btn`,"aria-label":`اعلان‌ها`,onClick:c[1]||=e=>n(M).push(`/profile/notifications`)},[o(b,{size:20})])]),l(`header`,me,[c[11]||=l(`div`,null,[l(`h1`,{class:`desktop-page__title`},`یادآورها`),l(`p`,{class:`desktop-page__subtitle`},`پیگیری و مدیریت یادآورهای مشتریان`)],-1),l(`div`,he,[l(`button`,{type:`button`,class:`desk-icon-btn`,"aria-label":`اعلان‌ها`,onClick:c[2]||=e=>n(M).push(`/profile/notifications`)},[o(b,{size:20})]),l(`button`,{type:`button`,class:`desk-new-btn`,onClick:$},[o(x,{size:18,color:`#fff`}),c[10]||=a(` یادآور جدید `,-1)])])]),l(`div`,ge,[l(`div`,_e,[(r(),s(p,null,f(et,t=>l(`button`,{key:t.id,type:`button`,role:`tab`,class:i([`tab`,{"tab--active":F.value===t.id}]),"aria-selected":F.value===t.id,onClick:e=>it(t.id)},[l(`span`,ye,[a(u(t.label)+` `,1),t.id===`past`&&H.value?(r(),s(`span`,be,u(H.value.toLocaleString(`fa-IR`)),1)):e(``,!0)])],10,ve)),64))]),R.value?(r(),t(se,{key:0,variant:`list`})):z.value&&!B.value?(r(),s(`p`,xe,u(z.value),1)):e(``,!0),B.value?(r(),s(`section`,Se,[c[17]||=l(`h3`,null,`یادآور جدید`,-1),z.value?(r(),s(`p`,Ce,u(z.value),1)):e(``,!0),l(`label`,null,[c[13]||=a(` مشتری `,-1),l(`div`,{ref_key:`customerRoot`,ref:K,class:`field-select`},[l(`button`,{type:`button`,class:i([`field-select__trigger`,{"is-open":G.value}]),"aria-haspopup":`listbox`,"aria-expanded":G.value,onClick:c[3]||=e=>G.value=!G.value},[l(`span`,{class:i({"is-placeholder":!W.value.customerId})},u(Qe.value),3),c[12]||=l(`svg`,{class:`field-select__chevron`,viewBox:`0 0 12 12`,"aria-hidden":`true`},[l(`path`,{d:`M2.5 4.5 6 8l3.5-3.5`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.4`,"stroke-linecap":`round`})],-1)],10,C),G.value?(r(),s(`ul`,w,[(r(!0),s(p,null,f(L.value,e=>(r(),s(`li`,{key:e.id},[l(`button`,{type:`button`,role:`option`,class:i([`field-select__option`,{"is-active":W.value.customerId===e.id}]),"aria-selected":W.value.customerId===e.id,onClick:t=>$e(e.id)},u(e.name||e.contactName),11,T)]))),128))])):e(``,!0)],512)]),l(`label`,null,[c[14]||=a(` عنوان `,-1),m(l(`input`,{"onUpdate:modelValue":c[4]||=e=>W.value.title=e,type:`text`,placeholder:`مثلاً پیگیری نمونه`},null,512),[[v,W.value.title]])]),l(`div`,E,[o(de,{modelValue:W.value.date,"onUpdate:modelValue":c[5]||=e=>W.value.date=e,label:`تاریخ`,class:`create-date`},null,8,[`modelValue`]),l(`label`,null,[c[15]||=a(` ساعت `,-1),m(l(`input`,{"onUpdate:modelValue":c[6]||=e=>W.value.time=e,type:`time`},null,512),[[v,W.value.time]])])]),l(`label`,null,[c[16]||=a(` یادداشت `,-1),m(l(`textarea`,{"onUpdate:modelValue":c[7]||=e=>W.value.note=e,rows:`2`,placeholder:`اختیاری`},null,512),[[v,W.value.note]])]),l(`div`,D,[l(`button`,{type:`button`,class:`btn-cancel`,onClick:c[8]||=e=>B.value=!1},`انصراف`),l(`button`,{type:`button`,class:`btn-save`,disabled:V.value,onClick:ot},u(V.value?`در حال ثبت...`:`ثبت یادآور`),9,O)])])):!R.value&&!z.value?(r(),s(p,{key:3},[l(`section`,k,[l(`div`,A,[l(`span`,we,u(nt.value),1),l(`div`,Te,[c[18]||=l(`svg`,{viewBox:`0 0 24 24`,fill:`none`},[l(`path`,{d:`M8 2.5V5.5M16 2.5V5.5M4.5 9.5H19.5M19 8.5V17.5C19 20 17.5 21.5 14.5 21.5H9.5C6.5 21.5 5 20 5 17.5V8.5C5 6 6.5 4.5 9.5 4.5H14.5C17.5 4.5 19 6 19 8.5Z`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})],-1),l(`span`,null,u(rt.value),1)])]),l(`div`,Ee,[l(`strong`,null,u(n(y)(tt.value)),1),c[19]||=l(`span`,null,`مورد`,-1)]),c[20]||=l(`p`,{class:`summary__sub`},`یادآورهای شما برای پیگیری مشتریان`,-1)]),q.value.length?e(``,!0):(r(),s(`div`,De,`یادآوری برای این بازه ثبت نشده است.`)),(r(!0),s(p,null,f(q.value,t=>(r(),s(`div`,{key:t.id,class:`reminder-row`},[l(`button`,{type:`button`,class:`reminder-row__check`,"aria-label":`تکمیل یادآور`,onClick:ie(e=>at(t.id),[`stop`])},null,8,Oe),l(`article`,{class:`reminder-card`,onClick:e=>n(M).push({path:`/reminder`,query:{id:t.id}})},[l(`div`,Ae,[l(`span`,je,u(t.time),1),l(`div`,Me,[l(`strong`,null,u(t.title),1),o(S,{size:18,class:`reminder-card__menu`})])]),l(`div`,Ne,[l(`span`,{class:i([`tag`,Q(t.interactionType)])},u(Z(t.interactionType)),3),l(`div`,Pe,[l(`div`,Fe,[l(`p`,Ie,u(t.customerName),1),l(`p`,Le,u(t.contactName),1)]),l(`div`,{class:`reminder-card__avatar`,style:d({background:t.avatarColor})},u(t.avatarLetter),5)])]),t.description?(r(),s(`p`,Re,u(t.description),1)):e(``,!0)],8,ke)]))),128)),l(`section`,ze,[l(`button`,{type:`button`,class:`completed-bar`,onClick:st},[(r(),s(`svg`,{class:i([`completed-bar__chevron`,{"is-open":U.value}]),viewBox:`0 0 12 12`,"aria-hidden":`true`},[...c[21]||=[l(`path`,{d:`M2.5 4.5 6 8l3.5-3.5`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.4`,"stroke-linecap":`round`},null,-1)]],2)),c[22]||=l(`span`,{class:`completed-bar__label`},`یادآورهای تکمیل شده امروز`,-1),l(`span`,Be,u(n(y)(J.value.length)),1)]),U.value?(r(),s(`div`,Ve,[(r(!0),s(p,null,f(J.value,t=>(r(),s(`div`,{key:t.id,class:`reminder-row reminder-row--done`},[c[23]||=l(`span`,{class:`reminder-row__check reminder-row__check--done`,"aria-hidden":`true`},null,-1),l(`article`,{class:`reminder-card reminder-card--done`,onClick:e=>n(M).push({path:`/reminder`,query:{id:t.id}})},[l(`div`,Ue,[l(`span`,We,u(t.time),1),l(`div`,Ge,[l(`strong`,null,u(t.title),1),o(S,{size:18,class:`reminder-card__menu`})])]),l(`div`,Ke,[l(`span`,{class:i([`tag`,Q(t.interactionType)])},u(Z(t.interactionType)),3),l(`div`,qe,[l(`div`,j,[l(`p`,Je,u(t.customerName),1),l(`p`,Ye,u(t.contactName),1)]),l(`div`,{class:`reminder-card__avatar`,style:d({background:t.avatarColor})},u(t.avatarLetter),5)])]),t.description?(r(),s(`p`,Xe,u(t.description),1)):e(``,!0)],8,He)]))),128)),J.value.length?e(``,!0):(r(),s(`p`,Ze,`یادآور تکمیل‌شده‌ای برای امروز نیست.`))])):e(``,!0)])],64)):e(``,!0),l(`button`,{type:`button`,class:`new-btn mobile-only`,onClick:$},[o(x,{size:20,color:`#fff`}),c[24]||=a(` یادآور جدید `,-1)])])]))}}),[[`__scopeId`,`data-v-5b2cf3dd`]]);export{M as default};