Initial commit
This commit is contained in:
commit
78f8d225ee
21173 changed files with 2907774 additions and 0 deletions
60
app/materials/[id]/page.tsx
Normal file
60
app/materials/[id]/page.tsx
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
'use client';
|
||||
|
||||
import Link from 'next/link';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useParams } from 'next/navigation';
|
||||
|
||||
export default function MaterialDetailsPage() {
|
||||
const { id } = useParams();
|
||||
const [material, setMaterial] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!id) return;
|
||||
|
||||
fetch(
|
||||
`${process.env.NEXT_PUBLIC_API_BASE_URL}/items/material/${id}?fields=id,name,abbreviation,common_names,technical_name,composition,material_cat.name,material_status.name,notes,override_reason,hazard_tags.hazard_tags_id.hazard_source.source,hazard_tags.hazard_tags_id.hazard_danger.danger,hazard_tags.hazard_tags_id.hazard_severity.severity`
|
||||
)
|
||||
.then((res) => res.json())
|
||||
.then((data) => setMaterial(data.data || null));
|
||||
}, [id]);
|
||||
|
||||
if (!material) return <div className="p-6">Loading...</div>;
|
||||
|
||||
return (
|
||||
<div className="p-6 max-w-4xl mx-auto">
|
||||
<h1 className="text-3xl font-bold mb-4">{material.name}</h1>
|
||||
<div className="space-y-2">
|
||||
<p><strong>Category:</strong> {material.material_cat?.name || '—'}</p>
|
||||
<p><strong>Status:</strong> {material.material_status?.name || '—'}</p>
|
||||
<p><strong>Abbreviation:</strong> {material.abbreviation || '—'}</p>
|
||||
<p><strong>Common Names:</strong> {material.common_names || '—'}</p>
|
||||
<p><strong>Technical Name:</strong> {material.technical_name || '—'}</p>
|
||||
<p><strong>Composition:</strong> {material.composition || '—'}</p>
|
||||
<p><strong>Notes:</strong> {material.notes || '—'}</p>
|
||||
<p><strong>Override Reason:</strong> {material.override_reason || '—'}</p>
|
||||
|
||||
<div>
|
||||
<strong>Hazard Tags</strong>
|
||||
<ul className="list-disc pl-6">
|
||||
{Array.isArray(material.hazard_tags) && material.hazard_tags.length > 0 ? (
|
||||
material.hazard_tags.map((tag, index) => (
|
||||
<li key={index}>
|
||||
{tag.hazard_tags_id?.hazard_source?.source || '—'} |{' '}
|
||||
{tag.hazard_tags_id?.hazard_danger?.danger || '—'} |{' '}
|
||||
{tag.hazard_tags_id?.hazard_severity?.severity || '—'}
|
||||
</li>
|
||||
))
|
||||
) : (
|
||||
<li>None</li>
|
||||
)}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-8">
|
||||
<Link href="/materials" className="text-blue-600 underline">← Back to Materials</Link>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
145
app/materials/page.tsx
Normal file
145
app/materials/page.tsx
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
'use client';
|
||||
|
||||
import Link from 'next/link';
|
||||
import { useEffect, useState, useMemo } from 'react';
|
||||
|
||||
function highlightMatch(text: string, query: string) {
|
||||
if (!query) return text;
|
||||
const parts = text.split(new RegExp(`(${query})`, 'gi'));
|
||||
return parts.map((part, i) =>
|
||||
part.toLowerCase() === query.toLowerCase() ? <mark key={i}>{part}</mark> : part
|
||||
);
|
||||
}
|
||||
|
||||
export default function MaterialsPage() {
|
||||
const [materials, setMaterials] = useState<any[]>([]);
|
||||
const [query, setQuery] = useState('');
|
||||
const [debouncedQuery, setDebouncedQuery] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => setDebouncedQuery(query), 300);
|
||||
return () => clearTimeout(timer);
|
||||
}, [query]);
|
||||
|
||||
useEffect(() => {
|
||||
fetch(
|
||||
`${process.env.NEXT_PUBLIC_API_BASE_URL}/items/material?fields=id,name,abbreviation,common_names,technical_name,material_cat.name,material_status.name&limit=-1`
|
||||
)
|
||||
.then((res) => res.json())
|
||||
.then((data) => setMaterials(data.data || []));
|
||||
}, []);
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
const q = debouncedQuery.toLowerCase();
|
||||
return materials.filter((mat) =>
|
||||
[
|
||||
mat.name,
|
||||
mat.technical_name,
|
||||
mat.common_names,
|
||||
mat.abbreviation,
|
||||
mat.material_status?.name
|
||||
]
|
||||
.filter(Boolean)
|
||||
.some((field) => field.toLowerCase().includes(q))
|
||||
);
|
||||
}, [materials, debouncedQuery]);
|
||||
|
||||
const grouped = useMemo<Record<string, typeof filtered>>(() => {
|
||||
return filtered.reduce((acc, mat) => {
|
||||
const key = mat.material_cat?.name || 'Uncategorized';
|
||||
acc[key] = acc[key] || [];
|
||||
acc[key].push(mat);
|
||||
return acc;
|
||||
}, {} as Record<string, typeof filtered>);
|
||||
}, [filtered]);
|
||||
|
||||
return (
|
||||
<div className="p-6 max-w-7xl mx-auto">
|
||||
<div className="mb-6 flex flex-col lg:flex-row gap-4">
|
||||
<div className="flex-1 card bg-card text-card-foreground relative pb-16">
|
||||
<h1 className="text-3xl font-bold mb-2">Laser Material Reference</h1>
|
||||
<input
|
||||
type="search"
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
placeholder="Search materials..."
|
||||
className="w-full max-w-md mb-4 dark:bg-background border border-border rounded-md p-2"
|
||||
/>
|
||||
<h2 className="font-semibold mb-1">📌 Disclaimer</h2>
|
||||
<p className="mb-6">
|
||||
The following materials are provided for educational purposes only and are not intended to be used as your sole or primary source of information when assessing the safety of any particular material. It is your responsibility alone to ensure your safety when operating your equipment. This resource is provided as-is, free of charge under the assumption you are exercising all other relevant safety precautions.
|
||||
</p>
|
||||
<div className="absolute bottom-4 left-4">
|
||||
<Link
|
||||
href="/"
|
||||
className="btn-primary"
|
||||
>
|
||||
← Back to Main Menu
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 card bg-[#422c17] text-white">
|
||||
<h2 className="font-bold text-base mb-2">⚠ Safety Level Definitions</h2>
|
||||
<ul className="space-y-2">
|
||||
<li><strong>Safe</strong> – Materials marked as safe are widely considered to be generally safe by the laser community at large. This does not mean normal safety protocols should not be observed.</li>
|
||||
<li><strong>Level I – Caution</strong> | These materials are typically safe when normal safety protocol observed. This includes skin, eye and respiratory protection, regulated marking parameters, and proper exhaust and filtration.</li>
|
||||
<li><strong>Level II – Dangerous</strong> | These materials can be harmful even if normal safety protocol observed. Strict adherence to safety protocols required at all times. Exercise extreme caution and mindfulness.</li>
|
||||
<li><strong>Level III – Critical Hazard</strong> | These materials pose an imminent threat of bodily harm or death. Materials marked Critical Hazard should not be processed by lasers in any environment for any reason.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{Object.entries(grouped).length === 0 ? (
|
||||
<p className="text-muted">No materials found.</p>
|
||||
) : (
|
||||
<div className="space-y-6">
|
||||
{Object.entries(grouped).map(([category, items]) => (
|
||||
<details key={category} className="border border-border rounded-md">
|
||||
<summary className="bg-card px-4 py-2 font-semibold cursor-pointer">
|
||||
{category} <span className="text-sm text-muted">({items.length})</span>
|
||||
</summary>
|
||||
<div className="overflow-x-auto">
|
||||
<table className="table-fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th className="w-48">Name</th>
|
||||
<th className="w-32 whitespace-nowrap">Status</th>
|
||||
<th className="w-32">Abbreviation</th>
|
||||
<th className="w-64">Common Names</th>
|
||||
<th className="w-64">Technical Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{items.map((material) => (
|
||||
<tr key={material.id} className="border-t border-border align-top">
|
||||
<td className="truncate max-w-[12rem]">
|
||||
<Link href={`/materials/${material.id}`} className="text-accent underline">
|
||||
{highlightMatch(material.name, debouncedQuery)}
|
||||
</Link>
|
||||
</td>
|
||||
<td className="whitespace-nowrap">
|
||||
{highlightMatch(material.material_status?.name || '—', debouncedQuery)}
|
||||
</td>
|
||||
<td className="truncate max-w-[8rem]">
|
||||
{highlightMatch(material.abbreviation || '—', debouncedQuery)}
|
||||
</td>
|
||||
<td className="truncate max-w-[16rem]">
|
||||
{highlightMatch(material.common_names || '—', debouncedQuery)}
|
||||
</td>
|
||||
<td className="truncate max-w-[16rem]">
|
||||
{highlightMatch(material.technical_name || '—', debouncedQuery)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</details>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue