import{o as S,p as v,aa as V,k as A,l as I,e as o,j as e,E as P,a9 as x,L as j,g as R,i as F}from"./app-BgLa5dit.js";import{u as E}from"./Brw8lpR5.chunk.js";import"./CY0zrGLk.chunk.js";function N(s){var l,c,g,u,h,p;const n=S(v.getDashboard(s.dashboardId)),a=V(s.videoId,!0),{presentations:f,isLoading:w}=E({},"video","review_dashboard","clickview"),y=A(),r=I(),i=o.getReviewItemErrorCode(a.data);function d(){let t=a.data.stage;if(i==="incorrect-stage"&&(t=a.data.stageValidation.stage),["published_video","review_video"].includes(t)){r.success("Video issues have been resolved! Reloading the page..."),window.setTimeout(()=>{j.Reload()},500);return}const m={query:a.data.id.toString()};n.data.presentationId&&(m.presentationId=n.data.presentationId.toString());const L=R.getHref({application:F.ASSEMBLY_LINE,action:o.mapStageToAction(t),params:m});j.PageLoad(L,!0)}async function b(){if(i==="incorrect-stage"){y(v.updateVideoStage(s.videoId,a.data.stage,a.data.stageValidation.stage)).then(d).catch(()=>{r.error(`Something went wrong while trying to resolve ${a.data.name}. Please try again.`)}).finally(s.closePopup);return}d(),s.closePopup()}return e.jsxs(P,{title:"Resolve issue",closePopup:s.closePopup,showLoadingSpinner:!a.data||!n.data||w,children:[a.data&&n.data?e.jsxs(e.Fragment,{children:[i==="previous-stage-valid"?e.jsxs("p",{children:["The video ",e.jsx("strong",{children:a.data.name})," hasn't passed all stages yet."]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["The video ",e.jsx("strong",{children:a.data.name})," has the following issues:"]}),e.jsx("ul",{children:a.data.stageValidation.columnValidationResults.map(t=>e.jsx("li",{children:o.mapValidationErrorToLabel(t,f)},`${t.column}:${t.errorCode}`))})]}),i==="incorrect-stage"&&e.jsxs("p",{children:["It will automatically be moved to the",e.jsx("strong",{children:` ${o.formatStageName((c=(l=a.data)==null?void 0:l.stageValidation)==null?void 0:c.stage)} `}),"stage where all issues will need to be resolved."]}),i==="previous-stage-invalid"&&e.jsxs("p",{children:["Do you want to edit the video in the ",e.jsx("strong",{children:o.formatStageName((u=(g=a.data)==null?void 0:g.stageValidation)==null?void 0:u.stage)})," stage?"]}),i==="previous-stage-valid"&&e.jsxs("p",{children:["Do you want to edit the video in the ",e.jsx("strong",{children:o.formatStageName((p=(h=a.data)==null?void 0:h.stageValidation)==null?void 0:p.stage)})," stage?"]})]}):e.jsx(e.Fragment,{}),e.jsx(x,{children:e.jsx(x.Submit,{text:"Resolve issue",variant:"dark",onClick:b,type:"button"})})]})}export{N as ResolveVideoIssueView};
//# sourceMappingURL=CdsX1tSC.chunk.js.map
