summary refs log tree commit diff
path: root/v2/screen/login.ts
blob: 525127bb119037feb504ec7cf0ede99b23d9f6ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { ElemType } from "../screenbuilder.ts";
import { Screen } from "../screen.ts";
import * as client from "../client.ts"
import { build } from "../screenbuilder.ts";
import HomeScreen from "./home.ts";

export default {
    elements: [
        {
            type: ElemType.TextElem,
            id: 'username-label',
            data: ["Username: \n"]
        },
        {
            type: ElemType.InputElem,
            id: 'username-input',
            data: [false]
        },
        {
            type: ElemType.TextElem,
            id: 'password-label',
            data: ["Password: \n"]
        },
        {
            type: ElemType.InputElem,
            id: 'password-input',
            data: [true]
        },
        {
            type: ElemType.ButtonElem,
            id: 'done-btn',
            data: ["Done", async function (this: Screen) {
                this.off()
                this.logs.push(`clicked button`)
                console.clear()
                console.log("logging in...")
                //@ts-ignore
                await client.login(this.elements.get("username-input").value, this.elements.get("password-input").value)
                build(HomeScreen);
                client
            }]
        }
    ],
    focus: "username-input",
    name: 'login'
}