- sesstions start by default

- added restart session button
This commit is contained in:
2025-11-19 11:52:37 +00:00
parent 516b43a2f8
commit ea93053dd3
3 changed files with 40 additions and 21 deletions

View File

@@ -4,7 +4,7 @@ import { useIntegrationsContext } from "../../context/IntegrationsContext";
import type { ReducedSightingType } from "../../types/types";
import { toast } from "sonner";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faFloppyDisk, faPause, faPlay, faStop } from "@fortawesome/free-solid-svg-icons";
import { faFloppyDisk, faPause, faPlay, faStop, faArrowRotateRight } from "@fortawesome/free-solid-svg-icons";
import VehicleSessionItem from "../UI/VehicleSessionItem";
import { useCameraBlackboard } from "../../hooks/useCameraBlackboard";
@@ -70,6 +70,21 @@ const SessionCard = () => {
if (result.reason === "OK") toast.success("Session saved");
};
const handleRestartClick = async () => {
const result = await mutation.mutateAsync({
operation: "INSERT",
path: "sessionStats",
value: [],
});
await mutation.mutateAsync({
operation: "SAVE",
path: "",
value: null,
});
if (result.reason === "OK") toast.success("Session restarted");
dispatch({ type: "SESSIONRESTART", payload: [] });
};
return (
<Card className="p-4 col-span-3">
<CardHeader title="Session" />
@@ -85,6 +100,17 @@ const SessionCard = () => {
<p>{sessionStarted ? "End Session" : "Start Session"}</p>
</div>
</button>
{sessionStarted && (
<button
className={`bg-none text-white px-4 py-2 rounded transition w-full border border-gray-500 hover:bg-gray-500 hover:text-gray-900`}
onClick={handleRestartClick}
>
<div className="flex flex-row gap-3 items-center justify-self-center">
<FontAwesomeIcon icon={faArrowRotateRight} />
<p>Restart Session</p>
</div>
</button>
)}
<div className="flex flex-col lg:flex-row gap-5">
{sessionStarted && (
<button