import{r as d,u as D,b as y,j as e,x as C,w as S}from"./vendor-rThclpOQ.js";import{I as u}from"./input-error-Br4ngfdE.js";import{L as E}from"./loading-button-DKhpmf6V.js";import{B as x}from"./button-ZcsoqUQn.js";import{D as L,a as R,b as T,c as B,d as _,e as q,f as z}from"./dialog-CDEDwQhm.js";import{L as p}from"./label-CtY1vfZY.js";import{T as F}from"./textarea-DM_GyfeP.js";import{c as H}from"./utils-8KAaAB9H.js";import"./index-DquVdLUg.js";const U=({review:t})=>{const[g,o]=d.useState(!1),[h,l]=d.useState(0),{props:j}=D(),{translate:f}=j,{button:n,input:i,frontend:r,common:I}=f,{data:a,setData:c,put:v,errors:m,processing:w,reset:b}=y({rating:t.rating,review:t.review}),N=s=>{s.preventDefault(),v(route("course-reviews.update",t.id),{onSuccess:()=>{o(!1),b()}})};return e.jsxs(L,{open:g,onOpenChange:o,children:[e.jsx(R,{asChild:!0,children:e.jsx(x,{size:"icon",variant:"secondary",children:e.jsx(C,{className:"h-4 w-4"})})}),e.jsxs(T,{children:[e.jsx(B,{children:e.jsx(_,{children:r.edit_review})}),e.jsxs("form",{onSubmit:N,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{className:"text-sm font-medium",children:[i.rating," *"]}),e.jsx("div",{className:"flex gap-1",children:[1,2,3,4,5].map(s=>e.jsx("button",{type:"button",className:"transition-transform hover:scale-110",onMouseEnter:()=>l(s),onMouseLeave:()=>l(0),onClick:()=>c("rating",s),children:e.jsx(S,{className:H("h-8 w-8 cursor-pointer transition-colors",s<=(h||a.rating)?"fill-amber-400 text-amber-400":"text-gray-300 hover:text-amber-200")})},s))}),a.rating>0&&e.jsxs("p",{className:"text-muted-foreground text-sm",children:[r.you_rated_this," ",a.rating," ",a.rating!==1?r.stars:r.star]}),e.jsx(u,{message:m.rating})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(p,{className:"text-sm font-medium text-gray-700",children:[i.review," *"]}),e.jsx(F,{required:!0,value:a.review,onChange:s=>c("review",s.target.value),placeholder:i.description,className:"min-h-[120px] w-full resize-none"}),e.jsx(u,{message:m.review})]}),e.jsxs(q,{children:[e.jsxs(E,{loading:w,children:[n.update," ",n.review]}),e.jsx(z,{asChild:!0,children:e.jsx(x,{variant:"outline",children:n.cancel})})]})]})]})]})};export{U as default};
