Skip to content

Commit

Permalink
feat: warn user that the appointment is already created
Browse files Browse the repository at this point in the history
- display warning
- remove back navigation
- change forward navigation text
- remove unused service

! Dev hint:
Do not refactor the "else then if" structure into a single "else if"
  • Loading branch information
BGruenberg committed Jan 17, 2025
1 parent 052581b commit 5183a9f
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 13 deletions.
38 changes: 26 additions & 12 deletions src/app/overview/overview.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,32 @@ <h1 class="text-center" data-id="overviewHeading">
class="btn-next-large"
forwardText="{{ 'poll.change' | translate }}"
></app-navigation>
}
@if (!isAdmin) {
<app-navigation
(backward)="goBack()"
(forward)="sendCreateAppointment()"
[hasBackwardButton]="true"
[hasForwardButton]="true"
[isInvalid]="false"
backwardText="{{ 'navigation.revise' | translate }}"
class="btn-next-large"
forwardText="{{ 'poll.start' | translate }}"
></app-navigation>
} @else {
@if (!isAppointmentSent()) {
<app-navigation
(backward)="goBack()"
(forward)="sendCreateAppointment()"
[hasBackwardButton]="true"
[hasForwardButton]="true"
[isInvalid]="false"
backwardText="{{ 'navigation.revise' | translate }}"
class="btn-next-large"
forwardText="{{ 'poll.start' | translate }}"
></app-navigation>
} @else {
<div class="row mt-2 px-3">
<div class="alert alert-warning">
{{ 'poll.warningAlreadyCreated' | translate }}
</div>
</div>
<app-navigation
(forward)="sendCreateAppointment()"
[hasForwardButton]="true"
[isInvalid]="false"
class="btn-next-large"
forwardText="{{ 'poll.showLinks' | translate }}"
></app-navigation>
}
}
</div>
</div>
8 changes: 7 additions & 1 deletion src/app/overview/overview.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {Appointment as ApiAppointment, SuggestedDate as ApiSuggestedDate} from '
import {DataRepositoryService} from '../shared/services/data-service';
import {ModelTransformerService} from '../shared/services/transformer';
import {RouteTitleService} from "../shared/services/route-title.service";
import {NullableUtils} from "../shared/utils";

@Component({
selector: 'app-overview',
Expand All @@ -22,7 +23,6 @@ export class OverviewComponent implements OnInit {
constructor(
private dataRepoService: DataRepositoryService,
private appStateService: AppStateService,
private modelTransformer: ModelTransformerService,
@Inject(LOCALE_ID) private localeId: string,
private router: Router,
private logger: Logger,
Expand All @@ -35,6 +35,12 @@ export class OverviewComponent implements OnInit {
this.routeTitle.setTitle('poll.checkData');
}

// Happens when a user navigates back after creating the appointment
isAppointmentSent() {
const apiAppointment: ApiAppointment = ModelTransformerService.transformAppointmentToApiAppointment(this.model);
return (!NullableUtils.isStringNullOrWhitespace(apiAppointment.appointmentId) && !NullableUtils.isStringNullOrWhitespace(apiAppointment.adminId));
}

sendCreateAppointment(): void {
const apiAppointment: ApiAppointment = ModelTransformerService.transformAppointmentToApiAppointment(this.model);

Expand Down
2 changes: 2 additions & 0 deletions src/locales/de-DE-du.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"create": "Umfrage erstellen",
"createNew": "Neue Umfrage erstellen",
"configure": "Konfiguriere Deine Umfrage",
"warningAlreadyCreated": "Die Umfrage wurde bereits erstellt! Um sie zu bearbeiten, musst Du den Adminlink verwenden.",
"showLinks": "Links anzeigen",
"start": "Umfrage starten",
"pause": "Umfrage pausieren",
"paused": "Die Umfrage kann derzeit nicht bearbeitet werden, da sie pausiert ist.",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/de-DE-sie.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"create": "Umfrage erstellen",
"createNew": "Neue Umfrage erstellen",
"configure": "Konfigurieren Sie Ihre Umfrage",
"warningAlreadyCreated": "Die Umfrage wurde bereits erstellt! Um sie zu bearbeiten, müssen Sie den Adminlink verwenden.",
"showLinks": "Links anzeigen",
"start": "Umfrage starten",
"pause": "Umfrage pausieren",
"paused": "Die Umfrage kann derzeit nicht bearbeitet werden, da sie pausiert ist.",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en-EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"create": "Create poll",
"createNew": "Create new poll",
"configure": "Configure your poll",
"warningAlreadyCreated": "The survey has already been created! To edit it, you must use the admin link.",
"showLinks": "Show links",
"start": "Start poll",
"pause": "Pause poll",
"paused": "You can't edit this poll, because it's paused.",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/platt.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"create": "Umfraag maken",
"createNew": "Nee Umfraag maken ",
"configure": "Konfigureer dien Umfraag",
"warningAlreadyCreated": "De Umfraag wur beriets erstellt! To bearbeiten muss du de Adminlenk benutzen.",
"showLinks": "To de Lenks",
"start": "Umfraag starten",
"pause": "Umfraag pauseren",
"paused": "De Umfraag kann opstunns nich bearbeit warrn, wiel se pauseert is.",
Expand Down

0 comments on commit 5183a9f

Please sign in to comment.