import{o as e,r as t,t as n}from"./jsx-runtime-BbTa8W_M-1776590214964.js";import{a as r,o as i,t as a}from"./app-CXDQ5oEH-1776590214964.js";import{t as o}from"./useTranslation-D1etqd9u-1776590214964.js";import{t as s}from"./loader-circle-BF-wgoyu-1776590214964.js";import{t as c}from"./star-wSlMsd-z-1776590214964.js";import{t as l}from"./button-WiAFyHfP-1776590214964.js";import{t as u}from"./textarea-DoC3T7xj-1776590214964.js";var d=e(t(),1),f=n();function p({productId:e,onSuccess:t}){let{auth:n}=i().props,{t:p}=o(),{data:m,setData:h,post:g,processing:_,reset:v}=r({rating:0,comment:``}),[y,b]=(0,d.useState)(0);return n.user?(0,f.jsxs)(`form`,{onSubmit:n=>{if(n.preventDefault(),m.rating===0)return a.error(p(`Please select a star rating.`));g(route(`marketplace.reviews.store`,e),{preserveScroll:!0,onSuccess:e=>{e.props.errors&&e.props.errors.error?a.error(p(e.props.errors.error)):(a.success(p(`Review submitted successfully!`)),v(),t())},onError:e=>{a.error(p(e.error||`Failed to submit review.`))}})},className:`space-y-4 border rounded-xl p-5 bg-card shadow-sm`,children:[(0,f.jsx)(`h4`,{className:`font-bold text-lg`,children:p(`Write a Review`)}),(0,f.jsx)(`div`,{className:`flex items-center gap-1`,children:[1,2,3,4,5].map(e=>(0,f.jsx)(`button`,{type:`button`,className:`focus:outline-none transition-transform hover:scale-110`,onMouseEnter:()=>b(e),onMouseLeave:()=>b(0),onClick:()=>h(`rating`,e),children:(0,f.jsx)(c,{className:`w-8 h-8 ${e<=(y||m.rating)?`fill-amber-500 text-amber-500`:`text-muted-foreground/30`}`})},e))}),(0,f.jsx)(u,{placeholder:p(`What did you like or dislike? How was the quality?`),value:m.comment,onChange:e=>h(`comment`,e.target.value),className:`resize-none h-24`}),(0,f.jsxs)(l,{type:`submit`,disabled:_||m.rating===0,className:`w-full sm:w-auto px-8`,children:[_?(0,f.jsx)(s,{className:`w-4 h-4 mr-2 animate-spin`}):null,p(`Submit Review`)]})]}):(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:p(`Please log in to leave a review.`)})}export{p as t};