fix: adjust library account user info

Closes #331
This commit is contained in:
Jovan Krunić
2022-11-04 13:25:20 +01:00
parent 0caa69c28c
commit bafabb1d4e
6 changed files with 36 additions and 9 deletions

View File

@@ -67,7 +67,11 @@ export class LibraryAccountService {
}
async getProfile() {
return this.performRequest<PAIAPatron>(`${this.baseUrl}/{patron}`);
const patron = ((await this.getValidToken()) as PAIATokenResponse).patron;
return {
...(await this.performRequest<PAIAPatron>(`${this.baseUrl}/{patron}`)),
id: patron,
} as PAIAPatron;
}
async getItems() {
@@ -78,14 +82,16 @@ export class LibraryAccountService {
return this.performRequest<PAIAFees>(`${this.baseUrl}/{patron}/fees`);
}
async getValidToken() {
return this.authHelper.getProvider(this.authType).getValidToken();
}
private async performRequest<T>(
urlTemplate: string,
method = 'GET',
data?: JQuery.PlainObject,
): Promise<T | undefined> {
const token = await this.authHelper
.getProvider(this.authType)
.getValidToken();
const token = await this.getValidToken();
const url = urlTemplate.replace(
'{patron}',
(token as PAIATokenResponse).patron,

View File

@@ -11,6 +11,7 @@ export class ProfilePageComponent {
patron?: PAIAPatron;
propertiesToShow: (keyof PAIAPatron)[] = [
'id',
'name',
'email',
'address',

View File

@@ -25,7 +25,18 @@
{{ patron[property] }}
</ng-container>
<ng-template #date>
{{ patron[property] | amDateFormat: 'll' }}
<ng-container
*ngIf="patron[property] === '9999-12-31'; else exactDate"
>
{{
'library.account.pages.profile.values.unlimited' | translate
}}
</ng-container>
<ng-template #exactDate>
{{
'library.account.pages.profile.values.expires' | translate
}}:&nbsp;{{ patron[property] | amDateFormat: 'll' }}
</ng-template>
</ng-template>
</ion-col>
</ion-row>

View File

@@ -14,6 +14,7 @@
*/
export interface PAIAPatron {
id: string;
name: string;
email?: string;
address?: string;

View File

@@ -253,14 +253,18 @@
"profile": {
"title": "Deine persönlichen Daten",
"labels": {
"id": "Nutzer-ID",
"id": "Bibliotheksausweisnummer",
"name": "Name",
"email": "E-Mail",
"address": "Adresse",
"expires": "Nutzungsberechtigung endet am",
"expires": "Nutzungsberechtigung",
"status": "Status",
"type": "Typ",
"note": "Nachricht"
},
"values": {
"unlimited": "unbefristet",
"expires": "endet am"
}
},
"holds": {

View File

@@ -253,14 +253,18 @@
"profile": {
"title": "library profile",
"labels": {
"id": "User ID",
"id": "Card number",
"name": "Name",
"email": "Email",
"address": "Address",
"expires": "Membership expires",
"expires": "Membership",
"status": "Status",
"type": "Type",
"note": "Note"
},
"values": {
"unlimited": "unlimited",
"expires": "expires"
}
},
"holds": {