import{c as k,a as x,aW as C,hp 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,hs as F,ht as z,hH as O,hI as R}from"./index-55b8aeb0.js";import{c as V,a as w,b as B}from"./index.esm-8f37a121.js";import{o as I}from"./yup-21078b88.js";import{u as L}from"./index.esm-31587b9b.js";import"./CustomDatepicker-9892b2ee.js";import{F as $}from"./FormInput-6413815f.js";import"./index-7c560a47.js";import"./ScrollableList-a069ff95.js";import"./SectionDivider-0fcc86df.js";import{T as H}from"./TextArea-c15d3047.js";import{D as M}from"./Dialog-5977b5ec.js";import{D as P}from"./DialogTitle-37cbd0b5.js";import{D as G}from"./DialogContent-c61b109b.js";import{D as J}from"./DialogContentText-766272a6.js";import{D as K}from"./DialogActions-57cb8efb.js";const hr=({id:c})=>{var d,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:p,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(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(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(D,{})})]}),r.jsx(G,{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:((d=o==null?void 0:o.asset)==null?void 0:d.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:p})}),r.jsx(i,{size:{xs:12,md:12},children:r.jsx(H,{name:"description",label:"Description",control:p,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};
