import{i as u}from"./emotion-use-insertion-effect-with-fallbacks.browser.esm-2ce7a1bc.js";import{a as i,j as U}from"./Tooltip-5ec3092e.js";import{c as A,g as H,h as q,i as d,j as D,k as p,m as l,z as e}from"./index-50f78195.js";import{D as J,r as K}from"./DatosDom-7c3a4cea.js";const{Button:Q,Container:W}=await u("@mui/material"),{useEffect:X,useState:Y}=await u("react"),eo=({id:g})=>{const I=g||0,f=A(),P=a=>{b(a)};X(()=>{(async()=>{try{const t=await d.post(`${D}/${p}/rest/mensajesPaperless/creaSession`,{iprid:s});await l.getData(parseInt(s),["sol","soldom","soldompar","solctt","solcrd"]).then(r=>{l.isTruthy(r.soldompar)&&(e.error("Domicilio ya cargado"),c(0))}).catch(r=>{e.error("Error al recuperar datos de solicitud"),console.error(r)})}catch(t){e.error("Error al actualizar domicilio"),console.error(t)}})()},[]);const b=a=>{v();const{CllId:t,DomCP:r,DomPuerta:$,LocId:V,PrvId:k,DomLat:F,DomLng:N,PartId:m,DomGoogleDet:n}=a;o("PrvId",k),o("DomCP",r?.toString()??""),o("LocId",V),o("CllId",t.toString()),o("DomPuerta",$),o("DomLat",F),o("DomLng",N),m!==void 0&&o("PartId",m),r!==void 0&&o("DomCP",r),n!==void 0&&o("DomGoogleDet",n)},{iprid:s}=H(),[h,c]=Y(1),{control:L,setValue:o,reset:v,handleSubmit:y,formState:C,watch:S,resetField:w,getValues:E}=q({defaultValues:{DomDet:"",PrvId:"",LocId:"",PartId:"",CllId:"",BarId:"",DomPuerta:"",DomCP:"",DomPiso:"",DomDepto:"",DomLat:"",DomLng:"",DomGoogleDet:"",DomObs:""}}),[j,O,x,G,z,B,M,R,T]=S(["DomLat","DomLng","PrvId","LocId","CllId","BarId","PartId","DomObs","DomPuerta"]);return i(W,{children:U("form",{hidden:h!==1,onSubmit:y(async a=>{console.log(a);const t=await K.guardar("Dom",{data:[{...a,DomObs:l.isTruthy(a.DomObs)?a.DomObs:"null",DomTip:"PAR"}],iprId:Number.parseInt(s===void 0?"":s)});t.success?(e.success("¡Domicilio guardado con exito!"),await d.post(`${D}/${p}/rest/mensajesPaperless/actualizaProc`,{iprid:s}).then(r=>{c(0),f("/carga-dom-success",{replace:!0})}).catch(r=>{console.error("Error en carga de dom:",r),e.error("Error al finalizar la carga")}).finally(()=>{})):e.error("Error al guardar el domicilio."),console.log(t)},()=>{console.log(C.errors),e.error("Por favor complete los campos obligatorios")}),style:{display:"grid",gridTemplateRows:"1fr max-content",rowGap:"10px",justifyContent:"center"},children:[i(J,{mode:"",control:L,dataPrc:I,cllId:z,prvId:x,locId:G,partId:M,barId:B,domObs:R,DomPuerta:T,getValues:E,isGoogleMapsOpen:!1,setIsGoogleMapsOpen:()=>{console.log("Mapa no habilitado")},triggerSeleccionarUbicacion:P,lat:j,lng:O,setValue:o,resetField:w,terminoCargaInicial:!0,mostrarCampo:["prv","loc","cll","bar","puerta","piso","depto","cp"],sinMapa:!0,disabled:!1},"datos-laborales-dom-form"),i(Q,{variant:"contained",type:"submit",children:"Enviar"})]})})};export{eo as default};
