Skip to content

Commit

Permalink
Add PE connect button when PE connected
Browse files Browse the repository at this point in the history
  • Loading branch information
JeromeBu committed Jun 30, 2023
1 parent 3a2da05 commit f6a05fb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ export const BeneficiaryFormSection = ({
const hasCurrentEmployer = useAppSelector(
conventionSelectors.hasCurrentEmployer,
);
const isSuccessfullyPeConnected = useAppSelector(
authSelectors.isSuccessfullyPeConnected,
);
const isSuccessfullyPeConnected = useAppSelector(authSelectors.isPeConnected);
const connectedUser = useAppSelector(authSelectors.connectedUser);
const userFieldsAreFilled = isSuccessfullyPeConnected && !!connectedUser;
const { register, getValues, setValue, formState } =
Expand Down
13 changes: 13 additions & 0 deletions front/src/app/components/layout/ImmersionHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { useAppSelector } from "src/app/hooks/reduxHooks";
import { routes, useRoute } from "src/app/routes/routes";
import { adminSelectors } from "src/core-logic/domain/admin/admin.selectors";
import { adminAuthSlice } from "src/core-logic/domain/admin/adminAuth/adminAuth.slice";
import { authSelectors } from "src/core-logic/domain/auth/auth.selectors";
import { authSlice } from "src/core-logic/domain/auth/auth.slice";

import immersionFacileLightLogo from "/assets/img/logo-if.svg";
import immersionFacileDarkLogo from "/assets/img/logo-if-dark.svg";
Expand Down Expand Up @@ -43,6 +45,7 @@ export const ImmersionHeader = () => {
} = domElementIds.header.navLinks;

const isAdminConnected = useAppSelector(adminSelectors.auth.isAuthenticated);
const isPeConnected = useAppSelector(authSelectors.isPeConnected);
const tools: HeaderProps["quickAccessItems"] = [headerFooterDisplayItem];
if (isAdminConnected) {
tools.push({
Expand All @@ -53,6 +56,16 @@ export const ImmersionHeader = () => {
},
});
}
if (isPeConnected) {
tools.push({
iconId: "fr-icon-lock-line",
text: "Se déconnecter (PE Connect)",
buttonProps: {
onClick: () =>
dispatch(authSlice.actions.federatedIdentityDeletionTriggered),
},
});
}
const isCandidateRoute =
currentRoute.name === routes.search().name ||
currentRoute.name === routes.homeCandidates().name;
Expand Down
4 changes: 2 additions & 2 deletions front/src/core-logic/domain/auth/auth.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const currentFederatedIdentity = createRootSelector(
(state) => state.auth.federatedIdentityWithUser,
);

const isSuccessfullyPeConnected = createSelector(
const isPeConnected = createSelector(
currentFederatedIdentity,
(federatedIdentity) =>
federatedIdentity?.provider === "peConnect" &&
Expand Down Expand Up @@ -45,7 +45,7 @@ const connectedUser = createSelector(

export const authSelectors = {
federatedIdentity: currentFederatedIdentity,
isSuccessfullyPeConnected,
isPeConnected,
isInclusionConnected,
inclusionConnectToken,
connectedUser,
Expand Down

0 comments on commit f6a05fb

Please sign in to comment.