diff --git a/src/components/admin/StopsHeaderActions.tsx b/src/components/admin/StopsHeaderActions.tsx index 85a391c..48435d5 100644 --- a/src/components/admin/StopsHeaderActions.tsx +++ b/src/components/admin/StopsHeaderActions.tsx @@ -1,74 +1,64 @@ "use client"; import { useState } from "react"; -import { useRouter } from "next/navigation"; -import { AdminButton } from "@/components/admin/design-system"; import ScheduleImportModal from "@/components/admin/ScheduleImportModal"; import AddStopModal from "@/components/admin/AddStopModal"; +import { useRouter } from "next/navigation"; +import { AdminButton } from "@/components/admin/design-system"; type Props = { brandId: string; + /** Hide on the Locations tab — actions belong to the Stops tab only. */ + tab?: "stops" | "locations"; }; -export default function StopsHeaderActions({ brandId }: Props) { - const router = useRouter(); - const [showAdd, setShowAdd] = useState(false); +export default function StopsHeaderActions({ brandId, tab = "stops" }: Props) { const [showImport, setShowImport] = useState(false); + const [showAdd, setShowAdd] = useState(false); + const router = useRouter(); - const refresh = () => router.refresh(); + if (tab !== "stops") return null; + + function handleImportComplete(count: number) { + router.refresh(); + } + + function handleAddSuccess(stopId: string) { + router.refresh(); + } return ( <> - setShowImport(true)} - icon={ - - - - } - > - Upload Schedule - - setShowAdd(true)} - icon={ - - - - } - > - Add Stop - +
+ setShowImport(true)} + icon={ + + + + } + > + Upload Schedule + + setShowAdd(true)} + icon={ + + + + } + > + Add Stop + +
{showImport && ( setShowImport(false)} - onComplete={refresh} + onComplete={handleImportComplete} /> )} @@ -76,7 +66,7 @@ export default function StopsHeaderActions({ brandId }: Props) { isOpen={showAdd} onClose={() => setShowAdd(false)} brandId={brandId} - onSuccess={refresh} + onSuccess={handleAddSuccess} /> );