import{r as I,m as f,ag as H,j as s,F as J,h as K,ah as Q,o as h,M as C,G as p}from"./index-e47c07e2.js";import{L as X}from"./PictureAsPdf-2d69fd1a.js";import{D as Y,r as Z}from"./DatosDom-c731b021.js";import"./DialogContentText-bbf9f64d.js";const ao=e=>{const{rowSelected:l,ejecutarAdministraWf:n,mode:t,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)&&!H.isNull(d)?s(J,{children:s(_,{solInfo:l.IPrId,ejecutarAdministraWf:n,mode:t,valoresDomicilio:d,tarActual:m,iprId:e.dataPrc})}):s(X,{})},_=e=>{const{ejecutarAdministraWf:l,mode:n,valoresDomicilio:t,tarActual:m}=e,[g,d]=I.useState(!1),{control:P,setValue:o,handleSubmit:b,formState:S,reset:y,watch:x,resetField:O,getValues:A}=K({defaultValues:{DomDet:"",PrvId:"",LocId:"",PartId:"",CllId:"",BarId:"",DomPuerta:"",DomCP:"",DomPiso:"",DomDepto:"",DomLat:"",DomLng:"",DomGoogleDet:"",DomObs:""}}),[E,G,j,B,F,R,T,w,M]=x(["DomLat","DomLng","PrvId","LocId","CllId","BarId","PartId","DomObs","DomPuerta"]),V=r=>{N(r)};I.useEffect(()=>{var r,i,a,c,D,u;!f.isTruthy(t)||t===void 0||(o("DomDet",t.DomDet),o("PrvId",(r=t.PrvId)==null?void 0:r.toString()),o("LocId",(i=t.LocId)==null?void 0:i.toString()),o("PartId",(a=t.PartId)==null?void 0:a.toString()),o("CllId",(c=t.CllId)==null?void 0:c.toString()),o("BarId",(D=t.BarId)==null?void 0:D.toString()),o("DomPuerta",(u=t.DomPuerta)==null?void 0:u.toString()),o("DomCP",t.DomCP),o("DomPiso",t.DomPiso),o("DomDepto",t.DomDepto),o("DomLat",t.DomLat),o("DomLng",t.DomLng),o("DomObs",t.DomObs))},[]);const W=()=>{console.log(S.errors),p.error("Por favor complete los campos obligatorios")},N=async r=>{const i={iprId:e.iprId,data:[{...r,DomTip:"PAR"}]};try{(await Z.guardar("Dom",i)).success?e.ejecutarAdministraWf({out:r,act:"END",tar:m}):p.error("Error al guardar los datos")}catch(a){console.error(a),p.error("Error al guardar datos")}},k=r=>{U(r)},U=r=>{y();const{CllId:i,DomCP:a,DomPuerta:c,LocId:D,PrvId:u,DomLat:q,DomLng:z,PartId:L,DomGoogleDet:v}=r;o("PrvId",u),o("DomCP",(a==null?void 0:a.toString())??""),o("LocId",D),o("CllId",i.toString()),o("DomPuerta",c),o("DomLat",q),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(Q,{style:{display:"grid",gridRowGap:"10px"},children:h("form",{onSubmit:b(V,W),children:[s(Y,{mode:e.mode,control:P,dataPrc:e.iprId,cllId:F,prvId:j,locId:B,partId:T,barId:R,domObs:w,DomPuerta:M,getValues:A,isGoogleMapsOpen:g,setIsGoogleMapsOpen:d,triggerSeleccionarUbicacion:k,lat:E,lng:G,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"&&h("div",{style:{display:"flex",justifyContent:"end",marginTop:"10px"},children:[s(C,{onClick:()=>{l({out:{},act:"ATR",tar:m})},variant:"outlined",children:"Atras"}),s(C,{sx:{marginLeft:"10px"},color:"secondary",type:"submit",variant:"contained",children:"Continuar"})]})]})})};export{ao as default};
