import{m as h}from"./bootstrap-vue-next-3DpAa4tb.js";import{u as B,ao as $,r as p,m as P,H as M,c as v,o as r,F as V,i as j,h as A,a as n,n as L,t as I,b as u,w as _,e as w,v as y,s as O,C}from"./index-CipWZKo_.js";import{_ as H}from"./ButtonDefault-CghIUDY0.js";import{_ as z}from"./FormTabs-D9V4Egc_.js";import{c as D,f as K,s as W}from"./time-DenPiOX5.js";import{s as S}from"./multiselect-DWCHRlfT.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";const q={class:"tw-overflow-y-auto tw-pr-2"},G={class:"tw-mb-2"},J={__name:"BlockNotificationsModal",props:["id","method"],setup(b){const c=b,s=B(),k=$(),i=p({});P(i.value,()=>{const o=new FormData;Object.keys(i.value).forEach(l=>{i.value[l]&&o.append(`${c.method}[]`,l)}),o.append("MethodID",c.method),o.append("ContactID",c.id),s.userEditContactSettings(o)}),M(async()=>{const o=await s.ContactData(c?.id);Object.keys(o).forEach(l=>{typeof o[l]=="object"&&Object.keys(o[l]).forEach(d=>{i.value[d]=o[l][d]})})});function T(o){i.value[o]=!i.value?.[o]}return(o,l)=>{const d=h;return r(),v("div",q,[(r(!0),v(V,null,j(y(k).data.Notifies.Types,(t,m)=>(r(),v(V,{key:m},[t.Title?(r(),v("div",{key:0,class:L([m>0?"tw-mt-4":"","tw-text-lg tw-font-medium tw-mb-2"])},I(t.Title),3)):A("",!0),n("div",G,[u(d,{id:m,name:m,checked:i.value[m],onInput:()=>T(m)},{default:_(()=>[w(I(t.Name),1)]),_:2},1032,["id","name","checked","onInput"])])],64))),128))])}}},Q={class:"tw-text-gray-500 tw-mt-2"},R={class:"tw-space-y-2"},X={class:"tw-mt-4"},Y={class:"tw-flex tw-gap-2 tw-mt-2 tw-w-full"},Z={class:"tw-basis-1/2"},ee={class:"tw-basis-1/2"},te={class:"tw-text-sm tw-text-gray-500 tw-mt-4"},me={__name:"ModalWindowEditContact",props:["data"],emits:["modalClose"],setup(b,{emit:c}){const s=b,k=c,i=B(),T=[{name:"Общие",value:"common"},{name:"Типы уведомлений",value:"notions"}],o=p([]),l=p(!1),d=p("common"),t=p({...s.data,TimeBegin:D(s.data.TimeBegin),TimeEnd:D(s.data.TimeEnd)});function m(){for(let f=0;f<=23;f++){const e=D(f);o.value.push({label:`${e}:00`,name:`${e}:00`,value:String(e)})}}async function E(){l.value=!0,await i.userEditContact({Address:t.value.Address,MethodID:t.value.MethodID,ContactID:t.value.ID,TimeBegin:t.value.TimeBegin,TimeEnd:t.value.TimeEnd,IsActive:t.value.IsActive?"yes":void 0,IsImmediately:t.value.IsImmediately?"yes":void 0,IsPrimary:t.value.IsPrimary?"yes":void 0,IsSendFiles:t.value.IsSendFiles?"yes":void 0}),l.value=!1,i.fetchUserData(),k("modalClose")}m();const x=f=>{f.key==="Enter"&&E()};return M(()=>{document.addEventListener("keyup",x)}),O(()=>{document.removeEventListener("keyup",x)}),(f,e)=>{const N=z,g=h,U=H,F=J;return r(),v(V,null,[e[15]||(e[15]=n("div",{class:"tw-text-2xl tw-font-medium md:tw-min-w-[600px]"},"Настройки",-1)),n("div",Q,I(s.data.MethodID)+" "+I(s.data.Address),1),u(N,{modelValue:d.value,"onUpdate:modelValue":e[0]||(e[0]=a=>d.value=a),tabs:T,class:"tw-mt-4"},null,8,["modelValue"]),d.value==="common"?(r(),v(V,{key:0},[n("div",R,[u(g,{class:"edit-settings__checkbox",id:"use-for-notifications",name:"use-for-notifications",modelValue:t.value.IsActive,"onUpdate:modelValue":e[1]||(e[1]=a=>t.value.IsActive=a)},{default:_(()=>e[8]||(e[8]=[w(" Использовать для уведомлений ",-1)])),_:1,__:[8]},8,["modelValue"]),u(g,{class:"edit-settings__checkbox",id:"notify-immediately",name:"notify-immediately",modelValue:t.value.IsImmediately,"onUpdate:modelValue":e[2]||(e[2]=a=>t.value.IsImmediately=a)},{default:_(()=>e[9]||(e[9]=[w(" Уведомлять немедленно ",-1)])),_:1,__:[9]},8,["modelValue"]),u(g,{class:"edit-settings__checkbox",id:"send-files",name:"send-files",modelValue:t.value.IsSendFiles,"onUpdate:modelValue":e[3]||(e[3]=a=>t.value.IsSendFiles=a)},{default:_(()=>e[10]||(e[10]=[w(" Присылать файлы/картинки ",-1)])),_:1,__:[10]},8,["modelValue"]),s.data.MethodID==="Email"?(r(),C(g,{key:0,class:"edit-settings__checkbox",id:"use-for-login",name:"use-for-login",modelValue:t.value.IsPrimary,"onUpdate:modelValue":e[4]||(e[4]=a=>t.value.IsPrimary=a)},{default:_(()=>e[11]||(e[11]=[w(" Использовать как логин ",-1)])),_:1,__:[11]},8,["modelValue"])):A("",!0)]),n("div",X,[e[14]||(e[14]=n("div",{class:"tw-text-lg"},"Время рассылки",-1)),n("div",Y,[n("div",Z,[e[12]||(e[12]=n("div",{class:"tw-text-sm tw-font-medium"},"Начало",-1)),u(y(S),{placeholder:"00:00",options:o.value,modelValue:t.value.TimeBegin,"onUpdate:modelValue":e[5]||(e[5]=a=>t.value.TimeBegin=a),label:"name"},null,8,["options","modelValue"])]),n("div",ee,[e[13]||(e[13]=n("div",{class:"tw-text-sm tw-font-medium"},"Конец",-1)),u(y(S),{modelValue:t.value.TimeEnd,"onUpdate:modelValue":e[6]||(e[6]=a=>t.value.TimeEnd=a),options:o.value,label:"name",placeholder:"00:00"},null,8,["modelValue","options"])])]),n("div",te," Адрес подтвержден "+I(y(K)(y(W)(s.data.Confirmed))),1)]),u(U,{onClick:e[7]||(e[7]=a=>E()),label:"Сохранить изменения","is-loading":l.value,class:"tw-mt-4"},null,8,["is-loading"])],64)):(r(),C(F,{key:1,id:s.data.ID,method:s.data.MethodID},null,8,["id","method"]))],64)}}};export{me as default};
