Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

feat: confirm dialog to switch activities instead of error toast

Khuram Niaz908d2313aec2
diff --git a/__tests__/ActivitiesContainer.spec.tsx b/__tests__/ActivitiesContainer.spec.tsx
index 72ca611..3802427 100644
--- a/__tests__/ActivitiesContainer.spec.tsx
+++ b/__tests__/ActivitiesContainer.spec.tsx
@@ -503,4 +503,131 @@ describe("ActivitiesContainer Search Functionality", () => {
});
});
});
+
+ describe("Start Activity Confirmation", () => {
+ it("starts the activity directly when nothing is currently in progress", async () => {
+ (getActivitiesList as any).mockResolvedValue({
+ success: true,
+ data: mockActivities,
+ total: 3,
+ });
+ (startActivityById as any).mockResolvedValue({
+ success: true,
+ newActivity: {
+ id: "new-1",
+ activityName: "TypeScript Learning",
+ startTime: new Date(),
+ endTime: null,
+ },
+ });
+
+ renderComponent();
+
+ await waitFor(() => {
+ expect(screen.getByText("TypeScript Learning")).toBeInTheDocument();
+ });
+
+ await act(async () => {
+ await user.click(screen.getAllByTitle("Start Activity")[0]);
+ });
+
+ await waitFor(() => {
+ expect(startActivityById).toHaveBeenCalledWith("1");
+ });
+ expect(stopActivityById).not.toHaveBeenCalled();
+ expect(
+ screen.queryByText(/is currently in progress/i)
+ ).not.toBeInTheDocument();
+ });
+
+ it("shows a confirm dialog naming the running activity instead of starting immediately", async () => {
+ (getActivitiesList as any).mockResolvedValue({
+ success: true,
+ data: mockActivities,
+ total: 3,
+ });
+ (getCurrentActivity as any).mockResolvedValue({
+ success: true,
+ activity: {
+ id: "current-1",
+ activityName: "Ongoing Task",
+ startTime: new Date(),
+ endTime: null,
+ description: null,
+ activityType: { id: "1", label: "Learning", value: "learning" },
+ },
+ });
+
+ renderComponent();
+
+ await waitFor(() => {
+ expect(screen.getByText("TypeScript Learning")).toBeInTheDocument();
+ });
+
+ await act(async () => {
+ await user.click(screen.getAllByTitle("Start Activity")[0]);
+ });
+
+ expect(startActivityById).not.toHaveBeenCalled();
+ expect(
+ await screen.findByText(/"Ongoing Task" is currently in progress/i)
+ ).toBeInTheDocument();
+ });
+
+ it("stops the running activity then starts the new one on confirm", async () => {
+ (getActivitiesList as any).mockResolvedValue({
+ success: true,
+ data: mockActivities,
+ total: 3,
+ });
+ (getCurrentActivity as any).mockResolvedValue({
+ success: true,
+ activity: {
+ id: "current-1",
+ activityName: "Ongoing Task",
+ startTime: new Date(),
+ endTime: null,
+ description: null,
+ activityType: { id: "1", label: "Learning", value: "learning" },
+ },
+ });
+ (stopActivityById as any).mockResolvedValue({ success: true });
+ (startActivityById as any).mockResolvedValue({
+ success: true,
+ newActivity: {
+ id: "new-1",
+ activityName: "TypeScript Learning",
+ startTime: new Date(),
+ endTime: null,
+ },
+ });
+
+ renderComponent();
+
+ await waitFor(() => {
+ expect(screen.getByText("TypeScript Learning")).toBeInTheDocument();
+ });
+
+ await act(async () => {
+ await user.click(screen.getAllByTitle("Start Activity")[0]);
+ });
+
+ const confirmButton = await screen.findByRole("button", {
+ name: "Stop & Start",
+ });
+
+ await act(async () => {
+ await user.click(confirmButton);
+ });
+
+ await waitFor(() => {
+ expect(stopActivityById).toHaveBeenCalledWith(
+ "current-1",
+ expect.any(Date),
+ expect.any(Number)
+ );
+ expect(startActivityById).toHaveBeenCalledWith("1");
+ });
+ });
+ });
});
diff --git a/__tests__/RecentCardToggle.spec.tsx b/__tests__/RecentCardToggle.spec.tsx
new file mode 100644
index 0000000..003825b
--- /dev/null
+++ b/__tests__/RecentCardToggle.spec.tsx
@@ -0,0 +1,93 @@
+import { render, screen, waitFor } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import RecentCardToggle from "@/components/dashboard/RecentCardToggle";
+import { useActivity } from "@/context/ActivityContext";
+
+vi.mock("@/context/ActivityContext", () => ({
+ useActivity: vi.fn(),
+}));
+
+describe("RecentCardToggle - Start Activity", () => {
+ const user = userEvent.setup();
+ const mockStartActivity = vi.fn();
+ const mockStopActivity = vi.fn();
+
+ const activities = [
+ {
+ id: "activity-1",
+ activityName: "Resume Review",
+ duration: 30,
+ endTime: new Date("2026-07-01T10:00:00"),
+ activityType: { label: "Job Search" },
+ },
+ ];
+
+ const renderComponent = () => {
+ render(<RecentCardToggle jobs={[]} activities={activities} />);
+ };
+
+ const switchToActivitiesTab = async () => {
+ await user.click(screen.getByRole("button", { name: "Activities" }));
+ };
+
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ it("starts the activity directly when nothing is currently in progress", async () => {
+ (useActivity as any).mockReturnValue({
+ currentActivity: undefined,
+ startActivity: mockStartActivity,
+ stopActivity: mockStopActivity,
+ });
+
+ renderComponent();
+ await switchToActivitiesTab();
+
+ await user.click(screen.getByTitle("Start Activity"));
+
+ expect(mockStartActivity).toHaveBeenCalledWith("activity-1");
+ expect(mockStopActivity).not.toHaveBeenCalled();
+ });
+
+ it("shows a confirm dialog naming the running activity instead of starting immediately", async () => {
+ (useActivity as any).mockReturnValue({
+ currentActivity: { id: "current-1", activityName: "Deep Work" },
+ startActivity: mockStartActivity,
+ stopActivity: mockStopActivity,
+ });
+
+ renderComponent();
+ await switchToActivitiesTab();
+
+ await user.click(screen.getByTitle("Start Activity"));
+
+ expect(mockStartActivity).not.toHaveBeenCalled();
+ expect(
+ await screen.findByText(/"Deep Work" is currently in progress/i)
+ ).toBeInTheDocument();
+ });
+
+ it("stops the running activity then starts the new one on confirm", async () => {
+ (useActivity as any).mockReturnValue({
+ currentActivity: { id: "current-1", activityName: "Deep Work" },
+ startActivity: mockStartActivity,
+ stopActivity: mockStopActivity,
+ });
+
+ renderComponent();
+ await switchToActivitiesTab();
+
+ await user.click(screen.getByTitle("Start Activity"));
+
+ const confirmButton = await screen.findByRole("button", {
+ name: "Stop & Start",
+ });
+ await user.click(confirmButton);
+
+ await waitFor(() => {
+ expect(mockStopActivity).toHaveBeenCalledTimes(1);
+ expect(mockStartActivity).toHaveBeenCalledWith("activity-1");
+ });
+ });
+});
diff --git a/__tests__/TasksContainer.spec.tsx b/__tests__/TasksContainer.spec.tsx
index 137fb27..02672a2 100644
--- a/__tests__/TasksContainer.spec.tsx
+++ b/__tests__/TasksContainer.spec.tsx
@@ -477,6 +477,86 @@ describe("TasksContainer Component", () => {
});
});
+ describe("Start Activity Confirmation", () => {
+ const mockStopActivity = vi.fn();
+
+ beforeEach(() => {
+ (getTasksList as any).mockResolvedValue({
+ success: true,
+ data: mockTasks,
+ total: 2,
+ });
+ });
+
+ it("starts the activity directly when nothing is currently in progress", async () => {
+ (startActivityFromTask as any).mockResolvedValue({ success: true });
+
+ render(<TasksContainer activityTypes={mockActivityTypes} />);
+
+ await waitFor(() => {
+ expect(screen.getByText("Task 1")).toBeInTheDocument();
+ });
+
+ const startActivityButtons = screen.getAllByTestId(/start-activity-/);
+ await user.click(startActivityButtons[0]);
+
+ await waitFor(() => {
+ expect(startActivityFromTask).toHaveBeenCalledWith("task-1");
+ });
+ expect(mockStopActivity).not.toHaveBeenCalled();
+ });
+
+ it("shows a confirm dialog naming the running activity instead of starting immediately", async () => {
+ (useActivity as any).mockReturnValue({
+ refreshCurrentActivity: mockRefreshCurrentActivity,
+ currentActivity: { id: "current-1", activityName: "Ongoing Task" },
+ stopActivity: mockStopActivity,
+ });
+
+ render(<TasksContainer activityTypes={mockActivityTypes} />);
+
+ await waitFor(() => {
+ expect(screen.getByText("Task 1")).toBeInTheDocument();
+ });
+
+ const startActivityButtons = screen.getAllByTestId(/start-activity-/);
+ await user.click(startActivityButtons[0]);
+
+ expect(startActivityFromTask).not.toHaveBeenCalled();
+ expect(
+ await screen.findByText(/"Ongoing Task" is currently in progress/i)
+ ).toBeInTheDocument();
+ });
+
+ it("stops the running activity then starts the task activity on confirm", async () => {
+ (useActivity as any).mockReturnValue({
+ refreshCurrentActivity: mockRefreshCurrentActivity,
+ currentActivity: { id: "current-1", activityName: "Ongoing Task" },
+ stopActivity: mockStopActivity,
+ });
+ (startActivityFromTask as any).mockResolvedValue({ success: true });
+
+ render(<TasksContainer activityTypes={mockActivityTypes} />);
+
+ await waitFor(() => {
+ expect(screen.getByText("Task 1")).toBeInTheDocument();
+ });
+
+ const startActivityButtons = screen.getAllByTestId(/start-activity-/);
+ await user.click(startActivityButtons[0]);
+
+ const confirmButton = await screen.findByRole("button", {
+ name: "Stop & Start",
+ });
+ await user.click(confirmButton);
+
+ await waitFor(() => {
+ expect(mockStopActivity).toHaveBeenCalledTimes(1);
+ expect(startActivityFromTask).toHaveBeenCalledWith("task-1");
+ });
+ });
+ });
+
describe("Filtering and Grouping", () => {
beforeEach(async () => {
(getTasksList as any).mockResolvedValue({
diff --git a/__tests__/useActivitySwitchConfirm.spec.tsx b/__tests__/useActivitySwitchConfirm.spec.tsx
new file mode 100644
index 0000000..d7f8994
--- /dev/null
+++ b/__tests__/useActivitySwitchConfirm.spec.tsx
@@ -0,0 +1,118 @@
+import { render, screen, waitFor } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { useActivitySwitchConfirm } from "@/hooks/useActivitySwitchConfirm";
+import { useActivity } from "@/context/ActivityContext";
+
+vi.mock("@/context/ActivityContext", () => ({
+ useActivity: vi.fn(),
+}));
+
+function TestHarness({ action }: { action: () => void }) {
+ const { requestStart, confirmDialog } = useActivitySwitchConfirm();
+ return (
+ <div>
+ <button onClick={() => requestStart(action)}>Trigger Start</button>
+ {confirmDialog}
+ </div>
+ );
+}
+
+describe("useActivitySwitchConfirm", () => {
+ const user = userEvent.setup();
+ const mockStopActivity = vi.fn();
+
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ it("runs the action immediately when there is no activity in progress", async () => {
+ (useActivity as any).mockReturnValue({
+ currentActivity: undefined,
+ stopActivity: mockStopActivity,
+ });
+
+ const action = vi.fn();
+ render(<TestHarness action={action} />);
+
+ await user.click(screen.getByText("Trigger Start"));
+
+ expect(action).toHaveBeenCalledTimes(1);
+ expect(mockStopActivity).not.toHaveBeenCalled();
+ expect(
+ screen.queryByText(/Stop current activity and start a new one/i)
+ ).not.toBeInTheDocument();
+ });
+
+ it("shows a confirm dialog naming the in-progress activity instead of running the action", async () => {
+ (useActivity as any).mockReturnValue({
+ currentActivity: { id: "a1", activityName: "Writing docs" },
+ stopActivity: mockStopActivity,
+ });
+
+ const action = vi.fn();
+ render(<TestHarness action={action} />);
+
+ await user.click(screen.getByText("Trigger Start"));
+
+ expect(action).not.toHaveBeenCalled();
+ expect(mockStopActivity).not.toHaveBeenCalled();
+ expect(
+ await screen.findByText(/Stop current activity and start a new one/i)
+ ).toBeInTheDocument();
+ expect(
+ screen.getByText(/"Writing docs" is currently in progress/i)
+ ).toBeInTheDocument();
+ });
+
+ it("stops the current activity then runs the pending action on confirm", async () => {
+ (useActivity as any).mockReturnValue({
+ currentActivity: { id: "a1", activityName: "Writing docs" },
+ stopActivity: mockStopActivity,
+ });
+
+ const action = vi.fn();
+ render(<TestHarness action={action} />);
+
+ await user.click(screen.getByText("Trigger Start"));
+
+ const confirmButton = await screen.findByRole("button", {
+ name: "Stop & Start",
+ });
+ await user.click(confirmButton);
+
+ await waitFor(() => {
+ expect(mockStopActivity).toHaveBeenCalledTimes(1);
+ expect(action).toHaveBeenCalledTimes(1);
+ });
+
+ await waitFor(() => {
+ expect(
+ screen.queryByText(/Stop current activity and start a new one/i)
+ ).not.toBeInTheDocument();
+ });
+ });
+
+ it("does not run the action when the dialog is dismissed", async () => {
+ (useActivity as any).mockReturnValue({
+ currentActivity: { id: "a1", activityName: "Writing docs" },
+ stopActivity: mockStopActivity,
+ });
+
+ const action = vi.fn();
+ render(<TestHarness action={action} />);
+
+ await user.click(screen.getByText("Trigger Start"));
+
+ const cancelButton = await screen.findByRole("button", { name: "Cancel" });
+ await user.click(cancelButton);
+
+ await waitFor(() => {
+ expect(
+ screen.queryByText(/Stop current activity and start a new one/i)
+ ).not.toBeInTheDocument();
+ });
+
+ expect(action).not.toHaveBeenCalled();
+ expect(mockStopActivity).not.toHaveBeenCalled();
+ });
+});
diff --git a/src/components/activities/ActivitiesContainer.tsx b/src/components/activities/ActivitiesContainer.tsx
index a3ca9ed..9a9d32f 100644
--- a/src/components/activities/ActivitiesContainer.tsx
+++ b/src/components/activities/ActivitiesContainer.tsx
@@ -21,6 +21,7 @@ import Loading from "../Loading";
import { APP_CONSTANTS } from "@/lib/constants";
import { RecordsCount } from "../RecordsCount";
import { useActivity } from "@/context/ActivityContext";
+import { useActivitySwitchConfirm } from "@/hooks/useActivitySwitchConfirm";
function ActivitiesContainer() {
const [activityFormOpen, setActivityFormOpen] = useState<boolean>(false);
@@ -34,6 +35,7 @@ function ActivitiesContainer() {
const sentinelRef = useRef<HTMLDivElement>(null);
const { currentActivity, startActivity } = useActivity();
+ const { requestStart, confirmDialog } = useActivitySwitchConfirm();
const prevActivityRef = useRef<Activity | undefined>(undefined);
const closeActivityForm = () => setActivityFormOpen(false);
@@ -77,11 +79,13 @@ function ActivitiesContainer() {
await loadActivities(1, APP_CONSTANTS.RECORDS_PER_PAGE, searchTerm || undefined);
}, [loadActivities, searchTerm]);
- const handleStartActivity = async (activityId: string) => {
- const success = await startActivity(activityId);
- if (success) {
- reloadActivities();
- }
+ const handleStartActivity = (activityId: string) => {
+ requestStart(async () => {
+ const success = await startActivity(activityId);
+ if (success) {
+ reloadActivities();
+ }
+ });
};
useEffect(() => {
@@ -192,7 +196,6 @@ function ActivitiesContainer() {
activities={activitiesList}
reloadActivities={reloadActivities}
onStartActivity={handleStartActivity}
- activityExist={Boolean(currentActivity)}
/>
</>
)}
@@ -204,6 +207,7 @@ function ActivitiesContainer() {
</div>
)}
</CardContent>
+ {confirmDialog}
</Card>
);
}
diff --git a/src/components/activities/ActivitiesTable.tsx b/src/components/activities/ActivitiesTable.tsx
index 56a7796..fd3914b 100644
--- a/src/components/activities/ActivitiesTable.tsx
+++ b/src/components/activities/ActivitiesTable.tsx
@@ -28,14 +28,12 @@ interface ActivitiesTableProps {
activities: Activity[];
reloadActivities: () => void;
onStartActivity: (activityId: string) => void;
- activityExist: boolean;
}
function ActivitiesTable({
activities,
reloadActivities,
onStartActivity,
- activityExist,
}: ActivitiesTableProps) {
const [alertOpen, setAlertOpen] = useState(false);
const [activityIdToDelete, setActivityIdToDelete] = useState<string>();
@@ -128,7 +126,6 @@ function ActivitiesTable({
<DropdownMenuItem
className="cursor-pointer text-green-600"
onClick={() => onStartActivity(activity.id!)}
- disabled={activityExist}
>
<CirclePlay className="mr-2 h-4 w-4" />
Start Activity
@@ -143,20 +140,18 @@ function ActivitiesTable({
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenu>
- {!activityExist && (
- <Button
- title="Start Activity"
- aria-haspopup="true"
- size="icon"
- variant="ghost"
- onClick={() => onStartActivity(activity.id!)}
- className="opacity-0 group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity duration-300"
- >
- <span>
- <CirclePlay className="text-green-600" />
- </span>
- </Button>
- )}
+ <Button
+ title="Start Activity"
+ aria-haspopup="true"
+ size="icon"
+ variant="ghost"
+ onClick={() => onStartActivity(activity.id!)}
+ className="opacity-0 group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity duration-300"
+ >
+ <span>
+ <CirclePlay className="text-green-600" />
+ </span>
+ </Button>
</TableCell>
</TableRow>
);
diff --git a/src/components/dashboard/RecentCardToggle.tsx b/src/components/dashboard/RecentCardToggle.tsx
index 516eb7c..2aceef8 100644
--- a/src/components/dashboard/RecentCardToggle.tsx
+++ b/src/components/dashboard/RecentCardToggle.tsx
@@ -2,11 +2,15 @@
import { useState } from "react";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
+import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { StatusBadge } from "@/components/StatusBadge";
import { getJobStatusBadgeColor } from "@/lib/badge-colors";
import { cn } from "@/lib/utils";
+import { useActivity } from "@/context/ActivityContext";
+import { useActivitySwitchConfirm } from "@/hooks/useActivitySwitchConfirm";
import { JobResponse } from "@/models/job.model";
+import { CirclePlay } from "lucide-react";
import { format } from "date-fns";
import Link from "next/link";
@@ -68,6 +72,8 @@ export default function RecentCardToggle({
activities,
}: RecentCardToggleProps) {
const [activeIndex, setActiveIndex] = useState(0);
+ const { startActivity } = useActivity();
+ const { requestStart, confirmDialog } = useActivitySwitchConfirm();
return (
<Card className="mb-2">
@@ -139,9 +145,23 @@ export default function RecentCardToggle({
<p className="text-xs font-semibold uppercase tracking-wide text-muted-foreground">
{date}
</p>
- <div className="grid gap-4 pl-3">
+ <div className="grid gap-4">
{dateActivities.map((activity) => (
- <div key={activity.id} className="flex items-center gap-4">
+ <div
+ key={activity.id}
+ className="group relative flex items-center gap-1"
+ >
+ <Button
+ title="Start Activity"
+ size="icon"
+ variant="ghost"
+ onClick={() => requestStart(() => startActivity(activity.id))}
+ className="h-5 w-5 shrink-0 opacity-0 group-hover:opacity-100 group-hover:pointer-events-auto transition-opacity duration-300"
+ >
+ <span>
+ <CirclePlay className="text-green-600 h-3.5 w-3.5" />
+ </span>
+ </Button>
<div className="grid gap-1 min-w-0 flex-1">
<p className="text-sm font-medium leading-none truncate">
{activity.activityName}
@@ -161,6 +181,7 @@ export default function RecentCardToggle({
</div>
))}
</CardContent>
+ {confirmDialog}
</Card>
);
}
diff --git a/src/components/tasks/TasksContainer.tsx b/src/components/tasks/TasksContainer.tsx
index 7b30047..ee130fc 100644
--- a/src/components/tasks/TasksContainer.tsx
+++ b/src/components/tasks/TasksContainer.tsx
@@ -45,6 +45,7 @@ import TasksTable from "./TasksTable";
import { TaskForm } from "./TaskForm";
import { ActivityType } from "@/models/activity.model";
import { useActivity } from "@/context/ActivityContext";
+import { useActivitySwitchConfirm } from "@/hooks/useActivitySwitchConfirm";
type TasksContainerProps = {
activityTypes: ActivityType[];
@@ -63,6 +64,7 @@ function TasksContainer({
}: TasksContainerProps) {
const router = useRouter();
const { refreshCurrentActivity } = useActivity();
+ const { requestStart, confirmDialog } = useActivitySwitchConfirm();
const [tasks, setTasks] = useState<Task[]>([]);
const [page, setPage] = useState(1);
const [totalTasks, setTotalTasks] = useState(0);
@@ -185,22 +187,24 @@ function TasksContainer({
}
};
- const onStartActivity = async (taskId: string) => {
- const { success, message } = await startActivityFromTask(taskId);
- if (success) {
- await refreshCurrentActivity();
- toast({
- variant: "success",
- description: "Activity started from task",
- });
- router.push("/dashboard/activities");
- } else {
- toast({
- variant: "destructive",
- title: "Error!",
- description: message,
- });
- }
+ const onStartActivity = (taskId: string) => {
+ requestStart(async () => {
+ const { success, message } = await startActivityFromTask(taskId);
+ if (success) {
+ await refreshCurrentActivity();
+ toast({
+ variant: "success",
+ description: "Activity started from task",
+ });
+ router.push("/dashboard/activities");
+ } else {
+ toast({
+ variant: "destructive",
+ title: "Error!",
+ description: message,
+ });
+ }
+ });
};
const resetEditTask = () => {
@@ -414,6 +418,7 @@ function TasksContainer({
dialogOpen={dialogOpen}
setDialogOpen={setDialogOpen}
/>
+ {confirmDialog}
</>
);
}
diff --git a/src/hooks/useActivitySwitchConfirm.tsx b/src/hooks/useActivitySwitchConfirm.tsx
new file mode 100644
index 0000000..34c8554
--- /dev/null
+++ b/src/hooks/useActivitySwitchConfirm.tsx
@@ -0,0 +1,47 @@
+"use client";
+import { useCallback, useState } from "react";
+import { useActivity } from "@/context/ActivityContext";
+import { DeleteAlertDialog } from "@/components/DeleteAlertDialog";
+
+export function useActivitySwitchConfirm() {
+ const { currentActivity, stopActivity } = useActivity();
+ const [pendingAction, setPendingAction] = useState<(() => void) | null>(null);
+
+ const requestStart = useCallback(
+ (action: () => void) => {
+ if (currentActivity) {
+ setPendingAction(() => action);
+ } else {
+ action();
+ }
+ },
+ [currentActivity],
+ );
+
+ const confirmSwitch = useCallback(async () => {
+ const action = pendingAction;
+ setPendingAction(null);
+ if (!action) return;
+ await stopActivity();
+ action();
+ }, [pendingAction, stopActivity]);
+
+ const confirmDialog = (
+ <DeleteAlertDialog
+ pageTitle="activity"
+ open={pendingAction !== null}
+ onOpenChange={(open) => !open && setPendingAction(null)}
+ onDelete={confirmSwitch}
+ alertTitle="Stop current activity and start a new one?"
+ alertDescription={
+ currentActivity
+ ? `"${currentActivity.activityName}" is currently in progress. Stop it and start the new activity?`
+ : undefined
+ }
+ actionLabel="Stop & Start"
+ actionVariant="default"
+ />
+ );
+
+ return { requestStart, confirmDialog };
+}