Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions src/app/components/user-info/component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<div class="info" label="Username">{{username}}</div>
<div class="info" label="Scopes">{{scopes}}</div>
<div class="info" label="Access token expires on">{{access_token_expire}} ‒ {{time_to_access_token_expire}}</div>
<div class="info" label="Refresh token expires on">{{refresh_token_expire}} ‒ {{time_to_refresh_token_expire}}</div>
<div class="info" label="Access token expires on">{{access_token_expire | date: date_format}} ‒
{{time_to_access_token_expire}}</div>
<div class="info" label="Refresh token expires on">{{refresh_token_expire | date: date_format}} ‒
{{time_to_refresh_token_expire}}</div>
23 changes: 4 additions & 19 deletions src/app/components/user-info/component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, inject, OnDestroy } from "@angular/core";
import { Component, inject, Input, OnDestroy } from "@angular/core";
import { AuthService } from "src/app/services/auth.service";

@Component({
Expand All @@ -11,6 +11,7 @@ export class UserInfoComponent implements OnDestroy {
time_to_access_token_expire: string = "";
time_to_refresh_token_expire: string = "";
#refreshingInterval: number | null = null;
@Input() date_format: string = 'medium';
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

date_format as an @Input name (and corresponding attribute) deviates from the codebase’s existing camelCase input naming (e.g., autosaveDebounce, placeholder). Consider renaming this input to dateFormat and updating call sites accordingly for consistency and to better align with Angular style.

Suggested change
@Input() date_format: string = 'medium';
@Input() dateFormat: string = 'medium';

Copilot uses AI. Check for mistakes.

constructor() {
this.#refreshingInterval = window.setInterval(() => { this.#updateCountdown(); }, 1_000)
Expand Down Expand Up @@ -86,28 +87,12 @@ export class UserInfoComponent implements OnDestroy {
get access_token_expire() {
const exp = this.#auth.getDecodedAccessToken()?.exp;
if (!exp) return 'undefined';

const userLocale = navigator.languages?.[0] || navigator.language || 'cs-CZ';
return new Intl.DateTimeFormat(
userLocale,
{
dateStyle: 'short',
timeStyle: 'medium'
}
).format(new Date(exp * 1000));
return new Date(exp * 1000);
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

access_token_expire returns the string 'undefined' when exp is missing, but the template now pipes access_token_expire through the date pipe. Piping a non-date value can trigger an InvalidPipeArgument runtime error. Return null/undefined (or Date | null) instead and handle the missing case in the template.

Copilot uses AI. Check for mistakes.
}

get refresh_token_expire() {
const exp = this.#auth.getDecodedRefreshToken()?.exp;
if (!exp) return 'undefined';

const userLocale = navigator.languages?.[0] || navigator.language || 'cs-CZ';
return new Intl.DateTimeFormat(
userLocale,
{
dateStyle: 'short',
timeStyle: 'medium'
}
).format(new Date(exp * 1000));
return new Date(exp * 1000);
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refresh_token_expire returns the string 'undefined' when exp is missing, but the template pipes it through the date pipe. Return null/undefined (or Date | null) and render a non-piped fallback string in the template for the missing case.

Copilot uses AI. Check for mistakes.
}
}
2 changes: 1 addition & 1 deletion src/app/user-profile/user-profile.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="details">
<h1>User details</h1>
<app-user-info></app-user-info>
<app-user-info date_format="full"></app-user-info>
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing date_format as a component attribute introduces a snake_case input name that appears inconsistent with other component inputs in this codebase (which use camelCase). If the input is renamed to dateFormat, update this usage as well.

Suggested change
<app-user-info date_format="full"></app-user-info>
<app-user-info dateFormat="full"></app-user-info>

Copilot uses AI. Check for mistakes.
</div>

<div class="details">
Expand Down