mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-19 16:13:06 +00:00
@@ -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,
|
||||
|
||||
@@ -11,6 +11,7 @@ export class ProfilePageComponent {
|
||||
patron?: PAIAPatron;
|
||||
|
||||
propertiesToShow: (keyof PAIAPatron)[] = [
|
||||
'id',
|
||||
'name',
|
||||
'email',
|
||||
'address',
|
||||
|
||||
@@ -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
|
||||
}}: {{ patron[property] | amDateFormat: 'll' }}
|
||||
</ng-template>
|
||||
</ng-template>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
export interface PAIAPatron {
|
||||
id: string;
|
||||
name: string;
|
||||
email?: string;
|
||||
address?: string;
|
||||
|
||||
Reference in New Issue
Block a user