| 1 |
"use strict";(globalThis.webpackChunkbooktics=globalThis.webpackChunkbooktics||[]).push([[416,1294,5375],{30416:(e,t,o)=>{o.r(t),o.d(t,{default:()=>g});var a=o(51609),n=o(47143),c=o(88802),l=o(55375),s=o(22564),r=o(27723);const g=(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:g}=(0,l.default)();return(0,a.createElement)(s.PrimaryOutlinedButton,{text:(0,r.__)(t?"Disconnect":"Connect","booktics"),disabled:!o?.google_calendar_connected||!o?.enable_google,onClick:g,size:"small",danger:t})})},31294:(e,t,o)=>{o.r(t);var a=o(51609),n=o(30416);window.wp?.hooks.addFilter("booktics_connect_google","booktics",()=>(0,a.createElement)(n.default,null),10)},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:r}=(0,a.useDispatch)(c.team),g=async(o={})=>{try{(await n.A.google.disconnectGoogle(o)).success&&(o?.team_member_id?r({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?g():(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?g(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)}}}}}]); |