From f3e790890e701b7ad1441b19000869e1bb3ef12a Mon Sep 17 00:00:00 2001
From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
Date: Thu, 10 Apr 2025 09:23:18 -0500
Subject: [PATCH] only allow admins to edit sub labels and plates
---
.../overlay/detail/SearchDetailDialog.tsx | 77 +++++++++++--------
1 file changed, 43 insertions(+), 34 deletions(-)
diff --git a/web/src/components/overlay/detail/SearchDetailDialog.tsx b/web/src/components/overlay/detail/SearchDetailDialog.tsx
index f5c19ecb6a..6762890d4a 100644
--- a/web/src/components/overlay/detail/SearchDetailDialog.tsx
+++ b/web/src/components/overlay/detail/SearchDetailDialog.tsx
@@ -76,6 +76,7 @@ import { FaPencilAlt } from "react-icons/fa";
import TextEntryDialog from "@/components/overlay/dialog/TextEntryDialog";
import { useTranslation } from "react-i18next";
import { TbFaceId } from "react-icons/tb";
+import { useIsAdmin } from "@/hooks/use-is-admin";
const SEARCH_TABS = [
"details",
@@ -295,6 +296,10 @@ function ObjectDetailsTab({
const mutate = useGlobalMutation();
+ // users
+
+ const isAdmin = useIsAdmin();
+
// data
const [desc, setDesc] = useState(search?.data.description);
@@ -687,23 +692,25 @@ function ObjectDetailsTab({
{getIconForLabel(search.label, "size-4 text-primary")}
{t(search.label, { ns: "objects" })}
{search.sub_label && ` (${search.sub_label})`}
-
-
-
- {
- setIsSubLabelDialogOpen(true);
- }}
- />
-
-
-
-
- {t("details.editSubLabel.title")}
-
-
-
+ {isAdmin && (
+
+
+
+ {
+ setIsSubLabelDialogOpen(true);
+ }}
+ />
+
+
+
+
+ {t("details.editSubLabel.title")}
+
+
+
+ )}
{search?.data.recognized_license_plate && (
@@ -716,23 +723,25 @@ function ObjectDetailsTab({
{search.data.recognized_license_plate}{" "}
{recognizedLicensePlateScore &&
` (${recognizedLicensePlateScore}%)`}
-
-
-
- {
- setIsLPRDialogOpen(true);
- }}
- />
-
-
-
-
- {t("details.editLPR.title")}
-
-
-
+ {isAdmin && (
+
+
+
+ {
+ setIsLPRDialogOpen(true);
+ }}
+ />
+
+
+
+
+ {t("details.editLPR.title")}
+
+
+
+ )}