feat: improve UI for timespan inputs on admin page (#726)

* Define Timestamp type

* Implement Timestamp utils

* Implement Timespan input

* Use timestamp input on config page

* Add timespan type to config services

* Refactor maxExpiration to use timespan type across services and components

* Update sessionDuration to use timespan type in config and adjust token expiration logic

* Update localized strings
This commit is contained in:
Aaron
2025-01-02 17:35:50 +01:00
committed by GitHub
parent df1ffaa2bc
commit 36afbf91b7
14 changed files with 158 additions and 20 deletions

View File

@@ -10,3 +10,20 @@ export function parseRelativeDateToAbsolute(relativeDate: string) {
)
.toDate();
}
type Timespan = {
value: number;
unit: "minutes" | "hours" | "days" | "weeks" | "months" | "years";
};
export function stringToTimespan(value: string): Timespan {
const [time, unit] = value.split(" ");
return {
value: parseInt(time),
unit: unit as Timespan["unit"],
};
}
export function timespanToString(timespan: Timespan) {
return `${timespan.value} ${timespan.unit}`;
}