Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deactivated account error-page #1503

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions apps/admin-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import NotificationsRouter from "./spa/notifications/router";
import Error404 from "./common/Error404";
import { UserPermissionChoice } from "@gql/gql-types";
import { UnitsRouter } from "./spa/unit/router";
import DeactivatedAccount from "common/src/components/DeactivatedAccount";

const Units = dynamic(() => import("./spa/unit"));

Expand Down Expand Up @@ -151,6 +152,15 @@ function ClientApp({
UserPermissionChoice.CanManageNotifications
)}
/>
<Route
path="/deactivated-account"
element={
<DeactivatedAccount
feedbackUrl={feedbackUrl}
imgSrc={`${PUBLIC_URL}/images/deactivated-account.png`}
/>
}
/>
</Routes>
</PageWrapper>
</BrowserRouter>
Expand Down
10 changes: 10 additions & 0 deletions apps/admin-ui/src/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,14 @@ i18n.addResourceBundle("fi", "forms", {
invalidEmail: "Sähköpostin tulee olla oikeassa muodossa (sisältäen @-merkin)",
});

i18n.addResourceBundle("fi", "errors", {
deactivatedAccount: {
heading: "Käyttäjätunnuksesi ei ole voimassa.",
subHeadingA: "Ota yhteyttä asiakaspalveluun sähköpostitse",
subHeadingB: "tai Ota yhteyttä-lomakkeella.",
email: "[email protected]",
button: "Ota yhteyttä",
},
});

export default i18n;
27 changes: 27 additions & 0 deletions apps/ui/pages/deactivated-account.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from "react";
import { getCommonServerSideProps } from "@/modules/serverUtils";
import { GetServerSidePropsContext } from "next";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import DeactivatedAccount from "common/src/components/DeactivatedAccount";

export async function getServerSideProps({
locale,
}: GetServerSidePropsContext) {
return {
props: {
...getCommonServerSideProps(),
...(await serverSideTranslations(locale ?? "fi")),
},
};
}

const DeactivatedAccountPage = ({ feedbackUrl }: { feedbackUrl: string }) => {
return (
<DeactivatedAccount
feedbackUrl={feedbackUrl}
imgSrc="/images/deactivated-account.png"
/>
);
};

export default DeactivatedAccountPage;
Binary file added apps/ui/public/images/deactivated-account.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions apps/ui/public/locales/en/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"500": {
"body": "Something unexpected happened"
},
"deactivatedAccount": {
"heading": "Your User ID is not valid.",
"subHeadingA": "Please contact support via email at",
"subHeadingB": "or via the Contact us form.",
"email": "[email protected]",
"button": "Contact us"
},
"applicationMutation": {
"Validation error": "Error in the API call",
"Form validation error": "Form validation error",
Expand Down
7 changes: 7 additions & 0 deletions apps/ui/public/locales/fi/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"500": {
"body": "Jotain meni pieleen"
},
"deactivatedAccount": {
"heading": "Käyttäjätunnuksesi ei ole voimassa.",
"subHeadingA": "Ota yhteyttä asiakaspalveluun sähköpostitse",
"subHeadingB": "tai Ota yhteyttä-lomakkeella.",
"email": "[email protected]",
"button": "Ota yhteyttä"
},
"applicationMutation": {
"Validation error": "Virheellinen rajapintakutsu",
"Form validation error": "Virheellinen lomake",
Expand Down
7 changes: 7 additions & 0 deletions apps/ui/public/locales/sv/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"500": {
"body": "Något oväntat hände"
},
"deactivatedAccount": {
"heading": "Ditt användar-ID är inte giltigt.",
"subHeadingA": "Var god och kontakta vår kundtjänst via email på",
"subHeadingB": "eller via Ta kontakt-formuläret.",
"email": "[email protected]",
"button": "Ta kontakt"
},
"applicationMutation": {
"Validation error": "Ett fel uppstod i API-anropet",
"Form validation error": "Formuläret innehåller fel",
Expand Down
103 changes: 103 additions & 0 deletions packages/common/src/components/DeactivatedAccount.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import React from "react";
import { useTranslation } from "next-i18next";
import styled from "styled-components";
import IconButton from "./IconButton";
import { IconArrowRight } from "hds-react";
import { fontBold, H1 } from "../common/typography";
import { breakpoints } from "../common/style";
import Image from "next/image";

const IMAGE_WIDTH = "418";
const IMAGE_HEIGHT = "350";

const ErrorContainer = styled.div`
display: flex;
flex-direction: column;
gap: var(--spacing-xl);
padding-top: var(--spacing-xl);
@media (min-width: ${breakpoints.m}) {
flex-direction: row;
}
`;

const Img = styled(Image)`
object-fit: contain;
width: auto;
height: auto;
margin: 0 auto;
@media (min-width: ${breakpoints.l}) {
flex-grow: 1;
display: flex;
max-width: ${`${IMAGE_WIDTH}px`};
}
`;

const TextContent = styled.div`
display: flex;
flex-direction: column;
gap: var(--spacing-xl);
justify-content: center;
@media (min-width: ${breakpoints.m}) {
order: -1;
}
`;

const Body = styled.p`
margin: 0;
`;

const Email = styled.a`
${fontBold}
`;

const constructFeedbackUrl = (
feedbackUrl: string,
i18n: { language: string }
) => {
try {
const url = new URL(feedbackUrl);
url.searchParams.set("lang", i18n.language);
return url.toString();
} catch (e) {
return null;
}
};

const DeactivatedAccount = ({
feedbackUrl,
imgSrc,
}: {
feedbackUrl: string;
imgSrc: string;
}) => {
const { t, i18n } = useTranslation();
return (
<ErrorContainer>
<Img
src={imgSrc}
alt={t("errors:deactivatedAccount.heading")}
width={IMAGE_WIDTH}
height={IMAGE_HEIGHT}
aria-hidden="true"
/>
<TextContent>
<H1>{t("errors:deactivatedAccount.heading")}</H1>
<Body>
{`${t("errors:deactivatedAccount.subHeadingA")} `}
<Email href={`mailto:${t("errors:deactivatedAccount.email")}`}>
{t("errors:deactivatedAccount.email")}
</Email>
{` ${t("errors:deactivatedAccount.subHeadingB")}`}
</Body>
<IconButton
label={t("errors:deactivatedAccount.button")}
icon={<IconArrowRight aria-hidden="true" />}
href={constructFeedbackUrl(feedbackUrl, i18n) ?? feedbackUrl}
rel="noopener noreferrer"
/>
</TextContent>
</ErrorContainer>
);
};

export default DeactivatedAccount;
Loading