import{aA as c,R as g,o as v,aa as x,l as f,k,j as e,E as w,ak as S,al as j,am as F,G as y,az as P,ax as R,a9 as o,p as n,aR as A}from"./app-BgLa5dit.js";const T=c.object().shape({feedback:c.string().max(500,"Feedback is too long").required("Feedback is required").default("")});function C(s){var l;const[u,m]=g.useState(!1),r=v(A.currentUser()),a=x(s.id),d=f(),t=k();async function h(i){if(m(!0),!r.data.id)return;const b=[t(n.updateVideoStageWithFeedback(s.id,"review_thumbnail",i,r.data.id)),t(n.updateVideoStage(s.id,"review_thumbnail","curated_thumbnail")),t(n.updateFlags(a.data,"hasCuratedThumbnail",!1)),t(n.updateReviewer([a.data],a.data.thumbnailReviewers.map(p=>({reviewerId:p.reviewer.id,approved:!1}))))];Promise.all(b).then(()=>{d.success(`Successfully moved <strong>${a.data.name}</strong> back to the curated thumbnail stage.`),s.closePopup()}).catch(()=>{d.error(`Something went wrong while moving <strong>${a.data.name}</strong>. Please try again.`),s.closePopup()})}return e.jsx(w,{title:"Give feedback",closePopup:s.closePopup,showLoadingSpinner:!a.data,children:!!a.data&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Leave some suggestions on how to improve the thumbnail for ",e.jsx("strong",{children:a.data.name}),". This video will be moved back to the Curated Thumbnails stage."]}),e.jsx("div",{className:"pb-2 img-padding position-relative mb-2",children:e.jsx(S,{data:(l=a.data.thumbnail)==null?void 0:l.url,imageType:F.Thumbnails,imageOptions:{size:j.Medium}})}),e.jsx(y,{initialValues:{feedback:""},onSubmit:null,validationSchema:T,children:i=>e.jsxs(P,{children:[e.jsx(R,{name:"feedback",id:"feedback",as:"textarea",className:"form-control",rows:3,placeholder:"Leave a comment here..."}),e.jsxs(o,{children:[e.jsx(o.Cancel,{onClick:s.closePopup}),e.jsx(o.Submit,{showSpinner:u,onClick:()=>h(i.values.feedback),disabled:!i.isValid,type:"button",variant:"dark",text:"Submit"})]})]})})]})})}export{C as AssemblyLineGiveFeedbackView};
//# sourceMappingURL=BBB4YV0P.chunk.js.map
