import{c as k,a as x,aW as C,ho as _,r as E,j as r,T as s,I as S,J as D,B as q,bA as A,K as i,E as j,hr as F,hs as z,hG as O,hH as R}from"./index-7414fd54.js";import{c as V,a as w,b as B}from"./index.esm-24ac0554.js";import{o as L}from"./yup-42c56a9b.js";import{u as I}from"./index.esm-87a8ddec.js";import"./CustomDatepicker-6be798ca.js";import{F as $}from"./FormInput-64d1ec95.js";import"./index-b6124309.js";import"./ScrollableList-abce50c2.js";import"./SectionDivider-ec0341fc.js";import{T as G}from"./TextArea-5df59b36.js";import{D as H}from"./Dialog-8695d0ea.js";import{D as M}from"./DialogTitle-68b28184.js";import{D as P}from"./DialogContent-05d9166f.js";import{D as J}from"./DialogContentText-ab6f5201.js";import{D as K}from"./DialogActions-0c149659.js";const hr=({id:c})=>{var p,h,u;const n=k();x(C);const{selectedData:o,loading:f,isWorkOrderVisible:g,pageParams:m}=x(_),t=()=>{n(F({})),T(),n(z(!1))},b=V().shape({total_hours:w().typeError("Total hours must be a number").required("Total hours is required"),description:B().required("Please enter description")}),{control:d,handleSubmit:y,reset:T,setValue:a,getValues:N,trigger:X,formState:{errors:Q}}=I({resolver:L(b)}),v=e=>{console.log("data",e);const l={work_request_id:c||"",processing_mode:2,total_hours:e==null?void 0:e.total_hours,description:e==null?void 0:e.description},W={formDataTime:{total_hours:e.total_hours},id:c,pageParams:m,clearDataFn:()=>{t()}};n(O({formData:l,pageParams:m,clearDataFn:t})),n(R(W))};return E.useEffect(()=>{console.log(o==null?void 0:o.description),o&&(a("total_hours",o==null?void 0:o.total_hours),a("description",o==null?void 0:o.description))},[o]),r.jsxs(H,{open:g,onClose:(e,l)=>{l!=="backdropClick"&&t()},"aria-labelledby":"convert-to-workorder",fullWidth:!0,maxWidth:"md",children:[r.jsxs(M,{sx:{display:"flex",justifyContent:"space-between"},children:[r.jsx(s,{variant:"h5",fontWeight:600,p:2,pl:0,children:"Convert to Work Order"}),r.jsx(S,{onClick:t,children:r.jsx(D,{})})]}),r.jsx(P,{children:f?r.jsxs(q,{textAlign:"center",children:[r.jsx(A,{}),r.jsx(s,{children:"Loading..."})]}):r.jsx(r.Fragment,{children:r.jsxs(J,{sx:{mb:2},children:[r.jsxs(i,{container:!0,spacing:2,sx:{bgcolor:"#f4f4f4",p:2,borderRadius:2},children:[r.jsxs(i,{size:{xs:12},children:[r.jsx(s,{variant:"body2",color:"gray",children:"Asset Name"}),r.jsx(s,{fontWeight:600,children:((p=o==null?void 0:o.asset)==null?void 0:p.name)||"-"})]}),r.jsxs(i,{size:{xs:12,md:6},children:[r.jsx(s,{variant:"body2",color:"gray",children:"Department"}),r.jsx(s,{fontWeight:600,children:((h=o==null?void 0:o.department)==null?void 0:h.name)||"-"})]}),r.jsxs(i,{size:{xs:12,md:6},children:[r.jsx(s,{variant:"body2",color:"gray",children:"Location"}),r.jsx(s,{fontWeight:600,children:((u=o==null?void 0:o.location)==null?void 0:u.name)||"-"})]})]}),r.jsxs("form",{style:{width:"100%"},onSubmit:y(v),children:[r.jsxs(i,{container:!0,spacing:2,mt:2,children:[r.jsx(i,{size:{xs:12,md:6},children:r.jsx($,{required:!0,name:"total_hours",label:"Estimation Time(Hours)",type:"number",placeholder:"Enter Estimation Time ",control:d})}),r.jsx(i,{size:{xs:12,md:12},children:r.jsx(G,{name:"description",label:"Description",control:d,placeholder:"Enter description",onChange:e=>{a("description",e.target.value,{shouldValidate:!0})}})})]}),r.jsxs(K,{sx:{px:3,pb:2,pr:0},children:[r.jsx(j,{variant:"outlined",onClick:t,color:"success",children:"Cancel"}),r.jsx(j,{type:"submit",variant:"contained",color:"success",children:"Raise"})]})]})]})})})]})};export{hr as C};
