import{b as T,eh as k,a,ez as z,eA as I,j as i,I as M,ec as F,eB as $,eg as E,K as h,eC as K}from"./index-43bf7a1c.js";import{o as R}from"./yup-3b80ed10.js";import{S as X}from"./SelectComponent-84e66b0a.js";import{u as G}from"./index.esm-0548c843.js";import{c,b as _}from"./index.esm-f9e0a906.js";import{D as H,a as J}from"./DialogContent-d5902709.js";import{D as L}from"./DialogTitle-20dc6f66.js";import{D as N}from"./DialogContentText-abf03c9f.js";import{D as O}from"./DialogActions-d63c6496.js";const ir=({open:S,hide:s,selectedData:r,params:f})=>{var p,d,u,m,x;const b=T(),{id:j}=k();a(n=>z(n));const{tenderStage:{loading:C,pageParams:o,selecteditems:Q,modal:U,itemsList:l}}=a(n=>I(n)),y=c().shape({tender_stage:c({label:_().required("Please select a tender stage"),value:_().required("Please select a tender stage")}).required("Please select a tender stage").nullable()}),{control:v,handleSubmit:B,reset:w,getValues:A}=G({resolver:R(y),values:{tender_stage:(p=r==null?void 0:r.tender_stage)!=null&&p.id?{label:(d=r==null?void 0:r.tender_stage)!=null&&d.name?(u=r==null?void 0:r.tender_stage)==null?void 0:u.name:"",value:(m=r==null?void 0:r.tender_stage)!=null&&m.id?(x=r==null?void 0:r.tender_stage)==null?void 0:x.id:""}:null}}),g=A("tender_stage"),q=n=>{var e;const t={tender_id:r.id,tender_stage_id:(e=n==null?void 0:n.tender_stage)==null?void 0:e.value};b(K({id:r!=null&&r.id?r==null?void 0:r.id:"",data:t,hide:s,params:f})),w()};return i.jsxs(H,{open:S,onClose:s,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[i.jsxs(L,{sx:{bgcolor:"primary.main",color:"white",p:1,px:2,display:"flex",alignItems:"center",justifyContent:"space-between"},variant:"h4",id:"alert-dialog-title",children:["Biding Stage",i.jsx(M,{onClick:s,children:i.jsx(F,{color:"white"})})]}),i.jsx(J,{sx:{px:"24px",pt:"12px !important",pb:0},children:i.jsx(N,{id:"alert-dialog-description",sx:{width:500},children:i.jsx("form",{style:{width:"100%"},children:i.jsx(X,{name:"tender_stage",label:"Bid Stage",control:v,rules:{required:!0},options:(l==null?void 0:l.map(n=>{var t,e;return{id:((t=n.stage)==null?void 0:t.id)||"",name:String(((e=n==null?void 0:n.stage)==null?void 0:e.name)||"")}}))??[],loading:C,selectParams:{page:o==null?void 0:o.page,page_size:o==null?void 0:o.page_size,search:o==null?void 0:o.search,no_of_pages:o==null?void 0:o.no_of_pages,tender:(r==null?void 0:r.id)||j},hasMore:(o==null?void 0:o.page)<(o==null?void 0:o.no_of_pages),fetchapi:$,clearData:E})})})}),i.jsxs(O,{sx:{p:2},children:[i.jsx(h,{onClick:s,variant:"outlined",color:"secondary",children:"Cancel"}),i.jsx(h,{variant:"contained",onClick:B(q),type:"submit",color:"primary",disabled:!(g!=null&&g.value),autoFocus:!0,children:"Save"})]})]})};export{ir as S};
