Skip to content

Commit

Permalink
feat(ember): add support page
Browse files Browse the repository at this point in the history
redirect to support page when receiving specific identity error
  • Loading branch information
Yelinz committed Jan 23, 2025
1 parent a7b862d commit e41cbc7
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 14 deletions.
1 change: 1 addition & 0 deletions ember/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const resetNamespace = true;
//eslint-disable-next-line array-callback-return
Router.map(function () {
this.route("login");
this.route("support");
this.route("notfound", { path: "/*path" });

this.route("protected", { path: "/" }, function () {
Expand Down
42 changes: 28 additions & 14 deletions ember/app/services/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ENV from "mysagw/config/environment";

export default class CustomSession extends Session {
@service store;
@service router;

currentIdentity = trackedTask(this, this.fetchCurrentIdentity, () => [
this.isAuthenticated,
Expand All @@ -18,21 +19,34 @@ export default class CustomSession extends Session {

if (!this.isAuthenticated) return null;

const data = yield Promise.all([
this.store.query(
"membership",
{
include: "organisation",
},
{ adapterOptions: { customEndpoint: "my-memberships" } },
),
this.store.queryRecord("identity", {}),
]);
try {
const data = yield Promise.all([
this.store.query(
"membership",
{
include: "organisation",
},
{ adapterOptions: { customEndpoint: "my-memberships" } },
),
this.store.queryRecord("identity", {}),
]);

return {
memberships: data[0],
identity: data[1],
};
} catch (error) {
this.invalidate();

if (
error.errors[0].detail ===
"Can't create Identity, because there is already an organisation with this email address."
) {
return this.router.transitionTo("support");
}

return {
memberships: data[0],
identity: data[1],
};
return this.router.transitionTo("login");
}
}

get identity() {
Expand Down
3 changes: 3 additions & 0 deletions ember/app/ui/support/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from "@ember/routing/route";

export default class SupportRoute extends Route {}
10 changes: 10 additions & 0 deletions ember/app/ui/support/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="uk-text-center">
<h1>{{t "support.title"}}</h1>
<h3>
{{t "support.subtitle"}}
<a href="mailto:[email protected]" target="_blank" rel="noopener noreferrer">
{{! template-lint-disable no-bare-strings }}
[email protected]
</a>
</h3>
</div>
3 changes: 3 additions & 0 deletions ember/translations/support/de.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
support:
title: "Ein Fehler ist aufgetreten."
subtitle: "Bitte wenden Sie sich an"
3 changes: 3 additions & 0 deletions ember/translations/support/en.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
support:
title: "An error has occurred."
subtitle: "Please contact"
3 changes: 3 additions & 0 deletions ember/translations/support/fr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
support:
title: "Une erreur s'est produite."
subtitle: "Veuillez contacter"

0 comments on commit e41cbc7

Please sign in to comment.