/** * @fileoverview Settings Page Component for Rantii * @author retoor * @description Application settings and preferences page * @keywords settings, page, preferences, options, config */ import { BaseComponent } from '../components/base-component.js'; class SettingsPage extends BaseComponent { init() { this.render(); this.bindEvents(); } render() { const isLoggedIn = this.isLoggedIn(); const user = this.getCurrentUser(); this.addClass('page', 'settings-page'); this.setHtml(`

Settings

${isLoggedIn ? `

Account

Logged in as ${user?.username || ''}
` : `

Account

Sign in to access all features

`}

Appearance

About

Rantii - A DevRant Client

Version 1.0.0

Made with care by retoor

Data

`); } bindEvents() { this.on(this, 'click', this.handleClick); } handleClick(e) { const backBtn = e.target.closest('.back-btn'); const loginBtn = e.target.closest('.login-btn'); const logoutBtn = e.target.closest('.logout-btn'); const clearCacheBtn = e.target.closest('.clear-cache-btn'); if (backBtn) { window.history.back(); return; } if (loginBtn) { this.getRouter()?.goToLogin(); return; } if (logoutBtn) { this.logout(); return; } if (clearCacheBtn) { this.clearCache(); } } logout() { this.getAuth()?.logout(); this.render(); this.getApp()?.toast?.success('Signed out successfully'); } clearCache() { const storage = this.getStorage(); if (storage) { storage.clear(); storage.setTheme(this.getTheme()?.getTheme() || 'dark'); } this.getApp()?.toast?.success('Cache cleared'); } } customElements.define('settings-page', SettingsPage); export { SettingsPage };