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

Register journey quick wins #25

Open
wants to merge 13 commits 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
6 changes: 3 additions & 3 deletions api/src/services/affiliation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {SecurityBindings, UserProfile} from '@loopback/security';

import {capitalize} from 'lodash';

import {WEBSITE_FQDN} from '../constants';
import {IDP_FQDN, realmName, WEBSITE_FQDN} from '../constants';
import {Affiliation, Citizen, User, Enterprise, Funder} from '../models';
import {
AffiliationRepository,
Expand Down Expand Up @@ -59,7 +59,7 @@ export class AffiliationService {
* @param enterpriseEmails[]: string[] - email patterns of the enterprise citizen want to be member
*/
isValidEmailProPattern(emailCitizen: string, enterpriseEmails: string[]): Boolean {
return enterpriseEmails.includes(emailCitizen.replace(/^.+@/, '@'));
return enterpriseEmails.map(email => email.toLowerCase()).includes(emailCitizen.replace(/^.+@/, '@').toLowerCase());
}

/**
Expand Down Expand Up @@ -178,7 +178,7 @@ export class AffiliationService {
* @param enterpriseName entreprise to be affiliated to
*/
async sendValidatedAffiliation(citizen: Citizen, enterpriseName: string) {
const websiteLink = `${WEBSITE_FQDN}/recherche`;
const websiteLink = `${IDP_FQDN}/auth/realms/${realmName}/protocol/openid-connect/auth?client_id=platform&redirect_uri=${WEBSITE_FQDN}/recherche&response_mode=fragment&response_type=code`;
await this.mailService.sendMailAsHtml(
citizen.personalInformation.email.value!,
"Votre demande d'affiliation a été acceptée !",
Expand Down
2 changes: 1 addition & 1 deletion api/src/services/citizen.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ export class CitizenService {

// Send a manual affiliation mail to the company's funders accepting the manual affiliation or to citizen
if (affiliation.status === AFFILIATION_STATUS.TO_AFFILIATE) {
if (enterprise!.enterpriseDetails.hasManualAffiliation) {
if (enterprise!.enterpriseDetails.hasManualAffiliation && !citizen.affiliation.enterpriseEmail) {
await this.affiliationService.sendManualAffiliationMail(citizen, enterprise!);
Logger.info(
CitizenService.name,
Expand Down
3 changes: 2 additions & 1 deletion idp/mcm_template/login/info.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
<p class="retour-ligne">${kcSanitize(msg("activeAccountDescription2"))?no_esc}</p>
<div class="button-redirect">
<a id="button-activated" href="${properties.redirectToLoginPage}">${kcSanitize(msg("btnLogIn"))?no_esc}</a>
<div>
</div>
<p class="retour-ligne" style="margin-top: 35px">${kcSanitize(msg("activeAccountDescription3"))?no_esc}</p>
<#else>
<#if pageRedirectUri?has_content>
<p><a href="${pageRedirectUri}">${kcSanitize(msg("backToApplication"))?no_esc}</a></p>
Expand Down
1 change: 1 addition & 0 deletions idp/mcm_template/login/messages/messages_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ passwordPolicy5=un caract\u00e8re sp\u00e9cial: \u0040\u0023\u0024\u0025\u005E\u
activeAccount=Votre compte est d\u00e9sormais actif.
activeAccountDescription1=Vous pouvez d\u00e9s \u00e0 pr\u00e9sent acc\u00e9der \u00e0 l''ensemble des fonctionnalit\u00e9s propos\u00e9es par Mon Compte Mobilit\u00e9 !
activeAccountDescription2=Connectez-vous \u00e0 l''aide du lien ci-dessous afin de g\u00e9rer votre compte et consulter les informations relatives \u00e0 votre profil et territoire.
activeAccountDescription3=Si vous avez pr\u00e9cis\u00e9 un mail professionnel, consultez ce dernier pour activer votre affiliation employeur. Cette affiliation est n\u00e9cessaire pour consulter les aides sp\u00e9cifiques propos\u00e9es par ce dernier.

#Custom MCM message key for OAuth concent page
consentProfile=Acc\u00e8s aux donn\u00e9es de votre profil
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/Profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ const Profile: FC<ProfileProps> = ({ crumbs }) => {
</div>
</>
) : (
Strings['profile.phrase.not.affiliated']
Strings['profile.phrase.not.affiliated.waiting']
)
) : (
UserAffiliationStatus[
Expand Down
1 change: 1 addition & 0 deletions website/src/components/Profile/locale/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"profile.label.gender.male": "M.",
"profile.label.gender.female": "Mme.",
"profile.phrase.not.affiliated": "Non Affilié",
"profile.phrase.not.affiliated.waiting": "En cours de validation par votre employeur",
"profile.tooltip.linked.accounts": "Rendez-vous sur votre application régionale de mobilité pour lier vos comptes et profiter de l'ensemble des fonctionnalités MOB",
"profile.tooltip.refresh.page": "Veuillez rafraîchir cette page pour visualiser le changement de statut",
"profile.modal.validate.button": "Valider ma désaffiliation",
Expand Down
1 change: 1 addition & 0 deletions website/src/components/Profile/locale/fr.json.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ interface Fr {
'profile.label.gender.female': string;
'profile.label.gender.male': string;
'profile.phrase.not.affiliated': string;
'profile.phrase.not.affiliated.waiting': string;
'profile.tooltip.linked.accounts': string;
'profile.tooltip.refresh.page': string;
'profile.modal.validate.button': string;
Expand Down
5 changes: 4 additions & 1 deletion website/src/components/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useState } from 'react';
import React, { FC, useEffect, useState } from 'react';
import classNames from 'classnames';

import './_tabs.scss';
Expand All @@ -19,6 +19,9 @@ const Tab: FC<TabProps> = ({ tabs, setSelectedIndex, defaultActiveTab }) => {
const [activeTab, setActiveTab] = useState<number>(
defaultActiveTab || tabs[0]?.id
);
useEffect(() => {
setActiveTab(defaultActiveTab || tabs[0]?.id)
}, [defaultActiveTab])

const handleTabClick = (tabID: React.SetStateAction<number>) => {
setActiveTab(tabID);
Expand Down
4 changes: 2 additions & 2 deletions website/src/components/Toast/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const toastOptions = {
},
};
const containerStyle = {
top: 0,
top: "115px",
left: 0,
bottom: 0,
right: 0,
right: 0
};

const Toast: FC = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Button from '@components/Button/Button';
import { useSession } from '../../../../context';

import Strings from '../../locale/fr.json';
import { navigate } from 'gatsby';
import { INCENTIVE_TYPE } from '../../../../utils/demandes';

const AffiliateSuccessMessage: FC = () => {
const { isKCInit, keycloak } = useSession();
Expand All @@ -26,6 +28,12 @@ const AffiliateSuccessMessage: FC = () => {
{Strings['affiliation.success.button']}
</Button>
)}
{isKCInit && keycloak?.authenticated && (
// User is logged in, invite them to go to incentives page
<Button onClick={() => navigate("/recherche?tab=" + INCENTIVE_TYPE.EMPLOYER_INCENTIVE)}>
{Strings['affiliation.success.button.incentives']}
</Button>
)}
</>
);
};
Expand Down
1 change: 1 addition & 0 deletions website/src/modules/inscription/locale/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"affiliation.success": "Félicitations ! Vous êtes désormais affilié à votre employeur.",
"affiliation.success.action": "Si vous avez activé votre compte, vous pouvez désormais vous connecter pour visualiser les aides de votre employeur.",
"affiliation.success.button": "Me connecter",
"affiliation.success.button.incentives": "Consulter mes aides employeur",
"affiliation.title": "Vous avez demandé une affiliation",
"affiliation.button": "Affilier mon compte",
"affiliation.profile": "Mon profil",
Expand Down
1 change: 1 addition & 0 deletions website/src/modules/inscription/locale/fr.json.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ interface Fr {
'affiliation.success': string;
'affiliation.success.action': string;
'affiliation.success.button': string;
'affiliation.success.button.incentives': string;
'affiliation.title': string;
'affiliation.button': string;
'affiliation.profile': string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ import { StatusCode } from '@utils/https';
import { matomoTrackEvent } from '@utils/matomo';
import { useMatomo } from '@datapunt/matomo-tracker-react';

import { useUser } from '../../../context';
import Strings from '../locale/fr.json';

const InscriptionPageAffiliation: FC<RouteComponentProps> = () => {
const [token] = useQueryParam('token', StringParam);
const { trackEvent } = useMatomo();
const { citizen, refetchCitizen } = useUser();
const { error, refetch, isIdle, isLoading, isSuccess, isError } = useQuery(
'affiliate',
async () => {
Expand All @@ -50,8 +52,11 @@ const InscriptionPageAffiliation: FC<RouteComponentProps> = () => {
}
}, []);

const handleClick = (): void => {
refetch();
const handleClick = async (): Promise<void> => {
await refetch();
if (citizen) {
refetchCitizen();
}
};

const renderMessage = (): React.ReactNode => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ const GererSalaries: FC<GestionSalarierProps> = ({ location, pageContext }) => {
const renderSalaries = (): ReactNode => {
if (salaries && salaries.length) {
return salaries.map(
({ id, firstName, lastName, enterpriseEmail, email, birthDate }) => {
({ id, firstName, lastName, enterpriseEmail, email, birthdate }) => {
return (
<CardLine key={id} classnames="salaries-card">
<CardLineContent classnames="salaries-card__name span">
Expand All @@ -222,7 +222,7 @@ const GererSalaries: FC<GestionSalarierProps> = ({ location, pageContext }) => {
<Button
secondary
onClick={() => {
openModal(id, lastName, firstName, email, birthDate);
openModal(id, lastName, firstName, email, birthdate);
}}
>
{
Expand Down Expand Up @@ -438,7 +438,7 @@ const GererSalaries: FC<GestionSalarierProps> = ({ location, pageContext }) => {
};

/*
* Open Modal Delete Affiliation
* Open any Modal
*/
const openModal = (
citizen: string,
Expand All @@ -458,7 +458,7 @@ const GererSalaries: FC<GestionSalarierProps> = ({ location, pageContext }) => {
};

/*
* Close Modal Delete Affiliation
* Close any Modal
*/
const closeModal = () => {
setShowModal(false);
Expand Down
5 changes: 4 additions & 1 deletion website/src/pages/locale/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,5 +298,8 @@
"search.incentive.tabs.all.incentives": "Toutes les aides {0}",
"search.incentive.tabs.territory.incentives": "Aides territoriales {0}",
"search.incentive.tabs.employees.incentives": "Aides employeur {0}",
"search.incentive.tabs.nationals.incentives": "Aides nationales {0}"
"search.incentive.tabs.nationals.incentives": "Aides nationales {0}",
"search.incentive.affiliation.toast.part1": "Votre affiliation employeur n'est pas finalisée, un email a du vous être envoyé sur l'adresse ",
"search.incentive.affiliation.toast.part2": "Consultez votre profil pour plus d'information, ou pour renvoyer l'email",
"search.incentive.affiliation.toast.close": "Fermer"
}
3 changes: 3 additions & 0 deletions website/src/pages/locale/fr.json.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ interface Fr {
'search.incentive.tabs.territory.incentives': string;
'search.incentive.tabs.employees.incentives': string;
'search.incentive.tabs.nationals.incentives': string;
'search.incentive.affiliation.toast.part1': string;
'search.incentive.affiliation.toast.part2': string;
'search.incentive.affiliation.toast.close': string;
}

declare const value: Fr;
Expand Down
24 changes: 23 additions & 1 deletion website/src/pages/recherche.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Breadcrumb } from 'gatsby-plugin-breadcrumb/';
import { useQueryParam, StringParam } from 'use-query-params';
import { useQueryClient, useQuery } from 'react-query';
import { useMatomo } from '@datapunt/matomo-tracker-react';
import toast from 'react-hot-toast';

import { AuthorizationRoute } from '@modules/routes';

Expand Down Expand Up @@ -32,6 +33,7 @@ import Strings from './locale/fr.json';
import { Helmet } from 'react-helmet';

import mobLogo from '../../static/mob-favicon.png';
import { navigate } from 'gatsby';

interface RechercheProps {
pageContext: { breadcrumb: { crumbs: string } };
Expand Down Expand Up @@ -380,6 +382,23 @@ const RechercheComponent: FC<RechercheProps> = ({ pageContext }) => {
setTermSearch(term);
};

useEffect(() => {
if (authenticated && citizen && citizen.affiliation && citizen.affiliation.status === "A_AFFILIER" && citizen.affiliation.enterpriseEmail) {
toast.loading((t) => (
<div>
<p>{Strings['search.incentive.affiliation.toast.part1']} {citizen.affiliation.enterpriseEmail}.</p>
<p>{Strings['search.incentive.affiliation.toast.part2']}: <button className="link-in-text" onClick={() => navigate('/mon-profil/', { replace: true })}>Mon Profil</button>.</p>
<button className="link-in-text" onClick={() => toast.dismiss(t.id)}>{Strings['search.incentive.affiliation.toast.close']}</button>
</div>
), {
style: {
minWidth: '50%',
}
})
}
return toast.dismiss
}, [])

useEffect(() => {
if (allIncentivesCount) {
setIncentivesCount((previousState) => ({
Expand Down Expand Up @@ -413,6 +432,9 @@ const RechercheComponent: FC<RechercheProps> = ({ pageContext }) => {
...previousState,
employerIncentives: employerIncentivesCount?.count,
}));
if (employerIncentivesCount?.count > 0 && !routeSelectedTab) {
setSelectedTab(INCENTIVE_TYPE.EMPLOYER_INCENTIVE)
}
}
}, [employerIncentivesCount]);

Expand All @@ -433,7 +455,7 @@ const RechercheComponent: FC<RechercheProps> = ({ pageContext }) => {
territoryFilter,
transportsFilter,
]);

return (
<Layout
footer={{
Expand Down
6 changes: 3 additions & 3 deletions website/src/utils/https.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ class Https {

https.interceptors.request.use(
(config) => {
this.showToaster();
//this.showToaster();
return injectToken(config);
},
(error) => Promise.reject(error)
);

https.interceptors.response.use(
(response) => {
this.dismissToaster();
//this.dismissToaster();
return response;
},
(error) => {
this.dismissToaster();
//this.dismissToaster();
const { response } = error;
return this.handleError(response);
}
Expand Down