exports.id=2009,exports.ids=[2009],exports.modules={82009:(e,t,r)=>{"use strict";r.a(e,async(e,s)=>{try{r.r(t),r.d(t,{default:()=>ReviewForm});var a=r(20997),i=r(75609),d=r(60802),o=r(45009),n=r(66644),l=r(90872),m=r(37547),c=r(13330),x=r(45641),u=r(61175),p=r(54574),h=r(16689),v=r(86201),g=r(89699),_=r.n(g),b=r(77649),w=r(11377),j=e([n,l,m,x,p,v]);[n,l,m,x,p,v]=j.then?(await j)():j;let f=i.object().shape({rating:i.number().min(1,"You must need to provide a rating").required("You must need to provide a rating"),comment:i.string().required("You must need to provide a comment"),photos:i.array()});function ReviewForm(){let{data:e}=(0,o.X9)(),{closeModal:t}=(0,o.SO)(),r=(0,u.useQueryClient)(),[s,i]=(0,h.useState)(null),{t:g}=(0,w.useTranslation)("common"),{mutate:j,isLoading:y}=(0,u.useMutation)(p.Z.reviews.create,{onSuccess:()=>{v.default.success(g("text-review-submitted")),t()},onError:e=>{v.default.error(e?.response?.data?.message),i(e?.response?.data)},onSettled:()=>{r.invalidateQueries(b.P.ORDERS_DOWNLOADS)}}),{mutate:N,isLoading:k}=(0,u.useMutation)(p.Z.reviews.update,{onSuccess:()=>{v.default.success(g("text-review-updated")),t()},onError:e=>{i(e?.response?.data)},onSettled:()=>{r.invalidateQueries(b.P.ORDERS_DOWNLOADS)}});return(0,a.jsxs)("div",{className:"flex h-full min-h-screen w-screen flex-col justify-center bg-light text-left dark:bg-dark-250 xs:h-auto xs:min-h-0 xs:max-w-[400px] md:max-w-[590px] md:rounded-md lg:max-w-[650px]",children:[a.jsx("h3",{className:"mb-2 pl-6 pr-6 text-center text-base font-medium tracking-[-0.3px] text-dark dark:text-light xs:mb-0 xs:border-b xs:border-dark/10 xs:py-4 xs:pr-10 xs:text-left xs:dark:border-light/10 md:py-5 md:pl-7 lg:py-6 lg:pr-16",children:g("text-make-review")}),a.jsx("div",{className:"p-7",children:a.jsx(n.l,{onSubmit:t=>{if(e?.my_review){N({...t,photos:t?.photos?.map(({__typename:e,...t})=>t),id:e.my_review.id,order_id:e.order_id});return}j({...t,product_id:e.product_id,shop_id:e.shop_id,order_id:e.order_id})},validationSchema:f,serverError:s,useFormProps:{defaultValues:{rating:e?.my_review?.rating??0,comment:e?.my_review?.comment??"",photos:e?.my_review?.photos??[]}},children:({register:t,control:r,formState:{errors:s},getValues:i})=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"mb-5",children:[a.jsx("label",{className:"block cursor-pointer pb-1 text-13px font-normal text-dark/70 dark:text-light/70",children:g("text-rating-title")}),(0,a.jsxs)("div",{className:"w-auto",children:[a.jsx(m.Z,{control:r,name:"rating",defaultValue:0,style:{fontSize:30},allowClear:!1}),s?.rating&&a.jsx("p",{className:"my-2 text-xs text-red-500",children:s?.rating?.message})]})]}),a.jsx(c.Z,{label:g("text-comment-label"),...t("comment"),className:"mb-5",error:s?.comment?.message}),a.jsx("div",{className:"mb-8",children:a.jsx(x.Controller,{name:"photos",control:r,render:({field:{ref:e,...t}})=>(0,a.jsxs)("div",{className:"sm:col-span-2",children:[a.jsx("span",{className:"block cursor-pointer pb-2.5 text-13px font-normal text-dark/70 dark:text-light/70",children:g("text-input-attachment")}),a.jsx("div",{className:"text-xs",children:a.jsx(l.Z,{multiple:!0,...t})})]})})}),a.jsx("div",{className:"mt-8",children:a.jsx(d.Z,{className:"text-sm",isLoading:y||k,disabled:y||k,children:_()(e?.my_review)?g("text-write-review"):g("text-update-review")})})]})})})]})}s()}catch(e){s(e)}})},37547:(e,t,r)=>{"use strict";r.a(e,async(e,s)=>{try{r.d(t,{Z:()=>__WEBPACK_DEFAULT_EXPORT__});var a=r(20997),i=r(13116),d=r.n(i);r(20354);var o=r(45641),n=e([o]);o=(n.then?(await n)():n)[0];let __WEBPACK_DEFAULT_EXPORT__=({control:e,name:t,...r})=>a.jsx(o.Controller,{control:e,name:t,render:({field:{ref:e,...t}})=>a.jsx(d(),{...t,...r})});s()}catch(e){s(e)}})},20354:()=>{}};