PageSourceSearch

https://bpadocs.replit.app/assets/AssetScanAction-BWxwI6u6.js

js bpadocs.replit.app collected 2026-10-04 03:48:28 UTC 7,831 bytes, 1 lines download raw bytes

1import{aR as B,aG as z,a$ as M,v as U,w as G,r as u,u as A,z as T,j as e,C as r,f as c,ar as S,B as l,e as p,E as V,O as q,ak as I,al as L,ae as x,af as H,ag as J,ah as Y,ai as W,aj as h,I as b,aI as X,b1 as R}from"./index-CCTT_da8.js";import{P as Z}from"./package-z_KJ7uZv.js";import{A as D,a as P}from"./arrow-up-from-line-DeXThvLY.js";const _={available:"bg-green-100 text-green-800 border-green-300",assigned:"bg-blue-100 text-blue-800 border-blue-300",maintenance:"bg-amber-100 text-amber-800 border-amber-300",retired:"bg-gray-200 text-gray-700 border-gray-300",disposed:"bg-gray-300 text-gray-800 border-gray-400"};function ae(){const{id:Q}=B(),a=parseInt(Q||"0",10),[,d]=z(),{user:F}=M(),{toast:o}=U(),n=G(),[m,f]=u.useState(""),[N,v]=u.useState(""),[y,K]=u.useState("good"),[w,E]=u.useState("IT Closet"),{data:s,isLoading:$}=A({queryKey:[`/api/it-assets/${a}`],enabled:!!a}),{data:O}=A({queryKey:["/api/it-assets/assignments/active"],enabled:!!a}),i=O?.find(t=>t.assetId===a&&!("checkedInAt"in t&&t.checkedInAt)),g=T({mutationFn:async()=>R("POST",`/api/it-assets/${a}/checkout`,{assignedToName:m.trim(),expectedReturnDate:N||void 0}),onSuccess:()=>{o({title:"Checked out",description:`Assigned to ${m}`}),n.invalidateQueries({queryKey:[`/api/it-assets/${a}`]}),n.invalidateQueries({queryKey:["/api/it-assets/assignments/active"]}),n.invalidateQueries({queryKey:["/api/it-assets"]}),f(""),v("")},onError:t=>o({title:"Checkout failed",description:t?.message||"Try again",variant:"destructive"})}),j=T({mutationFn:async()=>{if(!i)throw new Error("No active assignment");return R("POST",`/api/it-assets/assignments/${i.id}/checkin`,{conditionAtCheckin:y,location:w})},onSuccess:()=>{o({title:"Checked in",description:"Asset returned to inventory"}),n.invalidateQueries({queryKey:[`/api/it-assets/${a}`]}),n.invalidateQueries({queryKey:["/api/it-assets/assignments/active"]}),n.invalidateQueries({queryKey:["/api/it-assets"]})},onError:t=>o({title:"Check-in failed",description:t?.message||"Try again",variant:"destructive"})});if(!F)return e.jsx("div",{className:"min-h-screen flex items-center justify-center p-6 bg-slate-50",children:e.jsx(r,{className:"max-w-md w-full",children:e.jsxs(c,{className:"pt-6 text-center space-y-4",children:[e.jsx(S,{className:"w-12 h-12 mx-auto text-amber-500"}),e.jsx("p",{className:"text-lg font-medium",children:"Sign in required"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"You need to sign in to the staff portal to check this asset in or out."}),e.jsx(l,{onClick:()=>d("/staff-portal"),className:"w-full","data-testid":"button-signin",children:"Sign in"})]})})});if($)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-slate-50",children:e.jsx(p,{className:"w-8 h-8 animate-spin text-blue-600"})});if(!s)return e.jsx("div",{className:"min-h-screen flex items-center justify-center p-6 bg-slate-50",children:e.jsx(r,{className:"max-w-md w-full",children:e.jsxs(c,{className:"pt-6 text-center space-y-4",children:[e.jsx(S,{className:"w-12 h-12 mx-auto text-red-500"}),e.jsx("p",{className:"text-lg font-medium",children:"Asset not found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This QR code may be out of date or for a deleted asset."}),e.jsx(l,{onClick:()=>d("/staff-portal/asset-management"),variant:"outline",className:"w-full",children:"Open IT Assets"})]})})});const C=s.status==="available",k=s.status==="assigned"&&!!i;return e.jsxs("div",{className:"min-h-screen bg-slate-50 pb-24",children:[e.jsx("div",{className:"bg-white border-b sticky top-0 z-10",children:e.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-3 flex items-center gap-3",children:[e.jsx(l,{variant:"ghost",size:"sm",onClick:()=>d("/staff-portal/asset-management"),"data-testid":"button-back",children:e.jsx(V,{className:"w-4 h-4"})}),e.jsx("h1",{className:"font-semibold text-lg",children:"Asset Scan"})]})}),e.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-6 space-y-6",children:[e.jsx(r,{"data-testid":"card-asset-info",children:e.jsxs(c,{className:"pt-6",children:[e.jsxs("div",{className:"flex gap-4",children:[s.imageUrl?e.jsx("img",{src:s.imageUrl,alt:s.name,className:"w-24 h-24 object-cover rounded-lg border"}):e.jsx("div",{className:"w-24 h-24 rounded-lg border bg-slate-100 flex items-center justify-center",children:e.jsx(Z,{className:"w-10 h-10 text-slate-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"font-semibold text-lg truncate","data-testid":"text-asset-name",children:s.name}),s.assetTag&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Tag: ",s.assetTag]}),s.serialNumber&&e.jsxs("p",{className:"text-sm text-muted-foreground truncate",children:["S/N: ",s.serialNumber]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[e.jsx(q,{className:_[s.status]||"bg-slate-100 text-slate-700","data-testid":"badge-status",children:s.status}),e.jsx(q,{variant:"outline",children:s.condition})]})]})]}),s.location&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-3",children:["📍 ",s.location]})]})}),k&&e.jsxs(r,{children:[e.jsx(I,{children:e.jsxs(L,{className:"text-base flex items-center gap-2",children:[e.jsx(D,{className:"w-5 h-5 text-blue-600"}),"Check this asset back in"]})}),e.jsxs(c,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm bg-blue-50 border border-blue-200 rounded-md p-3",children:["Currently assigned to ",e.jsx("strong",{children:i?.assignedToName}),i?.expectedReturnDate&&e.jsxs(e.Fragment,{children:[" · expected back ",new Date(i.expectedReturnDate).toLocaleDateString()]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{children:"Condition at check-in"}),e.jsxs(H,{value:y,onValueChange:K,children:[e.jsx(J,{"data-testid":"select-condition-checkin",children:e.jsx(Y,{})}),e.jsxs(W,{children:[e.jsx(h,{value:"new",children:"New"}),e.jsx(h,{value:"good",children:"Good"}),e.jsx(h,{value:"fair",children:"Fair"}),e.jsx(h,{value:"repair",children:"Needs repair"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{children:"Return location"}),e.jsx(b,{value:w,onChange:t=>E(t.target.value),"data-testid":"input-return-location"})]}),e.jsx(l,{onClick:()=>j.mutate(),disabled:j.isPending,className:"w-full h-14 text-base","data-testid":"button-checkin",children:j.isPending?e.jsx(p,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"w-5 h-5 mr-2"}),"Check in"]})})]})]}),C&&e.jsxs(r,{children:[e.jsx(I,{children:e.jsxs(L,{className:"text-base flex items-center gap-2",children:[e.jsx(P,{className:"w-5 h-5 text-green-600"}),"Check this asset out"]})}),e.jsxs(c,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{children:"Assign to (full name)"}),e.jsx(b,{value:m,onChange:t=>f(t.target.value),placeholder:"e.g. Jane Doe","data-testid":"input-assigned-to"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{children:"Expected return (optional)"}),e.jsx(b,{type:"date",value:N,onChange:t=>v(t.target.value),"data-testid":"input-return-date"})]}),e.jsx(l,{onClick:()=>g.mutate(),disabled:!m.trim()||g.isPending,className:"w-full h-14 text-base","data-testid":"button-checkout",children:g.isPending?e.jsx(p,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(P,{className:"w-5 h-5 mr-2"}),"Check out"]})})]})]}),!C&&!k&&e.jsx(r,{children:e.jsxs(c,{className:"pt-6 text-center space-y-2",children:[e.jsx(X,{className:"w-10 h-10 mx-auto text-slate-400"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This asset is currently ",e.jsx("strong",{children:s.status})," and can't be checked in or out from here."]}),e.jsx(l,{variant:"outline",onClick:()=>d("/staff-portal/asset-management"),className:"mt-2",children:"Open full asset page"})]})})]})]})}export{ae 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.