PageSourceSearch

https://logystix.cloud/assets/WeightMismatchApprovalsListPage-BDBpzKu2.js

js logystix.cloud collected 2026-10-03 21:14:14 UTC 11,133 bytes, 1 lines download raw bytes

1import{V as Z,r as a,Q as i,N as s,bY as ee,cJ as se,cU as te,a3 as ae,a4 as re,bR as ie,b7 as R,bT as F,bU as T}from"./vendor-BEWp4egH.js";import{C as le}from"./CustomContainer-Cp3fRM7t.js";import{g as ne,z as u,A as z,a as P,c as D}from"./index-BWNAsnHU.js";import{D as oe}from"./DataTable-DykjiCXj.js";import{V as ce}from"./ViewBtn-z1ndnEL7.js";import{A as de,R as pe}from"./RejectBtn-CL0i4h-n.js";import{V as me}from"./VehicleNumberPlate-BnDBLxmx.js";import"./vendor-lottie-DipUA-V9.js";import"./RefreshBtn-DhNYGQQS.js";import"./Footer-B-qKtS_0.js";import"./StyledSelect-bEoUWtao.js";import"./NoData-D0CPz0rS.js";/* empty css                      */const Ce=()=>{document.title="Weight Tolerance Approvals | LogystiX";const b=Z(),[M,A]=a.useState(!0),[K,S]=a.useState([]),[W,_]=a.useState(0),[k,d]=a.useState(1),[g,L]=a.useState(10),[N,O]=a.useState(""),[p,q]=a.useState("inquiry_id"),[h,E]=a.useState("pending"),C=a.useRef(null),[l,x]=a.useState(null),[V,f]=a.useState(!1),[B,v]=a.useState(!1),[n,o]=a.useState(""),[w,y]=a.useState(!1),G=a.useMemo(()=>[{value:"inquiry_id",label:"TR Number"},{value:"truck_number",label:"Vehicle Number"},{value:"sales_order",label:"Sales Order"}],[]),I=a.useMemo(()=>[{value:"pending",label:"Pending Approval"},{value:"approved",label:"Approved"},{value:"rejected",label:"Rejected"}],[]),U=a.useMemo(()=>{switch(p){case"inquiry_id":return"Search by TR Number (e.g. 4730)...";case"sales_order":return"Search by Sales Order Number...";case"truck_number":default:return"Search by Vehicle Number (e.g. MH12AB1234)..."}},[p]),m=a.useCallback(async()=>{A(!0);try{const e={offset:(k-1)*g,limit:g};N&&(e.search=N,e.search_type=p),h&&(e.status=h);const t=await ne(u.createUrl("/delivery/weight-approvals-list",e));t&&!t.error&&t.data?(S(t.data.list||[]),_(t.data.total||0)):(S([]),_(0))}catch(e){console.error("Error fetching weight approvals list:",e),i.error("Failed to load weight approvals queue"),S([]),_(0)}finally{A(!1)}},[k,g,N,p,h]);a.useEffect(()=>{m()},[m]);const $=a.useCallback(e=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{O(typeof e=="string"?e.trim():""),d(1)},300)},[]),Q=a.useCallback(e=>{q(e),d(1)},[]),J=a.useCallback(e=>{E(e),d(1)},[]),X=async()=>{if(!n.trim()){i.warning("Approval justification remarks are mandatory.");return}y(!0);try{const e={driver_id:l.driver_id,remarks:n.trim()},t=await D(u.createUrl("/delivery/approve-weight-mismatch"),e);t&&!t.error?(i.success("Weight mismatch approved successfully!"),f(!1),o(""),x(null),m()):i.error(t?.message||"Failed to approve weight mismatch.")}catch(e){console.error("Error approving:",e),i.error(e?.response?.data?.message||"Failed to approve weight mismatch.")}finally{y(!1)}},Y=async()=>{if(!n.trim()){i.warning("Rejection reason remarks are mandatory.");return}y(!0);try{const e={driver_id:l.driver_id,remarks:n.trim()},t=await D(u.createUrl("/delivery/reject-weight-mismatch"),e);t&&!t.error?(i.info("Weight discrepancy rejected. Truck marked for re-weighing."),v(!1),o(""),x(null),m()):i.error(t?.message||"Failed to reject discrepancy.")}catch(e){console.error("Error rejecting:",e),i.error(e?.response?.data?.message||"Failed to reject discrepancy.")}finally{y(!1)}},H=a.useMemo(()=>[{header:"Vehicle Number",accessorKey:"truck_number",size:170,cell:({row:e})=>s.jsx("div",{className:"d-flex align-items-center gap-1.5 py-1",children:s.jsx(me,{number:e.original.truck_number||"",fontSize:11})})},{header:"TR",accessorKey:"inquiry_id",size:90,cell:({row:e})=>{const t=e.original.inquiry_id,r=e.original.driver_id||e.original.id,c=e.original.gate_pass_no,j=t&&r?`/gate-pass/dispatch/${t}/${r}`:t?`/gate-pass/dispatch/${t}`:null;return s.jsxs("div",{children:[j?s.jsx("div",{className:"fw-semibold text-primary",style:{fontSize:"13px",cursor:"pointer",textDecoration:"underline"},onClick:()=>b(j),title:"Click to view Gate Pass & Truck steps",children:t}):s.jsx("div",{className:"fw-semibold text-primary",style:{fontSize:"13px"},children:t||"--"}),c&&s.jsxs("small",{className:"text-muted",style:{fontSize:"11px"},children:["Pass: #",c]})]})}},{header:"SO No.",accessorKey:"sales_order",size:130,cell:({row:e})=>{const t=e.original.sales_order;return s.jsx("div",{className:"fw-semibold text-dark",style:{fontSize:"13px"},children:t||"--"})}},{header:"Customer",accessorKey:"customer_name",size:180,cell:({row:e})=>s.jsxs("div",{children:[s.jsx("div",{className:"fw-bold text-dark text-truncate",style:{fontSize:"13px",maxWidth:"170px"},title:e.original.customer_name||"--",children:e.original.customer_name||"--"}),s.jsx("small",{className:"text-muted",style:{fontSize:"11px"},children:e.original.customer_code?`Code: ${e.original.customer_code}`:"--"})]})},{header:"Driver",accessorKey:"driver_name",size:120,cell:({row:e})=>s.jsxs("div",{children:[s.jsx("div",{className:"fw-bold text-dark",style:{fontSize:"13px"},children:e.original.driver_name||"--"}),s.jsx("small",{className:"text-muted",style:{fontSize:"11px"},children:e.original.driver_mobile||"--"})]})},{header:"Net Wt.",accessorKey:"physical_net_kg",size:120,cell:({row:e})=>s.jsxs("div",{className:"text-start pe-2",children:[s.jsxs("div",{className:"fw-bold text-dark",style:{fontSize:"13px"}
1,children:[Number(e.original.physical_net_kg||0).toLocaleString()," KG"]}),s.jsxs("small",{className:"text-muted",style:{fontSize:"11px"},children:[((e.original.physical_net_kg||0)/1e3).toFixed(3)," MT"]})]})},{header:"Invoice Gross Wt.",accessorKey:"invoice_gross_kg",size:180,cell:({row:e})=>s.jsxs("div",{className:"text-center pe-2",children:[s.jsxs("div",{className:"fw-bold text-dark",style:{fontSize:"13px"},children:[Number(e.original.invoice_gross_kg||0).toLocaleString()," KG"]}),s.jsxs("small",{className:"text-muted",style:{fontSize:"11px"},children:[((e.original.invoice_gross_kg||0)/1e3).toFixed(3)," MT"]})]})},{header:"Variance",accessorKey:"variance_kg",size:130,cell:({row:e})=>{const t=e.original.is_tolerance_exceeded,r=Number(e.original.variance_kg||0);return s.jsxs("div",{className:"text-start pe-2",children:[s.jsxs("span",{className:"fw-bold",style:{fontSize:"13px",color:t?"#DC2626":"#059669"},children:[r>=0?`+${r.toFixed(1)}`:r.toFixed(1)," KG"]}),s.jsxs("div",{style:{fontSize:"10px",color:t?"#B91C1C":"#15803D"},children:["Limit: ±",e.original.limit_kg||200," KG"]})]})}},{header:"Approval Status",accessorKey:"approval_status",size:165,cell:({row:e})=>{const t=e.original;return t.is_overridden?s.jsxs("span",{className:"badge d-inline-flex align-items-center gap-1 px-2.5 py-1 fw-semibold",style:{backgroundColor:"#ECFDF5",color:"#059669",border:"1px solid #A7F3D0",fontSize:"11px"},children:[s.jsx(ee,{size:12})," Approved"]}):t.is_rejected?s.jsxs("span",{className:"badge d-inline-flex align-items-center gap-1 px-2.5 py-1 fw-semibold",style:{backgroundColor:"#FEF2F2",color:"#DC2626",border:"1px solid #FECACA",fontSize:"11px"},children:[s.jsx(se,{size:12})," Rejected"]}):s.jsxs("span",{className:"badge d-inline-flex align-items-center gap-1 px-2.5 py-1 fw-semibold",style:{backgroundColor:"#FFFBEB",color:"#D97706",border:"1px solid #FDE68A",fontSize:"11px"},children:[s.jsx(te,{size:12})," Pending Approval"]})}},{header:"Requested On",accessorKey:"approval_requested_at",size:140,cell:({row:e})=>{const t=e.original.approval_requested_at||e.original.created_at;if(!t)return s.jsx("span",{className:"text-muted",style:{fontSize:"12px"},children:"--"});const r=new Date(t);if(isNaN(r.getTime()))return s.jsx("span",{className:"text-muted",style:{fontSize:"12px"},children:"--"});const c=r.toLocaleDateString("en-IN",{day:"2-digit",month:"short",year:"numeric"}),j=r.toLocaleTimeString("en-IN",{hour:"2-digit",minute:"2-digit",hour12:!0});return s.jsxs("div",{children:[s.jsx("div",{className:"fw-semibold text-dark",style:{fontSize:"12px"},children:c}),s.jsx("small",{className:"text-muted",style:{fontSize:"11px"},children:j})]})}},{header:"Action",accessorKey:"action",size:140,cell:({row:e})=>{const t=e.original,r=!t.is_overridden&&!t.is_rejected,c=u.checkPermission("Weight Mismatch","update")||u.checkPermission("Weight Mismatch","create");return s.jsxs("div",{className:"d-flex align-items-center gap-2",children:[s.jsx(z,{text:"View Reconciliation Details",children:s.jsx(ce,{onClick:()=>b(`/weight-mismatch-approvals/${t.driver_id}`)})}),r&&c&&s.jsxs(s.Fragment,{children:[s.jsx(z,{text:"Quick Approve",children:s.jsx(de,{title:"Approve Weight Override",onClick:()=>{x(t),o(""),f(!0)}})}),s.jsx(z,{text:"Quick Reject",children:s.jsx(pe,{title:"Reject Weight Override",onClick:()=>{x(t),o(""),v(!0)}})})]})]})}}],[b]);return s.jsxs(le,{style:{padding:"80px 24px 30px 24px"},children:[s.jsx(ae,{children:s.jsx(re,{lg:12,children:s.jsx(ie,{className:"p-0",children:s.jsx(oe,{title:"Weight Mismatch Approvals",columns:H,data:K,totalRecords:W,handleRefreshButton:m,isPagination:!0,isCustomPageSize:!0,pagination:"pagination",paginationWrapper:"dataTables_paginate paging_simple_numbers",currentPage:k,pageSize:g,handlePageChange:e=>d(e),handlePageSizeChange:e=>{L(Number(e)),d(1)},isGlobalFilter:!0,searchType:p,searchTypeOptions:G,onSearchTypeChange:Q,debouncedSearch:$,searchPlaceholder:U,statusTabs:{options:I,visibleCount:3,value:h,onChange:J},isFooter:!0,isTableLoadingData:M})})})}),s.jsx(P,{isOpen:V,toggle:()=>f(!1),title:"Approve Weight Discrepancy",isLoading:w,primaryAction:{label:"Approve & Release Invoice",onClick:X,variant:"submit"},secondaryAction:{label:"Cancel",onClick:()=>f(!1)},children:s.jsxs("div",{className:"p-2",children:[s.jsxs("p",{className:"text-muted mb-3",style:{fontSize:"13px"},children:["You are approving the weight discrepancy for vehicle"," ",s.jsx("strong",{children:l?.truck_number})," (Gate Pass: #",l?.gate_pass_no||l?.sales_order,"). Final weight timestamp will be locked and invoice generation unlocked."]}),s.jsxs(R,{children:[s.jsxs(F,{className:"fw-bold small text-dark",children:["Mandatory Approval Justification ",s.jsx("span",{className:"text-danger",children:"*"})]}),s.jsx(T,{type:"textarea",rows:3,placeholder:"e.g. Load verified manually against consignment note; moisture level tolerance acceptable...",value:n,onChange:e=>o(e.target.value),className:"rounded-3",style:{fontSize:"13px"}})]})]})}),s.jsx(P,{isOpen:B,toggle:()=>v(!1),title:"Reject Weight Discrepancy",isLoading:w,primaryAction:{label:"Confirm Rejection (Request Re-Weigh)",onClick:Y,variant:"reject"},secondaryAction:{label:"Cancel",onClick:()=>v(!1)},children:s.jsxs("div",{className:"p-2",children:[s.jsxs("p",{className:"text-muted mb-3",style:{fontSize:"13px"},children:["Are you sure you want to reject the weight discrepancy for vehicle"," ",s.jsx("strong",{children:l?.truck_number}),"? The gate operator will be notified to re-weigh or rectify the truck load."]}),s.jsxs(R,{children:[s.jsxs(F,{className:"fw-bold small text-dark",children:["Reason for Rejection ",s.jsx("span",{className:"text-danger",children:"*"})]}),s.jsx(T,{type:"textarea",rows:3,placeholder:"e.g. Variance is unacceptably high (+290 KG); request truck re-weighing immediately...",value:n,onChange:e=>o(e.target.value),className:"rounded-3",style:{fontSize:"13px"}})]})]})})]})};export{Ce as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.