فهرست منبع

fix: refactor not found response handling in share link page

Shun Miyazawa 4 ماه پیش
والد
کامیت
2d36dd9e06
1فایلهای تغییر یافته به همراه17 افزوده شده و 28 حذف شده
  1. 17 28
      apps/app/src/pages/share/[[...path]]/page-data-props.ts

+ 17 - 28
apps/app/src/pages/share/[[...path]]/page-data-props.ts

@@ -15,6 +15,21 @@ let mongooseModel: typeof model;
 let Page: PageModel;
 let Page: PageModel;
 let ShareLink: ShareLinkModel;
 let ShareLink: ShareLinkModel;
 
 
+const notFoundProps: GetServerSidePropsResult<ShareLinkPageStatesProps> = {
+  props: {
+    isNotFound: true,
+    pageWithMeta: {
+      data: null,
+      meta: {
+        isNotFound: true,
+        isForbidden: false,
+      },
+    },
+    isExpired: undefined,
+    shareLink: undefined,
+  },
+};
+
 export const getPageDataForInitial = async (
 export const getPageDataForInitial = async (
   context: GetServerSidePropsContext,
   context: GetServerSidePropsContext,
 ): Promise<GetServerSidePropsResult<ShareLinkPageStatesProps>> => {
 ): Promise<GetServerSidePropsResult<ShareLinkPageStatesProps>> => {
@@ -38,20 +53,7 @@ export const getPageDataForInitial = async (
 
 
   // not found
   // not found
   if (shareLink == null) {
   if (shareLink == null) {
-    return {
-      props: {
-        isNotFound: true,
-        pageWithMeta: {
-          data: null,
-          meta: {
-            isNotFound: true,
-            isForbidden: false,
-          },
-        },
-        isExpired: undefined,
-        shareLink: undefined,
-      },
-    };
+    return notFoundProps;
   }
   }
 
 
   // expired
   // expired
@@ -76,20 +78,7 @@ export const getPageDataForInitial = async (
 
 
   // not found
   // not found
   if (pageWithMeta.data == null) {
   if (pageWithMeta.data == null) {
-    return {
-      props: {
-        isNotFound: true,
-        pageWithMeta: {
-          data: null,
-          meta: {
-            isNotFound: true,
-            isForbidden: false,
-          },
-        },
-        isExpired: undefined,
-        shareLink: undefined,
-      },
-    };
+    return notFoundProps;
   }
   }
 
 
   // Handle existing page
   // Handle existing page