From fb1e719275e6c606624136d09b17a6a8a966dbb1 Mon Sep 17 00:00:00 2001 From: vhande <78013271+vhande@users.noreply.github.com> Date: Fri, 22 Nov 2024 13:11:46 +0100 Subject: [PATCH] Remove useMemo --- .../[organizerId]/ownerships/index.page.tsx | 6 +- .../[organizerId]/preview/OrganizerLabels.tsx | 7 +- .../[organizerId]/preview/index.page.tsx | 230 +++++++++--------- 3 files changed, 114 insertions(+), 129 deletions(-) diff --git a/src/pages/organizers/[organizerId]/ownerships/index.page.tsx b/src/pages/organizers/[organizerId]/ownerships/index.page.tsx index 2344673ff..21e95a090 100644 --- a/src/pages/organizers/[organizerId]/ownerships/index.page.tsx +++ b/src/pages/organizers/[organizerId]/ownerships/index.page.tsx @@ -51,10 +51,8 @@ const Ownership = () => { isApproveAction ? 'confirm' : 'reject' }_modal`; - const organizerId = useMemo( - () => router.query.organizerId as string, - [router.query.organizerId], - ); + const organizerId = router.query.organizerId as string; + const getOrganizerByIdQuery = useGetOrganizerByIdQuery({ id: organizerId, }); diff --git a/src/pages/organizers/[organizerId]/preview/OrganizerLabels.tsx b/src/pages/organizers/[organizerId]/preview/OrganizerLabels.tsx index 049cc8c71..5062d518b 100644 --- a/src/pages/organizers/[organizerId]/preview/OrganizerLabels.tsx +++ b/src/pages/organizers/[organizerId]/preview/OrganizerLabels.tsx @@ -1,6 +1,6 @@ import { uniq } from 'lodash'; import { useRouter } from 'next/router'; -import React, { useMemo, useRef, useState } from 'react'; +import React, { useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { UseQueryResult } from 'react-query'; @@ -38,10 +38,7 @@ export const OrganizerLabelsForm = ({ organizer }: OrganizerLabelProps) => { }); const scope = ScopeTypes.ORGANIZERS; - const organizerId = useMemo( - () => router.query.organizerId as string, - [router.query.organizerId], - ); + const organizerId = router.query.organizerId as string; const options = labelsQuery.data?.member ?? []; const [labels, setLabels] = useState( diff --git a/src/pages/organizers/[organizerId]/preview/index.page.tsx b/src/pages/organizers/[organizerId]/preview/index.page.tsx index b3030678f..6cc6897e9 100644 --- a/src/pages/organizers/[organizerId]/preview/index.page.tsx +++ b/src/pages/organizers/[organizerId]/preview/index.page.tsx @@ -1,6 +1,6 @@ import getConfig from 'next/config'; import { useRouter } from 'next/router'; -import { useMemo, useState } from 'react'; +import { useState } from 'react'; import { Trans, useTranslation } from 'react-i18next'; import { dehydrate, useQueryClient } from 'react-query'; @@ -40,11 +40,8 @@ const OrganizersPreview = () => { const router = useRouter(); const { publicRuntimeConfig } = getConfig(); const isOwnershipEnabled = publicRuntimeConfig.ownershipEnabled === 'true'; + const organizerId = router.query.organizerId as string; - const organizerId = useMemo( - () => router.query.organizerId as string, - [router.query.organizerId], - ); const getOrganizerByIdQuery = useGetOrganizerByIdQuery({ id: organizerId, }); @@ -98,129 +95,122 @@ const OrganizersPreview = () => { {organizerName} - {isOwnershipEnabled && ( - - setIsQuestionModalVisible(false)} - onConfirm={() => { - requestOwnershipMutation.mutate({ - itemId: organizerId, - ownerId: userId, - }); - }} - size={ModalSizes.MD} - > - - - - - {isOwnershipRequested && ( - - - + + { - setIsSuccessAlertVisible(false); - }} - > - - + cancelTitle={t( + 'organizers.ownerships.request.confirm_modal.cancel', )} - {isErrorAlertVisible && ( - { - setIsErrorAlertVisible(false); + visible={isQuestionModalVisible} + variant={ModalVariants.QUESTION} + onClose={() => setIsQuestionModalVisible(false)} + onConfirm={() => { + requestOwnershipMutation.mutate({ + itemId: organizerId, + ownerId: userId, + }); + }} + size={ModalSizes.MD} + > + + - - - )} - - - - - - - {!canEdit && isOwnershipEnabled && !isOwnershipRequested && ( - - )} - {canEdit && ( - - {t('organizers.detail.actions.edit')} - - )} - {canEdit && isOwnershipEnabled && !isOwnershipRequested && ( - - {t('organizers.detail.actions.manage')} - - )} + /> + + + {isOwnershipRequested && ( + + + + )} + {isSuccessAlertVisible && ( + { + setIsSuccessAlertVisible(false); + }} + > + + + )} + {isErrorAlertVisible && ( + { + setIsErrorAlertVisible(false); + }} + > + + + )} + + + + + + + {!canEdit && isOwnershipEnabled && !isOwnershipRequested && ( + + )} + {canEdit && ( - {t('organizers.detail.actions.back')} + {t('organizers.detail.actions.edit')} - - - - )} - {!isOwnershipEnabled && } + )} + {canEdit && isOwnershipEnabled && !isOwnershipRequested && ( + + {t('organizers.detail.actions.manage')} + + )} + + {t('organizers.detail.actions.back')} + + + +