import{aw as x,di as E,R as r,w as m,j as a,az as R,ax as c,dj as g,aA as l,u as v,aP as S,G as F,V as G,g as M,h as w,i as A,aQ as d}from"./app-BgLa5dit.js";import{M as j,G as N,a as h}from"./nGg28n7I.chunk.js";function O(s){const e=x(),o=E(e),n=e.values.project===j;return r.useEffect(()=>{s.getMilestones(e.values.project),n&&s.getBranchNames(e.values.project)},[e.values.project]),r.useEffect(()=>{e.setFieldValue("milestone",m.first(s.milestones))},[s.milestones]),r.useEffect(()=>{e.setFieldValue("branchName",m.first(s.branchNames))},[s.branchNames]),a.jsxs(R,{children:[a.jsx(c,{as:"select",label:"Project",name:"project",id:"project",value:e.values.project,children:N.map(t=>a.jsx("option",{value:t.id,children:t.name},t.id))}),a.jsx(c,{as:"select",label:"Milestone",name:"milestone",id:"milestone",value:e.values.milestone,disabled:!s.milestones.length,children:s.milestones.map(t=>a.jsx("option",{value:t,children:t},t))}),n&&a.jsx(c,{as:"select",label:"Branch Name",name:"branchName",id:"branchName",value:e.values.branchName,disabled:!s.branchNames.length,children:s.branchNames.map(t=>a.jsx("option",{value:t,children:t},t))}),a.jsx("div",{className:"d-flex justify-content-between",children:a.jsx(g,{showSpinner:e.isSubmitting,type:"submit",disabled:!o,children:"Generate"})})]})}const V=l.object().shape({project:l.string().required("Project is required").default(""),milestone:l.string().required("Milestone is required").default(""),branchName:l.string().when("project",(s,e)=>s===j?e.required("Branch name is required"):e).default("")}).noUnknown(),q={project:m.first(N).id};function B(){const[s,e]=r.useState([]),[o,n]=r.useState([]),[,t]=v(G.RELEASE_NOTES_CONFIG),u=S();function b(i){t(i),M.trigger({application:A.RELEASE_NOTES,action:w.ReleaseNotes.GENERATOR})}function f(i){e([]),d(u,h.milestones(i,e))}function p(i){n([]),d(u,h.branchNames(i,n))}return a.jsxs(a.Fragment,{children:[a.jsx("h4",{className:"py-2",children:"Generate Release Notes"}),a.jsx(F,{initialValues:q,onSubmit:b,validationSchema:V,children:a.jsx(O,{getMilestones:f,milestones:s,getBranchNames:p,branchNames:o})})]})}export{B as ReleaseNotesFormView};
//# sourceMappingURL=CXAmLbiI.chunk.js.map
