import React, { useState } from "react"; const ProductForm = ({ editingProduct, setEditingProduct, onSave, onCancel, }) => { const [selectedCategory, setSelectedCategory] = useState(""); const categories = [ "Electronics", "Clothing", "Home & Garden", "Toys & Games", "Books", "Sports & Outdoors", "Automotive", "Beauty & Personal Care", "Health & Wellness", "Jewelry", "Art & Collectibles", "Food & Beverages", "Office Supplies", "Pet Supplies", "Music & Instruments", "Other", ]; const addCategory = () => { if ( selectedCategory && !(editingProduct.categories || []).includes(selectedCategory) ) { setEditingProduct((prev) => ({ ...prev, categories: [...(prev.categories || []), selectedCategory], })); setSelectedCategory(""); } }; const removeCategory = (categoryToRemove) => { setEditingProduct((prev) => ({ ...prev, categories: (prev.categories || []).filter( (cat) => cat !== categoryToRemove, ), })); }; return (
Please select at least one category
)}{editingProduct.images.length}{" "} {editingProduct.images.length === 1 ? "image" : "images"}{" "} selected