1import{a as Z}from"./rolldown-runtime-DS2seoW7.js";import{O as ee}from"./charts-DKxDZnH3.js";import{_ as se,c as w,i as te,s as re}from"./vendor-05Yv21q1.js";import{t as I}from"./box-BTHbhBgN.js";import{t as ae}from"./headphones-DXUkjyit.js";import{t as ie}from"./keyboard-Dh1bzpI6.js";import{t as ne}from"./laptop-DyJs7Po4.js";import{r as oe}from"./StudioController-vtXaE4LQ.js";import{t as le}from"./pencil-BW8DiKKZ.js";import{t as de}from"./plus-Pfnpbwz0.js";import{t as ce}from"./smartphone-zABZFIUe.js";import{t as me}from"./sparkles-DYEOgaN5.js";import{t as pe}from"./trash-2-BRkPtj37.js";import{ct as a,f as D,h as xe}from"./app-DpnV7LBm.js";import{t as _}from"./badge-D3kp24xm.js";import{a as ue,i as he,n as je,r as ge,t as fe}from"./page-toolbar-BM_ALgr9.js";import{a as be,n as ve,o as ye,r as Ne,t as _e}from"./card-DQ8kPFJB.js";import{t as Ce}from"./empty-state-DHPaH1Dw.js";import{c as A,i as k,n as z,s as F,t as E}from"./select-D2ThFgXz.js";import{a as i,n as Se,o as Te,r as n,s as q,t as we}from"./table-Bu92i3TJ.js";import{a as H,n as M,o as U,r as B,s as De,t as L}from"./dialog-D0EcvP6D.js";import{t as Ae}from"./app-layout-CMMm1Ial.js";import{t as O}from"./input-BsFpzQ64.js";import{t as l}from"./label-ylFiUAk-.js";import{t as $}from"./textarea-CP3SwdGR.js";import{t as d}from"./input-error-Cvr93wSv.js";import{t as ke}from"./use-asset-serial-lookup-B2nTwUa9.js";var c=Z(ee(),1),e=se(),ze=[{title:"Dashboard",href:"/dashboard"},{title:"My Assets",href:"/my-assets"}],Fe={laptop:(0,e.jsx)(ne,{className:"size-4"}),phone:(0,e.jsx)(ce,{className:"size-4"}),monitor:(0,e.jsx)(oe,{className:"size-4"}),keyboard:(0,e.jsx)(ie,{className:"size-4"}),headset:(0,e.jsx)(ae,{className:"size-4"}),other:(0,e.jsx)(I,{className:"size-4"})},Ee={excellent:"bg-emerald-500/10 text-emerald-700 border-emerald-500/30 dark:text-emerald-300",good:"bg-primary/10 text-primary border-primary/20",fair:"bg-amber-500/10 text-amber-700 border-amber-500/30 dark:text-amber-300",poor:"bg-destructive/10 text-destructive border-destructive/30"};function os({assets:x,types:P,conditions:Y,canSubmit:C,canUpdateCondition:R}){const h=x.filter(s=>s.is_pending_approval).length,V=x.length-h,[j,g]=(0,c.useState)(!1),[m,S]=(0,c.useState)(null),{data:p,setData:o,post:K,processing:T,errors:u,reset:W}=w({name:"",type:"laptop",serial_number:"",notes:""}),t=w({condition:"good",condition_note:""}),f=(0,c.useRef)(!1),b=(0,c.useRef)(!1),{suggestion:r,loading:v}=ke(p.serial_number);(0,c.useEffect)(()=>{r&&(!f.current&&r.name&&o("name",r.name),!b.current&&r.type&&o("type",r.type))},[r]),(0,c.useEffect)(()=>{j||(f.current=!1,b.current=!1)},[j]);const G=s=>{s.preventDefault(),K("/my-assets",{onSuccess:()=>{g(!1),W()}})},J=s=>{confirm("Cancel this submission? This will remove it from review and you can submit again if needed.")&&re.delete(`/my-assets/${s}`,{preserveScroll:!0})},Q=s=>{t.clearErrors(),t.setData({condition:s.condition??"good",condition_note:""}),S(s)},y=()=>{S(null),t.reset(),t.clearErrors()},X=s=>{s.preventDefault(),m&&t.patch(`/my-assets/${m.id}/condition`,{preserveScroll:!0,onSuccess:()=>y()})};return(0,e.jsxs)(Ae,{breadcrumbs:ze,children:[(0,e.jsx)(te,{title:"My Assets"}),(0,e.jsxs)("div",{className:"flex w-full flex-col gap-5 p-4 sm:p-6 lg:gap-7 lg:p-8",children:[(0,e.jsxs)(fe,{className:"pb-0",children:[(0,e.jsxs)(he,{children:[(0,e.jsx)(ue,{children:"My Assets"}),(0,e.jsx)(ge,{children:"Equipment assigned to you"})]}),(0,e.jsx)(je,{children:C&&(0,e.jsxs)(L,{open:j,onOpenChange:g,children:[(0,e.jsx)(De,{asChild:!0,children:(0,e.jsxs)(a,{children:[(0,e.jsx)(de,{className:"mr-2 h-4 w-4"}),"Submit Asset"]})}),(0,e.jsxs)(M,{children:[(0,e.jsxs)(H,{children:[(0,e.jsx)(U,{children:"Submit an asset for review"}),(0,e.jsx)(B,{children:"Tell us about a piece of equipment you have. An admin will review your submission and add it to the register."})]}),(0,e.jsxs)("form",{onSubmit:G,className:"grid gap-4",children:[(0,e.jsxs)("div",{className:"grid gap-2",children:[(0,e.jsx)(l,{htmlFor:"serial_number",children:"Serial Number"}),(0,e.jsx)(O,{id:"serial_number",value:p.serial_number,onChange:s=>o("serial_number",s.target.value),placeholder:"C02ABC123DEF",className:"font-mono",autoF
1ocus:!0}),v&&(0,e.jsxs)("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,e.jsx)(xe,{className:"size-3 animate-spin"}),"Checkingâ¦"]}),!v&&r&&(0,e.jsxs)("p",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,e.jsx)(me,{className:"size-3 text-primary"}),"Detected",r.name?`: ${r.name}`:""," · ",r.source==="prior_asset"?"matches prior asset":"pattern match"]}),!v&&!r&&(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Usually found on the bottom of the device or in system settings."}),(0,e.jsx)(d,{message:u.serial_number})]}),(0,e.jsxs)("div",{className:"grid gap-2",children:[(0,e.jsx)(l,{htmlFor:"name",children:"Asset Name *"}),(0,e.jsx)(O,{id:"name",value:p.name,onChange:s=>{f.current=!0,o("name",s.target.value)},placeholder:"MacBook Pro 14-inch",required:!0}),(0,e.jsx)(d,{message:u.name})]}),(0,e.jsxs)("div",{className:"grid gap-2",children:[(0,e.jsx)(l,{htmlFor:"type",children:"Asset Type *"}),(0,e.jsxs)(E,{value:p.type,onValueChange:s=>{b.current=!0,o("type",s)},children:[(0,e.jsx)(F,{children:(0,e.jsx)(A,{placeholder:"Select type"})}),(0,e.jsx)(z,{children:Object.entries(P).map(([s,N])=>(0,e.jsx)(k,{value:s,children:N},s))})]}),(0,e.jsx)(d,{message:u.type})]}),(0,e.jsxs)("div",{className:"grid gap-2",children:[(0,e.jsx)(l,{htmlFor:"notes",children:"Notes"}),(0,e.jsx)($,{id:"notes",value:p.notes,onChange:s=>o("notes",s.target.value),placeholder:"Any additional details (condition, accessories, etc.)",rows:3}),(0,e.jsx)(d,{message:u.notes})]}),(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)(a,{type:"button",variant:"outline",onClick:()=>g(!1),children:"Cancel"}),(0,e.jsxs)(a,{type:"submit",disabled:T,children:[T&&(0,e.jsx)(D,{className:"mr-2"}),"Submit for review"]})]})]})]})]})})]}),(0,e.jsxs)(_e,{children:[(0,e.jsxs)(be,{children:[(0,e.jsx)(ye,{children:"Your Equipment"}),(0,e.jsxs)(Ne,{children:[V," assigned",h>0&&` · ${h} awaiting admin review`]})]}),(0,e.jsx)(ve,{className:"p-0",children:x.length===0?(0,e.jsx)(Ce,{illustration:"empty-default",title:"No assets assigned",description:C?'You donât have any equipment registered yet. Use the "Submit Asset" button to register equipment you have.':"You donât have any equipment registered yet. An admin will assign assets to you here.",className:"px-5"}):(0,e.jsxs)(we,{children:[(0,e.jsx)(Te,{className:"bg-muted/30",children:(0,e.jsxs)(q,{children:[(0,e.jsx)(i,{children:"Asset"}),(0,e.jsx)(i,{children:"Type"}),(0,e.jsx)(i,{children:"Serial Number"}),(0,e.jsx)(i,{children:"Status"}),(0,e.jsx)(i,{children:"Condition"}),(0,e.jsx)(i,{children:"Date"}),(0,e.jsx)(i,{className:"w-12"})]})}),(0,e.jsx)(Se,{children:x.map(s=>(0,e.jsxs)(q,{children:[(0,e.jsxs)(n,{children:[(0,e.jsx)("div",{className:"font-medium",children:s.name}),s.notes&&(0,e.jsx)("div",{className:"line-clamp-1 text-sm text-muted-foreground",children:s.notes})]}),(0,e.jsx)(n,{children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[Fe[s.type]||(0,e.jsx)(I,{className:"size-4"}),(0,e.jsx)("span",{children:s.type_label})]})}),(0,e.jsx)(n,{children:(0,e.jsx)("span",{className:"font-mono text-sm",children:s.serial_number||"â"})}),(0,e.jsx)(n,{children:s.is_pending_approval?(0,e.jsx)(_,{variant:"outline",className:"border-warning/30 bg-warning/10 text-warning",children:"Pending review"}):(0,e.jsx)(_,{variant:"outline",className:"border-primary/20 bg-primary/10 text-primary",children:s.status_label})}),(0,e.jsx)(n,{children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[s.condition?(0,e.jsx)(_,{variant:"outline",className:Ee[s.condition]||"border-border bg-muted text-muted-foreground",children:s.condition_label}):(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"Not set"}),R&&(0,e.jsxs)(a,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>Q(s),title:"Update condition",children:[(0,e.jsx)(le,{className:"mr-1 size-3"}),"Update"]})]})}),(0,e.jsx)(n,{className:"text-muted-foreground",children:s.is_pending_approval?`Submitted ${s.submitted_at??""}`:s.assigned_at||"â"}),(0,e.jsx)(n,{className:"text-right",children:s.is_pending_approval&&(0,e.jsx)(a,{type:"button",variant:"ghost",size:"icon",onClick:()=>J(s.id),title:"Cancel submission","aria-label":"Cancel submission",children:(0,e.jsx)(pe,{className:"size-4 text-muted-foreground hover:text-destructive"})})})]},s.id))})]})})]}),(0,e.jsx)(L,{open:m!==null,onOpenChange:s=>{s||y()},children:(0,e.jsxs)(M,{children:[(0,e.jsxs)(H,{children:[(0,e.jsx)(U,{children:"Update condition"}),(0,e.jsx)(B,{children:m&&(0,e.jsxs)(e.Fragment,{children:["Update the condition of"," ",(0,e.jsx)("strong",{children:m.name}),". Your note will be appended to the asset's notes and a record will be added to the activity log."]})})]}),(0,e.jsxs)("form",{onSubmit:X,className:"grid gap-4",children:[(0,e.jsxs)("div",{className:"grid gap-2",children:[(0,e.jsx)(l,{htmlFor:"condition",children:"Condition *"}),(0,e.jsxs)(E,{value:t.data.condition,onValueChange:s=>t.setData("condition",s),children:[(0,e.jsx)(F,{children:(0,e.jsx)(A,{placeholder:"Select condition"})}),(0,e.jsx)(z,{children:Object.entries(Y).map(([s,N])=>(0,e.jsx)(k,{value:s,children:N},s))})]}),(0,e.jsx)(d,{message:t.errors.condition})]}),(0,e.jsxs)("div",{className:"grid gap-2",children:[(0,e.jsx)(l,{htmlFor:"condition_note",children:"Note (optional)"}),(0,e.jsx)($,{id:"condition_note",value:t.data.condition_note,onChange:s=>t.setData("condition_note",s.target.value),placeholder:"e.g. Small dent on the lid, screen still works fine.",rows:3,maxLength:500}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Up to 500 characters. Will be appended to the asset notes with a date and your name."}),(0,e.jsx)(d,{message:t.errors.condition_note})]}),(0,e.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,e.jsx)(a,{type:"button",variant:"outline",onClick:y,children:"Cancel"}),(0,e.jsxs)(a,{type:"submit",disabled:t.processing,children:[t.processing&&(0,e.jsx)(D,{className:"mr-2"}),"Save"]})]})]})]})})]})]})}export{os 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.