"use strict";(globalThis.webpackChunkbooktics=globalThis.webpackChunkbooktics||[]).push([[953],{52911:(e,a,t)=>{t.d(a,{A:()=>o});var s=t(47143),i=t(47767),c=t(40309),m=t(11534);const o=()=>{const{setTeamState:e}=(0,s.useDispatch)(c?.team),{setServicesState:a}=(0,s.useDispatch)(c?.services),{id:t}=(0,i.g)(),{teamMembers:o,enable_custom_availability:r,selectedServices:l,profileInfo:n,customSchedule:d,holiday:b,schedule:g,searchQuery:u}=(0,s.useSelect)(c?.team).getTeamState(),{serviceList:y}=(0,s.useSelect)(c?.services).getServicesState(),h=async(a={})=>{a?.resetFilter&&(a={service_id:"",paged:"",per_page:""});const t={...u,...a};e({isFiltering:!0});try{const a=await m.A.team.allTeamMembers(t);a.success&&e({teamMembers:{...a?.data},searchQuery:t})}catch(e){console.log(e)}};return{getMyprofileInfo:async()=>{try{const a=await m.A.team.getTeamMemberProfile();a.success&&e({profileInfo:a.data})}catch(e){console.log(e)}},getTeamMembers:h,addTeamMember:async a=>{try{e({editLoading:!0});const t=await m.A.team.createTeamMember(a);t.success&&e({teamMembers:{...o,total:o.total+1,items:[{...t?.data},...o.items]},visibleModal:!1}),e({editLoading:!1})}catch(a){console.log(a),e({editLoading:!1})}finally{e({editLoading:!1})}},deleteTeamMember:async a=>{try{if((await m.A.team.deleteSingleTeamMember(a)).success){const t=o.items.filter(e=>e.id!==a);e({teamMembers:{...o,total:t.length,items:t}})}}catch(e){console.log(e)}},getSingleTeamMember:async()=>{try{const a=await m.A.team.singleTeamMember(t);a.success&&e({singleTeamMember:{...a?.data},selectedServices:a?.data?.services})}catch(e){console.log(e)}},teamMemberBulkDelete:async(a=[])=>{try{if((await m.A.team.bulkDeleteTeamMember({ids:a})).success){const t=o.items.filter(e=>!a.includes(e.id));e({teamMembers:{...o,items:t}})}}catch(e){console.log(e)}},editTeamMember:async s=>{const i={...s,schedule:g,services:l,custom:s.enable_custom_schedule?d:[],holiday:s.enable_custom_holiday?b:[],enable_custom_availability:r},c=t||n.id;try{e({editLoading:!0});const t=await m.A.team.updateTeamMember(c,i);if(t?.success){const s=o?.items?.map(e=>e?.id===t?.data?.id?t?.data:e);e({teamMembers:{...o,items:s},editLoading:!1});const i=y?.map(e=>Array.isArray(e.team_member)&&e.team_member.includes(t?.data?.id)&&Array.isArray(e.team_member_details)?{...e,team_member_details:e.team_member_details.map(e=>e.id===t?.data?.id?{...e,image:t?.data?.image}:e)}:e);a({serviceList:i})}}catch(e){console.error("Failed to update team member:",e)}finally{e({editLoading:!1})}},reInviteTeam:async e=>{try{const a=await m.A.team.reInviteTeamMember(e);a.success&&window.wp?.hooks.doAction("notification",{type:"success",message:a?.message})}catch(e){console.log(e)}},onPaginationChange:(e,a)=>{h({paged:e,per_page:a})}}}},90953:(e,a,t)=>{t.r(a),t.d(a,{default:()=>m});var s=t(51609),i=t(22564),c=t(52911);const m=()=>{const{getTeamMembers:e}=(0,c.A)();return window?.wp?.hooks.applyFilters("booktics_location_create",(0,s.createElement)(i.EmptyScreen,{isPro:!0}),{getTeamMembers:e})}}}]);