import{r as I,m as f,bd as K,j as s,F as U,h as q,a9 as H,o as C,K as b,z as P}from"./index-7722cded.js";import{L as J}from"./PictureAsPdf-a0aef435.js";import{D as Q,r as X}from"./DatosDom-6f0f3839.js";import"./Close-24c851c2.js";import"./DialogContentText-8fb92df8.js";const to=e=>{const{rowSelected:l,ejecutarAdministraWf:n,mode:r,tarActual:m}=e,g=e.dataPrc,[d,p]=I.useState(null);return I.useEffect(()=>{f.getData(l.IPrId,["soldom"]).then(o=>{console.log(o),p(o.soldompar)}).catch(o=>{console.error(o)})},[]),f.isTruthy(g)&&!K.isNull(d)?s(U,{children:s(Y,{solInfo:l.IPrId,ejecutarAdministraWf:n,mode:r,valoresDomicilio:d,tarActual:m,iprId:e.dataPrc})}):s(J,{})},Y=e=>{const{ejecutarAdministraWf:l,mode:n,valoresDomicilio:r,tarActual:m}=e,[g,d]=I.useState(!1),{control:p,setValue:o,handleSubmit:h,formState:S,reset:y,watch:x,resetField:O}=q({defaultValues:{DomDet:"",PrvId:"",LocId:"",PartId:"",CllId:"",BarId:"",DomPuerta:"",DomCP:"",DomPiso:"",DomDepto:"",DomLat:"",DomLng:"",DomGoogleDet:"",DomObs:""}}),[A,E,j,G,B,F,R,T]=x(["DomLat","DomLng","PrvId","LocId","CllId","BarId","PartId","DomObs"]),w=t=>{W(t)};I.useEffect(()=>{var t,i,a,c,D,u;!f.isTruthy(r)||r===void 0||(o("DomDet",r.DomDet),o("PrvId",(t=r.PrvId)==null?void 0:t.toString()),o("LocId",(i=r.LocId)==null?void 0:i.toString()),o("PartId",(a=r.PartId)==null?void 0:a.toString()),o("CllId",(c=r.CllId)==null?void 0:c.toString()),o("BarId",(D=r.BarId)==null?void 0:D.toString()),o("DomPuerta",(u=r.DomPuerta)==null?void 0:u.toString()),o("DomCP",r.DomCP),o("DomPiso",r.DomPiso),o("DomDepto",r.DomDepto),o("DomLat",r.DomLat),o("DomLng",r.DomLng),o("DomObs",r.DomObs))},[]);const M=()=>{console.log(S.errors),P.error("Por favor complete los campos obligatorios")},W=async t=>{const i={iprId:e.iprId,data:[{...t,DomTip:"PAR"}]};try{(await X.guardar("Dom",i)).success?e.ejecutarAdministraWf({out:t,act:"END",tar:m}):P.error("Error al guardar los datos")}catch(a){console.error(a),P.error("Error al guardar datos")}},N=t=>{V(t)},V=t=>{y();const{CllId:i,DomCP:a,DomPuerta:c,LocId:D,PrvId:u,DomLat:k,DomLng:z,PartId:L,DomGoogleDet:v}=t;o("PrvId",u),o("DomCP",(a==null?void 0:a.toString())??""),o("LocId",D),o("CllId",i.toString()),o("DomPuerta",c),o("DomLat",k),o("DomLng",z),L!==void 0&&o("PartId",L),a!==void 0&&o("DomCP",a),v!==void 0&&o("DomGoogleDet",v),d(!1)};return s(H,{style:{display:"grid",gridRowGap:"10px"},children:C("form",{onSubmit:h(w,M),children:[s(Q,{mode:e.mode,control:p,dataPrc:e.iprId,cllId:B,prvId:j,locId:G,partId:R,barId:F,domObs:T,isGoogleMapsOpen:g,setIsGoogleMapsOpen:d,triggerSeleccionarUbicacion:N,lat:A,lng:E,setValue:o,resetField:O,terminoCargaInicial:!0,mostrarCampo:["prv","loc","cll","bar","puerta","piso","depto","cp","geo"],disabled:n==="history",sinMapa:!1},"datos-laborales-dom-form"),n!=="history"&&C("div",{style:{display:"flex",justifyContent:"end",marginTop:"10px"},children:[s(b,{onClick:()=>{l({out:{},act:"ATR",tar:m})},variant:"outlined",children:"Atras"}),s(b,{sx:{marginLeft:"10px"},color:"secondary",type:"submit",variant:"contained",children:"Continuar"})]})]})})};export{to as default};
