import{r as d,j as e,a8 as p,P,a as s,S as i,ad as R,H as B,_ as c,ar as v,as as k,at as M,af as z,I,T as l,D as Q,w as W,g as F}from"./index-09tpYl64.js";import{t as L}from"./tundishes.repository-nvfi-bIc.js";/* empty css                              */import{T as N}from"./TableContainer-B8l2b0Os.js";import{a as $,b as A,T as h}from"./TableRow-CDjskHei.js";const r=W(),E=Q(()=>({table:{"--ag-font-size":11,"& .ag-cell-label-container":{height:"2rem"}}})),V=()=>{const T=E(),[o,x]=d.useState([]),[m,f]=d.useState(r().startOf("month").toDate()),[g,S]=d.useState(r().toDate()),[D,u]=d.useState("thisMonth"),[q,b]=d.useState(!1),O=t=>{let a,n;switch(t){case"thisWeek":a=r().startOf("week"),n=r();break;case"thisMonth":a=r().startOf("month"),n=r();break;case"q1":a=r().month(0).startOf("quarter"),n=r().month(0).endOf("quarter");break;case"q2":a=r().month(3).startOf("quarter"),n=r().month(3).endOf("quarter");break;case"q3":a=r().month(6).startOf("quarter"),n=r().month(6).endOf("quarter");break;case"q4":a=r().month(9).startOf("quarter"),n=r().month(9).endOf("quarter");break;case"thisYear":a=r().startOf("year"),n=r();break;default:a=r().startOf("month"),n=r()}f(a.toDate()),S(n.toDate())},y=t=>{u(t),O(t)},C=async()=>{b(!0);const t=await L.getTundishTrackReport({start:m.toISOString(),end:g.toISOString()});if(t.ok){const a=F(t.data,"tables[0].rows",[]);x(a)}b(!1)};return e(p,{m:2,children:e(P,{elevation:3,children:e(p,{p:2,children:s(i,{container:!0,spacing:1,children:[e(i,{item:!0,xs:12,children:e(R,{variant:"h6",children:"Tundish Track Report"})}),s(i,{item:!0,xs:12,container:!0,spacing:3,alignItems:"center",children:[e(i,{item:!0,style:{minWidth:"300px"},children:s(B,{select:!0,variant:"outlined",label:"Quick Select","aria-label":"Quick Select",fullWidth:!0,value:D,onChange:t=>y(t.target.value),children:[e(c,{value:"thisWeek",children:"This Week"}),e(c,{value:"thisMonth",children:"This Month"}),e(c,{value:"q1",children:"Q1"}),e(c,{value:"q2",children:"Q2"}),e(c,{value:"q3",children:"Q3"}),e(c,{value:"q4",children:"Q4"}),e(c,{value:"thisYear",children:"This Year"})]})}),e(i,{item:!0,children:e(v,{value:r(m),onChange:(t,a)=>{t&&(f(t.toDate()),u("custom"))},timezone:k.getInstance().getServerTimeZone(),label:"Start Date"})}),e(i,{item:!0,children:e(v,{value:r(g),onChange:(t,a)=>{t&&(S(t.toDate()),u("custom"))},timezone:k.getInstance().getServerTimeZone(),label:"End Date"})}),e(i,{item:!0,children:e(M,{color:"primary",variant:"contained",fullWidth:!0,onClick:C,isLoading:q,children:"Search"})})]}),e(i,{item:!0,xs:12,container:!0,children:e(i,{item:!0,style:{height:"50vh",width:"100%"},className:`ag-theme-material ${T.table}`,children:e(z.AgGridReact,{rowSelection:"single",getRowId:t=>t.data.RootName,rowData:o,defaultColDef:{sortable:!0,resizable:!0},gridOptions:{rowHeight:25,rowStyle:{fontSize:12}},columnDefs:[{flex:1,field:"RootName",headerName:"Tundish"},{flex:1,field:"PermanentLiningHeats"},{flex:1,field:"RemainingLife",valueFormatter:t=>`${(t.value*100).toFixed(2)}%`,cellStyle:t=>{const a=(t.value+1)/2,n=Math.round(255*(1-a)),w=Math.round(255*a),H=Math.abs(t.value);return{backgroundColor:`rgba(${n}, ${w}, 0, ${H*.6})`,color:"#333",textAlign:"center"}}},{flex:1,field:"HeatsCast",headerName:"Heats Casted for Period"},{flex:1,field:"Builds",headerName:"Builds for Period"}]})})}),e(i,{item:!0,xs:12,children:e(I,{style:{maxWidth:"400px"},children:e(N,{children:e($,{size:"small",children:s(A,{children:[s(h,{children:[e(l,{children:"Fleet Avg:"}),e(l,{children:(o.reduce((t,a)=>t+a.PermanentLiningHeats,0)/o.length).toFixed(2)})]}),s(h,{children:[e(l,{children:"Heats of Period:"}),e(l,{children:o.reduce((t,a)=>t+a.HeatsCast,0)})]}),s(h,{children:[e(l,{children:"Builds of Period:"}),e(l,{children:o.reduce((t,a)=>t+a.Builds,0)})]}),s(h,{children:[e(l,{children:"Average Heats per Build Of Period"}),e(l,{children:(o.reduce((t,a)=>t+a.HeatsCast,0)/o.reduce((t,a)=>t+a.Builds,0)).toFixed(2)})]})]})})})})})]})})})})};export{V as TundishTrackReports};
//# sourceMappingURL=index-Tv-7s8ie.js.map
