import{r as I,m as p,bf as K,j as s,F as U,h as q,aa as H,o as C,K as b,z as f}from"./index-28356639.js";import{L as J}from"./PictureAsPdf-4f5f60d5.js";import{D as Q,r as X}from"./DatosDom-f11d8bf3.js";import"./DialogContentText-8cf287af.js";const ro=e=>{const{rowSelected:l,ejecutarAdministraWf:n,mode:r,tarActual:m}=e,g=e.dataPrc,[d,P]=I.useState(null);return I.useEffect(()=>{p.getData(l.IPrId,["soldom"]).then(o=>{console.log(o),P(o.soldompar)}).catch(o=>{console.error(o)})},[]),p.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;!p.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),f.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}):f.error("Error al guardar los datos")}catch(a){console.error(a),f.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{ro as default};
