import{u as g,r as d,j as r,b as a,S as x,A as c,d as N,c as m,e as S,t as v,B as t}from"./index-ktJf6c6X.js";import{d as C}from"./VisibilityOutlined-eD6-wycf.js";import{P as b,S as R}from"./SectionCard-TnS7Fu20.js";import{S as E}from"./StatusPill-Dl5XDc8M.js";import{R as w}from"./RowActionsMenu-SZn9B18W.js";import{u as T}from"./StockTransferReceivedNoteApi-tftQMQOy.js";import"./Breadcrumbs-CYyzjAdM.js";const k={POSTED:"success",CANCELLED:"error",DRAFT:"default"},F=()=>{const l=g(),[i,h]=d.useState({page:0,pageSize:20}),{data:n,isLoading:f,refetch:p}=T({page:i.page,size:i.pageSize,sort:"created_date,desc"}),s=d.useMemo(()=>n??[],[n]),u=e=>[{key:"view",label:"View",icon:a(C,{fontSize:"small"}),onClick:()=>l(`${m.STOCK_RECEIVED_NOTE}/${e.id}`)}];return r(t,{sx:{width:"100%",minHeight:"calc(100vh - 64px)",bgcolor:e=>e.palette.mode==="dark"?e.palette.background.default:"#F8FAFC",px:{xs:2,md:3},py:{xs:2,md:2.5}},children:[a(b,{breadcrumbs:[{label:"Inventory"},{label:"Stock Received Note"}],title:"Stock Received Note",subtitle:"Record receipts against dispatched stock transfers",actions:r(x,{direction:"row",spacing:1,children:[a(c,{btnType:"info",onClick:()=>p(),children:"Refresh"}),r(c,{btnType:"create",onClick:()=>l(m.STOCK_RECEIVED_NOTE_CREATE),children:[a(N,{fontSize:"small",sx:{mr:.5}}),"New Received Note"]})]})}),a(R,{noPadding:!0,children:a(S,{rows:s,columns:[{field:"docNo",headerName:"Doc No",flex:1,minWidth:160,renderCell:e=>a(t,{sx:{fontWeight:600,color:"text.primary"},children:e.value})},{field:"transferNo",headerName:"Transfer No",flex:1,minWidth:140},{field:"fromBranchName",headerName:"From → To",flex:1.4,minWidth:200,renderCell:e=>r(t,{sx:{fontSize:13},children:[a(t,{component:"span",sx:{color:"text.primary",fontWeight:500},children:e.row.fromBranchName??"—"}),a(t,{component:"span",sx:{color:"text.secondary",mx:.75},children:"→"}),a(t,{component:"span",sx:{color:"text.primary",fontWeight:500},children:e.row.toBranchName??"—"})]})},{field:"receivedDate",headerName:"Received Date",flex:.8,minWidth:120,valueFormatter:e=>e.value?v(e.value):""},{field:"items",headerName:"Lines",flex:.5,minWidth:80,renderCell:e=>{var o;return a(t,{children:((o=e.value)==null?void 0:o.length)??0})},sortable:!1},{field:"status",headerName:"Status",flex:.8,minWidth:130,renderCell:e=>{var o;return a(E,{label:((o=e.value)==null?void 0:o.replace(/_/g," "))??"—",tone:k[e.value]??"default",size:"small"})}},{field:"actions",headerName:"",width:72,sortable:!1,filterable:!1,align:"right",headerAlign:"right",renderCell:e=>a(w,{actions:u(e.row)})}],loading:f,rowCount:s.length,paginationModel:i,onPaginationModelChange:e=>h(e),getRowId:e=>e.id??0,height:"calc(100vh - 220px)"})})]})};export{F as default};
