Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web/src/components/card/ClassificationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export const ClassificationCard = forwardRef<
<div className="break-all smart-capitalize">
{data.name == "unknown"
? t("details.unknown")
: data.name == "none"
: data.name.toLowerCase() == "none"
? t("details.none")
: data.name}
</div>
Expand Down
4 changes: 3 additions & 1 deletion web/src/components/overlay/SetPasswordDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { useTranslation } from "react-i18next";
import { useDocDomain } from "@/hooks/use-doc-domain";
import useSWR from "swr";
import { formatSecondsToDuration } from "@/utils/dateUtil";
import { useDateLocale } from "@/hooks/use-date-locale";
import ActivityIndicator from "../indicators/activity-indicator";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
Expand All @@ -48,12 +49,13 @@ export default function SetPasswordDialog({
const { t } = useTranslation(["views/settings", "common"]);
const { getLocaleDocUrl } = useDocDomain();
const isAdmin = useIsAdmin();
const dateLocale = useDateLocale();

const { data: config } = useSWR("config");
const refreshSeconds: number | undefined =
config?.auth?.refresh_time ?? undefined;
const refreshTimeLabel = refreshSeconds
? formatSecondsToDuration(refreshSeconds)
? formatSecondsToDuration(refreshSeconds, dateLocale)
: t("time.30minutes", { ns: "common" });

// visibility toggles for password fields
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/overlay/detail/TrackingDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export function TrackingDetails({

const label = event.sub_label
? event.sub_label
: getTranslatedLabel(event.label);
: getTranslatedLabel(event.label, event.data.type);

const getZoneColor = useCallback(
(zoneName: string) => {
Expand Down Expand Up @@ -998,7 +998,7 @@ function LifecycleIconRow({
<div className="ml-3 flex-shrink-0 px-1 text-right text-xs text-primary-variant">
<div className="flex flex-row items-center gap-3">
<div className="whitespace-nowrap">{formattedEventTimestamp}</div>
{((isAdmin && config?.plus?.enabled) || item.data.box) && (
{isAdmin && config?.plus?.enabled && item.data.box && (
<DropdownMenu open={isOpen} onOpenChange={setIsOpen}>
<DropdownMenuTrigger>
<div className="rounded p-1 pr-2" role="button">
Expand Down
4 changes: 3 additions & 1 deletion web/src/components/settings/wizard/Step1NameCamera.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,9 @@ export default function Step1NameCamera({
<SelectContent>
{CAMERA_BRANDS.map((brand) => (
<SelectItem key={brand.value} value={brand.value}>
{brand.label}
{brand.label.toLowerCase() === "other"
? t("label.other", { ns: "common" })
: brand.label}
</SelectItem>
))}
</SelectContent>
Expand Down
9 changes: 7 additions & 2 deletions web/src/utils/dateUtil.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fromUnixTime, intervalToDuration, formatDuration } from "date-fns";
import { Locale } from "date-fns/locale";
import { enUS, Locale } from "date-fns/locale";
import { formatInTimeZone } from "date-fns-tz";
import i18n from "@/utils/i18n";
export const longToDate = (long: number): Date => new Date(long * 1000);
Expand Down Expand Up @@ -293,9 +293,13 @@ export const getDurationFromTimestamps = (
/**
*
* @param seconds - number of seconds to convert into hours, minutes and seconds
* @param locale - the date-fns locale to use for formatting
* @returns string - formatted duration in hours, minutes and seconds
*/
export const formatSecondsToDuration = (seconds: number): string => {
export const formatSecondsToDuration = (
seconds: number,
locale?: Locale,
): string => {
if (isNaN(seconds) || seconds < 0) {
return "Invalid duration";
}
Expand All @@ -304,6 +308,7 @@ export const formatSecondsToDuration = (seconds: number): string => {
return formatDuration(duration, {
format: ["hours", "minutes", "seconds"],
delimiter: ", ",
locale: locale ?? enUS,
});
};

Expand Down
5 changes: 4 additions & 1 deletion web/src/utils/lifecycleUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export function getLifecycleItemDescription(

const label = lifecycleItem.data.sub_label
? capitalizeFirstLetter(rawLabel)
: getTranslatedLabel(rawLabel);
: getTranslatedLabel(
rawLabel,
lifecycleItem.class_type === "heard" ? "audio" : "object",
);

switch (lifecycleItem.class_type) {
case "visible":
Expand Down