Settings
Manage your instance settings
Profile Settings
Manage your profile settings
Password Settings
Manage your password
"use client"; import Sidebar from "@/components/Sidebar"; import ErrorToast from "@/components/Error"; import { useState } from "react"; import axios from "axios"; import Cookies from "js-cookie"; interface SettingsPageProps { username: string; name: string; email: string; } export default function SettingsPage({ username, name, email }: SettingsPageProps) { const [profileUsername, setProfileUsername] = useState(username); const [profileName, setProfileName] = useState(name); const [profileEmail, setProfileEmail] = useState(email); const [oldPassword, setOldPassword] = useState(""); const [password, setPassword] = useState(""); const [passwordConfirm, setPasswordConfirm] = useState(""); const [error, setError] = useState(""); const saveProfile = async () => { try { const response = await axios.post("/api/user/change/profile", { token: Cookies.get("token"), username: profileUsername, name: profileName, email: profileEmail }); if (response.data.message !== "Profile updated successfully") { setError("Failed to update profile"); } else { window.location.reload(); } } catch (error: any) { setError(error.response.data.error); } } const savePassword = async () => { if (password !== passwordConfirm) { setError("Passwords do not match"); return; } if (oldPassword === password) { setError("Old password and new password cannot be the same"); return; } try { const response = await axios.post("/api/user/change/password", { token: Cookies.get("token"), old_password: oldPassword, password: password }); if (response.data.message !== "Password updated successfully") { setError("Failed to update password"); } } catch (error: any) { setError(error.response.data.error); } } return (
Manage your instance settings
Manage your profile settings
Manage your password