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

View File

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

View File

@@ -25,7 +25,18 @@
{{ patron[property] }} {{ patron[property] }}
</ng-container> </ng-container>
<ng-template #date> <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> </ng-template>
</ion-col> </ion-col>
</ion-row> </ion-row>

View File

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

View File

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

View File

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