import { observable, runInAction, action } from "mobx"; import * as React from "react"; import MainViewModal from "../views/MainViewModal"; import { observer } from "mobx-react"; import { library } from '@fortawesome/fontawesome-svg-core'; import * as fa from '@fortawesome/free-solid-svg-icons'; import { SelectionManager } from "./SelectionManager"; import "./SettingsManager.scss"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { Networking } from "../Network"; import { CurrentUserUtils } from "./CurrentUserUtils"; import { Utils } from "../../Utils"; library.add(fa.faWindowClose); @observer export default class SettingsManager extends React.Component<{}> { public static Instance: SettingsManager; @observable private isOpen = false; @observable private dialogueBoxOpacity = 1; @observable private overlayOpacity = 0.4; @observable private settingsContent = "password"; @observable private errorText = ""; @observable private successText = ""; private curr_password_ref = React.createRef(); private new_password_ref = React.createRef(); private new_confirm_ref = React.createRef(); public open = action(() => { SelectionManager.DeselectAll(); this.isOpen = true; }); public close = action(() => { this.isOpen = false; }); constructor(props: {}) { super(props); SettingsManager.Instance = this; } @action private dispatchRequest = async () => { const curr_pass = this.curr_password_ref.current?.value; const new_pass = this.new_password_ref.current?.value; const new_confirm = this.new_confirm_ref.current?.value; if (!(curr_pass && new_pass && new_confirm)) { this.changeAlertText("Hey, we're missing some fields!", ""); return; } const passwordBundle = { curr_pass, new_pass, new_confirm }; const { error } = await Networking.PostToServer('/internalResetPassword', passwordBundle); if (error) { this.changeAlertText("Uh oh! " + error[0].msg + "...", ""); return; } this.changeAlertText("", "Password successfully updated!"); } @action private changeAlertText = (errortxt: string, successtxt: string) => { this.errorText = errortxt; this.successText = successtxt; } @action onClick = (event: any) => { this.settingsContent = event.currentTarget.value; this.errorText = ""; this.successText = ""; } private get settingsInterface() { return (

settings

{this.settingsContent === "password" ?
{this.errorText ?
{this.errorText}
: undefined} {this.successText ?
{this.successText}
: undefined} forgot password?
: undefined} {this.settingsContent === "data" ?

WARNING:
THIS WILL ERASE ALL YOUR CURRENT DOCUMENTS STORED ON DASH. IF YOU WISH TO PROCEED, CLICK THE BUTTON BELOW.

: undefined}
); } render() { return ( ); } }