From 9def0fb2edf176acb9358b2d07473895e01a04c8 Mon Sep 17 00:00:00 2001 From: Basile Spaenlehauer Date: Mon, 30 Sep 2024 14:59:43 +0200 Subject: [PATCH] fix: remove usage of `false` in component return (#1487) --- cypress/support/commands.ts | 3 --- cypress/support/server.ts | 14 -------------- src/components/alerts/MemberValidationBanner.tsx | 4 ++-- src/components/common/ShowChatboxButton.tsx | 2 +- .../sharing/csvImport/DisplayInvitationSummary.tsx | 4 ++-- src/components/main/MainMenu.tsx | 4 ++-- 6 files changed, 7 insertions(+), 24 deletions(-) diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 312ad0071..1bd5473a3 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -61,7 +61,6 @@ import { mockGetMembers, mockGetMembersBy, mockGetMembershipRequestsForItem, - mockGetOwnItems, mockGetOwnMembershipRequests, mockGetParents, mockGetPublicationStatus, @@ -188,8 +187,6 @@ Cypress.Commands.add( mockGetAccessibleItems(cachedItems); - mockGetOwnItems(cachedItems); - mockGetSharedItems({ items: cachedItems, member: currentMember }); mockPostItem(cachedItems, postItemError); diff --git a/cypress/support/server.ts b/cypress/support/server.ts index 917676621..550e2302f 100644 --- a/cypress/support/server.ts +++ b/cypress/support/server.ts @@ -56,7 +56,6 @@ const { buildEditItemRoute, buildItemUnpublishRoute, buildGetItemRoute, - GET_OWN_ITEMS_ROUTE, buildGetMemberRoute, buildPostManyItemMembershipsRoute, ITEMS_ROUTE, @@ -165,19 +164,6 @@ export const mockGetCurrentMember = ( ).as('getCurrentMember'); }; -export const mockGetOwnItems = (items: ItemForTest[]): void => { - cy.intercept( - { - method: HttpMethod.Get, - url: `${API_HOST}/${GET_OWN_ITEMS_ROUTE}`, - }, - (req) => { - const own = items.filter(isRootItem); - req.reply(own); - }, - ).as('getOwnItems'); -}; - export const mockGetAccessibleItems = (items: ItemForTest[]): void => { cy.intercept( { diff --git a/src/components/alerts/MemberValidationBanner.tsx b/src/components/alerts/MemberValidationBanner.tsx index 659fbc8d9..977110196 100644 --- a/src/components/alerts/MemberValidationBanner.tsx +++ b/src/components/alerts/MemberValidationBanner.tsx @@ -36,7 +36,7 @@ const buildLocalizedDocumentationLink = (lang: string): string => { return `${buildLocalizedDocumentationOrigin(lang)}${MEMBER_VALIDATION_DOCUMENTATION_LINK}`; }; -const MemberValidationBanner = (): JSX.Element | false => { +const MemberValidationBanner = (): JSX.Element | null => { const { isOpen, closeModal } = useModalStatus({ isInitiallyOpen: true, }); @@ -71,6 +71,6 @@ const MemberValidationBanner = (): JSX.Element | false => { ); } - return false; + return null; }; export default MemberValidationBanner; diff --git a/src/components/common/ShowChatboxButton.tsx b/src/components/common/ShowChatboxButton.tsx index 6928ef3a2..464eda015 100644 --- a/src/components/common/ShowChatboxButton.tsx +++ b/src/components/common/ShowChatboxButton.tsx @@ -35,7 +35,7 @@ const ShowChatboxButton = ({ return ( { +}: Props): JSX.Element | null => { const { t } = useBuilderTranslation(); if (error) { const additionalMessage = getErrorFromPayload(error); @@ -115,6 +115,6 @@ const DisplayInvitationSummary = ({ } // no error and no data, display nothing - return false; + return null; }; export default DisplayInvitationSummary; diff --git a/src/components/main/MainMenu.tsx b/src/components/main/MainMenu.tsx index bec7d0aa8..743e97f77 100644 --- a/src/components/main/MainMenu.tsx +++ b/src/components/main/MainMenu.tsx @@ -46,7 +46,7 @@ const ResourceLinks = () => { ); }; -const MainMenu = (): JSX.Element | false => { +const MainMenu = (): JSX.Element | null => { const { t } = useBuilderTranslation(); const navigate = useNavigate(); const { pathname } = useLocation(); @@ -57,7 +57,7 @@ const MainMenu = (): JSX.Element | false => { }; if (!member || !member.id) { - return false; + return null; } const individualMenuItems =