Skip to content

Commit

Permalink
feat: add env var pour avenir pro
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurlbrjc committed Dec 5, 2024
1 parent bffdef2 commit c39dae6
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 23 deletions.
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ NEXT_PUBLIC_IMILO_URL=https://portail.i-milo.fr/
NEXT_PUBLIC_FAQ_MILO_EXTERNAL_LINK=http://perdu.com/
NEXT_PUBLIC_FAQ_PE_EXTERNAL_LINK=http://perdu.com/
NEXT_PUBLIC_FAQ_PASS_EMPLOI_EXTERNAL_LINK=http://perdu.com/
NEXT_PUBLIC_ENABLE_AVENIR_PRO_SSO=true
55 changes: 35 additions & 20 deletions app/(connexion)/login/passemploi/LoginPassEmploiPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ import FailureAlert from 'components/ui/Notifications/FailureAlert'
import { signin } from 'utils/auth/auth'
import { useLoginErrorMessage } from 'utils/auth/loginErrorMessageContext'

function LoginPage() {
type LoginPassEmploiPageProps = {
ssoAvenirProEstActif?: boolean
}

function LoginPassEmploiPage({
ssoAvenirProEstActif,
}: LoginPassEmploiPageProps) {
const [errorMsg, setErrorMsg] = useLoginErrorMessage()
const searchParams = useSearchParams()

Expand Down Expand Up @@ -85,7 +91,9 @@ function LoginPage() {
<h2 className='text-l-bold text-primary_darken text-center my-6 mx-4'>
Connexion conseiller AIJ
</h2>
<ul className='px-6 pt-6 flex flex-col gap-4 layout_s:border-r-2 layout_s:border-grey_100'>
<ul
className={`px-6 pt-6 flex flex-col gap-4 ${ssoAvenirProEstActif ? 'layout_s:border-r-2 layout_s:border-grey_100' : ''}`}
>
<li>
<LoginButton
altText='France Travail AIJ'
Expand All @@ -100,28 +108,35 @@ function LoginPage() {
</li>
</ul>

<h2 className='text-l-bold text-primary_darken text-center my-6 mx-4'>
Connexion conseiller Avenir Pro
</h2>
<ul className='px-6 pt-6 flex flex-col gap-4'>
<li>
<LoginButton
altText='France Travail Avenir Pro'
label='France Travail'
className='whitespace-nowrap'
style={ButtonStyle.SECONDARY}
illustrationName={IllustrationName.LogoFT}
handleSubmit={(event) =>
handleSignin(event, 'avenirpro-conseiller')
}
/>
</li>
</ul>
{ssoAvenirProEstActif && (
<>
<h2 className='text-l-bold text-primary_darken text-center my-6 mx-4'>
Connexion conseiller Avenir Pro
</h2>
<ul className='px-6 pt-6 flex flex-col gap-4'>
<li>
<LoginButton
altText='France Travail Avenir Pro'
label='France Travail'
className='whitespace-nowrap'
style={ButtonStyle.SECONDARY}
illustrationName={IllustrationName.LogoFT}
handleSubmit={(event) =>
handleSignin(event, 'avenirpro-conseiller')
}
/>
</li>
</ul>
</>
)}
</main>
</div>
</div>
</div>
)
}

export default withTransaction(LoginPage.name, 'page')(LoginPage)
export default withTransaction(
LoginPassEmploiPage.name,
'page'
)(LoginPassEmploiPage)
8 changes: 7 additions & 1 deletion app/(connexion)/login/passemploi/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,11 @@ export default async function LoginPassEmploi({
}) {
await redirectIfAlreadyConnected(searchParams)

return <LoginPassEmploiPage />
return (
<LoginPassEmploiPage
ssoAvenirProEstActif={
process.env.NEXT_PUBLIC_ENABLE_AVENIR_PRO_SSO === 'true'
}
/>
)
}
5 changes: 4 additions & 1 deletion tests/pages/LoginPassEmploiPage.server.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ describe('LoginPassEmploiPage server side', () => {
expect(metadata).toEqual({
title: "Connexion dans l'espace conseiller - Outil du pass emploi",
})
expect(LoginPassEmploiPage).toHaveBeenCalledWith({}, {})
expect(LoginPassEmploiPage).toHaveBeenCalledWith(
{ ssoAvenirProEstActif: true },
{}
)
})
})
2 changes: 1 addition & 1 deletion tests/pages/LoginPassEmploiPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('LoginPassEmploiPage client side', () => {
beforeEach(async () => {
;({ container } = render(
<LoginErrorMessageProvider state={[undefined, setErrorMsg]}>
<LoginPassEmploiPage />
<LoginPassEmploiPage ssoAvenirProEstActif={true} />
</LoginErrorMessageProvider>
))
})
Expand Down

0 comments on commit c39dae6

Please sign in to comment.