Skip to content
Snippets Groups Projects
Commit afb777fe authored by OZGCloud's avatar OZGCloud
Browse files

Merge pull request 'OZG-6497-Postfach-Signatur-speichern' (#755) from...

Merge pull request 'OZG-6497-Postfach-Signatur-speichern' (#755) from OZG-6497-Postfach-Signatur-speichern into master

Reviewed-on: https://git.ozg-sh.de/ozgcloud-app/alfa/pulls/755


Reviewed-by: default avatarOZGCloud <ozgcloud@mgm-tp.com>
parents 2005e212 6682f2cb
No related branches found
No related tags found
No related merge requests found
Showing
with 41 additions and 0 deletions
import { HttpError, StateResource } from '@alfa-client/tech-shared';
import { createEmptyStateResource, StateResource } from '@alfa-client/tech-shared';
import { SnackBarService } from '@alfa-client/ui';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Observable, startWith, tap } from 'rxjs';
import { SettingName } from '../admin-settings.model';
import { PostfachResourceService } from './postfach-resource.service';
import { Postfach, PostfachResource, PostfachSettingsItem } from './postfach.model';
@Injectable()
export class PostfachService {
constructor(private postfachResourceService: PostfachResourceService) {}
constructor(
private postfachResourceService: PostfachResourceService,
private snackbarService: SnackBarService,
) {}
public get(): Observable<StateResource<PostfachResource>> {
return this.postfachResourceService.get();
}
public save(postfach: Postfach): Observable<StateResource<PostfachResource | HttpError>> {
return this.postfachResourceService.save(this.buildPostfachSettingItem(postfach));
public save(postfach: Postfach): Observable<StateResource<PostfachResource>> {
return this.postfachResourceService.save(this.buildPostfachSettingItem(postfach)).pipe(
tap((stateResource: StateResource<PostfachResource>) =>
this.showInfoAfterSave(stateResource),
),
startWith(createEmptyStateResource<PostfachResource>(true)),
);
}
private showInfoAfterSave(stateResource: StateResource<PostfachResource>) {
if (!stateResource.loading) {
this.snackbarService.showInfo('Die Signatur wird erfolgreich gespeichert.');
}
}
private buildPostfachSettingItem(postfach: Postfach): PostfachSettingsItem {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment