import{o as h,p as r,k as v,l as y,e as s,j as t,E as f,a9 as u,g as S,i as w,L as b}from"./app-BgLa5dit.js";function I(n){var c,d,g,p;const i=h(r.getDashboard(n.dashboardId)),e=(c=h(i.data&&r.getAssemblyLineTopics([i.data.topicId])).data)==null?void 0:c[0],m=v(),x=y(),a=s.getReviewItemErrorCode(e);function l(){const o=S.getHref({application:w.ASSEMBLY_LINE,action:s.mapStageToAction(e.stageValidation.stage),params:{query:e.id.toString(),presentationId:e.presentationId.toString()}});b.PageLoad(o,!0)}async function j(){if(a==="incorrect-stage"){m(r.updateTopicStage(i.data.topicId,e.stage,e.stageValidation.stage)).then(l).catch(()=>{x.error(`Something went wrong while trying to resolve ${e.name}. Please try again.`)}).finally(n.closePopup);return}l(),n.closePopup()}return t.jsxs(f,{title:"Resolve issue",closePopup:n.closePopup,showLoadingSpinner:!e,children:[e&&i.data?t.jsxs(t.Fragment,{children:[a==="previous-stage-valid"?t.jsxs("p",{children:["The topic ",t.jsx("strong",{children:e.name})," hasn't passed all stages yet."]}):t.jsxs(t.Fragment,{children:[t.jsxs("p",{children:["The topic ",t.jsx("strong",{children:e.name})," has the following issues:"]}),t.jsx("ul",{children:e.stageValidation.columnValidationResults.map(o=>t.jsx("li",{children:s.mapValidationErrorToLabel(o)},`${o.column}:${o.errorCode}`))})]}),a==="incorrect-stage"&&t.jsxs("p",{children:["It will automatically be moved to the",t.jsx("strong",{children:` ${s.formatStageName((d=e==null?void 0:e.stageValidation)==null?void 0:d.stage)} `}),"stage where all issues will need to be resolved."]}),a==="previous-stage-invalid"&&t.jsxs("p",{children:["Do you want to edit the topic in the ",t.jsx("strong",{children:s.formatStageName((g=e==null?void 0:e.stageValidation)==null?void 0:g.stage)})," stage?"]}),a==="previous-stage-valid"&&t.jsxs("p",{children:["Do you want to edit the topic in the ",t.jsx("strong",{children:s.formatStageName((p=e==null?void 0:e.stageValidation)==null?void 0:p.stage)})," stage?"]})]}):t.jsx(t.Fragment,{}),t.jsx(u,{children:t.jsx(u.Submit,{text:"Resolve issue",variant:"dark",onClick:j,type:"button"})})]})}export{I as ResolveTopicIssueView};
//# sourceMappingURL=7iLKmpy6.chunk.js.map
