aboutsummaryrefslogtreecommitdiff
path: root/src/debug/Test.tsx
blob: 79f87f4aca1c74460837dfab1287aa5b49767095 (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
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { DocServer } from '../client/DocServer';
import { Doc } from '../new_fields/Doc';

const protoId = "protoDoc";
const delegateId = "delegateDoc";
class Test extends React.Component {
    onCreateClick = () => {
        const proto = new Doc(protoId, true);
        const delegate = Doc.MakeDelegate(proto, delegateId);
    }

    onReadClick = async () => {
        console.log("reading");
        const docs = await DocServer.GetRefFields([delegateId, protoId]);
        console.log("done");
        console.log(docs);
    }

    onDeleteClick = () => {
        DocServer.DeleteDocuments([protoId, delegateId]);
    }

    render() {
        return (
            <div>
                <button onClick={this.onCreateClick}>Create Docs</button>
                <button onClick={this.onReadClick}>Read Docs</button>
                <button onClick={this.onDeleteClick}>Delete Docs</button>
            </div>
        );
    }
}

DocServer.init(window.location.protocol, window.location.hostname, 4321, "test");
ReactDOM.render(
    <Test />,
    document.getElementById('root')
);