Fix SSO expiration dropdown to reflect the actual "Hours" or "Days" (#345)

This commit is contained in:
Eduard Gert
2024-03-01 17:01:26 +01:00
committed by GitHub
parent 8e7bcc0c22
commit 071feb02f9

View File

@@ -56,7 +56,9 @@ export default function AuthenticationTab({ account }: Props) {
account.settings.peer_login_expiration || 86400,
);
const [expiresIn, setExpiresIn] = useState(() => {
if (expiresInSeconds <= 86400) return "1";
if (expiresInSeconds <= 86400) {
return Math.round(expiresInSeconds / 3600).toString();
}
return Math.round(expiresInSeconds / 86400).toString();
});
@@ -64,7 +66,7 @@ export default function AuthenticationTab({ account }: Props) {
* Interval
*/
const initialInterval = useMemo(() => {
if (Number(expiresIn) <= 86400) return "hours";
if (expiresInSeconds <= 86400) return "hours";
return "days";
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);