diff --git a/src/handlers/PageHandler.jsx b/src/handlers/PageHandler.jsx index 1ab4055..2ee536a 100644 --- a/src/handlers/PageHandler.jsx +++ b/src/handlers/PageHandler.jsx @@ -10,7 +10,7 @@ export default function PageHandler() { else if (page === 3) return else if (page === 4) return else if (page === 5) return - else if (page === 6) return - else if (page === 7) return + else if (page === 6) return + else if (page === 7) return else throw new Error(`page ${page} does not exist`); } \ No newline at end of file diff --git a/src/pages/Colors/index.jsx b/src/pages/Colors/index.jsx index b3df09e..ebd11f5 100644 --- a/src/pages/Colors/index.jsx +++ b/src/pages/Colors/index.jsx @@ -81,7 +81,6 @@ export default function Theme() { else if (modal === "accent") config.theme.accentColor = color; setConfig({ ...config }); }} /> - } ) diff --git a/src/pages/Finalize/index.jsx b/src/pages/Finalize/index.jsx new file mode 100644 index 0000000..67c4c08 --- /dev/null +++ b/src/pages/Finalize/index.jsx @@ -0,0 +1,103 @@ +import { useContext } from "react"; +import { ConfigContext } from "@stores/config"; +import Button from "@components/Button"; +import styles from "@styles"; + +export default function Finalize() { + const { config } = useContext(ConfigContext); + + const convertConfigToFile = () => { + const configStore = { ...config }; + delete configStore.canGoForward; + const blob = new Blob([JSON.stringify(configStore, null, 4)], { type: "application/json" }); + const url = URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = url; + a.download = "config.json"; + a.click(); + URL.revokeObjectURL(url); + } + + return ( + <> +
Are these settings correct?
+
+ You can always go back and change these settings at any time. +
+ Information +
    +
  • Server Name: {config.information.name}
  • +
  • Welcome Message: {config.information.welcome}
  • +
  • Welcome Description: {config.information.description}
  • +
  • Pronunciation Enabled: {config.information.pronunciation.enabled ? "Yes" : "No"}
  • + { + config.information.pronunciation.enabled &&
  • Pronunciation Text: {config.information.pronunciation.text}
  • + } +
+
+
+ Theme +
    +
  • Background Color: {config.theme.backgroundColor || "Default"}
  • +
  • Background Blooks Enabled: {config.theme.backgroundBlooks ? "Yes" : "No"}
  • +
  • Primary Color: {config.theme.primaryColor || "Default"}
  • +
  • Secondary Color: {config.theme.secondaryColor || "Default"}
  • +
  • Accent Color: {config.theme.accentColor || "Default"}
  • +
+
+
+ Database +
    +
  • Database Type: {config.database.type}
  • + {!["", "sqlite"].includes(config.database.type) && <> +
  • Database Host: {config.database.host}
  • +
  • Database Port: {config.database.port}
  • +
  • Database Name: {config.database.name}
  • +
  • Database Username: {config.database.username}
  • +
  • Database Password Enabled: {config.database.password.enabled ? "Yes" : "No"}
  • + { + config.database.password.enabled &&
  • Database Password: {config.database.password.value.split("").map(() => "*").join("")}
  • + } + } +
+
+
+ PayPal +
    +
  • PayPal Enabled: {config.paypal.enabled ? "Yes" : "No"}
  • + { + config.paypal.enabled && <> +
  • PayPal Mode: {config.paypal.mode}
  • +
  • PayPal Client ID: {config.paypal.clientID}
  • +
  • PayPal Client Secret: {config.paypal.clientSecret.split("").map(() => "*").join("")}
  • + + } +
+
+
+ Miscellaneous +
    +
  • Server Port: {config.miscellaneous.server_port}
  • + { + config.miscellaneous.discord_invite !== "" &&
  • Discord Invite: {config.miscellaneous.discord_invite}
  • + } +
  • Verbose Logging Enabled: {config.miscellaneous.verbose_logging ? "Yes" : "No"}
  • +
  • Block Proxies Enabled: {config.miscellaneous.block_proxies ? "Yes" : "No"}
  • +
  • Allow Multiple Accounts Enabled: {config.miscellaneous.allow_multiple_accounts ? "Yes" : "No"}
  • +
  • Backup Enabled: {config.miscellaneous.backup_enabled ? "Yes" : "No"}
  • + { + config.miscellaneous.backup_enabled &&
  • Backup Interval: {config.miscellaneous.backup_interval}
  • + } +
  • Level Difficulty: {config.miscellaneous.level_difficulty}
  • +
+
+ +
+ +
+
+ + ) +} \ No newline at end of file diff --git a/src/pages/Miscellaneous/index.jsx b/src/pages/Miscellaneous/index.jsx new file mode 100644 index 0000000..9b5e2ed --- /dev/null +++ b/src/pages/Miscellaneous/index.jsx @@ -0,0 +1,76 @@ +import { useContext } from "react"; +import { ConfigContext } from "@stores/config"; +import Container from "@components/Container"; +import Select from "@components/Select"; +import Input from "@components/Input"; +import Checkbox from "@components/Checkbox"; + +export default function Miscellaneous() { + const { config, setConfig } = useContext(ConfigContext); + + return ( + <> + + Miscellaneous settings for your Blacket server. + + }}> + + { + if (e.target.value.match(/[^0-9]/gi) || e.target.value > 65535 || e.target.value.startsWith("0")) return e.preventDefault(); + config.miscellaneous.server_port = e.target.value; + setConfig({ ...config }); + }} value={config.miscellaneous.server_port} /> + + { + if (e.target.value.match(/[^a-z0-9]/gi)) return e.preventDefault(); + config.miscellaneous.discord_invite = e.target.value; + setConfig({ ...config }); + }} value={config.miscellaneous.discord_invite} /> + + { + config.miscellaneous.verbose_logging = !config.miscellaneous.verbose_logging; + setConfig({ ...config }); + }}> + Verbose Logging + + + { + config.miscellaneous.block_proxies = !config.miscellaneous.block_proxies; + setConfig({ ...config }); + }}> + Block Proxies + + + { + config.miscellaneous.allow_multiple_accounts = !config.miscellaneous.allow_multiple_accounts; + setConfig({ ...config }); + }}> + Allow Multiple Accounts + + + { + config.miscellaneous.backup_enabled = !config.miscellaneous.backup_enabled; + setConfig({ ...config }); + }}> + Enable Backups + + + {config.miscellaneous.backup_enabled && <> + { + if (e.target.value.match(/[^0-9]/gi) || e.target.value.startsWith("0")) return e.preventDefault(); + config.miscellaneous.backup_interval = e.target.value; + setConfig({ ...config }); + }} value={config.miscellaneous.backup_interval} /> + } + + { + if (isNaN(e.target.value)) return e.preventDefault(); + config.miscellaneous.level_difficulty = e.target.value; + setConfig({ ...config }); + }} value={config.miscellaneous.level_difficulty} /> + + + ) +} \ No newline at end of file diff --git a/src/pages/index.js b/src/pages/index.js index ef94e74..b8d33b1 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -3,11 +3,15 @@ import Information from "@pages/Information"; import Theme from "@pages/Colors"; import Database from "@pages/Database"; import PayPal from "@pages/PayPal"; +import Miscellaneous from "@pages/Miscellaneous"; +import Finalize from "@pages/Finalize"; export default { Welcome, Information, Theme, Database, - PayPal + PayPal, + Miscellaneous, + Finalize } \ No newline at end of file diff --git a/src/stores/config.jsx b/src/stores/config.jsx index a4a3a9f..a816274 100644 --- a/src/stores/config.jsx +++ b/src/stores/config.jsx @@ -3,10 +3,7 @@ import { createContext, useEffect, useState } from "react"; export const ConfigContext = createContext(); export function ConfigProvider({ children }) { - /*const [config, setConfig] = useState(JSON.parse(localStorage.getItem("config")) || { - canGoForward: true - });*/ - const [config, setConfig] = useState({ + const [config, setConfig] = useState(JSON.parse(localStorage.getItem("config")) || { canGoForward: true, information: { name: "", @@ -40,6 +37,16 @@ export function ConfigProvider({ children }) { mode: "sandbox", clientID: "", clientSecret: "" + }, + miscellaneous: { + server_port: 3000, + discord_invite: "", + verbose_logging: false, + block_proxies: false, + allow_multiple_accounts: false, + backup_enabled: false, + backup_interval: 288000000, + level_difficulty: 0.75 } });