import React, { useState } from 'react'; export default function WorkCategoryTool() { const [categories] = useState([ { id: 1, name: "Clarifications" }, { id: 2, name: "02-05 Demolition" }, { id: 3, name: "02-10 Remediation/Abatement" }, { id: 4, name: "03-05 Concrete" }, { id: 5, name: "03-10 Reinforcing Steel" }, // Add more categories as needed... ]); const [selectedCategories, setSelectedCategories] = useState([]); const handleSelectCategory = (category) => { if (!selectedCategories.includes(category)) { const updatedCategories = [...selectedCategories, category] .sort((a, b) => a.name.localeCompare(b.name)); const clarification = updatedCategories.find( (cat) => cat.name === "Clarifications" ); const withoutClarifications = updatedCategories.filter( (cat) => cat.name !== "Clarifications" ); setSelectedCategories( clarification ? [clarification, ...withoutClarifications] : updatedCategories ); } }; const handleRemoveCategory = (id) => { setSelectedCategories(selectedCategories.filter((category) => category.id !== id)); }; const handleSelectAll = () => { const sortedCategories = [...categories].sort((a, b) => a.name.localeCompare(b.name)); const clarification = sortedCategories.find( (cat) => cat.name === "Clarifications" ); const withoutClarifications = sortedCategories.filter( (cat) => cat.name !== "Clarifications" ); setSelectedCategories( clarification ? [clarification, ...withoutClarifications] : sortedCategories ); }; const handleAssembleDescriptions = () => { alert("Assembled descriptions: " + selectedCategories.map((cat) => cat.name).join(", ")); }; return (

Work Category Tool

Available Categories

    {categories.map((category) => (
  • handleSelectCategory(category)} className="cursor-pointer p-2 border rounded hover:bg-gray-100" > {category.name}
  • ))}

Selected Categories

    {selectedCategories.map((category) => (
  • {category.name}
  • ))}
); } import React, { useState } from 'react'; export default function WorkCategoryTool() { const [categories] = useState([ { id: 1, name: "Clarifications" }, { id: 2, name: "02-05 Demolition" }, { id: 3, name: "02-10 Remediation/Abatement" }, { id: 4, name: "03-05 Concrete" }, { id: 5, name: "03-10 Reinforcing Steel" }, // Add more categories as needed... ]); const [selectedCategories, setSelectedCategories] = useState([]); const handleSelectCategory = (category) => { if (!selectedCategories.includes(category)) { const updatedCategories = [...selectedCategories, category] .sort((a, b) => a.name.localeCompare(b.name)); const clarification = updatedCategories.find( (cat) => cat.name === "Clarifications" ); const withoutClarifications = updatedCategories.filter( (cat) => cat.name !== "Clarifications" ); setSelectedCategories( clarification ? [clarification, ...withoutClarifications] : updatedCategories ); } }; const handleRemoveCategory = (id) => { setSelectedCategories(selectedCategories.filter((category) => category.id !== id)); }; const handleSelectAll = () => { const sortedCategories = [...categories].sort((a, b) => a.name.localeCompare(b.name)); const clarification = sortedCategories.find( (cat) => cat.name === "Clarifications" ); const withoutClarifications = sortedCategories.filter( (cat) => cat.name !== "Clarifications" ); setSelectedCategories( clarification ? [clarification, ...withoutClarifications] : sortedCategories ); }; const handleAssembleDescriptions = () => { alert("Assembled descriptions: " + selectedCategories.map((cat) => cat.name).join(", ")); }; return (

Work Category Tool

Available Categories

    {categories.map((category) => (
  • handleSelectCategory(category)} className="cursor-pointer p-2 border rounded hover:bg-gray-100" > {category.name}
  • ))}

Selected Categories

    {selectedCategories.map((category) => (
  • {category.name}
  • ))}
); }