"use strict";(globalThis.webpackChunkbooktics=globalThis.webpackChunkbooktics||[]).push([[8409],{3038:(e,t,a)=>{a.d(t,{A:()=>l});var r=a(47143),i=a(47767),c=a(40309),s=a(11534),n=a(56580),o=a(88802);const l=function(){const e=(0,r.useSelect)(e=>e(c.services).getServicesState(),[]),{selectedServices:t}=(0,r.useSelect)(e=>e(c.team).getTeamState(),[]),{setServicesState:a}=(0,r.useDispatch)(c.services),{setTeamState:l}=(0,r.useDispatch)(c.team),d=(0,n.useAdminLicense)(),{searchQuery:m,serviceList:u=[],total:g,singleService:p,selectedTeamMembers:y,selectedExtraServices:v=[],schedule:h,selectedLocations:b}=e,_=(0,i.Zp)(),{id:S}=(0,i.g)(),E=async(e={})=>{e?.resetFilter&&(e={search:"",category_id:"",team_member_id:""});const t={...m,...e};a({isFiltering:!0});try{const e=await(s.A?.service?.allServices(t));e?.success&&a({serviceList:e?.data?.items,total:e?.data?.total,searchQuery:t})}catch(e){console.error("Error fetching services:",e)}finally{return a({isFiltering:!1}),{complete:!0}}};return{createService:async(e,r=!0)=>{try{a({isFiltering:!0});const i=await(s.A?.service?.createService(e));i?.success&&(a({serviceList:[i?.data,...u||[]],total:g+1}),r?_(`/services/update/${i?.data.id}`):(a({visibleCreateServiceModal:!1}),l({selectedServices:[i.data.id,...t]})))}catch(e){console.error("Error creating service:",e)}finally{a({isFiltering:!1})}},updateService:async(e,t="deactive",r=!1)=>{if(r||a({loadingServiceId:!0}),e?.custom_field){let t=Array.isArray(e?.custom_field?.fields)?e?.custom_field?.fields?.map(e=>"global"===e?.from?e:{...e,from:"service"}):void 0;e.custom_field={...e?.custom_field,fields:t}}try{const r={...p,...e,status:t,extra_services:v,team_member:y,schedule:e.enable_custom_schedule?h:{},show_end_time:Number(e.show_end_time)||!1};delete r.extra_service_details,d||(delete r.extra_services,delete r.custom_field);const i=await s.A.service.updateService(S,r);if(i?.success){const e=u?.map(e=>e?.id===i?.data?.id?i?.data:e);a({serviceList:e}),a({loadingServiceId:!1})}return i}catch(e){console.error("Error updating service:",e)}finally{a({loadingServiceId:!1})}},updateStatus:async({id:e,...t})=>{try{delete t.extra_service_details;const a=await(s.A?.service?.updateService(e,t));if(a?.success){const e=(0,r.select)(c.services).getServicesState("serviceList"),t=e?.map(e=>e.id===a.data.id?a.data:e);(0,r.dispatch)(c.services).setServicesState({serviceList:t})}return a}catch(e){console.error("Error updating status:",e)}finally{(0,r.dispatch)(c.services).setServicesState({loadingServiceId:null})}},getServices:E,deleteSingleService:async e=>{try{const t=await(s.A?.service?.deleteSingleService(e));if(t?.success){const{serviceList:t,total:a}=(0,r.select)(c.services).getServicesState();(0,r.dispatch)(c.services).setServicesState({serviceList:t?.filter(t=>t.id!==e),total:a-1})}return t}catch(e){console.error("Error deleting service:",e)}},bulkDeleteService:async(e=[])=>{try{const t=await(s.A?.service?.bulkDeleteService({ids:e}));if(t?.success&&(a({serviceList:u.filter(t=>!e.includes(t.id))}),e.length<g)){const{paged:e="",per_page:t=""}=m;E({paged:e,per_page:t})}}catch(e){console.error("Error bulk deleting services:",e)}finally{return{complete:!0}}},duplicateService:async e=>{try{a({isFiltering:!0});const t=await(s.A?.service?.cloneService(e));if(t?.success){const r=u.findIndex(t=>t.id===e);if(-1===r)throw new Error("Service not found for duplication.");const i=[...u.slice(0,r+1),t.data,...u.slice(r+1)];a({serviceList:i,total:g+1})}}catch(e){console.error("Error duplicating service:",e)}finally{a({isFiltering:!1})}},getSingleService:async()=>{try{const e=await s.A.service.singleService(S);e.success&&a({singleService:{...e?.data,custom_field:{...e?.data?.custom_field,fields:e?.data?.custom_field?.fields?.length?e?.data?.custom_field?.fields:o.defaultFields}}})}catch(e){console.log(e)}},onPaginationChange:(e,t)=>{E({paged:e,per_page:t})}}}},25723:(e,t,a)=>{e.exports=a.p+"images/user_avtar.d4c06dd9.png"},44064:(e,t,a)=>{a.d(t,{Dz:()=>c,Mu:()=>l,bw:()=>n,k_:()=>s,wL:()=>o});var r=a(59e3),i=a(22564);const c=(0,r.A)(i.Flex)`
    h4 {
        font-size: 20px;
        line-height: 30px;
        color: ${({theme:e})=>e.colors.neutralDark};
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
        max-width: 250px;
    }
    p {
        font-size: 14px;
        font-weight: normal;
        color: ${({theme:e})=>e.colors.neutralLight};
        white-space: nowrap;
    }
    .bkt-service-title {
        cursor: pointer;
        &:hover {
            text-decoration: underline;
            color: ${({theme:e})=>e.colors.primary};
        }
    }
`,s=(0,r.A)(i.AdvancedCard)`
    .ant-card-body {
        padding: 0px;
    }
    p {
        white-space: nowrap;
    }
    .btk-holiday {
        color: #ed695e;
    }
`,n=r.A.div`
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 190px;
`,o=r.A.div`
    padding: 20px;
    border-top: 1px solid #cdd0d6;

    .btk-re-invite-btn {
        height: 36px;
        border-radius: 4px;
        box-shadow: none;
        font-weight: 500;
        font-size: 14px;
    }
    .btk-edit-btn {
        height: 36px !important;
    }
`,l=(0,r.A)(i.Flex)`
    margin-top: 16px;
`},52911:(e,t,a)=>{a.d(t,{A:()=>n});var r=a(47143),i=a(47767),c=a(40309),s=a(11534);const n=()=>{const{setTeamState:e}=(0,r.useDispatch)(c?.team),{setServicesState:t}=(0,r.useDispatch)(c?.services),{id:a}=(0,i.g)(),{teamMembers:n,enable_custom_availability:o,selectedServices:l,profileInfo:d,customSchedule:m,holiday:u,schedule:g,searchQuery:p}=(0,r.useSelect)(c?.team).getTeamState(),{serviceList:y}=(0,r.useSelect)(c?.services).getServicesState(),v=async(t={})=>{t?.resetFilter&&(t={service_id:"",paged:"",per_page:""});const a={...p,...t};e({isFiltering:!0});try{const t=await s.A.team.allTeamMembers(a);t.success&&e({teamMembers:{...t?.data},searchQuery:a})}catch(e){console.log(e)}};return{getMyprofileInfo:async()=>{try{const t=await s.A.team.getTeamMemberProfile();t.success&&e({profileInfo:t.data})}catch(e){console.log(e)}},getTeamMembers:v,addTeamMember:async t=>{try{e({editLoading:!0});const a=await s.A.team.createTeamMember(t);a.success&&e({teamMembers:{...n,total:n.total+1,items:[{...a?.data},...n.items]},visibleModal:!1}),e({editLoading:!1})}catch(t){console.log(t),e({editLoading:!1})}finally{e({editLoading:!1})}},deleteTeamMember:async t=>{try{if((await s.A.team.deleteSingleTeamMember(t)).success){const a=n.items.filter(e=>e.id!==t);e({teamMembers:{...n,total:a.length,items:a}})}}catch(e){console.log(e)}},getSingleTeamMember:async()=>{try{const t=await s.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 s.A.team.bulkDeleteTeamMember({ids:t})).success){const a=n.items.filter(e=>!t.includes(e.id));e({teamMembers:{...n,items:a}})}}catch(e){console.log(e)}},editTeamMember:async r=>{const i={...r,schedule:g,services:l,custom:r.enable_custom_schedule?m:[],holiday:r.enable_custom_holiday?u:[],enable_custom_availability:o},c=a||d.id;try{e({editLoading:!0});const a=await s.A.team.updateTeamMember(c,i);if(a?.success){const r=n?.items?.map(e=>e?.id===a?.data?.id?a?.data:e);e({teamMembers:{...n,items:r},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 s.A.team.reInviteTeamMember(e);t.success&&window.wp?.hooks.doAction("notification",{type:"success",message:t?.message})}catch(e){console.log(e)}},onPaginationChange:(e,t)=>{v({paged:e,per_page:t})}}}},79836:(e,t,a)=>{a.d(t,{Ch:()=>_,Es:()=>y,Kz:()=>S,QB:()=>m,Wb:()=>o,Xd:()=>v,Yz:()=>l,ee:()=>d,ff:()=>b,i5:()=>n,pj:()=>g,rG:()=>p,sI:()=>u});var r=a(59e3),i=a(22564),c=a(2812);const{Dropdown:s}=window?.booktics?.library||{},n=(0,r.A)(i.Flex)`
    margin-bottom: 10px;
`,o=(0,r.A)(i.TextInput)`
    &.ant-form-item {
        width: 100%;
        margin-bottom: 0px;
    }
    .ant-input-group-addon {
        padding-inline: 0px;
    }
`,l=(0,r.A)(i.Flex)`
    margin-bottom: 16px;
`,d=(0,r.A)(i.Card)`
    border-color: #cdd0d6;
    border-radius: 4px;
`,m=r.A.div`
    cursor: pointer;
`,u=(0,r.A)(c.Q)`
    .ant-input-number-group-addon {
        padding: 0;
        width: 80px;
        background-color: white;
        .ant-form-item {
            margin-bottom: 0;
        }
    }
`,g=((0,r.A)(i.Flex)`
    margin-bottom: 10px;
`,r.A.div`
    background-color: white;
    border-radius: 4px;
`),p=(0,r.A)(i.TextInput)`
    width: 100%;
    margin-bottom: 0px;
`,y=(0,r.A)(i.PrimaryOutlinedButton)`
    width: 100%;
    margin-bottom: 0px;
    border: none;
    justify-content: flex-start;
    background-color: #fafffd;
    margin-top: 10px;
`,v=((0,r.A)(s)`
    height: 46px;
    background-color: blue;
`,(0,r.A)(i.Flex)`
    .bkt-publish-btn-dropdown {
        button {
            height: 46px;
            padding: 12px 15px;
            :where(
                    .css-dev-only-do-not-override-mc1tut
                ).ant-btn-variant-outlined:not(:disabled):not(
                    .ant-btn-disabled
                ):hover {
                border-color: ${({theme:e})=>e.colors.primary};
                color: ${({theme:e})=>e.colors.primary};
            }
        }
    }
`),h={pointerEvents:"none",opacity:"0.5",cursor:"not-allowed"},b=r.A.div`
    ${e=>e.disabled&&h};
`,_=(0,r.A)(i.SwitchInput)`
    margin-bottom: 0px;
    margin-top: 10px;
`,S=(0,r.A)(i.Card)`
    .ant-card-body {
        padding: 16px 20px;
    }
`},88409:(e,t,a)=>{a.r(t),a.d(t,{default:()=>q});var r=a(51609),i=a(47143),c=a(86087),s=a(84976),n=a(47767),o=a(3038),l=a(22639),d=a(40309),m=a(22564),u=a(56580),g=a(93524),p=a(79836),y=a(95937),v=a(27723);const h=React.memo(()=>{const{isMobile:e}=(0,g.U)(),{copy:t,copied:a}=(0,y.A)(),{visibleShortcodeModal:s,shortcode:n}=(0,i.useSelect)(e=>e(d.services).getServicesState(),[]),{setServicesState:o}=(0,i.useDispatch)(d.services),l=()=>o({visibleShortcodeModal:!1});return(0,c.useEffect)(()=>{a&&window.wp?.hooks?.doAction("notification",{type:"success",message:(0,v.__)("Copied Shortcode","booktics")})},[a]),(0,r.createElement)(m.Modal,{open:s,title:(0,v.__)("Shortcode","booktics"),width:e?360:500,onClose:l,onCancel:l},(0,r.createElement)(m.Flex,{gap:5},(0,r.createElement)(p.rG,{value:n,readOnly:!0}),(0,r.createElement)(m.PrimaryButton,{text:(0,v.__)("Copy","booktics"),onClick:()=>t(n)})))});var b=a(88802),_=a(44064),S=a(46714),E=a(25723);const w=e=>{const{updateStatus:t}=(0,o.A)(),[a,r]=(0,c.useState)("active"===e.status);return{activeService:a,handleStatusChange:async a=>{try{const i={...e,status:a?"active":"deactive"};(await t(i)).success&&r(a)}catch(e){r(!a),console.error("Failed to update service status:",e)}}}};var x=a(59e3);const k=x.A.div`
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 190px;

    .btk-service-card-text {
        width: 110px;
    }
`,f=(0,x.A)(m.AdvancedCard)`
    opacity: ${({activeService:e})=>e?1:.5};

    .ant-card-body {
        padding: 0px;
    }
    p {
        white-space: nowrap;
    }
`,{DeleteOutlined:A}=window?.booktics?.libraryIcons||{},C=({service:e})=>{const{copy:t,copied:a}=(0,y.A)(),{deleteSingleService:s,duplicateService:n}=(0,o.A)(),{setServicesState:l}=(0,i.useDispatch)(d.services),g=(0,c.useCallback)(()=>{t(e.link)},[t,e.link]),p=(0,c.useCallback)(async()=>{await n(e.id)},[n,e.id]),h=(0,c.useCallback)(()=>{window.wp?.hooks?.doAction("delete_confirmation",{title:(0,v.__)("Are you sure you want to delete the service","booktics"),onOk:()=>s(e.id)})},[s,e.id]),b=(0,c.useCallback)(()=>{window.open(e.link,"_blank")},[e.link]),_=(0,c.useCallback)(()=>{l({visibleShortcodeModal:!0,shortcode:e.shortcode})},[]);(0,c.useEffect)(()=>{a&&window.wp?.hooks?.doAction("notification",{type:"success",message:(0,v.__)("Link copied","booktics")})},[a]);const{isAdmin:E}=(0,u.useUserRole)(),w=(0,c.useMemo)(()=>{const e=[{key:"copy_link",label:(0,r.createElement)(m.Flex,{gap:6},(0,r.createElement)(S.CopyLinkIcon,null)," ",(0,v.__)("Copy Link","booktics")),onClick:g},{key:"preview",label:(0,r.createElement)(m.Flex,{gap:6},(0,r.createElement)(S.PreviewIcon,null)," ",(0,v.__)("Preview","booktics")),onClick:b}];return E?[...e,{key:"short_code",label:(0,r.createElement)(m.Flex,{gap:6},(0,r.createElement)(S.ShortCodeIcon,null)," ",(0,v.__)("Short code","booktics")),onClick:_},{key:"clone",label:(0,r.createElement)(m.Flex,{gap:6},(0,r.createElement)(S.CopyIcon,null)," ",(0,v.__)("Clone","booktics")),onClick:p},{key:"delete",label:(0,r.createElement)(m.Flex,{gap:6},(0,r.createElement)(A,null)," ",(0,v.__)("Delete","booktics")),danger:!0,onClick:h}]:e},[E,g,b,_,p,h]);return(0,r.createElement)(m.Dropdown,{menu:{items:w},placement:"bottomRight",arrow:!1,trigger:"hover"},(0,r.createElement)(m.IconButton,{icon:(0,r.createElement)(S.ThreeDotIcon,null)}))},F=({service:e})=>{const t=(0,n.Zp)(),{data:a}=(0,i.useSelect)(e=>e(d.settings).getSettingsState()),{activeService:s,handleStatusChange:o}=w(e),l=e?.additional_durations?.[0]||{},u=(0,c.useMemo)(()=>(0,r.createElement)(_.Dz,{align:"flex-start",gap:10,justify:"space-between",wrap:!0},(0,r.createElement)(m.Flex,{gap:12},(0,r.createElement)(m.Avatar,{shape:"square",size:50,src:e.image||null,alt:e.display_name}),(0,r.createElement)("div",null,(0,r.createElement)("h4",{onClick:()=>t(`update/${e.id}`),className:"bkt-service-title"},e.title.slice(0,18),e.title.length>18?"...":null),(0,r.createElement)("p",null,Array.isArray(e?.category_details)?e?.category_details[0]?.name:(0,v.__)("Uncategorized","booktics")," ")))," ",(0,r.createElement)(m.Can,null,(0,r.createElement)(m.Switch,{checked:s,onChange:o}))),[s]);return(0,r.createElement)(f,{title:u,activeService:s},(0,r.createElement)(k,null,(0,r.createElement)(m.Flex,{align:"flex-start"},(0,r.createElement)("p",{className:"btk-service-card-text"},(0,v.__)("Team:","booktics")),(0,r.createElement)(m.AvatarGroup,{size:"large",max:{count:4}},Array.isArray(e.team_member_details)&&e.team_member_details.map(e=>(0,r.createElement)(m.Tooltip,{title:e.display_name,placement:"top",key:e.id},(0,r.createElement)(m.Avatar,{src:e.image||E,alt:e.display_name}))))),(0,r.createElement)(m.Flex,{justify:"flex-start",align:"center"},(0,r.createElement)("p",{className:"btk-service-card-text"},(0,v.__)("Durations:","booktics")),(0,r.createElement)(m.DurationTag,{time:l?.duration_time,unit:l?.duration_unit})),e?.extra_service_details&&(0,r.createElement)(m.Flex,{justify:"flex-start",align:"center"},(0,r.createElement)("p",{className:"btk-service-card-text"},(0,v.__)("Extra Service:","booktics")),(0,r.createElement)(m.Flex,{gap:4,wrap:!0},(0,r.createElement)(m.TagWithDropdown,{tags:e?.extra_service_details.map(e=>e.title),visibleTagNumber:1})))),(0,r.createElement)(_.wL,null,(0,r.createElement)(m.Flex,{justify:"space-between",align:"center"},l?.charge_amount?(0,r.createElement)(m.Pricing,{settings:a,price:e?.additional_durations?.length?e?.additional_durations[0]?.charge_amount:0}):(0,r.createElement)(m.Description,{text:(0,v.__)("Free","booktics")}),(0,r.createElement)(m.Flex,{gap:8},(0,r.createElement)(m.Can,null,(0,r.createElement)(m.Tooltip,{title:(0,v.__)("Edit Service","booktics")},(0,r.createElement)(m.IconButton,{icon:(0,r.createElement)(S.EditIcon,null),onClick:()=>t(`update/${e.id}`)}))),(0,r.createElement)(C,{service:e})))))},L=()=>{const{total:e,searchQuery:t,serviceList:a}=(0,i.useSelect)(e=>e(d.services).getServicesState(),[]),{onPaginationChange:c}=(0,o.A)();return a.length?(0,r.createElement)(r.Fragment,null,(0,r.createElement)(m.Row,{gutter:[20,20]},(a||[])?.map((e,t)=>(0,r.createElement)(m.Col,{xs:24,md:12,lg:8,xxl:8,key:e.id},(0,r.createElement)(F,{service:e})))),(0,r.createElement)(_.Mu,{justify:"flex-end",align:"center"},(0,r.createElement)(m.Pagination,{total:e,current:t.paged,pageSize:t.per_page||e,pageSizeOptions:b.pagination.pageSizeOptions,showSizeChanger:!0,onShowSizeChange:c,onChange:c}))):null},{PlusOutlined:T}=window?.booktics?.libraryIcons||{},M=()=>{const e=(0,n.Zp)();return(0,r.createElement)(m.Flex,{gap:8,align:"center"},(0,r.createElement)(m.ViewSelector,{defaultView:"card"}),(0,r.createElement)(m.Can,null,(0,r.createElement)(m.PrimaryButton,{text:(0,v.__)("New Service","booktics"),icon:(0,r.createElement)(T,null),onClick:()=>e(l.FC)})))};var I=a(4581);const{__}=wp.i18n||{},D=({setIsFiltered:e,selectedRowKeys:t,setSelectedRowKeys:a})=>{const{bulkDeleteService:i,getServices:c}=(0,o.A)();return(0,r.createElement)(r.Fragment,null,t.length?(0,r.createElement)(m.BulkDelete,{selectedRowKeys:t,setSelectedRowKeys:a,deleteApi:i}):(0,r.createElement)(m.Flex,{gap:6},(0,r.createElement)(m.SecondaryOutlineButton,{icon:(0,r.createElement)(S.FilterIcon,null),text:__("Filter","booktics"),onClick:()=>e(e=>!e),className:"bkt-filter-button"}),(0,r.createElement)(I.A,{searchFunc:c})))};var R=a(90803),z=a(52911);const{paged:Q,per_page:P}=b.pagination,B=()=>{const{searchQuery:e}=(0,i.useSelect)(e=>e(d.services).getServicesState(),[]),{categoryList:t}=(0,i.useSelect)(e=>e(d.category).getCategoryState(),[]),{teamMembers:a,isFiltering:r}=(0,i.useSelect)(e=>e(d.team).getTeamState(),[]),{getServices:c}=(0,o.A)(),{getCategories:s}=(0,R.A)(),{setServicesState:n}=(0,i.useDispatch)(d.services),{getTeamMembers:l}=(0,z.A)();return{getServices:c,getCategories:s,getTeamMembers:l,setServicesState:n,searchQuery:e,categoryList:t,teamMembers:a,teamIsFiltering:r,handleCategoryChange:t=>{const a={...e,paged:1,per_page:100,category_id:t};n({searchQuery:a}),c(a)},handleClearAll:()=>{n({searchQuery:{paged:Q,per_page:P},serviceList:null}),c({resetFilter:!0})},handleFilterByTeam:t=>{const a={...e,paged:1,team_member_id:t||void 0};n({searchQuery:a}),c(a)}}},K=()=>{const{searchQuery:e,categoryList:t,getCategories:a,handleCategoryChange:i}=B();return(0,c.useEffect)(()=>{t||a()},[]),t?(0,r.createElement)(m.Col,{xs:24,md:4},(0,r.createElement)(m.SelectInput,{showSearch:!0,placeholder:(0,v.__)("Select Category","booktics"),value:e?.category_id||void 0,onChange:i,options:Array.isArray(t)?t.map(e=>({label:e?.name,value:e?.id})):[]})):null},N=()=>{const{getTeamMembers:e,teamMembers:t,searchQuery:a,handleFilterByTeam:i}=B();return(0,c.useEffect)(()=>{t||e()},[]),t?(0,r.createElement)(m.Col,{xs:24,md:4},(0,r.createElement)(m.SelectInput,{showSearch:!0,optionFilterProp:"label",value:a.team_member_id||void 0,placeholder:(0,v.__)("Select Team","booktics"),options:Array.isArray(t?.items)?t?.items.map(e=>({label:e?.display_name,value:e?.id})):[],onChange:i})):null},$=()=>{const{searchQuery:e,handleClearAll:t}=B();return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(K,null),(0,r.createElement)(m.Can,null,(0,r.createElement)(N,null)),(e?.team_member_id||e?.category_id)&&(0,r.createElement)(m.Col,{xs:24,md:4},(0,r.createElement)(m.Button,{color:"red",variant:"link",onClick:t},(0,v.__)("All Clear","booktics"))))},O=({selectedRowKeys:e,setSelectedRowKeys:t})=>{const[a,i]=(0,c.useState)(!1),[n]=(0,s.ok)(),o=n.get("view")||"card";return(0,r.createElement)(m.SecondaryMenu,{selectedView:o,filteredTopMenu:(0,r.createElement)(r.Fragment,null,(0,r.createElement)(D,{setIsFiltered:i,selectedRowKeys:e,setSelectedRowKeys:t}),(0,r.createElement)(M,null)),isFiltered:a,filteredOptions:(0,r.createElement)($,null)})},j=({record:e})=>{const t=(0,n.Zp)();return(0,r.createElement)(m.Flex,{gap:8},(0,r.createElement)(m.Can,null,(0,r.createElement)(m.Tooltip,{title:(0,v.__)("Edit Service","booktics")},(0,r.createElement)(m.IconButton,{icon:(0,r.createElement)(S.EditIcon,null),onClick:()=>t(`update/${e.id}`)}))),(0,r.createElement)(C,{service:e}))},Z=({record:e})=>{const{activeService:t,handleStatusChange:a}=w(e);return(0,r.createElement)(m.Switch,{checked:t,onChange:a})},U=({record:e})=>{const{data:t}=(0,i.useSelect)(e=>e(d.settings).getSettingsState(),[]);return(0,r.createElement)(m.Pricing,{settings:t,price:e?.additional_durations?.length?e?.additional_durations[0]?.charge_amount:0})},G=({record:e})=>(0,r.createElement)(m.Tooltip,{title:e?.title},(0,r.createElement)(m.Flex,{align:"center",gap:10},(0,r.createElement)(m.Avatar,{shape:"square",size:50,src:e.image||null}),(0,r.createElement)(m.Flex,{vertical:!0},(0,r.createElement)("h4",null,e?.title.slice(0,15)),(0,r.createElement)(m.Description,{text:Array.isArray(e?.category_details)?e?.category_details[0]?.name:(0,v.__)("Uncategorized","booktics")})))),V=({record:e})=>(0,r.createElement)(m.AvatarGroup,{size:"large",max:{count:4}},Array.isArray(e.team_member_details)&&e.team_member_details.map(e=>(0,r.createElement)(m.Tooltip,{title:e.display_name,placement:"top",key:e.id},(0,r.createElement)(m.Avatar,{src:e.image||E,alt:e.display_name})))),W=({selectedRowKeys:e,setSelectedRowKeys:t})=>{const a=(()=>{const{isAdmin:e}=(0,u.useUserRole)(),t=[{title:(0,v.__)("Service","booktics"),dataIndex:"title",key:"title",fixed:"left",width:"200px",render:(e,t)=>(0,r.createElement)(G,{record:t})},{title:(0,v.__)("Duration","booktics"),dataIndex:"duration_time",key:"duration_time",width:"180px",render:(e,t)=>t?.additional_durations.length?(0,r.createElement)(m.DurationTag,{time:t?.additional_durations[0].duration_time,unit:t?.additional_durations[0].duration_unit}):null},{title:(0,v.__)("Price","booktics"),dataIndex:"charge_amount",key:"charge_amount",width:"140px",render:(e,t)=>(0,r.createElement)(U,{record:t})},{title:(0,v.__)("Extra Service","booktics"),dataIndex:"extra_service",key:"extra_service",width:"250px",render:(e,t)=>t?.extra_service_details?(0,r.createElement)(m.TagWithDropdown,{tags:t?.extra_service_details.map(e=>e.title),visibleTagNumber:1}):(0,r.createElement)(m.Text,{text:(0,v.__)("No extra service","booktics")})},{title:(0,v.__)("Team","booktics"),dataIndex:"team",key:"team",render:(e,t)=>(0,r.createElement)(V,{record:t})}];return e&&t.push({title:(0,v.__)("Active","booktics"),dataIndex:"active",key:"active",width:"150px",render:(e,t)=>(0,r.createElement)(Z,{record:t})}),t.push({title:(0,v.__)("Action","booktics"),dataIndex:"action",key:"action",width:"150px",fixed:"right",render:(e,t)=>(0,r.createElement)(j,{record:t})}),t})(),c=(0,n.Zp)(),{isAdmin:s}=(0,u.useUserRole)(),{total:l,searchQuery:g,serviceList:p}=(0,i.useSelect)(e=>e(d.services).getServicesState(),[]),{onPaginationChange:y}=(0,o.A)(),h={selectedRowKeys:e,onChange:e=>t(e)};return(0,r.createElement)(m.Table,{total:l,current:g.paged,pageSize:g.per_page||l,dataSource:p,pageSizeOptions:b.pagination.pageSizeOptions,columns:a,scroll:{x:1e3},rowSelection:!!s&&h,onPaginationChange:y,onRow:e=>({onClick:()=>{c(`update/${e.id}`)}})})},q=()=>{const[e,t]=(0,c.useState)([]),[a]=(0,s.ok)(),{getServices:g}=(0,o.A)(),p=(0,n.Zp)(),{serviceList:y,searchQuery:b}=(0,i.useSelect)(e=>e(d.services).getServicesState(),[]),{resetServices:_}=(0,i.useDispatch)(d.services),{paged:S,per_page:E}=b||{},{isQueried:w}=(0,u.useSearchEmptyState)(b),x=a.get("view")||"card",k=(0,c.useMemo)(()=>"card"===x?(0,r.createElement)(L,null):(0,r.createElement)(W,{selectedRowKeys:e,setSelectedRowKeys:t}),[x,e]);return(0,c.useEffect)(()=>{y||g({paged:S,per_page:E})},[b]),y?w||0!==y.length?(0,r.createElement)(r.Fragment,null,(0,r.createElement)(O,{selectedRowKeys:e,setSelectedRowKeys:t}),w&&0===y?.length?(0,r.createElement)(m.SearchNotFoundScreen,{searchQuery:b?.search||"",onClear:()=>_()}):k,(0,r.createElement)(h,null)):(0,r.createElement)(r.Fragment,null,(0,r.createElement)(m.EmptyScreen,{addButtonText:(0,v.__)("Add New Service","booktics"),onAddButtonClick:()=>p(l.FC),title:(0,v.__)("No Services Found","booktics"),description:(0,v.__)("You can add a new service by clicking the button below.","booktics")})):(0,r.createElement)(m.RowSkeleton,null)}},90803:(e,t,a)=>{a.d(t,{A:()=>n});var r=a(47143),i=a(47767),c=a(11534),s=a(40309);const n=()=>{const{setCategoryState:e}=(0,r.useDispatch)(s?.category),{id:t}=(0,i.g)(),a=(0,i.Zp)(),{categoryList:n=[],categoryIds:o,total:l,selectedServices:d,searchQuery:m}=(0,r.useSelect)(s?.category).getCategoryState();return{getCategories:async(t={})=>{t?.resetFilter&&(t={search:"",paged:"",per_page:""});const a={...m,...t};try{const t=await c.A.category.allCategories(a);t.success&&e({categoryList:t?.data?.items,total:t?.data?.total,searchQuery:a})}catch(e){console.error("Error fetching services:",e)}finally{return e({isFiltering:!1}),{complete:!0}}},addCategory:async(t,r=!0)=>{const i={...t,services:d};try{e({editLoading:!0});const t=await c.A.category.createCategory(i);t.success&&e({categoryList:[t?.data,...n],total:l+1,visibleModal:!1,categoryIds:[...o,t.data.id]}),e({editLoading:!1,visibleModal:!1}),r&&a("/services/category")}catch(t){console.log(t),e({editLoading:!1,visibleModal:!1})}finally{e({editLoading:!1,visibleModal:!1})}},getSingleCategory:async()=>{try{const a=await c.A.category.singleCategory(t);a.success&&e({singleCategory:{...a?.data}})}catch(e){console.log(e)}},editCategory:async r=>{const i={...r,services:d,category_id:t};try{e({editLoading:!0});const r=await c.A.category.updateCategory(t,i);if(r.success){const t=n?.map(e=>e?.id===r?.data?.id?r?.data:e);e({categoryList:t}),a("/services/category")}e({editLoading:!1})}catch(t){console.log(t),e({editLoading:!1})}finally{e({editLoading:!1})}},categoryBulkDelete:async(t=[])=>{try{if((await c.A.category.bulkDeleteCategory({ids:t})).success){const a=n.filter(e=>!t.includes(e.id));e({categoryList:a})}}catch(e){console.log(e)}},duplicateCategory:async t=>{try{e({isFiltering:!0});const a=await(c.A?.category?.cloneCategory(t));if(a?.success){const r=[...n],i=r.findIndex(e=>e.id===t);-1!==i?r.splice(i+1,0,a.data):r.push(a.data),e({categoryList:r,total:r.length})}}catch(e){console.error("Error duplicating category:",e)}finally{e({isFiltering:!1})}},deleteCategory:async t=>{try{if((await c.A.category.deleteSingleCategory(t)).success){const a=n.filter(e=>e.id!==t);e({categoryList:a,total:l-1})}}catch(e){console.log(e)}}}}}}]);