From 15d74ef936964ca96550819a30b86ce7443ae856 Mon Sep 17 00:00:00 2001 From: Boris Date: Mon, 4 Nov 2024 18:47:21 +0800 Subject: [PATCH] feat: extract SpaceSettings container component (#1053) --- .../collaborator/CollaboratorPage.tsx | 45 ++++---- .../space-setting/general/GeneralPage.tsx | 102 +++++++++--------- .../app/components/SpaceSettingContainer.tsx | 25 +++++ .../src/features/auth/pages/LoginPage.tsx | 6 +- 4 files changed, 99 insertions(+), 79 deletions(-) create mode 100644 apps/nextjs-app/src/features/app/components/SpaceSettingContainer.tsx diff --git a/apps/nextjs-app/src/features/app/blocks/space-setting/collaborator/CollaboratorPage.tsx b/apps/nextjs-app/src/features/app/blocks/space-setting/collaborator/CollaboratorPage.tsx index c56a31b4c..5c9155893 100644 --- a/apps/nextjs-app/src/features/app/blocks/space-setting/collaborator/CollaboratorPage.tsx +++ b/apps/nextjs-app/src/features/app/blocks/space-setting/collaborator/CollaboratorPage.tsx @@ -8,6 +8,7 @@ import { useRouter } from 'next/router'; import { useTranslation } from 'next-i18next'; import { Collaborators } from '@/features/app/components/collaborator-manage/space/Collaborators'; import { SpaceCollaboratorModalTrigger } from '@/features/app/components/collaborator-manage/space/SpaceCollaboratorModalTrigger'; +import { SpaceSettingContainer } from '@/features/app/components/SpaceSettingContainer'; import { spaceConfig } from '@/features/i18n/space.config'; export const CollaboratorPage = () => { @@ -22,31 +23,25 @@ export const CollaboratorPage = () => { }); return ( -
-
-
-

{t('space:spaceSetting.collaborators')}

-
- {t('space:spaceSetting.collaboratorDescription')} -
+ + {isHydrated && !!space && ( +
+ + + + +
- - {isHydrated && !!space && ( -
- - - - - -
- )} -
-
+ )} + ); }; diff --git a/apps/nextjs-app/src/features/app/blocks/space-setting/general/GeneralPage.tsx b/apps/nextjs-app/src/features/app/blocks/space-setting/general/GeneralPage.tsx index 64998cc72..91ffc5edb 100644 --- a/apps/nextjs-app/src/features/app/blocks/space-setting/general/GeneralPage.tsx +++ b/apps/nextjs-app/src/features/app/blocks/space-setting/general/GeneralPage.tsx @@ -10,6 +10,7 @@ import { useRouter } from 'next/router'; import { Trans, useTranslation } from 'next-i18next'; import { useState } from 'react'; import { CopyButton } from '@/features/app/components/CopyButton'; +import { SpaceSettingContainer } from '@/features/app/components/SpaceSettingContainer'; import { spaceConfig } from '@/features/i18n/space.config'; export const GeneralPage = () => { @@ -67,60 +68,57 @@ export const GeneralPage = () => { return ( <> -
-
-
-

{t('space:spaceSetting.general')}

- {space && hasPermission(space.role, 'space|delete') && ( -
- {t('space:spaceSetting.generalDescription')} -
- )} -
- - {!!space && ( -
-
-

{t('common:noun.space')}

- -
-
- {t('space:spaceSetting.spaceName')} - {isEditing ? ( - - ) : ( - <> - {space.name} - {hasPermission(space.role, 'space|update') && ( - - )} - - )} -
-
- {t('space:spaceSetting.spaceId')} - {spaceId} - + {!!space && ( +
+
+

{t('common:noun.space')}

+ +
+
+ {t('space:spaceSetting.spaceName')} + {isEditing ? ( + -
+ ) : ( + <> + {space.name} + {hasPermission(space.role, 'space|update') && ( + + )} + + )}
- )} -
-
+
+ {t('space:spaceSetting.spaceId')} + {spaceId} + +
+
+ )} + + { + return ( +
+
+
+

{title}

+ {description &&
{description}
} +
+
{children}
+
+
+ ); +}; diff --git a/apps/nextjs-app/src/features/auth/pages/LoginPage.tsx b/apps/nextjs-app/src/features/auth/pages/LoginPage.tsx index 15399d316..ae5e0965e 100644 --- a/apps/nextjs-app/src/features/auth/pages/LoginPage.tsx +++ b/apps/nextjs-app/src/features/auth/pages/LoginPage.tsx @@ -3,13 +3,14 @@ import { Tabs, TabsList, TabsTrigger } from '@teable/ui-lib/shadcn'; import { useRouter } from 'next/router'; import { useTranslation } from 'next-i18next'; import { NextSeo } from 'next-seo'; -import { useState, type FC, useCallback } from 'react'; +import { useState, useCallback } from 'react'; import { authConfig } from '@/features/i18n/auth.config'; import type { ISignForm } from '../components/SignForm'; import { SignForm } from '../components/SignForm'; import { SocialAuth } from '../components/SocialAuth'; -export const LoginPage: FC = () => { +export const LoginPage = (props: { children?: React.ReactNode | React.ReactNode[] }) => { + const { children } = props; const { t } = useTranslation(authConfig.i18nNamespaces); const router = useRouter(); const redirect = router.query.redirect as string; @@ -37,6 +38,7 @@ export const LoginPage: FC = () => {
+ {children}