;
-
-export const Authorized: Story = {
- render: () => {
- const Component = withAuthorization(BuildIcon, {
- redirectionLink,
- currentMember: { id: 'member', name: 'member' } as CompleteMember,
- });
- return ;
- },
-};
diff --git a/src/Authorization/withAuthorization.tsx b/src/Authorization/withAuthorization.tsx
deleted file mode 100644
index 77e87e654..000000000
--- a/src/Authorization/withAuthorization.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import { ComponentType } from 'react';
-
-import { CompleteMember, redirect } from '@graasp/sdk';
-
-import RedirectionContent from './RedirectionContent.js';
-
-export type WithAuthorizationProps = {
- redirectionLink: string;
- currentMember?: CompleteMember | null;
- onRedirect?: () => void;
-};
-
-const withAuthorization =
- (
- ChildComponent: ComponentType
,
- { currentMember, redirectionLink, onRedirect }: WithAuthorizationProps,
- ): ((props: P) => JSX.Element) =>
- (childProps: P) => {
- const redirectToSignIn = (): void => {
- if (!redirectionLink) {
- return console.debug('No link has been set for redirection');
- }
- redirect(window, redirectionLink);
- };
-
- // check authorization: user shouldn't be empty
- if (currentMember && currentMember.id) {
- return ;
- }
-
- onRedirect?.();
-
- redirectToSignIn();
-
- // redirect page if redirection is not working
- return ;
- };
-
-export default withAuthorization;
diff --git a/src/UserSwitch/UserSwitch.stories.tsx b/src/UserSwitch/UserSwitch.stories.tsx
index 38f6697b9..a32e12794 100644
--- a/src/UserSwitch/UserSwitch.stories.tsx
+++ b/src/UserSwitch/UserSwitch.stories.tsx
@@ -20,7 +20,7 @@ type Story = StoryObj;
export const SignedIn = {
args: {
currentMember: MOCK_CURRENT_MEMBER,
- renderAvatar: () => (
+ avatar: (
(
+ avatar: (
MouseEventHandler;
- renderAvatar?: (member?: CompleteMember | null) => JSX.Element;
+ avatar?: JSX.Element;
signedOutTooltipText?: string;
};
@@ -49,7 +49,7 @@ export const UserSwitch = ({
isMemberLoading = false,
currentMember,
menuId,
- renderAvatar = () => <>>,
+ avatar,
signedOutTooltipText = 'You are not signed in.',
}: Props): JSX.Element => {
const [anchorEl, setAnchorEl] = useState<(EventTarget & Element) | null>(
@@ -121,7 +121,7 @@ export const UserSwitch = ({
return (