"use client" import { useState } from "react" import Modal from "../Modal" export default function ProductionTrackingSection({ reportId, data, shiftName }: any) { const [tracking, setTracking] = useState(data || []) const [showModal, setShowModal] = useState(false) const [formData, setFormData] = useState({ hour: "", totalProduction: "", productionThisHour: "", comment: "" }) // Generate shift hours based on shift name const getShiftHours = () => { if (shiftName === "AM") { // AM shift: 8:00 AM to 7:00 PM return [ "8:00 AM", "9:00 AM", "10:00 AM", "11:00 AM", "12:00 PM", "1:00 PM", "2:00 PM", "3:00 PM", "4:00 PM", "5:00 PM", "6:00 PM", "7:00 PM" ] } else { // PM shift: 8:00 PM to 7:00 AM return [ "8:00 PM", "9:00 PM", "10:00 PM", "11:00 PM", "12:00 AM", "1:00 AM", "2:00 AM", "3:00 AM", "4:00 AM", "5:00 AM", "6:00 AM", "7:00 AM" ] } } const handleAdd = async () => { const updated = [...tracking, formData] setTracking(updated) await fetch(`/api/reports/${reportId}`, { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ productionTracking: updated }) }) setShowModal(false) setFormData({ hour: "", totalProduction: "", productionThisHour: "", comment: "" }) } return (

Production Tracking

{tracking.map((t: any, i: number) => ( ))}
Hour Total Production This Hour Comment
{t.hour} {t.totalProduction} {t.productionThisHour} {t.comment}
{showModal && ( setShowModal(false)}>

Add Production Tracking

setFormData({...formData, totalProduction: e.target.value})} className="w-full px-3 py-2 border rounded-lg" />
setFormData({...formData, productionThisHour: e.target.value})} className="w-full px-3 py-2 border rounded-lg" />