From 5b453c829e96f4505814e77d8a30c274425a29ed Mon Sep 17 00:00:00 2001 From: Aj - Thomas <49837342+ajnart@users.noreply.github.com> Date: Fri, 13 May 2022 02:44:05 +0200 Subject: [PATCH] Delete tryconfig.tsx --- pages/tryconfig.tsx | 101 -------------------------------------------- 1 file changed, 101 deletions(-) delete mode 100644 pages/tryconfig.tsx diff --git a/pages/tryconfig.tsx b/pages/tryconfig.tsx deleted file mode 100644 index 6fb38734c..000000000 --- a/pages/tryconfig.tsx +++ /dev/null @@ -1,101 +0,0 @@ -import { getCookie, setCookies } from 'cookies-next'; -import { GetServerSidePropsContext } from 'next/types'; -import fs from 'fs'; -import path from 'path'; -import { Button, JsonInput, Select, Space } from '@mantine/core'; -import { useEffect, useState } from 'react'; -import { Config } from '../tools/types'; -import { useConfig } from '../tools/state'; - -export async function getServerSideProps({ - req, - res, -}: GetServerSidePropsContext): Promise<{ props: { config: Config } }> { - let cookie = getCookie('config-name', { req, res }); - if (!cookie) { - setCookies('config-name', 'default', { req, res, maxAge: 60 * 60 * 24 * 30 }); - cookie = 'default'; - } - // Check if the config file exists - const configPath = path.join(process.cwd(), 'data/configs', `${cookie}.json`); - if (!fs.existsSync(configPath)) { - return { - props: { - config: { - name: cookie.toString(), - services: [], - settings: { - enabledModules: [], - searchBar: true, - searchUrl: 'https://www.google.com/search?q=', - }, - }, - }, - }; - } - - const config = fs.readFileSync(configPath, 'utf8'); - // Print loaded config - return { - props: { - config: JSON.parse(config), - }, - }; -} - -export default function TryConfig(props: any) { - const { config: initialConfig }: { config: Config } = props; - const { config, loadConfig, setConfig, getConfigs } = useConfig(); - const [value, setValue] = useState(JSON.stringify(config, null, 2)); - const [configList, setConfigList] = useState([] as string[]); - useEffect(() => { - setValue(JSON.stringify(initialConfig, null, 2)); - setConfig(initialConfig); - }, [initialConfig]); - useEffect(() => { - setValue(JSON.stringify(config, null, 2)); - // setConfig(initialConfig); - }, [config]); - - return ( -
-

Try Config

-

- This page is a demo of the config API. -

-

- The config API is a way to store configuration data in a JSON file. -

-

- Cookie loaded was {initialConfig.name} -

- - - - -