2025-02-18 17:17:51 +03:00
|
|
|
import { ObjectLifecycleSequence } from "@/types/timeline";
|
2025-03-16 18:36:20 +03:00
|
|
|
import { t } from "i18next";
|
2025-06-26 00:45:24 +03:00
|
|
|
import { getTranslatedLabel } from "./i18n";
|
2025-10-26 01:15:36 +03:00
|
|
|
import { capitalizeFirstLetter } from "./stringUtil";
|
2025-02-18 17:17:51 +03:00
|
|
|
|
|
|
|
|
export function getLifecycleItemDescription(
|
|
|
|
|
lifecycleItem: ObjectLifecycleSequence,
|
|
|
|
|
) {
|
2025-06-26 00:45:24 +03:00
|
|
|
const rawLabel = Array.isArray(lifecycleItem.data.sub_label)
|
|
|
|
|
? lifecycleItem.data.sub_label[0]
|
|
|
|
|
: lifecycleItem.data.sub_label || lifecycleItem.data.label;
|
|
|
|
|
|
2025-10-24 15:50:06 +03:00
|
|
|
const label = lifecycleItem.data.sub_label
|
2025-10-26 01:15:36 +03:00
|
|
|
? capitalizeFirstLetter(rawLabel)
|
2025-10-24 15:50:06 +03:00
|
|
|
: getTranslatedLabel(rawLabel);
|
2025-02-18 17:17:51 +03:00
|
|
|
|
|
|
|
|
switch (lifecycleItem.class_type) {
|
|
|
|
|
case "visible":
|
2025-03-16 18:36:20 +03:00
|
|
|
return t("objectLifecycle.lifecycleItemDesc.visible", {
|
|
|
|
|
ns: "views/explore",
|
2025-03-17 15:26:01 +03:00
|
|
|
label,
|
2025-03-16 18:36:20 +03:00
|
|
|
});
|
2025-02-18 17:17:51 +03:00
|
|
|
case "entered_zone":
|
2025-03-16 18:36:20 +03:00
|
|
|
return t("objectLifecycle.lifecycleItemDesc.entered_zone", {
|
|
|
|
|
ns: "views/explore",
|
2025-03-17 15:26:01 +03:00
|
|
|
label,
|
2025-03-16 18:36:20 +03:00
|
|
|
zones: lifecycleItem.data.zones.join(" and ").replaceAll("_", " "),
|
|
|
|
|
});
|
2025-02-18 17:17:51 +03:00
|
|
|
case "active":
|
2025-03-16 18:36:20 +03:00
|
|
|
return t("objectLifecycle.lifecycleItemDesc.active", {
|
|
|
|
|
ns: "views/explore",
|
2025-03-17 15:26:01 +03:00
|
|
|
label,
|
2025-03-16 18:36:20 +03:00
|
|
|
});
|
2025-02-18 17:17:51 +03:00
|
|
|
case "stationary":
|
2025-03-16 18:36:20 +03:00
|
|
|
return t("objectLifecycle.lifecycleItemDesc.stationary", {
|
|
|
|
|
ns: "views/explore",
|
2025-03-17 15:26:01 +03:00
|
|
|
label,
|
2025-03-16 18:36:20 +03:00
|
|
|
});
|
2025-02-18 17:17:51 +03:00
|
|
|
case "attribute": {
|
|
|
|
|
let title = "";
|
|
|
|
|
if (
|
|
|
|
|
lifecycleItem.data.attribute == "face" ||
|
|
|
|
|
lifecycleItem.data.attribute == "license_plate"
|
|
|
|
|
) {
|
2025-03-16 18:36:20 +03:00
|
|
|
title = t(
|
|
|
|
|
"objectLifecycle.lifecycleItemDesc.attribute.faceOrLicense_plate",
|
|
|
|
|
{
|
2025-03-17 15:26:01 +03:00
|
|
|
ns: "views/explore",
|
2025-03-16 18:36:20 +03:00
|
|
|
label,
|
2025-10-24 15:50:06 +03:00
|
|
|
attribute: getTranslatedLabel(
|
|
|
|
|
lifecycleItem.data.attribute.replaceAll("_", " "),
|
|
|
|
|
),
|
2025-03-16 18:36:20 +03:00
|
|
|
},
|
|
|
|
|
);
|
2025-02-18 17:17:51 +03:00
|
|
|
} else {
|
2025-03-16 18:36:20 +03:00
|
|
|
title = t("objectLifecycle.lifecycleItemDesc.attribute.other", {
|
2025-03-17 15:26:01 +03:00
|
|
|
ns: "views/explore",
|
2025-03-16 18:36:20 +03:00
|
|
|
label: lifecycleItem.data.label,
|
2025-10-24 15:50:06 +03:00
|
|
|
attribute: getTranslatedLabel(
|
|
|
|
|
lifecycleItem.data.attribute.replaceAll("_", " "),
|
|
|
|
|
),
|
2025-03-16 18:36:20 +03:00
|
|
|
});
|
2025-02-18 17:17:51 +03:00
|
|
|
}
|
|
|
|
|
return title;
|
|
|
|
|
}
|
|
|
|
|
case "gone":
|
2025-03-16 18:36:20 +03:00
|
|
|
return t("objectLifecycle.lifecycleItemDesc.gone", {
|
|
|
|
|
ns: "views/explore",
|
2025-03-17 15:26:01 +03:00
|
|
|
label,
|
2025-03-16 18:36:20 +03:00
|
|
|
});
|
2025-02-18 17:17:51 +03:00
|
|
|
case "heard":
|
2025-03-16 18:36:20 +03:00
|
|
|
return t("objectLifecycle.lifecycleItemDesc.heard", {
|
|
|
|
|
ns: "views/explore",
|
2025-03-17 15:26:01 +03:00
|
|
|
label,
|
2025-03-16 18:36:20 +03:00
|
|
|
});
|
2025-02-18 17:17:51 +03:00
|
|
|
case "external":
|
2025-03-16 18:36:20 +03:00
|
|
|
return t("objectLifecycle.lifecycleItemDesc.external", {
|
|
|
|
|
ns: "views/explore",
|
2025-03-17 15:26:01 +03:00
|
|
|
label,
|
2025-03-16 18:36:20 +03:00
|
|
|
});
|
2025-02-18 17:17:51 +03:00
|
|
|
}
|
|
|
|
|
}
|