makearmy-app/.next/static/chunks/app/lasers/page-b5e5aab1b35d6fb3.js
2025-09-22 10:37:53 -04:00

1 line
No EOL
6.6 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8339],{498:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>c});var a=t(5155),l=t(2115),r=t(6874),n=t.n(r);function c(){let[e,s]=(0,l.useState)([]),[t,r]=(0,l.useState)(""),[c,d]=(0,l.useState)(""),[i,o]=(0,l.useState)({}),[m,x]=(0,l.useState)("model"),[h,p]=(0,l.useState)("asc");(0,l.useEffect)(()=>{let e=setTimeout(()=>d(t),300);return()=>clearTimeout(e)},[t]),(0,l.useEffect)(()=>{fetch("".concat("https://forms.lasereverything.net","/items/laser_source?limit=-1&fields=*,op.label")).then(e=>e.json()).then(e=>s(e.data||[]))},[]);let u=(e,s)=>s&&e?e.split(RegExp("(".concat(s,")"),"gi")).map((e,t)=>e.toLowerCase()===s.toLowerCase()?(0,a.jsx)("mark",{children:e},t):e):e,j=(0,l.useMemo)(()=>{let s=c.toLowerCase();return e.filter(e=>[e.make,e.model].filter(Boolean).some(e=>e.toLowerCase().includes(s)))},[e,c]),b=(0,l.useMemo)(()=>j.reduce((e,s)=>{let t=s.make||"Unknown Make";return e[t]=e[t]||[],e[t].push(s),e},{}),[j]),N=[10600,1064,455,355],f=(e,s)=>{o(t=>({...t,[e]:t[e]===s?null:s}))},w=e=>{x(e),p(e=>"asc"===e?"desc":"asc")},k=(e,s)=>e?"w"===s?parseFloat(e.replace(/[^\d.]/g,""))||0:["mj","nm","khz","ns","v"].includes(s.toLowerCase())?parseFloat(e)||0:e.toString().toLowerCase():"",g=e=>m===e?"asc"===h?" ▲":" ▼":"",y=(0,l.useMemo)(()=>{var s;let t=new Set,a={};for(let s of e)if(s.make&&t.add(s.make),s.nm){let e=s.nm;a[e]=(a[e]||0)+1}let l=(null==(s=Object.entries(a).sort((e,s)=>(Number(s[1])||0)-(Number(e[1])||0))[0])?void 0:s[0])||"—";return{total:e.length,uniqueMakes:t.size,commonNm:l}},[e]),v=(0,l.useMemo)(()=>[...e].filter(e=>e.submission_id).sort((e,s)=>s.submission_id-e.submission_id).slice(0,5),[e]);return(0,a.jsxs)("div",{className:"p-6 max-w-7xl mx-auto",children:[(0,a.jsxs)("div",{className:"grid gap-4 md:grid-cols-3 mb-6",children:[(0,a.jsxs)("div",{className:"card p-4",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-2",children:"Database Summary"}),(0,a.jsxs)("p",{children:["Total Sources: ",y.total]}),(0,a.jsxs)("p",{children:["Unique Makes: ",y.uniqueMakes]}),(0,a.jsxs)("p",{children:["Most Common Wavelength: ",y.commonNm]})]}),(0,a.jsxs)("div",{className:"card p-4",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-2",children:"Recent Additions"}),(0,a.jsx)("ul",{className:"text-sm list-disc pl-4",children:v.map(e=>(0,a.jsx)("li",{children:(0,a.jsxs)(n(),{className:"text-accent underline",href:"/lasers/".concat(e.submission_id),children:[e.make," ",e.model]})},e.id))})]}),(0,a.jsxs)("div",{className:"card p-4",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold mb-2",children:"Feedback"}),(0,a.jsx)("p",{className:"text-sm mb-2",children:"See something wrong or want to suggest an improvement?"}),(0,a.jsx)(n(),{href:"#",className:"btn-primary inline-block",children:"Submit Feedback"})]})]}),(0,a.jsxs)("div",{className:"mb-6 card bg-card text-card-foreground",children:[(0,a.jsx)("h1",{className:"text-3xl font-bold mb-2",children:"Laser Source Database"}),(0,a.jsx)("input",{type:"search",value:t,onChange:e=>r(e.target.value),placeholder:"Search by make or model...",className:"w-full max-w-md mb-4 dark:bg-background border border-border rounded-md p-2"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Browse laser source specifications collected from community-submitted and verified sources."})]}),0===Object.entries(b).length?(0,a.jsx)("p",{className:"text-muted",children:"No laser sources found."}):(0,a.jsx)("div",{className:"space-y-6",children:Object.entries(b).map(e=>{let[s,t]=e,l=null!=i[s]?t.filter(e=>parseInt(e.nm)===i[s]):t,r=[...l].sort((e,s)=>{let t=k(e[m],m),a=k(s[m],m);return t<a?"asc"===h?-1:1:t>a?"asc"===h?1:-1:0});return(0,a.jsxs)("details",{className:"border border-border rounded-md",children:[(0,a.jsxs)("summary",{className:"bg-card px-4 py-2 font-semibold cursor-pointer flex justify-between items-center",children:[(0,a.jsxs)("span",{children:[s," ",(0,a.jsxs)("span",{className:"text-sm text-muted",children:["(",l.length,")"]})]}),(0,a.jsx)("div",{className:"space-x-2",children:N.map(e=>(0,a.jsx)("button",{onClick:t=>{t.stopPropagation(),f(s,e)},className:"px-2 py-1 text-xs rounded-md border ".concat(i[s]===e?"bg-accent text-white":"bg-muted text-muted-foreground"),children:e},e))})]}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full min-w-[900px] text-sm whitespace-nowrap",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-2 py-2 text-left",children:"Make"}),(0,a.jsx)("th",{className:"px-2 py-2 text-left w-64",children:(0,a.jsxs)("button",{onClick:()=>w("model"),children:["Model",g("model")]})}),(0,a.jsx)("th",{className:"px-2 py-2 text-left",children:(0,a.jsxs)("button",{onClick:()=>w("w"),children:["W",g("w")]})}),(0,a.jsx)("th",{className:"px-2 py-2 text-left",children:(0,a.jsxs)("button",{onClick:()=>w("mj"),children:["mJ",g("mj")]})}),(0,a.jsx)("th",{className:"px-2 py-2 text-left",children:(0,a.jsxs)("button",{onClick:()=>w("op"),children:["OP",g("op")]})}),(0,a.jsx)("th",{className:"px-2 py-2 text-left",children:(0,a.jsxs)("button",{onClick:()=>w("nm"),children:["nm",g("nm")]})}),(0,a.jsx)("th",{className:"px-2 py-2 text-left",children:(0,a.jsxs)("button",{onClick:()=>w("kHz"),children:["kHz",g("kHz")]})}),(0,a.jsx)("th",{className:"px-2 py-2 text-left",children:(0,a.jsxs)("button",{onClick:()=>w("ns"),children:["ns",g("ns")]})}),(0,a.jsx)("th",{className:"px-2 py-2 text-left",children:(0,a.jsxs)("button",{onClick:()=>w("v"),children:["V",g("v")]})})]})}),(0,a.jsx)("tbody",{children:r.map(e=>{var s;return(0,a.jsxs)("tr",{className:"border-t border-border",children:[(0,a.jsx)("td",{className:"px-2 py-2 truncate max-w-[10rem]",children:u(e.make||"—",c)}),(0,a.jsx)("td",{className:"px-2 py-2 truncate max-w-[16rem]",children:(0,a.jsx)(n(),{href:"/lasers/".concat(e.submission_id),className:"text-accent underline",children:u(e.model||"—",c)})}),(0,a.jsx)("td",{className:"px-2 py-2 whitespace-nowrap",children:e.w||"—"}),(0,a.jsx)("td",{className:"px-2 py-2 whitespace-nowrap",children:e.mj||"—"}),(0,a.jsx)("td",{className:"px-2 py-2 whitespace-nowrap",children:(null==(s=e.op)?void 0:s.label)||e.op||"—"}),(0,a.jsx)("td",{className:"px-2 py-2 whitespace-nowrap",children:e.nm||"—"}),(0,a.jsx)("td",{className:"px-2 py-2 whitespace-nowrap",children:e.kHz||"—"}),(0,a.jsx)("td",{className:"px-2 py-2 whitespace-nowrap",children:e.ns||"—"}),(0,a.jsx)("td",{className:"px-2 py-2 whitespace-nowrap",children:e.v||"—"})]},e.id)})})]})})]},s)})})]})}},5290:(e,s,t)=>{Promise.resolve().then(t.bind(t,498))}},e=>{var s=s=>e(e.s=s);e.O(0,[6874,8441,1684,7358],()=>s(5290)),_N_E=e.O()}]);