import{i as L}from"./emotion-use-insertion-effect-with-fallbacks.browser.esm-6809063d.js";import{a as e,F as K,j as p}from"./Tooltip-ae8d7992.js";import{L as Q}from"./Loader-45efafef.js";import{m as I,l as X,h as Y,E as u}from"./index-dfa17bed.js";import{D as Z,r as _}from"./DatosDom-24d9f33c.js";const{Button:f,Container:$}=await L("@mui/material"),{useEffect:v,useState:C}=await L("react"),io=t=>{const{rowSelected:m,ejecutarAdministraWf:l,mode:r,tarActual:d}=t,n=t.dataPrc,[i,c]=C(null);return v(()=>{I.getData(m.IPrId,["soldom"]).then(o=>{console.log(o),c(o.soldompar)}).catch(o=>{console.error(o)})},[]),I.isTruthy(n)&&!X.isNull(i)?e(K,{children:e(oo,{solInfo:m.IPrId,ejecutarAdministraWf:l,mode:r,valoresDomicilio:i,tarActual:d,iprId:t.dataPrc})}):e(Q,{})},oo=t=>{const{ejecutarAdministraWf:m,mode:l,valoresDomicilio:r,tarActual:d}=t,[n,i]=C(!1),{control:c,setValue:o,handleSubmit:h,formState:b,reset:S,watch:y,resetField:x,getValues:O}=Y({defaultValues:{DomDet:"",PrvId:"",LocId:"",PartId:"",CllId:"",BarId:"",DomPuerta:"",DomCP:"",DomPiso:"",DomDepto:"",DomLat:"",DomLng:"",DomGoogleDet:"",DomObs:""}}),[A,j,E,G,w,B,F,R,T]=y(["DomLat","DomLng","PrvId","LocId","CllId","BarId","PartId","DomObs","DomPuerta"]),M=a=>{W(a)};v(()=>{!I.isTruthy(r)||r===void 0||(o("DomDet",r.DomDet),o("PrvId",r.PrvId?.toString()),o("LocId",r.LocId?.toString()),o("PartId",r.PartId?.toString()),o("CllId",r.CllId?.toString()),o("BarId",r.BarId?.toString()),o("DomPuerta",r.DomPuerta?.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 V=()=>{console.log(b.errors),u.error("Por favor complete los campos obligatorios")},W=async a=>{const D={iprId:t.iprId,data:[{...a,DomTip:"PAR"}]};try{(await _.guardar("Dom",D)).success?t.ejecutarAdministraWf({out:a,act:"END",tar:d}):u.error("Error al guardar los datos")}catch(s){console.error(s),u.error("Error al guardar datos")}},N=a=>{k(a)},k=a=>{S();const{CllId:D,DomCP:s,DomPuerta:U,LocId:q,PrvId:z,DomLat:H,DomLng:J,PartId:g,DomGoogleDet:P}=a;o("PrvId",z),o("DomCP",s?.toString()??""),o("LocId",q),o("CllId",D.toString()),o("DomPuerta",U),o("DomLat",H),o("DomLng",J),g!==void 0&&o("PartId",g),s!==void 0&&o("DomCP",s),P!==void 0&&o("DomGoogleDet",P),i(!1)};return e($,{style:{display:"grid",gridRowGap:"10px"},children:p("form",{onSubmit:h(M,V),children:[e(Z,{mode:t.mode,control:c,dataPrc:t.iprId,cllId:w,prvId:E,locId:G,partId:F,barId:B,domObs:R,DomPuerta:T,getValues:O,isGoogleMapsOpen:n,setIsGoogleMapsOpen:i,triggerSeleccionarUbicacion:N,lat:A,lng:j,setValue:o,resetField:x,terminoCargaInicial:!0,mostrarCampo:["prv","loc","cll","bar","puerta","piso","depto","cp","geo"],disabled:l==="history",sinMapa:!1},"datos-laborales-dom-form"),l!=="history"&&p("div",{style:{display:"flex",justifyContent:"end",marginTop:"10px"},children:[e(f,{onClick:()=>{m({out:{},act:"ATR",tar:d})},variant:"outlined",children:"Atras"}),e(f,{sx:{marginLeft:"10px"},color:"secondary",type:"submit",variant:"contained",children:"Continuar"})]})]})})};export{io as default};
