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-d9e0bbb9.js";import{c as R,a as V,b as w}from"./index.esm-65c50bc3.js";import{o as I}from"./yup-267c2267.js";import{u as L}from"./index.esm-97139da9.js";import"./CustomDatepicker-9495774a.js";import{F as $}from"./FormInput-44ad439a.js";import"./index-e61c8ded.js";import"./ScrollableList-03cda798.js";import"./SectionDivider-95fcfa90.js";import{T as J}from"./TextArea-18d8079e.js";import{D as M}from"./Dialog-ef39ad8f.js";import{D as P}from"./DialogTitle-60c6eefe.js";import{D as G}from"./DialogContent-4a855a79.js";import{D as H}from"./DialogContentText-b49b6920.js";import{D as K}from"./DialogActions-2abea93f.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};
