Skip to content

Commit

Permalink
chore: add isCurrentUser props (#661)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasCharrier authored Nov 21, 2024
1 parent bdd944e commit b965760
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/app/(private)/(dashboard)/account/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default async function Page() {
matomoInfo={userInformations.matomoInfo}
sentryInfo={userInformations.sentryInfo}
startups={userInformations.startups}
isCurrentUser={true}
/>
);
}
1 change: 1 addition & 0 deletions src/app/(private)/(dashboard)/community/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default async function Page({
matomoInfo={userInformations.matomoInfo}
sentryInfo={userInformations.sentryInfo}
startups={userInformations.startups}
isCurrentUser={false}
/>
);
}
3 changes: 3 additions & 0 deletions src/components/MemberPage/MemberPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface MemberPageProps {
startups: Awaited<ReturnType<typeof getUserStartups>>;
canEdit: boolean;
isAdmin: boolean;
isCurrentUser: boolean;
}

/*
Expand All @@ -80,6 +81,7 @@ export default function MemberPage({
canEdit,
isAdmin,
avatar,
isCurrentUser,
}: MemberPageProps) {
const tabs = [
{
Expand Down Expand Up @@ -139,6 +141,7 @@ export default function MemberPage({
matomoInfo={matomoInfo}
sentryInfo={sentryInfo}
redirections={redirections}
isCurrentUser={isCurrentUser}
/>
),
},
Expand Down
16 changes: 13 additions & 3 deletions src/components/MemberPage/MemberStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,10 @@ const emailStatusRow = (
];
};

const MatomoInfoRow = (matomo: MemberPageProps["matomoInfo"]) => {
const MatomoInfoRow = (
matomo: MemberPageProps["matomoInfo"],
isCurrentUser: boolean
) => {
const status = !!matomo ? matomo.status : "unset";
return [
<>Compte Matomo</>,
Expand Down Expand Up @@ -294,14 +297,19 @@ const MatomoInfoRow = (matomo: MemberPageProps["matomoInfo"]) => {
headers={["nom", "type", "niveau d'accès"]}
/>
</Accordion>
) : (
) : isCurrentUser ? (
<>
Tu n'as pas de compte matomo. Si tu as besoin d'un compte tu
peux en faire la demande{" "}
<a href="/services/matomo" className="fr-link">
ici
</a>
</>
) : (
<>
Ce membre n'a pas de compte matomo, un demande peut être faite
depuis son espace-membre
</>
),
];
};
Expand Down Expand Up @@ -339,6 +347,7 @@ export const MemberStatus = ({
redirections,
matomoInfo,
sentryInfo,
isCurrentUser,
}: {
isExpired: MemberPageProps["isExpired"];
emailInfos: MemberPageProps["emailInfos"];
Expand All @@ -347,6 +356,7 @@ export const MemberStatus = ({
redirections: MemberPageProps["redirections"];
matomoInfo: MemberPageProps["matomoInfo"];
sentryInfo: MemberPageProps["sentryInfo"];
isCurrentUser: boolean;
}) => {
const rows = [
// Account status
Expand All @@ -365,7 +375,7 @@ export const MemberStatus = ({
// Mattermost account status
mattermostInfo && mattermostInfoRow(mattermostInfo, userInfos.uuid),
// Matomo account status
MatomoInfoRow(matomoInfo),
MatomoInfoRow(matomoInfo, isCurrentUser),
// Sentry account status
sentryInfo && sentryInfoRow(sentryInfo),
].filter((z) => !!z);
Expand Down

0 comments on commit b965760

Please sign in to comment.