import{b as T,eh as k,a as m,er as I,es as M,j as i,I as z,ec as F,et as $,eg as E,K as x,eu as K}from"./index-76d4793e.js";import{o as R}from"./yup-688ec4f6.js";import{S as X}from"./SelectComponent-3c1140e6.js";import{u as G}from"./index.esm-3adfd9f7.js";import{c as h,b as _}from"./index.esm-ad8a7c9f.js";import{D as H,a as J}from"./DialogContent-7bd8dd8f.js";import{D as L}from"./DialogTitle-71dd5b3a.js";import{D as N}from"./DialogContentText-7642f81f.js";import{D as O}from"./DialogActions-5a5e1db9.js";const ir=({open:S,hide:s,selectedData:r,params:f})=>{var g,p,a,u,c;const b=T(),{id:j}=k();m(n=>I(n));const{tenderStage:{loading:y,pageParams:o,selecteditems:Q,modal:U,itemsList:l}}=m(n=>M(n)),C=h().shape({tender_stage:h({label:_().required("Please select a tender stage"),value:_().required("Please select a tender stage")}).required("Please select a tender stage").nullable()}),{control:v,handleSubmit:w,reset:B,getValues:q}=G({resolver:R(C),values:{tender_stage:(g=r==null?void 0:r.tender_stage)!=null&&g.id?{label:(p=r==null?void 0:r.tender_stage)!=null&&p.name?(a=r==null?void 0:r.tender_stage)==null?void 0:a.name:"",value:(u=r==null?void 0:r.tender_stage)!=null&&u.id?(c=r==null?void 0:r.tender_stage)==null?void 0:c.id:""}:null}}),d=q("tender_stage"),A=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})),B()};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(z,{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:y,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: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(x,{onClick:s,variant:"outlined",color:"secondary",children:"Cancel"}),i.jsx(x,{variant:"contained",onClick:w(A),type:"submit",color:"primary",disabled:!(d!=null&&d.value),autoFocus:!0,children:"Save"})]})]})};export{ir as S};
