"use strict";(globalThis.webpackChunkbooktics=globalThis.webpackChunkbooktics||[]).push([[5375],{55375:(e,o,t)=>{t.r(o),t.d(o,{default:()=>s});var c=t(47143),a=t(11534),n=t(40309);const s=()=>{const{setSettingsState:e}=(0,c.useDispatch)(n.settings),{data:o}=(0,c.useSelect)(e=>e(n.settings).getSettingsState(),[]),{google_calendar_connected:t}=o||{},{singleTeamMember:s,profileInfo:l}=(0,c.useSelect)(e=>e(n.team).getTeamState(),[]),{setTeamState:g}=(0,c.useDispatch)(n.team),r=async(t={})=>{try{(await a.A.google.disconnectGoogle(t)).success&&(t?.team_member_id?g({singleTeamMember:{...s,google_calendar_connected:!1}}):e({data:{...o,google_calendar_connected:!1}}))}catch(e){console.log(e)}};return{adminGoogleSettings:e=>{const{google_redirect_url:o,...c}=e;t?r():(async e=>{try{const{google_redirect_url:o,...t}=e,c=await a.A.google.configureGoogle(t);c.success&&window.location.replace(c?.data?.auth_url,"noopener,noreferrer")}catch(e){console.log(e)}})(c)},teamGoogleSettings:()=>{if(!o?.google_calendar_connected)return;const e={team_member_id:s?.id||l.id};s?.google_calendar_connected?r(e):(async(e={})=>{try{const o=await a.A.google.connectGoogle(e);o.success&&window.location.replace(o?.data?.auth_url,"noopener,noreferrer")}catch(e){console.log(e)}})(e)}}}}}]);