Files
gustavoo-me/wp-content/plugins/fluent-crm/assets/v3app/src/Modules/Companies/CompanyContacts.js
T
2026-07-23 22:56:30 -03:00

2 lines
17 KiB
JavaScript

import{L as t,D as s,E as e,e as a,aB as i,k as n,az as o,aG as l,ay as r,c,aT as d}from"../../../../vendor-element-plus.js?ver=3.1.8";import{aQ as h,W as p,X as _,ab as m,a5 as f,b2 as g,Z as C,bB as u,aa as v,J as w,az as y,Y as b,a6 as x,a9 as B,a8 as F,a0 as S}from"../../../../vendor.js?ver=3.1.8";import{F as L,C as k}from"../../../../_ContactsTable.js?ver=3.1.8";import{_ as A,I as j}from"../../../../fc-bits-ui.js?ver=3.1.8";import"../../../../Tagger.js?ver=3.1.8";import"../../../../data_config.js?ver=3.1.8";import"../../../../CompanyEditForm.js?ver=3.1.8";import"../../../../fc-bits.js?ver=3.1.8";import"../../../../Filterer.js?ver=3.1.8";import"../../../../Filterer2.js?ver=3.1.8";import"../../../../Searcher.js?ver=3.1.8";import"../../../../PaginationBar.js?ver=3.1.8";import"../../../../DataTable.js?ver=3.1.8";import"../../../../FloatingBulkActionShell.js?ver=3.1.8";import"../../../../Confirm.js?ver=3.1.8";import"../../../../_OptionSelector.js?ver=3.1.8";import"../Contacts/Filter/FilterPopover.js?ver=3.1.8";import"../Contacts/Filter/ActiveFiltersBar.js?ver=3.1.8";import"../../../../_IntlTelInput.js?ver=3.1.8";import"../../../../Badge.js?ver=3.1.8";import"../../../../relations.js?ver=3.1.8";import"../../../../clipboard.js?ver=3.1.8";const M={key:0},E={key:1,class:"fcrm_assign_empty"},Z={class:"fcrm_assign_empty_body"},$={class:"fcrm_assign_empty_text"},T={key:2,class:"fcrm_assign_list"},U={class:"fcrm_assign_item_body"},I={class:"fcrm_assign_avatar"},D=["src","alt"],G={key:1,class:"fcrm_assign_avatar_ph"},V={class:"fcrm_assign_info"},O={class:"fcrm_assign_name"},z={class:"fcrm_assign_email"},N={key:0,class:"fcrm_assign_actions"};const q={class:"icon"},P={key:0,class:"fcrm_drawer_content"},H={class:"fcrm_tab_menu"},R={class:"fcrm_tab_text"},J={key:0,class:"fcrm_tab_line"},K={class:"fcrm_tab_text"},Q={key:0,class:"fcrm_tab_line"},W={class:"fcrm_adder_content"},X={key:0,class:"fcrm_assign_existing"},Y={key:1,class:"fcrm_assign_create_new"};const tt=A({name:"CompanyMembers",props:["company_id","company"],components:{ContactsTable:k,ContactAdder:A({name:"ContactAdded",props:["company"],components:{Icons:j,ContactAssignSelector:A({name:"ContactAssignSelector",props:["company"],components:{Search:s,Plus:t},emits:["attached","createNew"],data:()=>({contact_search:"",contacts:[],searched:!1,loading:!1,selectedIds:[],attaching:!1,searchTimer:null}),watch:{contact_search(){this.searchTimer&&clearTimeout(this.searchTimer),this.searchTimer=setTimeout(()=>{this.fetchContacts()},350)}},methods:{fetchContacts(){const t=(this.contact_search||"").trim(),s=!!t;this.loading=!0,this.selectedIds=[],this.$get("companies/search-unattached-contacts",{limit:s?20:10,search:t,company_id:this.company.id}).then(t=>{this.contacts=t.results,this.searched=s}).catch(t=>{this.handleError(t)}).finally(()=>{this.loading=!1})},attachContacts(){this.attaching=!0,this.$post("companies/attach-subscribers",{subscriber_ids:this.selectedIds,company_ids:[this.company.id]}).then(t=>{this.$notify.success(t.message),this.$emit("attached")}).catch(t=>{this.handleError(t)}).finally(()=>{this.attaching=!1})}},mounted(){this.fetchContacts()},beforeUnmount(){this.searchTimer&&clearTimeout(this.searchTimer)}},[["render",function(t,s,c,d,S,L){const k=h("Search"),A=e,j=a,q=i,P=h("Plus"),H=n,R=o,J=l,K=r;return p(),_("div",null,[m(j,{modelValue:S.contact_search,"onUpdate:modelValue":s[1]||(s[1]=t=>S.contact_search=t),placeholder:t.$t("Search Contact"),onKeyup:s[2]||(s[2]=g(t=>L.fetchContacts(),["enter"])),class:"fcrm_assign_search"},{prefix:f(()=>[m(A,{onClick:s[0]||(s[0]=t=>L.fetchContacts()),style:{cursor:"pointer"}},{default:f(()=>[m(k)],void 0,!0),_:1})]),_:1},8,["modelValue","placeholder"]),S.loading?(p(),_("div",M,[m(q,{animated:!0,rows:3})])):S.searched&&!S.contacts.length?(p(),_("div",E,[C("div",Z,[s[6]||(s[6]=u('<div class="fcrm_illust"><svg class="fcrm_illust_dots" xmlns="http://www.w3.org/2000/svg" width="84" height="79" viewBox="0 0 84 79" fill="none"><path d="M42.6099 77.5944C63.2868 77.5944 80.0499 60.9145 80.0499 40.2667C80.0499 19.6189 63.213 2.93896 42.6099 2.93896C21.933 2.93896 5.16992 19.6189 5.16992 40.2667C5.16992 60.9145 21.933 77.5944 42.6099 77.5944Z" fill="var(--fc-secondary-bg)"></path><path d="M77.3168 15.8715C78.9889 15.8715 80.3444 14.5227 80.3444 12.8589C80.3444 11.195 78.9889 9.84619 77.3168 9.84619C75.6446 9.84619 74.2891 11.195 74.2891 12.8589C74.2891 14.5227 75.6446 15.8715 77.3168 15.8715Z" fill="#F1F3F9"></path><path d="M81.7474 4.11486C82.8893 4.11486 83.8151 3.19372 83.8151 2.05743C83.8151 0.921144 82.8893 0 81.7474 0C80.6054 0 79.6797 0.921144 79.6797 2.05743C79.6797 3.19372 80.6054 4.11486 81.7474 4.11486Z" fill="#EAEEF9"></path><path d="M2.06769 21.0153C3.20965 21.0153 4.13538 20.0941 4.13538 18.9578C4.13538 17.8215 3.20965 16.9004 2.06769 16.9004C0.925737 16.9004 0 17.8215 0 18.9578C0 20.0941 0.925737 21.0153 2.06769 21.0153Z" fill="#EAEEF9"></path><path d="M13.4396 78.1824C15.5604 78.1824 17.2796 76.4717 17.2796 74.3615C17.2796 72.2512 15.5604 70.5405 13.4396 70.5405C11.3188 70.5405 9.59961 72.2512 9.59961 74.3615C9.59961 76.4717 11.3188 78.1824 13.4396 78.1824Z" fill="var(--fc-secondary-bg)"></path></svg><svg class="fcrm_illust_cloud" xmlns="http://www.w3.org/2000/svg" width="140" height="106" viewBox="0 0 140 106" fill="none"><g filter="url(#filter0_d_5420_1669)"><path d="M118 54.848C118 64.3426 110.283 72.0208 100.659 72.0208C100.493 72.0208 99.082 72.0208 88.7104 72.0208C81.4917 72.0208 69.9585 72.0208 51.5384 72.0208H42.7433C31.21 72.2685 22 63.1042 22 52.041C22 40.8952 31.293 31.6483 42.9922 32.2262C53.0319 1.018 98.999 5.39375 102.899 37.6753C111.528 38.7486 118 46.014 118 54.848Z" fill="url(#paint0_linear_5420_1669)"></path></g><path d="M100.658 72.0208C110.2 72.0208 117.999 64.3426 117.999 54.8481C117.999 45.3535 110.2 37.6753 100.658 37.6753C91.1159 37.6753 83.3164 45.3535 83.3164 54.8481C83.3164 64.3426 91.1159 72.0208 100.658 72.0208Z" fill="url(#paint1_linear_5420_1669)"></path><path d="M72.364 72.1859C89.3735 72.1859 103.23 58.4807 103.23 41.5556C103.23 24.6305 89.3735 10.9253 72.364 10.9253C55.3546 10.9253 41.498 24.6305 41.498 41.5556C41.498 58.4807 55.2716 72.1859 72.364 72.1859Z" fill="url(#paint2_linear_5420_1669)"></path><defs><filter id="filter0_d_5420_1669" x="0" y="0" width="140" height="105.026" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"></feColorMatrix><feOffset dy="11"></feOffset><feGaussianBlur stdDeviation="11"></feGaussianBlur><feColorMatrix type="matrix" values="0 0 0 0 0.397708 0 0 0 0 0.47749 0 0 0 0 0.575 0 0 0 0.27 0"></feColorMatrix><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_5420_1669"></feBlend><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_5420_1669" result="shape"></feBlend></filter><linearGradient id="paint0_linear_5420_1669" x1="69.9999" y1="36.2182" x2="69.969" y2="72.6836" gradientUnits="userSpaceOnUse"><stop stop-color="white"></stop><stop offset="0.9964" stop-color="#ECF0F5"></stop></linearGradient><linearGradient id="paint1_linear_5420_1669" x1="81.471" y1="33.978" x2="96.7608" y2="50.7838" gradientUnits="userSpaceOnUse"><stop stop-color="#BCCBE1"></stop><stop offset="0.9942" stop-color="white" stop-opacity="0"></stop></linearGradient><linearGradient id="paint2_linear_5420_1669" x1="38.6078" y1="27.5001" x2="62.8048" y2="37.0164" gradientUnits="userSpaceOnUse"><stop stop-color="#E2E8F0"></stop><stop offset="0.9942" stop-color="white" stop-opacity="0"></stop></linearGradient></defs></svg><div class="fcrm_illust_rec"></div><svg class="fcrm_illust_x_sm" xmlns="http://www.w3.org/2000/svg" width="7" height="7" viewBox="0 0 7 7" fill="none"><path d="M4.88688 3.31409L6.33038 1.87448C6.75141 1.4546 6.75141 0.734797 6.33038 0.314913C5.90936 -0.104971 5.18761 -0.104971 4.76659 0.314913L3.32308 1.75452L1.87957 0.314913C1.45854 -0.104971 0.736791 -0.104971 0.315767 0.314913C-0.105256 0.734797 -0.105256 1.4546 0.315767 1.87448L1.75928 3.31409L0.315767 4.75369C-0.105256 5.17357 -0.105256 5.89337 0.315767 6.31326C0.556352 6.55319 0.796936 6.61318 1.09767 6.61318C1.3984 6.61318 1.63898 6.49321 1.87957 6.31326L3.32308 4.87366L4.76659 6.31326C5.00717 6.55319 5.24775 6.61318 5.54849 6.61318C5.84922 6.61318 6.0898 6.49321 6.33038 6.31326C6.75141 5.89337 6.75141 5.17357 6.33038 4.75369L4.88688 3.31409Z" fill="#989FB0"></path></svg><svg class="fcrm_illust_x_md" xmlns="http://www.w3.org/2000/svg" width="8" height="7" viewBox="0 0 8 7" fill="none"><path d="M5.42986 3.31409L7.03376 1.87448C7.50157 1.4546 7.50157 0.734797 7.03376 0.314913C6.56596 -0.104971 5.76401 -0.104971 5.2962 0.314913L3.69231 1.75452L2.08841 0.314913C1.6206 -0.104971 0.818656 -0.104971 0.350853 0.314913C-0.116951 0.734797 -0.116951 1.4546 0.350853 1.87448L1.95475 3.31409L0.350853 4.75369C-0.116951 5.17357 -0.116951 5.89337 0.350853 6.31326C0.618169 6.55319 0.885482 6.61318 1.21963 6.61318C1.55377 6.61318 1.82109 6.49321 2.08841 6.31326L3.69231 4.87366L5.2962 6.31326C5.56352 6.55319 5.83084 6.61318 6.16498 6.61318C6.49913 6.61318 6.76645 6.49321 7.03376 6.31326C7.50157 5.89337 7.50157 5.17357 7.03376 4.75369L5.42986 3.31409Z" fill="#989FB0"></path></svg><svg class="fcrm_illust_line_short" xmlns="http://www.w3.org/2000/svg" width="8" height="4" viewBox="0 0 8 4" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M0.0398168 0.954173C0.212906 0.276602 0.90524 -0.133057 1.58619 0.0391729L6.40108 1.25699C7.08203 1.42922 7.49373 2.11811 7.32065 2.79569C7.14756 3.47326 6.45522 3.88292 5.77427 3.71069L0.95938 2.49287C0.27843 2.32064 -0.133272 1.63174 0.0398168 0.954173Z" fill="#989FB0"></path></svg><svg class="fcrm_illust_line_long" xmlns="http://www.w3.org/2000/svg" width="9" height="11" viewBox="0 0 9 11" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M0.557602 0.218632C1.13893 -0.174006 1.93008 -0.0233776 2.32467 0.555069L8.08056 8.99275C8.47515 9.5712 8.32377 10.3584 7.74244 10.7511C7.16111 11.1437 6.36996 10.9931 5.97537 10.4146L0.219487 1.97694C-0.175109 1.39849 -0.0237291 0.611269 0.557602 0.218632Z" fill="#989FB0"></path></svg><svg class="fcrm_illust_line_vert" xmlns="http://www.w3.org/2000/svg" width="5" height="13" viewBox="0 0 5 13" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.02544 0.0244312C1.71468 -0.111313 2.384 0.334604 2.52042 1.02042L4.51037 11.0242C4.6468 11.71 4.19865 12.376 3.50942 12.5118C2.82019 12.6475 2.15087 12.2016 2.01444 11.5158L0.0244911 1.51199C-0.11193 0.826179 0.336211 0.160176 1.02544 0.0244312Z" fill="#989FB0"></path></svg><svg class="fcrm_illust_line_sm" xmlns="http://www.w3.org/2000/svg" width="3" height="6" viewBox="0 0 3 6" fill="none"><path d="M0 0H2.95385V3.66666C2.95385 4.48234 2.2926 5.14358 1.47692 5.14358C0.661241 5.14358 0 4.48234 0 3.66666V0Z" fill="#989FB0"></path></svg><svg class="fcrm_illust_excl_circle" xmlns="http://www.w3.org/2000/svg" width="31" height="30" viewBox="0 0 31 30" fill="none"><path d="M29.9772 17.6827C29.6623 19.0029 29.19 20.2723 28.6128 21.4401C27.091 24.182 24.8345 26.4162 22.0008 27.7871C19.0621 29.2596 15.5986 29.7674 12.0827 29.1073C3.89643 27.4317 -1.40367 19.7137 0.328045 11.7419C2.05976 3.77008 9.98368 -1.3583 18.2225 0.31731C21.1611 0.926622 23.7325 2.29757 25.884 4.27784C29.4524 7.83216 30.9742 12.859 29.9772 17.6827Z" fill="url(#paint0_linear_5420_1684)"></path><defs><linearGradient id="paint0_linear_5420_1684" x1="-0.0138663" y1="14.6991" x2="30.2824" y2="14.6991" gradientUnits="userSpaceOnUse"><stop stop-color="#B0BACC"></stop><stop offset="1" stop-color="#969EAE"></stop></linearGradient></defs></svg><svg class="fcrm_illust_excl_mark" xmlns="http://www.w3.org/2000/svg" width="6" height="14" viewBox="0 0 6 14" fill="none"><path d="M2.8457 0.5C4.28122 0.5 5.28011 1.82099 5.18652 3.31836L5.18555 3.32715L4.58496 10.7363C4.52737 11.6717 3.79991 12.5215 2.8457 12.5215C1.89172 12.5212 1.165 11.6715 1.10742 10.7363L0.506836 3.32715L0.505859 3.31934C0.412132 1.87331 1.40482 0.500286 2.8457 0.5Z" fill="white" stroke="white"></path></svg><svg class="fcrm_illust_excl_dot" xmlns="http://www.w3.org/2000/svg" width="6" height="6" viewBox="0 0 6 6" fill="none"><path d="M2.8457 0.5C4.14511 0.5 5.19234 1.53792 5.19238 2.83691C5.19238 4.13595 4.14514 5.17383 2.8457 5.17383C1.54648 5.17359 0.5 4.1358 0.5 2.83691C0.500043 1.53807 1.5465 0.50024 2.8457 0.5Z" fill="white" stroke="white"></path></svg></div>',1)),C("p",$,v(t.$t("No Results Found")),1),m(H,{class:"fcrm_assign_create_btn",onClick:s[3]||(s[3]=s=>t.$emit("createNew"))},{default:f(()=>[m(A,null,{default:f(()=>[m(P)],void 0,!0),_:1}),C("span",null,v(t.$t("Create New Contact")),1)],void 0),_:1})])])):S.contacts.length?(p(),_("div",T,[m(J,{class:"fcrm_assign_chk_grp",modelValue:S.selectedIds,"onUpdate:modelValue":s[4]||(s[4]=t=>S.selectedIds=t)},{default:f(()=>[(p(!0),_(w,null,y(S.contacts,t=>(p(),b(R,{key:t.id,value:t.id,class:"fcrm_assign_item"},{default:f(()=>[C("div",U,[C("div",I,[t.photo?(p(),_("img",{key:0,src:t.photo,alt:t.full_name},null,8,D)):(p(),_("div",G,v(t.full_name?t.full_name.charAt(0).toUpperCase():"?"),1))]),C("div",V,[C("div",O,v(t.full_name),1),C("div",z,v(t.email),1)])])],void 0,!0),_:2},1032,["value"]))),128))],void 0),_:1},8,["modelValue"]),S.selectedIds.length?(p(),_("div",N,[x((p(),b(H,{disabled:S.attaching,onClick:s[5]||(s[5]=t=>L.attachContacts()),class:"fcrm_assign_attach_btn"},{default:f(()=>[B(v(t.$t("Attach Selected Contacts"))+" ("+v(S.selectedIds.length)+") ",1)],void 0),_:1},8,["disabled"])),[[K,S.attaching]])])):F("",!0)])):F("",!0)])}]]),FormHandler:L,Plus:t,Close:c},emits:["reloadContacts"],data:()=>({direction:"rtl",assignState:"existing",newContactDrawer:!1}),mounted(){window.fcAdmin&&window.fcAdmin.is_rtl&&(this.direction="ltr")},methods:{showContactAdd(){this.assignState="existing",this.newContactDrawer=!0},handleCreated(t){this.newContactDrawer=!1,this.$router.push({name:"subscriber",params:{id:t.id}})},handleAttached(){this.newContactDrawer=!1,this.$emit("reloadContacts")}}},[["render",function(t,s,e,a,i,o){const l=h("Icons"),r=n,c=h("contact-assign-selector"),g=h("form-handler"),u=d;return p(),_("div",null,[m(r,{onClick:s[0]||(s[0]=t=>o.showContactAdd()),size:"small",type:"primary"},{default:f(()=>[C("span",q,[m(l,{"icon-name":"plus"})]),B(" "+v(t.$t("Add Contact")),1)],void 0),_:1}),m(u,{direction:i.direction,class:"fcrm_contact_adder_drawer","with-header":!0,size:t.globalDrawerSize,"append-to-body":!0,title:t.$t("Add contact & Assign"),onClose:s[5]||(s[5]=t=>i.newContactDrawer=!1),modelValue:i.newContactDrawer,"onUpdate:modelValue":s[6]||(s[6]=t=>i.newContactDrawer=t)},{default:f(()=>[i.newContactDrawer?(p(),_("div",P,[C("div",H,[C("div",{class:S(["fcrm_tab_item",{fcrm_tab_active:"existing"===i.assignState}]),onClick:s[1]||(s[1]=t=>i.assignState="existing")},[C("span",R,v(t.$t("Add Existing")),1),"existing"===i.assignState?(p(),_("div",J)):F("",!0)],2),C("div",{class:S(["fcrm_tab_item",{fcrm_tab_active:"new"===i.assignState}]),onClick:s[2]||(s[2]=t=>i.assignState="new")},[C("span",K,v(t.$t("Create New")),1),"new"===i.assignState?(p(),_("div",Q)):F("",!0)],2)]),C("div",W,["existing"==i.assignState?(p(),_("div",X,[m(c,{onAttached:s[3]||(s[3]=t=>o.handleAttached()),onCreateNew:s[4]||(s[4]=t=>i.assignState="new"),company:e.company},null,8,["company"])])):(p(),_("div",Y,[m(g,{onCreated:o.handleCreated,company_id:e.company.id},null,8,["onCreated","company_id"])]))])])):F("",!0)],void 0),_:1},8,["direction","size","title","modelValue"])])}]])},data:()=>({loading:!1,subscribers:[],columns:[],pagination:{current_page:1,per_page:10,total:0},query_data:{tags:[],lists:[],search:"",statuses:[],sort_by:"id",sort_type:"DESC",custom_fields:!1},ui_config:{show_list:!0,show_tag:!0,disable_filters_without_selection:!0},options:{tags:[],lists:[],statuses:[],sms_statuses:[],countries:[],sampleCsv:null,delimiter:"comma"}}),methods:{fetchContacts(){this.loading=!0,this.$get("subscribers",{company_ids:[this.company_id],per_page:this.pagination.per_page,page:this.pagination.current_page,...this.query_data}).then(t=>{this.subscribers=t.subscribers.data,this.pagination.total=t.subscribers.total}).catch(t=>{this.handleError(t)}).finally(()=>{this.loading=!1})},getOptions(){const t={fields:"yes"!==window.fcAdmin.sms_enabled?"tags,lists,statuses,contact_types,sampleCsv,custom_fields":"tags,lists,statuses,sms_statuses,contact_types,sampleCsv,custom_fields"};this.$get("reports/options",t).then(t=>{this.options=t.options})}},mounted(){this.fetchContacts(),this.getOptions()}},[["render",function(t,s,e,a,i,n){const o=h("contact-adder"),l=h("contacts-table"),c=r;return x((p(),_("div",null,[m(l,{fire_ready_fetch:!0,options:i.options,always_searchbar:!0,query_data:i.query_data,is_loading:i.loading,ui_config:i.ui_config,subscribers:i.subscribers,onFetch:s[1]||(s[1]=t=>n.fetchContacts()),pagination:i.pagination},{after_search_box:f(()=>[m(o,{onReloadContacts:s[0]||(s[0]=t=>n.fetchContacts()),company:e.company},null,8,["company"])]),_:1},8,["options","query_data","is_loading","ui_config","subscribers","pagination"])])),[[c,i.loading]])}]]);export{tt as default};