"use strict";(globalThis.webpackChunkbooktics=globalThis.webpackChunkbooktics||[]).push([[416,5375],{30416:(e,t,o)=>{o.r(t),o.d(t,{default:()=>r});var a=o(51609),n=o(47143),c=o(88802),l=o(55375),s=o(22564),g=o(27723);const r=(0,s.wrapWithTheme)(()=>{const{singleTeamMember:e}=(0,n.useSelect)(e=>e(c.teamStoreName).getTeamState(),[]),{google_calendar_connected:t}=e||{},{data:o}=(0,n.useSelect)(e=>e(c.settingsStore).getSettingsState(),[]),{teamGoogleSettings:r}=(0,l.default)();return(0,a.createElement)(s.PrimaryOutlinedButton,{text:(0,g.__)(t?"Disconnect":"Connect","booktics"),disabled:!o?.google_calendar_connected||!o?.enable_google,onClick:r,size:"small",danger:t})})},55375:(e,t,o)=>{o.r(t),o.d(t,{default:()=>l});var a=o(47143),n=o(11534),c=o(40309);const l=()=>{const{setSettingsState:e}=(0,a.useDispatch)(c.settings),{data:t}=(0,a.useSelect)(e=>e(c.settings).getSettingsState(),[]),{google_calendar_connected:o}=t||{},{singleTeamMember:l,profileInfo:s}=(0,a.useSelect)(e=>e(c.team).getTeamState(),[]),{setTeamState:g}=(0,a.useDispatch)(c.team),r=async(o={})=>{try{(await n.A.google.disconnectGoogle(o)).success&&(o?.team_member_id?g({singleTeamMember:{...l,google_calendar_connected:!1}}):e({data:{...t,google_calendar_connected:!1}}))}catch(e){console.log(e)}};return{adminGoogleSettings:e=>{const{google_redirect_url:t,...a}=e;o?r():(async e=>{try{const{google_redirect_url:t,...o}=e,a=await n.A.google.configureGoogle(o);a.success&&window.location.replace(a?.data?.auth_url,"noopener,noreferrer")}catch(e){console.log(e)}})(a)},teamGoogleSettings:()=>{if(!t?.google_calendar_connected)return;const e={team_member_id:l?.id||s.id};l?.google_calendar_connected?r(e):(async(e={})=>{try{const t=await n.A.google.connectGoogle(e);t.success&&window.location.replace(t?.data?.auth_url,"noopener,noreferrer")}catch(e){console.log(e)}})(e)}}}}}]);