mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-01-22 20:18:30 +03:00
fix: fix set password dialog jwt time i18n wrong
This commit is contained in:
parent
b8716dd648
commit
d825e9719d
@ -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";
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
@ -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";
|
||||
}
|
||||
@ -304,6 +308,7 @@ export const formatSecondsToDuration = (seconds: number): string => {
|
||||
return formatDuration(duration, {
|
||||
format: ["hours", "minutes", "seconds"],
|
||||
delimiter: ", ",
|
||||
locale: locale ?? enUS,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user