import{c as k,a as x,aW as C,hq as _,r as E,j as r,T as s,I as S,J as q,B as D,bB as A,K as i,E as j,ht as F,hu as z,hI as B,hJ as O}from"./index-7d3dbb9c.js";import{c as R,a as V,b as w}from"./index.esm-9d396c5f.js";import{o as I}from"./yup-55e79238.js";import{u as L}from"./index.esm-12cc9f7b.js";import"./CustomDatepicker-6d5ad1ab.js";import{F as $}from"./FormInput-602ae51d.js";import"./index-b5c17d61.js";import"./ScrollableList-ffeab0b0.js";import"./SectionDivider-be0a23cf.js";import{T as J}from"./TextArea-4d76f175.js";import{D as M}from"./Dialog-d125aee1.js";import{D as P}from"./DialogTitle-a3176c12.js";import{D as G}from"./DialogContent-d34f4ba4.js";import{D as H}from"./DialogContentText-9128b573.js";import{D as K}from"./DialogActions-99629c3a.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=R().shape({total_hours:V().typeError("Total hours must be a number").required("Total hours is required"),description:w().required("Please enter description")}),{control:d,handleSubmit:y,reset:T,setValue:a,getValues:N,trigger:X,formState:{errors:Q}}=L({resolver:I(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(B({formData:l,pageParams:m,clearDataFn:t})),n(O(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(M,{open:g,onClose:(e,l)=>{l!=="backdropClick"&&t()},"aria-labelledby":"convert-to-workorder",fullWidth:!0,maxWidth:"md",children:[r.jsxs(P,{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(q,{})})]}),r.jsx(G,{children:f?r.jsxs(D,{textAlign:"center",children:[r.jsx(A,{}),r.jsx(s,{children:"Loading..."})]}):r.jsx(r.Fragment,{children:r.jsxs(H,{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(J,{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};
