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

feat: hide button ProConnect when logged in #1243

Merged
merged 1 commit into from
Oct 3, 2024
Merged
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
43 changes: 31 additions & 12 deletions app/(header-default)/lp/agent-public/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Metadata } from 'next';
import { default as ButtonProConnect } from '#components-ui/button-pro-connect';
import Container from '#components-ui/container';
import { administrationsMetaData } from '#models/administrations';
import { isLoggedIn } from '#models/user/rights';
import { ISession } from '#models/user/session';
import { AppRouterProps } from '#utils/server-side-helper/app/extract-params';
import getSession from '#utils/server-side-helper/app/get-session';
import { IronSession } from 'iron-session';
import { Metadata } from 'next';
import styles from './style.module.css';

export const metadata: Metadata = {
Expand All @@ -15,8 +19,15 @@ export const metadata: Metadata = {
},
};

const LandingPageAgent = (props: AppRouterProps) => {
const isLoggedInMessage = (session: IronSession<ISession> | null) => (
<div>
Vous êtes connecté avec : <strong>{session?.user?.email}</strong>
</div>
);

const LandingPageAgent = async (props: AppRouterProps) => {
const { pathFrom } = props.searchParams;
const session = await getSession();

return (
<div className={styles['page']}>
Expand All @@ -37,11 +48,15 @@ const LandingPageAgent = (props: AppRouterProps) => {
.
</p>
</header>
<ButtonProConnect
useCurrentPathForRediction={false}
alternatePathForRedirection={pathFrom as string}
event="BTN_LP_HERO"
/>
{isLoggedIn(session) ? (
isLoggedInMessage(session)
) : (
<ButtonProConnect
useCurrentPathForRediction={false}
alternatePathForRedirection={pathFrom as string}
event="BTN_LP_HERO"
/>
)}
</div>
<img src="/images/lp-agent/secure-folder 1.svg" alt="" />
</section>
Expand Down Expand Up @@ -109,11 +124,15 @@ const LandingPageAgent = (props: AppRouterProps) => {
}}
>
<h2>Rejoignez les agents qui utilisent déjà l’espace agent !</h2>
<ButtonProConnect
useCurrentPathForRediction={false}
alternatePathForRedirection={pathFrom as string}
event="BTN_LP_BOTTOM"
/>
{isLoggedIn(session) ? (
isLoggedInMessage(session)
) : (
<ButtonProConnect
useCurrentPathForRediction={false}
alternatePathForRedirection={pathFrom as string}
event="BTN_LP_BOTTOM"
/>
)}
</section>
</Container>
<section>
Expand Down
Loading