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