Skip to content

Commit

Permalink
Merge pull request #651 from Opetushallitus/feature/OPHKIOS-25
Browse files Browse the repository at this point in the history
YKI(Frontend): OPHKIOS-25 Jatka tutkintoon -näkymä tunnistautuneena
  • Loading branch information
pkoivisto authored Apr 17, 2024
2 parents eb36ffd + 551cfe7 commit e29d743
Show file tree
Hide file tree
Showing 28 changed files with 410 additions and 69 deletions.
9 changes: 8 additions & 1 deletion frontend/packages/yki/public/i18n/en-GB/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@
"activeRegistrations_one": "You have already started 1 registration.",
"activeRegistrations_other": "You have already started {{count}} registrations.",
"continueToRegistration": "Return to the registration form.",
"logOut": "Log out"
"logOut": "Log out",
"logOutDialog": {
"cancelButton": "I do not want to log out",
"confirmButton": "Yes, log me out",
"description1": "Are you sure you want to log out?",
"description2": "Any information you have filled in will be lost and your registration will be terminated.",
"title": "Log out"
}
},
"lang": {
"en": "In English",
Expand Down
18 changes: 18 additions & 0 deletions frontend/packages/yki/public/i18n/en-GB/public.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,18 @@
},
"steps": {
"identify": {
"alreadyLoggedIn": {
"caption": "Check identification details",
"currentLoginInformation": "You have identified yourself with the following information:",
"labels": {
"abort": "Quit registration",
"continueToRegistration": "Continue registration",
"email": "Email address",
"name": "Name"
},
"reauthenticate": "Check that you have identified yourself with the personal information of the person taking the YKI test. If you have identified yourself with someone else's personal information, click the Log out button at the top of the page and start the registration again.",
"title": "Identify yourself for registration"
},
"caption": "You must identify yourself to register for a YKI test. Use the personal information of the person taking the YKI test for the identification.",
"emailButtonText": "identify with email",
"emailError": "Invalid email address",
Expand Down Expand Up @@ -347,6 +359,11 @@
"description": "Registration is not possible anymore. The registration period has ended.",
"title": "Registration period has ended"
},
"unauthorized": {
"backToIdentification": "Proceed to select your identification method",
"description": "We could not find your identification details. Your previous identification may have expired. You must identify yourself to register for a YKI test.",
"title": "You have not identified yourself"
},
"upcoming": {
"description": "Registration is not possible at the moment. The registration period has not started yet.",
"title": "Registration has not started"
Expand Down Expand Up @@ -425,6 +442,7 @@
"confirm": "Yes, I want to quit the registration"
},
"description": "Do you want to quit the registration? Any information you have filled in will be lost.",
"notice": "If you have identified yourself, your identification will remain active even if you quit the registration. If you no longer want to use the service as identified, click the Log out button at the top of the page.",
"title": "Quit registration"
},
"description": {
Expand Down
9 changes: 8 additions & 1 deletion frontend/packages/yki/public/i18n/fi-FI/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@
"activeRegistrations_one": "Sinulla on 1 ilmoittautuminen kesken.",
"activeRegistrations_other": "Sinulla on {{count}} ilmoittautumista kesken.",
"continueToRegistration": "Siirry takaisin ilmoittautumislomakkeelle.",
"logOut": "Kirjaudu ulos"
"logOut": "Kirjaudu ulos",
"logOutDialog": {
"cancelButton": "En halua kirjautua ulos",
"confirmButton": "Kyllä, kirjaudun ulos",
"description1": "Haluatko varmasti kirjautua ulos?",
"description2": "Menetät täyttämäsi tiedot ja ilmoittautumisesi keskeytyy.",
"title": "Kirjaudu ulos"
}
},
"lang": {
"en": "In English",
Expand Down
18 changes: 18 additions & 0 deletions frontend/packages/yki/public/i18n/fi-FI/public.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,18 @@
},
"steps": {
"identify": {
"alreadyLoggedIn": {
"caption": "Tarkista tunnistautumistiedot",
"currentLoginInformation": "Olet tunnistautunut seuraavilla tiedoilla:",
"labels": {
"abort": "Keskeytä ilmoittautuminen",
"continueToRegistration": "Jatka ilmoittautumiseen",
"email": "Sähköpostiosoite",
"name": "Nimi"
},
"reauthenticate": "Tarkista, että olet tunnistautunut sen henkilön tiedoilla, joka osallistuu YKI-testiin. Jos olet tunnistautunut väärän henkilön tiedoilla, paina Kirjaudu ulos -painiketta sivun yläosassa ja aloita ilmoittautuminen uudelleen.",
"title": "Tunnistaudu ilmoittautumista varten"
},
"caption": "Sinun täytyy tunnistautua YKI-testiin ilmoittautumista varten. Käytä tunnistautumiseen osallistujan henkilötietoja.",
"emailButtonText": "tunnistaudu sähköpostilla",
"emailError": "Virheellinen sähköpostiosoite",
Expand Down Expand Up @@ -347,6 +359,11 @@
"description": "Tilaisuuteen ilmoittautuminen ei ole enää mahdollista. Ilmoittautumisaika on päättynyt.",
"title": "Ilmoittautumisaika on päättynyt"
},
"unauthorized": {
"backToIdentification": "Siirry valitsemaan tunnistautumistapasi",
"description": "Emme löytäneet tunnistautumistietojasi. Aikaisempi tunnistautumisesi on voinut vanhentua. Sinun täytyy tunnistautua YKI-testiin ilmoittautumista varten.",
"title": "Et ole tunnistautunut"
},
"upcoming": {
"description": "Ilmoittautuminen ei ole vielä mahdollista. Ilmoittautumisaika ei ole alkanut.",
"title": "Ilmoittautumisaika ei ole alkanut"
Expand Down Expand Up @@ -425,6 +442,7 @@
"confirm": "Kyllä, keskeytän ilmoittautumisen"
},
"description": "Haluatko keskeyttää ilmoittautumisen? Menetät täyttämäsi tiedot.",
"notice": "Jos olet tunnistautunut, tunnistautumisesi säilyy aktiivisena, vaikka keskeytät ilmoittautumisen. Jos et halua jatkaa palvelun käyttöä tunnistautuneena, paina Kirjaudu ulos -painiketta sivun yläosassa.",
"title": "Keskeytä ilmoittautuminen"
},
"description": {
Expand Down
9 changes: 8 additions & 1 deletion frontend/packages/yki/public/i18n/sv-SE/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@
"activeRegistrations_one": "Du har redan påbörjat 1 anmälan.",
"activeRegistrations_other": "Du har redan påbörjat {{count}} anmälningar.",
"continueToRegistration": "Gå tillbaka till anmälningsblanketten.",
"logOut": "Logga ut"
"logOut": "Logga ut",
"logOutDialog": {
"cancelButton": "Jag vill inte logga ut",
"confirmButton": "Ja, jag loggar ut",
"description1": "Är du säker på att du vill logga ut? ",
"description2": "Du förlorar uppgifterna som du har fyllt i och din anmälan kommer att avbrytas.",
"title": "Logga ut"
}
},
"lang": {
"en": "In English",
Expand Down
18 changes: 18 additions & 0 deletions frontend/packages/yki/public/i18n/sv-SE/public.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,18 @@
},
"steps": {
"identify": {
"alreadyLoggedIn": {
"caption": "Kontrollera identifieringsuppgifterna",
"currentLoginInformation": "Du har identifierat dig med följande uppgifter:",
"labels": {
"abort": "Avbryt anmälan",
"continueToRegistration": "Fortsätt anmälan",
"email": "E-postadress",
"name": "Namn"
},
"reauthenticate": "Kontrollera att du har identifierat dig med de uppgifter som tillhör personen som deltar i YKI-testet. Om du har identifierat dig med någon annans personuppgifter, tryck på logga ut högst uppe på sidan och börja anmälan på nytt.",
"title": "Identifiera dig för anmälan"
},
"caption": "Du ska identifiera dig för att anmäla dig till allmän språkexamen (YKI). Använd testdeltagarens personuppgifter vid anmälan.",
"emailButtonText": "Identifiera dig med din e-postadress",
"emailError": "Felaktig e-postadress",
Expand Down Expand Up @@ -347,6 +359,11 @@
"description": "Det är inte längre möjligt att anmäla sig. Anmälningstiden har upphört.",
"title": "Anmälningstiden har upphört"
},
"unauthorized": {
"backToIdentification": "Klicka här för att välja identifieringsmetod",
"description": "Vi hittade inte dina identifieringsuppgifter. Din tidigare identifiering kan ha gått ut. Du ska identifiera dig för att anmäla dig till ett YKI-test.",
"title": "Du har inte identifierat dig"
},
"upcoming": {
"description": "Det är inte ännu möjligt att anmäla sig. Anmälningstiden har inte börjat.",
"title": "Anmälningstiden har inte börjat"
Expand Down Expand Up @@ -425,6 +442,7 @@
"confirm": "Ja, jag vill avbryta min anmälan"
},
"description": "Vill du avbryta anmälan? Du förlorar uppgifterna som du har fyllt i.",
"notice": "Om du har identifierat dig, förblir din identifiering aktiv även om du avbryter anmälan. Om du inte längre vill använda tjänsten som identifierad, klicka på logga ut högst uppe på sidan.",
"title": "Avbryt anmälan"
},
"description": {
Expand Down
9 changes: 6 additions & 3 deletions frontend/packages/yki/setupProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ const quarantines = {

const initialOrganizers = [...organizers];

/*
const adminUser = {
identity: {
username: 'ykitestaaja',
Expand All @@ -283,6 +284,7 @@ const adminUser = {
},
'auth-method': 'CAS',
};
*/

/*
const organizerUser = {
Expand Down Expand Up @@ -310,7 +312,7 @@ const loginLinkAuthenticatedUser = {
};
*/

/*

const suomiFiAuthenticatedUser = {
identity: {
first_name: 'Susanna',
Expand All @@ -326,7 +328,6 @@ const suomiFiAuthenticatedUser = {
},
'auth-method': 'SUOMIFI',
};
*/

/*
const unauthenticatedUser = {
Expand Down Expand Up @@ -1022,7 +1023,7 @@ module.exports = function (app) {
app.get('/yki/api/user/identity', (req, res) => {
try {
res.set('Content-Type', 'application/json; charset=utf-8');
res.send(adminUser);
res.send(suomiFiAuthenticatedUser);
} catch (err) {
printError(req, err);
res.status(404).send(err.message);
Expand Down Expand Up @@ -1064,6 +1065,8 @@ module.exports = function (app) {
// This error case shouldn't ordinarily happen
case 14:
res.status(409).send({ error: { full: false, registered: false } });
case 16:
res.status(401).send("Unauthorized");
default:
req.body.exam_session_id % 2 === 0
? res.send(initRegistrationEmailAuth)
Expand Down
60 changes: 48 additions & 12 deletions frontend/packages/yki/src/components/layouts/SessionStateHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import Button from '@mui/material/Button';
import { FC, useEffect } from 'react';
import { generatePath, Link, matchPath, useLocation } from 'react-router-dom';
import { Text } from 'shared/components';
import { APIResponseStatus, Color, Variant } from 'shared/enums';
import { useWindowProperties } from 'shared/hooks';
import { APIResponseStatus, Color, Severity, Variant } from 'shared/enums';
import { useDialog, useWindowProperties } from 'shared/hooks';

import { useCommonTranslation } from 'configs/i18n';
import { useAppDispatch, useAppSelector } from 'configs/redux';
Expand Down Expand Up @@ -69,6 +69,18 @@ const OpenRegistrationsContent = ({
);
};

const LogoutDialogContents = () => {
const translateCommon = useCommonTranslation();

return (
<Text>
{translateCommon('header.sessionState.logOutDialog.description1')}
<br />
{translateCommon('header.sessionState.logOutDialog.description2')}
</Text>
);
};

export const SessionStateHeader: FC = () => {
const location = useLocation();
const translateCommon = useCommonTranslation();
Expand All @@ -87,6 +99,30 @@ export const SessionStateHeader: FC = () => {
const exampleOpenRegistration =
notOnRegistrationPage && openRegistrations && openRegistrations[0];

const { showDialog } = useDialog();
const handleLogout = () => {
showDialog({
severity: Severity.Info,
title: translateCommon('header.sessionState.logOutDialog.title'),
content: <LogoutDialogContents />,
actions: [
{
title: translateCommon(
'header.sessionState.logOutDialog.confirmButton',
),
variant: Variant.Outlined,
action: () => (document.location = generateLogoutURL()),
},
{
title: translateCommon(
'header.sessionState.logOutDialog.cancelButton',
),
variant: Variant.Contained,
},
],
});
};

useEffect(() => {
const needsUserOpenRegistrations =
isAuthenticated &&
Expand All @@ -113,16 +149,15 @@ export const SessionStateHeader: FC = () => {
<PersonIcon className="session-header__user-icon" />
{getUserName(session)}
</Text>
<a href={generateLogoutURL()}>
<Button
className="session-header__logout-button"
color={Color.Secondary}
variant={Variant.Outlined}
>
<LogoutIcon />
{translateCommon('header.sessionState.logOut')}
</Button>
</a>
<Button
className="session-header__logout-button"
color={Color.Secondary}
variant={Variant.Outlined}
onClick={handleLogout}
>
<LogoutIcon />
{translateCommon('header.sessionState.logOut')}
</Button>
</div>
{exampleOpenRegistration && (
<div className="session-header__open-registrations rows">
Expand Down Expand Up @@ -153,6 +188,7 @@ export const SessionStateHeader: FC = () => {
className="session-header__logout-button"
color={Color.Secondary}
variant={Variant.Outlined}
onClick={handleLogout}
>
<LogoutIcon />
{translateCommon('header.sessionState.logOut')}
Expand Down
Loading

0 comments on commit e29d743

Please sign in to comment.