'use client'; import React from 'react'; const SampleDetailsSection = ({ sampleDetails, setSampleDetails }) => { const preservativeOptions = [ '', 'Trizol', 'RNA later', 'Ethanol', 'Formalin', 'FFPE', 'Others' ]; const tempOptions = [ '', 'Ambient', 'Cool pack', 'Dry ice', 'Others' ]; const handleSampleChange = (index, field, value) => { const newSampleDetails = [...sampleDetails]; newSampleDetails[index] = { ...newSampleDetails[index], [field]: value }; setSampleDetails(newSampleDetails); }; const addRow = () => { setSampleDetails([...sampleDetails, { Serial_Number: '', Sample_Name: '', Storage_Temp: '', Preservative_Reagent: '', Temp_Information: '', Comments: '' }]); }; const removeRow = (index) => { if (sampleDetails.length > 1) { const newSampleDetails = sampleDetails.filter((_, i) => i !== index); setSampleDetails(newSampleDetails); } }; return (

Sample Details

{/* Desktop Table View */}
{sampleDetails.map((sample, index) => ( ))}
Serial Number Sample Name Storage Temp (in °C) Preservative Reagent Temp Information Comments
handleSampleChange(index, 'Serial_Number', e.target.value)} style={{ color: '#555555' }} className="w-full text-xs h-8 p-1 border-none outline-none" /> handleSampleChange(index, 'Sample_Name', e.target.value)} style={{ color: '#555555' }} className="w-full text-xs h-8 p-1 border-none outline-none" /> handleSampleChange(index, 'Storage_Temp', e.target.value)} style={{ color: '#555555' }} className="w-full text-xs h-8 p-1 border-none outline-none" /> handleSampleChange(index, 'Comments', e.target.value)} style={{ color: '#555555' }} className="w-full text-xs h-8 p-1 border-none outline-none" />
{/* Mobile Card View */}
{sampleDetails.map((sample, index) => (
handleSampleChange(index, 'Serial_Number', e.target.value)} style={{ color: '#555555' }} className="w-full p-2 border border-gray-300 rounded text-xs h-8" />
handleSampleChange(index, 'Sample_Name', e.target.value)} style={{ color: '#555555' }} className="w-full p-2 border border-gray-300 rounded text-xs h-8" />
handleSampleChange(index, 'Storage_Temp', e.target.value)} style={{ color: '#555555' }} className="w-full p-2 border border-gray-300 rounded text-xs h-8" />
handleSampleChange(index, 'Comments', e.target.value)} style={{ color: '#555555' }} className="w-full p-2 border border-gray-300 rounded text-xs h-8" />
))}
{/* Add Row Button */}
); }; export default SampleDetailsSection;