"use client"; import { useState } from "react"; import { markPickupComplete } from "@/actions/pickup"; type Props = { orderId: string; brandId: string | null; currentlyPickedUp: boolean; }; export default function OrderPickupAction({ orderId, brandId, currentlyPickedUp, }: Props) { const [pickingUp, setPickingUp] = useState(false); const [toast, setToast] = useState<{ type: "success" | "error"; msg: string } | null>(null); async function handlePickup() { setPickingUp(true); const result = await markPickupComplete(orderId, brandId); setPickingUp(false); if (result.success) { setToast({ type: "success", msg: "Order marked as picked up." }); setTimeout(() => window.location.reload(), 1200); } else { setToast({ type: "error", msg: result.error ?? "Failed to mark picked up." }); } } if (currentlyPickedUp) { return ( Picked Up ); } return (