diff --git a/src/components/settings/index.tsx b/src/components/settings/index.tsx
new file mode 100644
index 0000000..f2da56a
--- /dev/null
+++ b/src/components/settings/index.tsx
@@ -0,0 +1,109 @@
+import React, { useEffect, useRef, useState } from "react";
+import { AuthState, useAuthStore } from "../../store/auth";
+
+import "./settings.scss";
+
+function Settings() {
+ const auth = useAuthStore();
+ const [load, setLoad] = useState(false);
+
+ useEffect(() => {
+ if (auth.token === null) {
+ document.location.href = "/";
+ return;
+ }
+
+ auth.checkToken(auth.token).then((ok) => {
+ if (!ok) {
+ document.location.href = "/";
+ return;
+ }
+
+ setLoad(true);
+ });
+ }, [auth, load]);
+
+ if (!load) {
+ return (
+ <>>
+ );
+ }
+
+ return (
+
+
General
+
+
+
+ );
+}
+
+function SettingBox({ children }: { children: React.ReactNode }) {
+ return (
+
+ {children}
+
+ );
+}
+
+function ChangePassword({ auth }: { auth: AuthState }) {
+ const orRef = useRef
(null);
+ const pwRef = useRef(null);
+ const ckRef = useRef(null);
+
+ return (
+
+ Change Password
+ If you change your password, you will need to log in again.
+
+
+
+ );
+}
+
+export default Settings;
diff --git a/src/components/settings/settings.scss b/src/components/settings/settings.scss
new file mode 100644
index 0000000..083548d
--- /dev/null
+++ b/src/components/settings/settings.scss
@@ -0,0 +1,41 @@
+.ka-settings {
+ width: 100%;
+ height: 100%;
+ display: flex;
+ margin: 1rem 0;
+ flex-direction: column;
+
+ .setting-box {
+ width: 100%;
+ display: flex;
+ margin: 2rem 0;
+ flex-direction: column;
+
+ input {
+ background-color: var(--nav-color);
+ }
+
+ .box-row {
+ width: 100%;
+ display: flex;
+ margin: 0 2rem;
+ flex-direction: row;
+ }
+
+ .box-col {
+ display: flex;
+ min-width: 300px;
+ flex-direction: column;
+ }
+
+ .line {
+ margin-bottom: 15px;
+ }
+
+ #pw-change {
+ input {
+ margin-bottom: 10px;
+ }
+ }
+ }
+}
diff --git a/src/store/auth.ts b/src/store/auth.ts
index f5753e2..27f6424 100644
--- a/src/store/auth.ts
+++ b/src/store/auth.ts
@@ -7,10 +7,11 @@ export interface AuthData {
}
-interface AuthState {
+export interface AuthState {
token: string | null;
setToken: (token: string) => void;
clearToken: () => void;
+ checkToken: (token: string) => Promise;
}
export const useAuthStore = create()(
@@ -19,6 +20,15 @@ export const useAuthStore = create()(
token: null,
setToken: (token) => set({ token }),
clearToken: () => set({ token: null }),
+ checkToken: async (token: string) => {
+ const res = await fetch("/api/auth/check", {
+ headers: {
+ "Authorization": `Basic ${token}`
+ }
+ });
+
+ return res.status === 200;
+ }
}),
{
name: "auth-storage"