import{a,W as E,j as e,b as m,y as h}from"./BulkImageUpload-DGPbX05r.js";import{I as D}from"./Input-CR3dcIBA.js";import{U as A}from"./User-DMCQU0ZG.js";import B from"./TabLink-DQDfvC1b.js";import{S as x}from"./sweetalert2.all-CGGHY7K6.js";import L from"./Path-BGQq4Hlj.js";import"./bootstrap.esm-e_F80uXB.js";const F=i=>{const[u,T]=a.useState("services"),[p,U]=a.useState(""),[l,q]=a.useState(i.lid),[r,I]=a.useState(i.services),[n,v]=a.useState(-1),[d,o]=a.useState(""),{data:R,setData:j,post:f,processing:N,errors:c,reset:Y,clearErrors:b}=E({name:"",lid:i.lid}),S=s=>{j(s.target.name,s.target.type==="checkbox"?s.target.checked:s.target.value),b(s.target.name)},g=s=>{s.preventDefault(),f(route("service.store"),{preserveState:t=>Object.keys(t.props.errors).length})},y=s=>()=>{v(s),o(r[s].name)},w=s=>()=>{h.put(route("service.update",r[s].id),{name:d,lid:l},{preserveState:!1})},k=s=>()=>{x.fire({title:"Are you sure want to Delete?",icon:"warning",showCancelButton:!0,confirmButtonText:"Yes, delete!"}).then(t=>{t.isConfirmed&&h.delete(route("service.destroy",r[s].id),{onSuccess:()=>{x.fire("Deleted!","Service Removed Sucessfully","success")},preserveState:!1})})};return e.jsxs(A,{children:[e.jsx(L,{title:"Business Services"}),e.jsx("div",{className:"container",children:e.jsx("div",{className:"row new-listing",children:e.jsx("div",{className:"col-md-10 p-0 listing-col mx-auto",children:e.jsxs("div",{className:"card shadow text-center",children:[e.jsx("div",{className:"card-header p-0",children:e.jsx(B,{active:u,typ:p,lid:l})}),e.jsx("div",{className:"card-body tab-content p-0",children:e.jsxs("div",{className:"form-container ",children:[c.limit&&e.jsxs("div",{className:"alert mb-4 alert-danger",role:"alert",children:["You reached your Maximum Limit",e.jsx(m,{className:"fw-bolder text-decoration-underline",href:route("choos-package"),children:" Upgrade your plan "}),"to add more"]}),e.jsx("form",{onSubmit:g,children:e.jsxs("div",{className:"row form-row",children:[e.jsxs("div",{className:"col-md-4",children:[e.jsx(D,{type:"text",className:c.name&&"inerror",name:"name",handleChange:S,placeholder:"Enter Service Name"}),c.name&&e.jsx("div",{className:"smart-valid",children:c.name})]}),e.jsx("div",{className:"col-md-2",children:e.jsx("button",{disabled:N,type:"submit",className:"btn btn-primary",children:"Add Service"})})]})}),e.jsx("div",{className:"row pb-1",children:r&&r.map((s,t)=>e.jsx("div",{className:"col-md-4 mb-4",children:e.jsxs("div",{className:"service-cover justify-content-between d-flex shado-1 p-3",children:[n!=t?e.jsx("h4",{className:"mb-0 text-truncate lh fs-6 text-start",children:s.name}):e.jsx("input",{type:"text",onChange:C=>o(C.target.value),className:"form-control mb-0",value:d}),n!=t?e.jsxs("div",{style:{width:"45px"},className:"icons align-content-stretch cp",children:[e.jsx("i",{onClick:y(t),className:"bi pe-2 bi-pencil-square"}),e.jsx("i",{onClick:k(t),className:"bi bi-trash3"})]}):e.jsx("div",{className:"icons d-flex flex-wrap align-items-center cp",children:e.jsx("i",{onClick:w(t),className:"bi ps-2 text-primary fs-5 bi-check-square"})})]})},t))})]})}),e.jsx("div",{className:"card-footer text-muted",children:e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col-md-6 pt-2 left",children:e.jsx("p",{children:"Step 4 of 7"})}),e.jsx("div",{className:"col-md-6 right",children:e.jsx(m,{href:route("user-dashboard"),children:e.jsx("button",{className:"btn  btn-light",children:"Skip and Go to Dashboard"})})})]})})]})})})})]})};export{F as default};
