import{r as p,i as f,a_ as U,j as i,F as _,d as q,l as C,z as S,t as P}from"./index-cc84e56a.js";import{L as H}from"./PictureAsPdf-01d63a75.js";import{c as J,r as K}from"./GenericForm-b723407d.js";import{C as Q}from"./Container-56e8d2d4.js";import"./ContentCopy-975c4378.js";import"./Delete-96744410.js";import"./ListItemText-a965cfbd.js";import"./ImageViewerModal-6b52c15d.js";import"./cjs-0b69d496.js";import"./AdmUsuarios-10c7fd6e.js";import"./Edit-5a622c9b.js";import"./ListItemIcon-77037982.js";import"./Divider-b784899a.js";import"./NoRowsComponent-73b1b6ea.js";import"./MoreVert-64b91ae9.js";import"./createContainer-a5dd8c1d.js";import"./useForm-48439e2f.js";import"./useThemeProps-34ae68cb.js";import"./Card-ecc10a21.js";import"./CardContent-3949478d.js";import"./OmegaTransferList-a83f6ea3.js";import"./CardHeader-ce2759f4.js";import"./Avatar-74796535.js";import"./_commonjs-dynamic-modules-334f5ece.js";import"./env-198ff0f3.js";import"./mapValues-ae7c2760.js";import"./Scheduler-d20f7c7d.js";import"./___vite-browser-external_commonjs-proxy-159536b4.js";const xo=e=>{const{rowSelected:d,ejecutarAdministraWf:u,mode:r,tarActual:l}=e,I=e.dataPrc,[m,g]=p.useState(null);return p.useEffect(()=>{f.getData(d.IPrId,["soldom"]).then(o=>{console.log(o),g(o.soldompar)}).catch(o=>{console.error(o)})},[]),f.isTruthy(I)&&!U.isNull(m)?i(_,{children:i(X,{solInfo:d.IPrId,ejecutarAdministraWf:u,mode:r,valoresDomicilio:m,tarActual:l,iprId:e.dataPrc})}):i(H,{})},X=e=>{const{ejecutarAdministraWf:d,mode:u,valoresDomicilio:r,tarActual:l}=e,[I,m]=p.useState(!1),{control:g,setValue:o,handleSubmit:b,formState:h,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=>{M(t)};p.useEffect(()=>{var t,s,a,n,c,D;!f.isTruthy(r)||r===void 0||(o("DomDet",r.DomDet),o("PrvId",(t=r.PrvId)==null?void 0:t.toString()),o("LocId",(s=r.LocId)==null?void 0:s.toString()),o("PartId",(a=r.PartId)==null?void 0:a.toString()),o("CllId",(n=r.CllId)==null?void 0:n.toString()),o("BarId",(c=r.BarId)==null?void 0:c.toString()),o("DomPuerta",(D=r.DomPuerta)==null?void 0:D.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 W=()=>{console.log(h.errors),P.error("Por favor complete los campos obligatorios")},M=async t=>{const s={iprId:e.iprId,data:[{...t,DomTip:"PAR"}]};try{(await K.guardar("Dom",s)).success?e.ejecutarAdministraWf({out:t,act:"END",tar:l}):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:s,DomCP:a,DomPuerta:n,LocId:c,PrvId:D,DomLat:k,DomLng:z,PartId:L,DomGoogleDet:v}=t;o("PrvId",D),o("DomCP",(a==null?void 0:a.toString())??""),o("LocId",c),o("CllId",s.toString()),o("DomPuerta",n),o("DomLat",k),o("DomLng",z),L!==void 0&&o("PartId",L),a!==void 0&&o("DomCP",a),v!==void 0&&o("DomGoogleDet",v),m(!1)};return i(Q,{style:{display:"grid",gridRowGap:"10px"},children:C("form",{onSubmit:b(w,W),children:[i(J,{mode:e.mode,control:g,dataPrc:e.iprId,cllId:B,prvId:j,locId:G,partId:R,barId:F,domObs:T,isGoogleMapsOpen:I,setIsGoogleMapsOpen:m,triggerSeleccionarUbicacion:N,lat:A,lng:E,setValue:o,resetField:O,terminoCargaInicial:!0,mostrarCampo:["prv","loc","cll","bar","puerta","piso","depto","cp","geo"]},"datos-laborales-dom-form"),u!=="history"&&C("div",{style:{display:"flex",justifyContent:"end",marginTop:"10px"},children:[i(S,{onClick:()=>{d({out:{},act:"ATR",tar:l})},variant:"outlined",children:"Atras"}),i(S,{sx:{marginLeft:"10px"},color:"secondary",type:"submit",variant:"contained",children:"Continuar"})]})]})})};export{xo as default};
