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