Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
finished site
Browse files Browse the repository at this point in the history
  • Loading branch information
XOTlC committed Dec 2, 2023
1 parent 0cecbb8 commit d38d613
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/handlers/PageHandler.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function PageHandler() {
else if (page === 3) return <pages.Theme />
else if (page === 4) return <pages.Database />
else if (page === 5) return <pages.PayPal />
else if (page === 6) return <pages.Welcome />
else if (page === 7) return <pages.Welcome />
else if (page === 6) return <pages.Miscellaneous />
else if (page === 7) return <pages.Finalize />
else throw new Error(`page ${page} does not exist`);
}
1 change: 0 additions & 1 deletion src/pages/Colors/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export default function Theme() {
else if (modal === "accent") config.theme.accentColor = color;
setConfig({ ...config });
}} />

</Modal>}
</>
)
Expand Down
103 changes: 103 additions & 0 deletions src/pages/Finalize/index.jsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<div className={styles.all.bigText}>Are these settings correct?</div>
<div className={styles.all.smallText}>
You can always go back and change these settings at any time.
<details style={{ marginTop: "20px" }}>
<summary>Information</summary>
<ul style={{ textAlign: "left" }}>
<li><b>Server Name:</b> {config.information.name}</li>
<li><b>Welcome Message:</b> {config.information.welcome}</li>
<li><b>Welcome Description:</b> {config.information.description}</li>
<li><b>Pronunciation Enabled:</b> {config.information.pronunciation.enabled ? "Yes" : "No"}</li>
{
config.information.pronunciation.enabled && <li><b>Pronunciation Text:</b> {config.information.pronunciation.text}</li>
}
</ul>
</details>
<details>
<summary>Theme</summary>
<ul style={{ textAlign: "left" }}>
<li><b>Background Color:</b> {config.theme.backgroundColor || "Default"}</li>
<li><b>Background Blooks Enabled:</b> {config.theme.backgroundBlooks ? "Yes" : "No"}</li>
<li><b>Primary Color:</b> {config.theme.primaryColor || "Default"}</li>
<li><b>Secondary Color:</b> {config.theme.secondaryColor || "Default"}</li>
<li><b>Accent Color:</b> {config.theme.accentColor || "Default"}</li>
</ul>
</details>
<details>
<summary>Database</summary>
<ul style={{ textAlign: "left" }}>
<li><b>Database Type:</b> {config.database.type}</li>
{!["", "sqlite"].includes(config.database.type) && <>
<li><b>Database Host:</b> {config.database.host}</li>
<li><b>Database Port:</b> {config.database.port}</li>
<li><b>Database Name:</b> {config.database.name}</li>
<li><b>Database Username:</b> {config.database.username}</li>
<li><b>Database Password Enabled:</b> {config.database.password.enabled ? "Yes" : "No"}</li>
{
config.database.password.enabled && <li><b>Database Password:</b> {config.database.password.value.split("").map(() => "*").join("")}</li>
}
</>}
</ul>
</details>
<details>
<summary>PayPal</summary>
<ul style={{ textAlign: "left" }}>
<li><b>PayPal Enabled:</b> {config.paypal.enabled ? "Yes" : "No"}</li>
{
config.paypal.enabled && <>
<li><b>PayPal Mode:</b> {config.paypal.mode}</li>
<li><b>PayPal Client ID:</b> {config.paypal.clientID}</li>
<li><b>PayPal Client Secret:</b> {config.paypal.clientSecret.split("").map(() => "*").join("")}</li>
</>
}
</ul>
</details>
<details>
<summary>Miscellaneous</summary>
<ul style={{ textAlign: "left" }}>
<li><b>Server Port:</b> {config.miscellaneous.server_port}</li>
{
config.miscellaneous.discord_invite !== "" && <li><b>Discord Invite:</b> {config.miscellaneous.discord_invite}</li>
}
<li><b>Verbose Logging Enabled:</b> {config.miscellaneous.verbose_logging ? "Yes" : "No"}</li>
<li><b>Block Proxies Enabled:</b> {config.miscellaneous.block_proxies ? "Yes" : "No"}</li>
<li><b>Allow Multiple Accounts Enabled:</b> {config.miscellaneous.allow_multiple_accounts ? "Yes" : "No"}</li>
<li><b>Backup Enabled:</b> {config.miscellaneous.backup_enabled ? "Yes" : "No"}</li>
{
config.miscellaneous.backup_enabled && <li><b>Backup Interval:</b> {config.miscellaneous.backup_interval}</li>
}
<li><b>Level Difficulty:</b> {config.miscellaneous.level_difficulty}</li>
</ul>
</details>

<div style={{ marginTop: "20px", width: "50%", marginLeft: "auto", marginRight: "auto" }}>
<Button onClick={convertConfigToFile}>
Download Configuration
</Button>
</div>
</div>
</>
)
}
76 changes: 76 additions & 0 deletions src/pages/Miscellaneous/index.jsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<Container header={{
big: "Miscellaneous",
small: <>
Miscellaneous settings for your Blacket server.
</>
}}>

<Input icon="fas fa-colon" placeholder="Server Port" onChange={(e) => {
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} />

<Input icon="fab fa-discord" placeholder="Discord Invite" onChange={(e) => {
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} />

<Checkbox checked={config.miscellaneous.verbose_logging} onClick={() => {
config.miscellaneous.verbose_logging = !config.miscellaneous.verbose_logging;
setConfig({ ...config });
}}>
Verbose Logging
</Checkbox>

<Checkbox checked={config.miscellaneous.block_proxies} onClick={() => {
config.miscellaneous.block_proxies = !config.miscellaneous.block_proxies;
setConfig({ ...config });
}}>
Block Proxies
</Checkbox>

<Checkbox checked={config.miscellaneous.allow_multiple_accounts} onClick={() => {
config.miscellaneous.allow_multiple_accounts = !config.miscellaneous.allow_multiple_accounts;
setConfig({ ...config });
}}>
Allow Multiple Accounts
</Checkbox>

<Checkbox checked={config.miscellaneous.backup_enabled} onClick={() => {
config.miscellaneous.backup_enabled = !config.miscellaneous.backup_enabled;
setConfig({ ...config });
}}>
Enable Backups
</Checkbox>

{config.miscellaneous.backup_enabled && <>
<Input icon="fas fa-clock" placeholder="Backup Interval" onChange={(e) => {
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} />
</>}

<Input icon="fas fa-turn-up" placeholder="Level Difficulty" onChange={(e) => {
if (isNaN(e.target.value)) return e.preventDefault();
config.miscellaneous.level_difficulty = e.target.value;
setConfig({ ...config });
}} value={config.miscellaneous.level_difficulty} />
</Container>
</>
)
}
6 changes: 5 additions & 1 deletion src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
15 changes: 11 additions & 4 deletions src/stores/config.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
Expand Down Expand Up @@ -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
}
});

Expand Down

0 comments on commit d38d613

Please sign in to comment.