"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4255],{4255:function(e,r,t){t.r(r),t.d(r,{default:function(){return QuestionForm}});var s=t(85893),a=t(16310),n=t(60802),l=t(66644),d=t(13330),i=t(45009),o=t(88767),c=t(28319),x=t(86501),u=t(77649),m=t(5233);let p=a.Ry().shape({question:a.Z_().required("Tell us more about it")});function QuestionForm(){let{data:e}=(0,i.X9)(),{t:r}=(0,m.$G)("common"),{closeModal:t}=(0,i.SO)(),a=(0,o.useQueryClient)(),{mutate:h,isLoading:f}=(0,o.useMutation)(c.Z.questions.create,{onSuccess:()=>{x.ZP.success(r("text-ask-question-success"))},onError:e=>{var t;let{response:{data:s}}=null!=e?e:{};(null==s?void 0:null===(t=s.message)||void 0===t?void 0:t.includes("MAXIMUM_QUESTION_LIMIT_EXCEEDED"))?x.ZP.error(r("text-ask-question-error")):x.ZP.error(null==s?void 0:s.message)},onSettled:()=>{a.refetchQueries([u.P.PRODUCTS_QUESTIONS]),t()}});return(0,s.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-xl lg:max-w-[650px]",children:[(0,s.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:r("text-ask-seller-question")}),(0,s.jsx)("div",{className:"p-6 md:p-7",children:(0,s.jsx)(l.l,{onSubmit:r=>{h({product_id:e.product_id,shop_id:e.shop_id,question:r.question})},validationSchema:p,children:e=>{var t;let{register:a,formState:{errors:l}}=e;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.Z,{...a("question"),className:"mb-5",error:null==l?void 0:null===(t=l.question)||void 0===t?void 0:t.message}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-xs leading-5 text-dark/60 ltr:pr-8 rtl:pl-8 dark:text-light/60",children:r("text-ask-question-desc")}),(0,s.jsx)(n.Z,{className:"text-sm",isLoading:f,disabled:f,children:r("text-submit")})]})]})}})})]})}},66644:function(e,r,t){t.d(r,{l:function(){return Form}});var s=t(85893),a=t(87536),n=t(47533),l=t(67294);let Form=e=>{let{onSubmit:r,children:t,useFormProps:d,validationSchema:i,serverError:o,resetFields:c,...x}=e,u=(0,a.cI)({...d,...i&&{resolver:(0,n.X)(i)}});return(0,l.useEffect)(()=>{o&&Object.entries(o).forEach(e=>{let[r,t]=e;u.setError(r,{type:"manual",message:t})})},[o,u]),(0,l.useEffect)(()=>{c&&u.reset(c)},[c,u]),(0,s.jsx)("form",{noValidate:!0,onSubmit:u.handleSubmit(r),...x,children:t(u)})}},13330:function(e,r,t){var s=t(85893),a=t(67294),n=t(93967),l=t.n(n),d=t(5233);let i=(0,a.forwardRef)((e,r)=>{let{label:t,error:a,className:n,inputClassName:i="bg-transparent",...o}=e,{t:c}=(0,d.$G)("common");return(0,s.jsxs)("div",{className:n,children:[(0,s.jsxs)("label",{className:"block text-13px",children:[t&&(0,s.jsx)("span",{className:"block cursor-pointer pb-2.5 font-normal text-dark/70 dark:text-light/70",children:c(t)}),(0,s.jsx)("textarea",{ref:r,...o,className:l()("min-h-[150px] w-full appearance-none rounded border border-light-500 px-4 py-3 text-13px text-dark ring-[0.5px] ring-light-500 placeholder:text-dark-900 focus:border-brand focus:ring-[0.5px] focus:ring-brand dark:border-dark-600 dark:text-light dark:ring-dark-600 dark:placeholder:text-dark-700 dark:focus:border-brand dark:focus:ring-brand lg:px-5",i)})]}),a&&(0,s.jsx)("span",{role:"alert",className:"block pt-2 text-xs text-warning",children:c(a)})]})});i.displayName="Textarea",r.Z=i}}]);