"use strict";(globalThis.webpackChunkbooktics=globalThis.webpackChunkbooktics||[]).push([[1960],{50847:(e,t,o)=>{o.d(t,{$j:()=>r,Ic:()=>i,TQ:()=>s,yO:()=>c});var l=o(59e3),n=o(16784),a=o(22564);const r=(0,l.A)(a.Title)`
    margin-block: 0px !important;
`,s=(0,l.A)(a.Divider)`
    margin-block: 16px;
`,c=(0,l.A)(a.Text)`
    margin: 0px !important;
    font-weight: 500;
`,i=(0,l.A)(n.A)`
    .ant-table-thead .ant-table-cell {
        padding-left: 8px;
        padding-block: 0px;
        height: 48px;
        background-color: #ECEEF2;
    }
`},51960:(e,t,o)=>{o.r(t),o.d(t,{default:()=>P});var l=o(51609),n=o(47143),a=o(86087),r=o(48876),s=o(60742),c=o(40309),i=o(11534);const m=()=>{const{setCustomerState:e}=(0,n.useDispatch)(c?.customer),{customerList:t=[],singleCustomer:o,searchQuery:l,total:a}=(0,n.useSelect)(e=>e(c?.customer).getCustomerState(),[]),r=async(t={})=>{t?.resetFilter&&(t={customer_id:"",paged:"",per_page:""});const o={...l,...t};e({isFiltering:!0});try{const t=await i.A.customer.allCustomers(o);t.success&&e({customerList:t?.data.items||[],total:t.data.total,searchQuery:o})}catch(e){console.log(e)}finally{return e({isFiltering:!1}),{complete:!0}}};return{getAllCustomers:r,addCustomer:async o=>{const l={name:o.name,email:o.email,phone:o.phone};try{e({editLoading:!0});const o=await i.A.customer.createCustomer(l);o.success&&e({customerList:[o.data,...t],total:a+1,visibleModal:!1}),e({editLoading:!1})}catch(t){console.log(t),e({editLoading:!1})}finally{e({editLoading:!1})}},deleteSingleCustomer:async o=>{try{if((await i.A.customer.deleteSingleCustomer(o)).success){const l=t.filter(e=>e.id!==o);e({customerList:l,total:a-1})}}catch(e){console.log(e)}},getSingleCustomer:async t=>{try{const o=await i.A.customer.singleCustomer(t);o.success&&e({singleCustomer:o?.data})}catch(e){console.log(e)}},customerBulkDelete:async(o=[])=>{try{if((await i.A.customer.bulkDeleteCustomer({ids:o})).success){const l=t.filter(e=>!o.includes(e.id));e({customerList:l})}}catch(e){console.log(e)}},editCustomer:async l=>{if(o)try{e({editLoading:!0});const n=await i.A.customer.updateCustomer(o.id,l);if(n?.success){const o=t?.map(e=>e?.id===n?.data?.id?n?.data:e);e({customerList:o,visibleEditModal:!1,editLoading:!1})}}catch(t){console.error("Failed to update team member:",t),e({editLoading:!1,visibleEditModal:!1})}finally{e({editLoading:!1,visibleEditModal:!1})}},onPaginationChange:(e,t)=>{r({paged:e,per_page:t})}}};var u=o(22564),d=o(93524),E=o(27723);const g=React.memo(()=>{const{isMobile:e}=(0,d.U)(),{visibleModal:t,editLoading:o}=(0,n.useSelect)(e=>e(c.customer).getCustomerState(),[]),{setCustomerState:a}=(0,n.useDispatch)(c.customer),{addCustomer:r}=m(),[i]=s.A.useForm();return(0,l.createElement)(u.Modal,{open:t,title:(0,E.__)("Add New customer","booktics"),width:e?350:650,onClose:()=>a({visibleModal:!1}),onCancel:()=>a({visibleModal:!1}),footer:(0,l.createElement)(u.Flex,{gap:8,justify:"flex-end"},(0,l.createElement)(u.SecondaryButton,{text:(0,E.__)("Close","booktics"),onClick:()=>a({visibleModal:!1})}),(0,l.createElement)(u.PrimaryButton,{text:(0,E.__)("Add customer","booktics"),onClick:i.submit,loading:o}))},(0,l.createElement)(s.A,{layout:"vertical",form:i,onFinish:r},(0,l.createElement)(u.Row,{gutter:[20]},(0,l.createElement)(u.Col,{xs:24,md:12},(0,l.createElement)(u.TextInput,{label:(0,E.__)("Full Name","booktics"),name:"name",placeholder:(0,E.__)("Enter Customer full name","booktics"),required:!0})),(0,l.createElement)(u.Col,{xs:24,md:12},(0,l.createElement)(u.EmailInput,{label:(0,E.__)("Email","booktics"),name:"email",required:!0,placeholder:(0,E.__)("Enter Email","booktics")})),(0,l.createElement)(u.Col,{xs:24},(0,l.createElement)(u.CountryPhoneInput,{name:"phone",label:(0,E.__)("Phone","booktics"),placeholder:(0,E.__)("Enter phone number","booktics")})))))});var _=o(46714);const{DeleteOutlined:b}=window?.booktics?.libraryIcons||{},p=({record:e})=>{const{setCustomerState:t}=(0,n.useDispatch)(c.customer),{deleteSingleCustomer:o,getSingleCustomer:r}=m(),s=(0,a.useCallback)(()=>{window.wp?.hooks?.doAction("delete_confirmation",{title:(0,E.__)("Are you sure you want to delete the customer","booktics"),onOk:()=>o(e.id)})},[o,e.id]),i=async()=>{await r(e.id),t({visibleReportModal:!0})},d=(0,a.useMemo)(()=>[{key:"report",label:(0,l.createElement)(u.Flex,{gap:6},(0,l.createElement)(_.ReportIcon,null)," ",(0,E.__)("Report","booktics")),onClick:i},{key:"delete",danger:!0,label:(0,l.createElement)(u.Flex,{gap:6},(0,l.createElement)(b,null)," ",(0,E.__)("Delete","booktics")),onClick:s}],[s,i]);return(0,l.createElement)(u.Flex,{gap:8},(0,l.createElement)(u.Tooltip,{title:(0,E.__)("Edit Customer","booktics")},(0,l.createElement)(u.IconButton,{icon:(0,l.createElement)(_.EditIcon,null),onClick:async()=>{await r(e.id),t({visibleEditModal:!0})}})),(0,l.createElement)(u.Dropdown,{menu:{items:d},placement:"bottomRight",arrow:!1,trigger:"hover"},(0,l.createElement)(u.IconButton,{icon:(0,l.createElement)(_.ThreeDotIcon,null)})))},k=({record:e})=>{const{data:t}=(0,n.useSelect)(e=>e(c.settings).getSettingsState(),[]);return(0,l.createElement)(u.Pricing,{settings:t,price:e.total_amount})},C=[{title:(0,E.__)("Customer","booktics"),dataIndex:"display_name",key:"display_name",fixed:"left",width:"200px",render:(e,t)=>(0,l.createElement)(u.Flex,{vertical:!0},(0,l.createElement)(u.Title,{text:t.display_name,level:5}),(0,l.createElement)(u.Description,{text:t?.email}))},{title:(0,E.__)("Total Bookings","booktics"),dataIndex:"total_booking",key:"total_booking",width:"150px",render:(e,t)=>(0,l.createElement)("span",null,t.total_booking)},{title:(0,E.__)("Total Amount","booktics"),dataIndex:"total_amount",key:"total_amount",width:"100px",render:(e,t)=>(0,l.createElement)(k,{record:t})},{title:(0,E.__)("Registered On","booktics"),dataIndex:"user_registered",key:"user_registered",width:"200px",render:(e,t)=>(0,l.createElement)("span",null,t.user_registered)},{title:(0,E.__)("Action","booktics"),dataIndex:"action",key:"action",fixed:"right",width:"160px",render:(e,t)=>(0,l.createElement)(p,{record:t})}];var y=o(56580),x=o(4581);const h=({selectedRowKeys:e,setSelectedRowKeys:t,m:o})=>{const{customerBulkDelete:n,getAllCustomers:a}=m();return(0,l.createElement)(l.Fragment,null,e.length?(0,l.createElement)(u.BulkDelete,{selectedRowKeys:e,setSelectedRowKeys:t,deleteApi:n}):(0,l.createElement)(u.Flex,{gap:6},(0,l.createElement)(x.A,{searchFunc:a})))},{PlusOutlined:S}=window?.booktics?.libraryIcons||{},w=({selectedRowKeys:e,setSelectedRowKeys:t})=>{const{setCustomerState:o}=(0,n.useDispatch)(c.customer);return(0,l.createElement)(u.SecondaryMenu,{selectedView:"table",filteredTopMenu:(0,l.createElement)(l.Fragment,null,(0,l.createElement)(h,{selectedRowKeys:e,setSelectedRowKeys:t}),(0,l.createElement)(u.PrimaryButton,{text:(0,E.__)("New Customer","booktics"),icon:(0,l.createElement)(S,null),onClick:()=>o({visibleModal:!0})}))})};var v=o(50847);const f=({singleCustomer:e})=>(0,l.createElement)("div",null,(0,l.createElement)(v.$j,{level:5,text:(0,E.__)("Customer Information","booktics")}),(0,l.createElement)(v.TQ,null),(0,l.createElement)(u.Row,{gutter:[16,16]},(0,l.createElement)(u.Col,{xs:24,md:12},(0,l.createElement)(v.$j,{level:5,text:(0,E.__)("Name","booktics")}),(0,l.createElement)(u.Text,{text:e.name})),(0,l.createElement)(u.Col,{xs:24,md:12},(0,l.createElement)(v.$j,{level:5,text:(0,E.__)("Registered On","booktics")}),(0,l.createElement)(u.Text,{text:e?.user_registered})),(0,l.createElement)(u.Col,{xs:24,md:12},(0,l.createElement)(v.$j,{level:5,text:(0,E.__)("Email","booktics")}),(0,l.createElement)(u.Text,{text:e?.email})),e?.phone&&(0,l.createElement)(u.Col,{xs:24,md:12},(0,l.createElement)(v.$j,{level:5,text:(0,E.__)("Phone","booktics")}),(0,l.createElement)(u.Text,{text:e?.phone})))),R=({price:e})=>{const{data:t}=(0,n.useSelect)(e=>e(c.settings).getSettingsState(),[]);return(0,l.createElement)(u.Pricing,{settings:t,price:e})},A=[{title:(0,E.__)("No","booktics"),dataIndex:"no",key:"no",render:(e,t,o)=>(0,l.createElement)("span",null,o+1)},{title:(0,E.__)("Date","booktics"),dataIndex:"date",key:"date",render:(e,t)=>(0,l.createElement)("span",null,t?.date)},{title:(0,E.__)("Total Service","booktics"),dataIndex:"total_booking",key:"total_booking",render:(e,t)=>(0,l.createElement)("span",null,t?.total_booking)},{title:(0,E.__)("Amount","booktics"),dataIndex:"total_amount",key:"total_amount",render:(e,t)=>(0,l.createElement)(R,{price:t?.total_amount})}],F=({singleCustomer:e})=>(0,l.createElement)("div",null,(0,l.createElement)(v.$j,{level:5,text:(0,E.__)("Service Summary","booktics")}),(0,l.createElement)(v.TQ,null),(0,l.createElement)(v.Ic,{columns:A,dataSource:e?.orders,pagination:!1})),I=()=>{const{singleCustomer:e}=(0,n.useSelect)(e=>e(c.customer).getCustomerState(),[]),{data:t}=(0,n.useSelect)(e=>e(c.settings).getSettingsState(),[]);return(0,l.createElement)("div",null,(0,l.createElement)(v.$j,{level:5,text:(0,E.__)("Payment Summary","booktics")}),(0,l.createElement)(v.TQ,null),(0,l.createElement)(u.Flex,{justify:"space-between"},(0,l.createElement)(v.yO,{text:(0,E.__)("Subtotal","booktics")}),(0,l.createElement)(u.Pricing,{settings:t,price:e?.total_amount})),(0,l.createElement)(v.TQ,null),(0,l.createElement)(u.Flex,{justify:"space-between"},(0,l.createElement)(v.$j,{level:5,text:(0,E.__)("Total","booktics")}),(0,l.createElement)(u.Pricing,{settings:t,price:e?.total_amount})))},M=React.memo(()=>{const{isMobile:e}=(0,d.U)(),{visibleReportModal:t,singleCustomer:o}=(0,n.useSelect)(e=>e(c.customer).getCustomerState(),[]),{setCustomerState:a}=(0,n.useDispatch)(c.customer),r=()=>a({visibleReportModal:!1});if(o)return(0,l.createElement)(u.Modal,{open:t,title:o?.display_name,width:e?350:720,onClose:r,onCancel:r},(0,l.createElement)(u.Flex,{vertical:!0,gap:30},(0,l.createElement)(f,{singleCustomer:o}),(0,l.createElement)(F,{singleCustomer:o}),(0,l.createElement)(I,{singleCustomer:o})))}),T=({form:e})=>{const{editCustomer:t}=m();return(0,l.createElement)(s.A,{layout:"vertical",form:e,onFinish:t},(0,l.createElement)(u.Row,{gutter:[20]},(0,l.createElement)(u.Col,{xs:24,md:12},(0,l.createElement)(u.TextInput,{label:(0,E.__)("Full Name","booktics"),name:"name",placeholder:(0,E.__)("Enter Customer full name","booktics"),required:!0})),(0,l.createElement)(u.Col,{xs:24,md:12},(0,l.createElement)(u.EmailInput,{label:(0,E.__)("Email","booktics"),name:"email",disabled:!0,placeholder:(0,E.__)("Enter Email","booktics")})),(0,l.createElement)(u.Col,{xs:24},(0,l.createElement)(u.CountryPhoneInput,{name:"phone",label:(0,E.__)("Phone","booktics"),placeholder:(0,E.__)("Enter phone number","booktics")}))))},D=React.memo(()=>{const{isMobile:e}=(0,d.U)(),{visibleEditModal:t,editLoading:o,singleCustomer:a}=(0,n.useSelect)(e=>e(c.customer).getCustomerState(),[]),[r]=u.Form.useForm(),{setCustomerState:s}=(0,n.useDispatch)(c.customer),i=()=>{s({visibleEditModal:!1})};if(a)return r.setFieldsValue(a),(0,l.createElement)(u.Modal,{open:t,title:(0,E.__)("Update Customer","booktics"),width:e?350:650,onClose:i,onCancel:i,footer:(0,l.createElement)(u.Flex,{gap:8,justify:"flex-end"},(0,l.createElement)(u.SecondaryButton,{text:(0,E.__)("Close","booktics"),onClick:i}),(0,l.createElement)(u.PrimaryButton,{text:(0,E.__)("Update customer","booktics"),onClick:r.submit,loading:o}))},(0,l.createElement)(T,{form:r}))}),P=()=>{const{setCustomerState:e,resetCustomer:t}=(0,n.useDispatch)(c.customer),{customerList:o,total:s,searchQuery:i}=(0,n.useSelect)(e=>e(c?.customer).getCustomerState(),[]),{getAllCustomers:d,onPaginationChange:_}=m(),{rowSelection:b,selectedRowKeys:p,setSelectedRowKeys:k}=(()=>{const[e,t]=(0,a.useState)([]);return{rowSelection:{selectedRowKeys:e,onChange:e=>t(e)},selectedRowKeys:e,setSelectedRowKeys:t}})(),{isQueried:x}=(0,y.useSearchEmptyState)(i);return(0,a.useEffect)(()=>{o||d()},[i]),o?x||0!==o.length?x&&0===o.length?(0,l.createElement)(l.Fragment,null,(0,l.createElement)(r.A,{title:(0,E.__)("Customers","booktics")}),(0,l.createElement)(u.ResponsiveContainer,null,(0,l.createElement)(w,{selectedRowKeys:p,setSelectedRowKeys:k}),(0,l.createElement)(u.SearchNotFoundScreen,{searchQuery:i?.search||"",onClear:()=>t()})),(0,l.createElement)(g,null)):(0,l.createElement)(l.Fragment,null,(0,l.createElement)(r.A,{title:(0,E.__)("Customers","booktics")}),(0,l.createElement)(u.ResponsiveContainer,null,(0,l.createElement)(w,{selectedRowKeys:p,setSelectedRowKeys:k}),(0,l.createElement)(u.Table,{total:s,pageSize:i.per_page||s,currentPage:i.paged,dataSource:o,columns:C,scroll:{x:1e3},rowSelection:b,onPaginationChange:_})),(0,l.createElement)(g,null),(0,l.createElement)(M,null),(0,l.createElement)(D,null)):(0,l.createElement)(l.Fragment,null,(0,l.createElement)(r.A,{title:(0,E.__)("Customers","booktics")}),(0,l.createElement)(u.ResponsiveContainer,null,(0,l.createElement)(u.EmptyScreen,{description:(0,E.__)(" Add a new customer to get started.","booktics"),title:(0,E.__)("No Customers Found","booktics"),addButtonText:(0,E.__)("Add New Customer","booktics"),onAddButtonClick:()=>e({visibleModal:!0})})),(0,l.createElement)(g,null)):(0,l.createElement)(u.RowSkeleton,null)}}}]);