PageSourceSearch

https://junkbin.io/assets/MyJunkbin-aSZt1znl.js

js junkbin.io collected 2026-10-08 02:30:50 UTC 10,335 bytes, 1 lines download raw bytes

1import{a as D,u as k,c as w,j as e}from"./vendor-query-BS2dq783.js";import{r as c}from"./vendor-sentry-D2THoUNl.js";import{u as M,j as y}from"./index-XSMUCKQL.js";import{c as v}from"./vendor-utils-BVzZ8OFP.js";import{u as B}from"./vendor-i18n-D2HZKkC3.js";import{N as Q,L as m}from"./vendor-router-B8t7gLgI.js";import{L as C,P as S,b as W,aH as K,E as U,j as V,p as H,I as $}from"./vendor-icons-CK634XgA.js";const z={new:"New",working:"Working",broken:"Broken / For Parts",unknown:"Unknown"},G={available:"For Trade",not_for_trade:"Not for Trade"};function ne(){const{t:s}=B(),{isAuthenticated:h}=M(),g=D(),[r,E]=c.useState("have"),[L,x]=c.useState(null),[P,l]=c.useState(null),[u,T]=c.useState(""),[b,O]=c.useState(""),[q,f]=c.useState({}),{data:o}=k({queryKey:["junkbin","my-summary"],queryFn:()=>y.mySummary(),enabled:h}),{data:A,isLoading:F}=k({queryKey:["junkbin","my-items",r,u,b],queryFn:()=>y.myItems({item_type:r,...u&&{content_type:u},...b&&{status:b}}),enabled:h}),p=w({mutationFn:({id:t,data:n})=>y.update(t,n),onSuccess:()=>{g.invalidateQueries({queryKey:["junkbin"]}),x(null),f({})}}),j=w({mutationFn:t=>y.delete(t),onSuccess:()=>{g.invalidateQueries({queryKey:["junkbin"]}),l(null)}});if(!h)return e.jsx(Q,{to:"/login",replace:!0});const N=A?.results||[],_=t=>q[t]||{},d=(t,n)=>{f(i=>({...i,[t]:{...i[t],...n}}))},I=t=>{const n=_(t.id);if(Object.keys(n).length===0){x(null);return}p.mutate({id:t.id,data:n})};return e.jsx("div",{className:"py-8",children:e.jsxs("div",{className:"mx-auto max-w-7xl px-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[e.jsx("h1",{className:"font-display text-3xl font-bold text-white",children:s("my_junkbin.title")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[o&&e.jsxs("div",{className:"flex items-center gap-4 text-sm font-mono",children:[e.jsxs("span",{className:"text-cyber-green",children:[o.have_count," ",e.jsx("span",{className:"text-gray-500",children:s("my_junkbin.tab_have").toLowerCase()})]}),e.jsxs("span",{className:"text-cyber-yellow",children:[o.want_count," ",e.jsx("span",{className:"text-gray-500",children:s("my_junkbin.tab_want").toLowerCase()})]}),e.jsxs("span",{className:"text-cyber-cyan",children:[o.available_count," ",e.jsx("span",{className:"text-gray-500",children:s("my_junkbin.for_trade")})]})]}),e.jsx(m,{to:"/swap",className:"flex items-center gap-1.5 border border-cyber-cyan/50 px-3 py-1.5 text-xs font-mono text-cyber-cyan hover:bg-cyber-cyan/10 transition-colors whitespace-nowrap",children:"BROWSE SWAP SHOP →"})]})]}),e.jsx("div",{className:"flex gap-1 border-b border-cyber-light/30 mb-6",children:["have","want"].map(t=>e.jsxs("button",{onClick:()=>{E(t),x(null),l(null)},className:v("py-3 px-6 font-mono text-sm border-b-2 transition-colors",r===t?t==="have"?"border-cyber-green text-cyber-green":"border-cyber-yellow text-cyber-yellow":"border-transparent text-gray-500 hover:text-white"),children:[s(t==="have"?"my_junkbin.tab_have":"my_junkbin.tab_want"),o&&e.jsxs("span",{className:"ml-2 text-xs opacity-60",children:["(",t==="have"?o.have_count:o.want_count,")"]})]},t))}),e.jsxs("div",{className:"flex gap-3 mb-6",children:[e.jsxs("select",{value:u,onChange:t=>T(t.target.value),className:"bg-cyber-dark border border-cyber-light/50 px-3 py-1.5 text-sm text-white font-mono focus:border-cyber-cyan focus:outline-none",children:[e.jsx("option",{value:"",children:s("my_junkbin.all_types")}),e.jsx("option",{value:"product",children:"Products"}),e.jsx("option",{value:"component",children:"Components"})]}),r==="have"&&e.jsxs("select",{value:b,onChange:t=>O(t.target.value),className:"bg-cyber-dark border border-cyber-light/50 px-3 py-1.5 text-sm text-white font-mono focus:border-cyber-cyan focus:outline-none",children:[e.jsx("option",{value:"",children:s("my_junkbin.all_statuses")}),e.jsx("option",{value:"available",children:s("my_junkbin.for_trade_filter")}),e.jsx("option",{value:"not_for_trade",children:s("my_junkbin.not_for_trade_filter")})]})]}),F?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(C,{className:"h-6 w-6 animate-spin text-cyber-cyan"})}):N.length===0?e.jsxs("div",{className:"card-cyber p-12 text-center",children:[e.jsx(S,{className:"h-14 w-14 text-gray-600 mx-auto mb-4"}),e.jsx("h3",{className:"font-display text-lg text-white mb-2",children:s(r==="have"?"my_junkbin.no_have_title":"my_junkbin.no_want_title")}),e.jsx("p",{className:"text-gray-400 text-sm mb-4",children:s(r==="have"?"my_junkbin.no_have_desc":"my_junkbin.no_want_desc")}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx(m,{to:"/products",className:"btn-cyber text-sm",children:"BROWSE PRODUCTS"}),e.jsx(m,{to:"/components",className:"border border-cyber-light/50 px-4 py-2 text-sm font-mono text-gray-400 hover:text-white hover:border-white transition-colors",children:"BROWSE COMPONENTS"})]})]}):e.jsx("div",{className:"space-y-3",children:N.map(t=>{const n=L===t.id,i=_(t.id),R=t.content_type==="product"?`/products/${t.object_id}`:`/components/${t.object_id}/products`;return e.jsxs("div",{className:v("card-cyber transition-all",n&&"border-cyber-cyan/50"),children:[e.jsxs("div",{className:"p-4 flex items-center gap-4 cursor-pointer",onClick:()=>{x(n?null:t.id),l(null)},children:[e.jsx("div",{className:"w-10 h-10 bg-cyber-dark border border-cyber-light/20 flex items-center justify-center flex-shrink-0",children:t.content_type==="product"?e.jsx(S,{className:"h-5 w-5 text-cyber-cyan"}):e.jsx(W,{className:"h-5 w-5 text-cyber-pink"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(m,{to:R,onClick:a=>a.stopPropagation(),className:"text-white hover:text-cyber-cyan font-semibold truncate block",children:t.item_name}),e.jsx("div",{className:"text-xs text-gray-500 font-mono",children:t.item_manufacturer})]}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2 flex-shrink-0",children:[r==="have"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:v("badge-cyber text-[10px]",t.status==="available"?"text-cyber-green border-cyber-green":"text-gray-400 border-gray-600"),children:G[t.status]}),e.jsx("span",{className:"badge-cyber text-[10px] text-gray-400 border-gray-600",children:z[t.condition]})]}),t.quantity>1&&e.jsxs("span",{className:"text-xs text-gray-500 font-mono",children:["x",t.quantity]}),t.visibility==="private"?e.jsx(K,{className:"h-3.5 w-3.5 text-gray-600"}):e.jsx(U,{className:"h-3.5 w-3.5 text-gray-500"})]}),n?e.jsx(V,{className:"h-4 w-4 text-gray-500 flex-shrink-0"}):e.jsx(H,{className:"h-4 w-4 text-gray-500 flex-shrink-0"})]}),n&&e.jsxs("div",{className:"px-4 pb-4 border-t border-cyber-light/20 pt-4 space-y-4",children:[r==="have"&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-mono text-gray-500 uppercase block mb-1",children:"Status"}),e.jsxs("select",{value:i.status??t.status,onChange:a=>d(t.id,{status:a.target.value}),className:"w-full bg-cyber-dark border border-cyber-light/50 px-3 py-2 text-sm text-white focus:border-cyber-cyan focus:outline-none",children:[e.jsx("option",{value:"not_for_trade",children:s("my_junkbin.not_for_trade_filter")}),e.jsx("option",{value:"available",children:"Available for Trade"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-mono text-gray-500 uppercase block mb-1",children:"Condition"}),e.jsxs("select",{value:i.condition??t.condition,onChange:a=>d(t.id,{condition:a.target.value}),className:"w-full bg-cyber-dark border border-cyber-light/50 px-3 py-2 text-sm text-white focus:border-cyber-cyan focus:outline-none",children:[e.jsx("option",{value:"new",children:s("my_junkbin.condition_new")}),e.jsx("option",{value:"working",children:s("my_junkbin.condition_working")}),e.jsx("option",{value:"broken",children:s("my_junkbin.condition_broken")}),e.jsx("option",{value:"unknown",children:s("my_junkbin.condition_unknown")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-mono text-gray-500 uppercase block mb-1",children:"Visibility"}),e.jsxs("select",{value:i.visibility??t.visibility,onChange:a=>d(t.id,{visibility:a.target.value}),className:"w-full bg-cyber-dark border border-cyber-light/50 px-3 py-2 text-sm text-white focus:border-cyber-cyan focus:outline-none",children:[e.jsx("option",{value:"public",children:s("my_junkbin.visibility_public")}),e.jsx("option",{value:"private",children:s("my_junkbin.visibility_private")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-mono text-gray-500 uppercase block mb-1",children:"Quantity"}),e.jsx("input",{type:"number",min:"1",value:i.quantity??t.quantity,onChange:a=>d(t.id,{quantity:parseInt(a.target.value)||1}),className:"w-full bg-cyber-dark border border-cyber-light/50 px-3 py-2 text-sm text-white focus:border-cyber-cyan focus:outline-none"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-mono text-gray-500 uppercase block mb-1",children:"Notes"}),e.jsx("textarea",{value:i.notes??t.notes,onChange:a=>d(t.id,{notes:a.target.value}),maxLength:500,rows:2,className:"w-full bg-cyber-dark border border-cyber-light/50 px-3 py-2 text-sm text-white placeholder-gray-600 focus:border-cyber-cyan focus:outline-none resize-none"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:P===t.id?e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-gray-400",children:s("my_junkbin.remove_confirm")}),e.jsx("button",{onClick:()=>j.mutate(t.id),disabled:j.isPending,className:"text-xs text-cyber-pink hover:text-white font-mono",children:j.isPending?"REMOVING...":"YES, REMOVE"}),e.jsx("button",{onClick:()=>l(null),className:"text-xs text-gray-500 hover:text-white font-mono",children:"CANCEL"})]}):e.jsxs("button",{onClick:()=>l(t.id),className:"flex items-center gap-1 text-xs text-gray-500 hover:text-cyber-pink transition-colors",children:[e.jsx($,{className:"h-3.5 w-3.5"}),"Remove"]})}),e.jsx("button",{onClick:()=>I(t),disabled:p.isPending,className:"btn-cyber text-sm py-1.5 px-4",children:p.isPending?e.jsx(C,{className:"h-4 w-4 animate-spin"}):s("common.save")})]})]})]},t.id)})})]})})}export{ne 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.