import{r as I,i as f,b8 as U,j as s,F as q,d as H,l as C,z as b,t as P}from"./index-91e9700c.js";import{L as J}from"./PictureAsPdf-73d459d3.js";import{D as K,r as Q}from"./DatosDom-1b7497dd.js";import{C as X}from"./Container-3bb74340.js";import"./Close-84438d62.js";import"./DialogContentText-3801f418.js";import"./Divider-d0fc16ba.js";import"./createContainer-1f2487c8.js";const so=e=>{const{rowSelected:l,ejecutarAdministraWf:m,mode:r,tarActual:n}=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)&&!U.isNull(d)?s(q,{children:s(Y,{solInfo:l.IPrId,ejecutarAdministraWf:m,mode:r,valoresDomicilio:d,tarActual:n,iprId:e.dataPrc})}):s(J,{})},Y=e=>{const{ejecutarAdministraWf:l,mode:m,valoresDomicilio:r,tarActual:n}=e,[g,d]=I.useState(!1),{control:p,setValue:o,handleSubmit:h,formState:S,reset:y,watch:x,resetField:O}=H({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 Q.guardar("Dom",i)).success?e.ejecutarAdministraWf({out:t,act:"END",tar:n}):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(X,{style:{display:"grid",gridRowGap:"10px"},children:C("form",{onSubmit:h(w,M),children:[s(K,{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:m==="history",sinMapa:!1},"datos-laborales-dom-form"),m!=="history"&&C("div",{style:{display:"flex",justifyContent:"end",marginTop:"10px"},children:[s(b,{onClick:()=>{l({out:{},act:"ATR",tar:n})},variant:"outlined",children:"Atras"}),s(b,{sx:{marginLeft:"10px"},color:"secondary",type:"submit",variant:"contained",children:"Continuar"})]})]})})};export{so as default};
