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-c910e189.js";import{c as V,a as w,b as B}from"./index.esm-4b824583.js";import{o as L}from"./yup-e6171339.js";import{u as I}from"./index.esm-cb7a914e.js";import"./CustomDatepicker-fa2ab383.js";import{F as $}from"./FormInput-a4f22564.js";import"./index-f58a077c.js";import"./ScrollableList-4f192da2.js";import"./SectionDivider-782acfa4.js";import{T as G}from"./TextArea-173e49c2.js";import{D as H}from"./Dialog-a2882bbb.js";import{D as M}from"./DialogTitle-9a53d260.js";import{D as P}from"./DialogContent-589114d5.js";import{D as J}from"./DialogContentText-1b4ebcf7.js";import{D as K}from"./DialogActions-d05865c7.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};
