From 1325abe31d660ea0a3e2fb3bd13ffa107833175d Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Wed, 4 Oct 2023 19:22:26 -0700 Subject: [PATCH] Updated validations for websites. --- src/app/(main)/settings/websites/[id]/page.js | 12 +++--------- src/pages/api/websites/[id]/index.ts | 6 +++--- src/pages/api/websites/index.ts | 2 +- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/app/(main)/settings/websites/[id]/page.js b/src/app/(main)/settings/websites/[id]/page.js index bdf3b076fe..37324659ac 100644 --- a/src/app/(main)/settings/websites/[id]/page.js +++ b/src/app/(main)/settings/websites/[id]/page.js @@ -1,15 +1,9 @@ import WebsiteSettings from '../WebsiteSettings'; -async function getDisabled() { - return !!process.env.CLOUD_MODE; -} - -export default async function WebsiteSettingsPage({ params }) { - const disabled = await getDisabled(); - - if (!params.id || disabled) { +export default async function WebsiteSettingsPage({ params: { id } }) { + if (process.env.cloudMode) { return null; } - return ; + return ; } diff --git a/src/pages/api/websites/[id]/index.ts b/src/pages/api/websites/[id]/index.ts index 084d0fea49..02e317868e 100644 --- a/src/pages/api/websites/[id]/index.ts +++ b/src/pages/api/websites/[id]/index.ts @@ -24,9 +24,9 @@ const schema = { }), POST: yup.object().shape({ id: yup.string().uuid().required(), - name: yup.string().required(), - domain: yup.string().required(), - shareId: yup.string().matches(SHARE_ID_REGEX, { excludeEmptyString: true }), + name: yup.string(), + domain: yup.string(), + shareId: yup.string().matches(SHARE_ID_REGEX, { excludeEmptyString: true }).nullable(), }), }; diff --git a/src/pages/api/websites/index.ts b/src/pages/api/websites/index.ts index d28e49e2d8..b30681cfc4 100644 --- a/src/pages/api/websites/index.ts +++ b/src/pages/api/websites/index.ts @@ -24,7 +24,7 @@ const schema = { POST: yup.object().shape({ name: yup.string().max(100).required(), domain: yup.string().max(500).required(), - shareId: yup.string().max(50), + shareId: yup.string().max(50).nullable(), }), };