Refactor env check.

This commit is contained in:
Mike Cao 2022-10-27 16:42:57 -07:00
parent ba63991a92
commit fc9584eb44
14 changed files with 30 additions and 76 deletions

View file

@ -1,11 +1,3 @@
import Index from './index';
export default Index;
export async function getServerSideProps() {
return {
props: {
pageDisabled: !!process.env.DISABLE_UI,
},
};
}

View file

@ -2,11 +2,13 @@ import React from 'react';
import Layout from 'components/layout/Layout';
import Settings from 'components/pages/Settings';
import useRequireLogin from 'hooks/useRequireLogin';
import useConfig from 'hooks/useConfig';
export default function SettingsPage({ pageDisabled }) {
export default function SettingsPage() {
const { loading } = useRequireLogin();
const { adminDisabled } = useConfig();
if (pageDisabled || loading) {
if (adminDisabled || loading) {
return null;
}
@ -16,11 +18,3 @@ export default function SettingsPage({ pageDisabled }) {
</Layout>
);
}
export async function getServerSideProps() {
return {
props: {
pageDisabled: !!process.env.DISABLE_UI || !!process.env.isAdminDisabled,
},
};
}

View file

@ -1,11 +1,3 @@
import Index from './index';
export default Index;
export async function getServerSideProps() {
return {
props: {
pageDisabled: !!process.env.DISABLE_UI,
},
};
}