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:
@@ -1,4 +1,5 @@
|
||||
import moment from "moment";
|
||||
import { Timespan } from "../types/timespan.type";
|
||||
|
||||
export const getExpirationPreview = (
|
||||
messages: {
|
||||
@@ -30,3 +31,14 @@ export const getExpirationPreview = (
|
||||
moment(expirationDate).format("LLL"),
|
||||
);
|
||||
};
|
||||
|
||||
export const timespanToString = (timespan: Timespan) => {
|
||||
return `${timespan.value} ${timespan.unit}`;
|
||||
}
|
||||
|
||||
export const stringToTimespan = (value: string): Timespan => {
|
||||
return {
|
||||
value: parseInt(value.split(" ")[0]),
|
||||
unit: value.split(" ")[1],
|
||||
} as Timespan;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user