import { permissions, type ManufacturingStationInput, type ManufacturingStationDto } from "@mrp/shared"; import { useEffect, useState } from "react"; import { useAuth } from "../../auth/AuthProvider"; import { api, ApiError } from "../../lib/api"; import { WorkOrderListPage } from "./WorkOrderListPage"; const emptyStationInput: ManufacturingStationInput = { code: "", name: "", description: "", queueDays: 0, isActive: true, }; export function ManufacturingPage() { const { token, user } = useAuth(); const [stations, setStations] = useState([]); const [form, setForm] = useState(emptyStationInput); const [status, setStatus] = useState("Define manufacturing stations once so routings and work orders can schedule automatically."); const [isSaving, setIsSaving] = useState(false); const canManage = user?.permissions.includes(permissions.manufacturingWrite) ?? false; useEffect(() => { if (!token) { return; } api.getManufacturingStations(token).then(setStations).catch(() => setStations([])); }, [token]); async function handleSubmit(event: React.FormEvent) { event.preventDefault(); if (!token) { return; } setIsSaving(true); setStatus("Saving station..."); try { const station = await api.createManufacturingStation(token, form); setStations((current) => [...current, station].sort((left, right) => left.code.localeCompare(right.code))); setForm(emptyStationInput); setStatus("Station saved."); } catch (error: unknown) { const message = error instanceof ApiError ? error.message : "Unable to save station."; setStatus(message); } finally { setIsSaving(false); } } return (

Manufacturing Stations

Scheduling anchors

Stations define where operation time belongs. Buildable items reference them in their routing template, and work orders inherit those steps automatically into planning.

{stations.length === 0 ? (
No stations defined yet.
) : (
{stations.map((station) => (
{station.code} - {station.name}
{station.description || "No description"}
{station.queueDays} expected wait day(s)
{station.isActive ? "Active" : "Inactive"}
))}
)}
{canManage ? (

New Station