Browse Source

imprv AdminNotFoundPage rendering

kaori 3 years ago
parent
commit
5257b36c8f

+ 2 - 2
packages/app/src/components/Layout/AdminLayout.tsx

@@ -12,7 +12,7 @@ const AdminNotFoundPage = dynamic(() => import('../Admin/NotFoundPage').then(mod
 
 
 
 
 type Props = {
 type Props = {
-  title?: string
+  title: string
   /**
   /**
    * Set the current option of AdminNavigation
    * Set the current option of AdminNavigation
    * Expected it is in ["home", "app", "security", "markdown", "customize", "importer", "export",
    * Expected it is in ["home", "app", "security", "markdown", "customize", "importer", "export",
@@ -45,7 +45,7 @@ const AdminLayout = ({
                 <AdminNavigation selected={selectedNavOpt} />
                 <AdminNavigation selected={selectedNavOpt} />
               </div>
               </div>
               <div className="col-lg-9">
               <div className="col-lg-9">
-                {title != null ? children : <AdminNotFoundPage />}
+                {children || <AdminNotFoundPage />}
               </div>
               </div>
             </div>
             </div>
           </div>
           </div>

+ 3 - 4
packages/app/src/pages/admin/[[...path]].page.tsx

@@ -176,14 +176,13 @@ const AdminMarkdownSettingsPage: NextPage<Props> = (props: Props) => {
     },
     },
   };
   };
 
 
-  const getTargetPageToRender = (pagesMap, keys) => {
+  const getTargetPageToRender = (pagesMap, keys): {title: string, component: JSX.Element} => {
     return keys.reduce((pagesMap, key) => {
     return keys.reduce((pagesMap, key) => {
       return pagesMap[key];
       return pagesMap[key];
     }, pagesMap);
     }, pagesMap);
   };
   };
 
 
-  const targetPage: {title: string, component: JSX.Element} = getTargetPageToRender(adminPagesMap, pagePathKeys);
-  const title = targetPage.title;
+  const targetPage = getTargetPageToRender(adminPagesMap, pagePathKeys);
 
 
   useCurrentUser(props.currentUser != null ? JSON.parse(props.currentUser) : null);
   useCurrentUser(props.currentUser != null ? JSON.parse(props.currentUser) : null);
   useIsMailerSetup(props.isMailerSetup);
   useIsMailerSetup(props.isMailerSetup);
@@ -260,7 +259,7 @@ const AdminMarkdownSettingsPage: NextPage<Props> = (props: Props) => {
 
 
   return (
   return (
     <Provider inject={[...injectableContainers, ...adminSecurityContainers]}>
     <Provider inject={[...injectableContainers, ...adminSecurityContainers]}>
-      <AdminLayout title={title} selectedNavOpt={firstPath}>
+      <AdminLayout title={targetPage.title} selectedNavOpt={firstPath}>
         {targetPage.component}
         {targetPage.component}
       </AdminLayout>
       </AdminLayout>
     </Provider>
     </Provider>