Skip to content

Commit e7e4c3c

Browse files
committed
adjust hook
1 parent aeebbe7 commit e7e4c3c

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

‎frontend/main/src/components/user/MemberValidShow.tsx‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export default function MemberValidShow({
1717
notValidComponent: JSX.Element;
1818
}): JSX.Element {
1919
const auth = useAuth();
20-
const { member, team } = useIsMember(user);
2120

2221
if (!sectionLesson || sectionLesson?.access_mode === AccessMode.free) {
2322
return <section>{children}</section>;
@@ -28,9 +27,29 @@ export default function MemberValidShow({
2827
return <section>{children}</section>;
2928
} else if (
3029
sectionLesson?.access_mode === AccessMode.closed &&
31-
(member || team)
30+
auth?.currentUser?.uid
3231
) {
33-
return <section>{children}</section>;
32+
<CheckMember user={user} notValidComponent={notValidComponent}>
33+
{children}
34+
</CheckMember>;
3435
}
3536
return <>{notValidComponent}</>;
3637
}
38+
39+
const CheckMember = ({
40+
user,
41+
children,
42+
notValidComponent,
43+
}: {
44+
user: UserInfoExtended;
45+
children: JSX.Element;
46+
notValidComponent: JSX.Element;
47+
}): JSX.Element => {
48+
const auth = useAuth();
49+
const { member, team } = useIsMember(user);
50+
51+
if (auth?.currentUser?.uid && (member || team)) {
52+
return <section>{children}</section>;
53+
}
54+
return <>{notValidComponent}</>;
55+
};

0 commit comments

Comments
 (0)