import{a as r,W as g,j as e}from"./BulkImageUpload-DGPbX05r.js";import{U as b}from"./User-DMCQU0ZG.js";import{U as w}from"./UserMenu-BCHgG7Y0.js";import S from"./Path-BGQq4Hlj.js";import{P as R}from"./Pagination-C_2iCAT4.js";import{S as l}from"./sweetalert2.all-CGGHY7K6.js";import"./bootstrap.esm-e_F80uXB.js";const A=c=>{const[t,n]=r.useState(c.review.data),[d,k]=r.useState(c.review.links),[m,o]=r.useState(-1),{data:x,setData:u,put:j,processing:y,errors:C,delete:v}=g({message:""}),h=s=>()=>{u("message",t[s].message),o(s)},f=s=>()=>{j(route("rating.update",s),{onSuccess:()=>{let a=t;a.forEach(i=>{i.id==s&&(i.message=x.message)}),n(a),l.fire("Updated!","Review Updated Successfully","success")}}),o(-1)},p=s=>()=>{l.fire({title:"Are you sure want to Delete?",icon:"warning",showCancelButton:!0,confirmButtonText:"Yes, delete!"}).then(a=>{a.isConfirmed&&v(route("rating.destroy",s),{onSuccess:()=>{n(i=>i.filter(N=>N.id!=s)),l.fire("Deleted!","Review Removed Successfully","success")},preserveState:!0})})};return e.jsxs(b,{children:[e.jsx(S,{title:"Reviews"}),e.jsx("div",{className:"container-fluid user-container",children:e.jsx("div",{className:"container",children:e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col-md-3",children:e.jsx(w,{user:c.auth.user})}),e.jsxs("div",{className:"col-md-9",children:[t&&t.map((s,a)=>e.jsxs("div",{className:"reiview no-margin bg-white py-3 mb-3 side-card row",children:[e.jsx("div",{className:"business",children:e.jsx("h4",{className:"fs-5 mb-1",children:s.business})}),e.jsxs("div",{className:"row  mb-1",children:[e.jsxs("div",{className:"rev pt-0 col-md-6",children:[e.jsx("i",{className:`${s.rating>=1&&"act"} pe-1 s-6 bi bi-star-fill`}),e.jsx("i",{className:`${s.rating>=2&&"act"} bi pe-1 bi-star-fill`}),e.jsx("i",{className:`${s.rating>=3&&"act"} bi  pe-1 bi-star-fill`}),e.jsx("i",{className:`${s.rating>=4&&"act"} bi pe-1 bi-star-fill`}),e.jsx("i",{className:`${s.rating>=5&&"act"} bi pe-1 bi-star-fill`})]}),e.jsx("div",{className:"col-md-6 text-end",children:e.jsxs("li",{className:"cp",children:[m!=a?e.jsxs("span",{onClick:h(a),children:[e.jsx("i",{className:"bi bi-pencil-square"})," Edit"]}):e.jsxs("span",{onClick:f(s.id),children:[e.jsx("i",{className:"bi bi-check2-square"})," Save"]}),e.jsxs("span",{onClick:p(s.id),children:[" ",e.jsx("i",{className:"bi ps-3 bi-trash"})," Delete "]})]})})]}),e.jsx("div",{className:"msgtxt",children:m!=a?e.jsx("p",{children:s.message}):e.jsx("textarea",{onChange:i=>u("message",i.target.value),value:x.message,className:"form-control mb-0 mt-1"})})]},a)),d.length===3?"":e.jsx("div",{className:"card-footer",children:e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col-md-6 pt-2"}),e.jsx("div",{className:"col-md-6 d-flex justify-content-end",children:e.jsx(R,{links:d})})]})})]})]})})})]})};export{A as default};
