Skip to content

Commit

Permalink
Updated validations for websites.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecao committed Oct 5, 2023
1 parent 5c933d1 commit 1325abe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
12 changes: 3 additions & 9 deletions src/app/(main)/settings/websites/[id]/page.js
Original file line number Diff line number Diff line change
@@ -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 <WebsiteSettings websiteId={params.id} />;
return <WebsiteSettings websiteId={id} />;
}
6 changes: 3 additions & 3 deletions src/pages/api/websites/[id]/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}),
};

Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/websites/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}),
};

Expand Down

0 comments on commit 1325abe

Please sign in to comment.