import * as appstate from '../appstate.js'; import * as shared from './shared/index.js'; import { css, cssManager, customElement, DeesElement, html, state, type TemplateResult, } from '@design.estate/dees-element'; @customElement('sg-view-settings') export class SgViewSettings extends DeesElement { @state() accessor settingsState: appstate.ISettingsState = { user: null, sessions: [] }; constructor() { super(); const sub = appstate.settingsStatePart .select((s) => s) .subscribe((s) => { this.settingsState = s; }); this.rxSubscriptions.push(sub); } public static styles = [ cssManager.defaultStyles, shared.viewHostCss, ]; async connectedCallback() { super.connectedCallback(); await appstate.settingsStatePart.dispatchAction(appstate.fetchMeAction, null); await appstate.settingsStatePart.dispatchAction(appstate.fetchUserSessionsAction, null); } public render(): TemplateResult { return html` `; } private async saveProfile(detail: { displayName?: string; avatarUrl?: string }) { await appstate.settingsStatePart.dispatchAction(appstate.updateProfileAction, detail); } private async changePassword(detail: { currentPassword: string; newPassword: string }) { await appstate.settingsStatePart.dispatchAction(appstate.changePasswordAction, detail); } private async revokeSession(sessionId: string) { await appstate.settingsStatePart.dispatchAction(appstate.revokeSessionAction, { sessionId }); } private async deleteAccount(password: string) { // TODO: implement delete account action } }