-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathGetChatInfo.tsx
More file actions
92 lines (83 loc) · 2.42 KB
/
GetChatInfo.tsx
File metadata and controls
92 lines (83 loc) · 2.42 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { useState, useContext } from 'react';
import {
Section,
SectionItem,
CodeFormatter,
SectionButton,
} from '../components/StyledComponents';
import Loader from '../components/Loader';
import { EnvContext } from '../context';
import * as PushAPI from '@pushprotocol/restapi';
import ChatTest from './ChatTest';
const GetChatInfoTest = () => {
const { env } = useContext<any>(EnvContext);
const [isLoading, setLoading] = useState(false);
const [getChatInfoReponse, setGetChatInfoResponse] = useState<any>('');
const [chatId, setChatId] = useState<string>('');
const [address, setAddress] = useState<string>('');
const updateChatId = (e: React.SyntheticEvent<HTMLElement>) => {
setChatId((e.target as HTMLInputElement).value);
};
const updateAddress = (e: React.SyntheticEvent<HTMLElement>) => {
setAddress((e.target as HTMLInputElement).value);
};
const testGetChatInfo = async () => {
try {
setLoading(true);
const response = await PushAPI.chat.getChatInfo({
chatId: chatId,
address: address,
env: env,
});
setGetChatInfoResponse(response);
} catch (e) {
console.error(e);
} finally {
setLoading(false);
}
};
return (
<div>
<ChatTest />
<h2>Get Chat Info Test page</h2>
<Loader show={isLoading} />
<Section>
<div>
<SectionItem style={{ marginTop: 20 }}>
<label>chatId</label>
<input
type="text"
onChange={updateChatId}
value={chatId}
style={{ width: 400, height: 30 }}
/>
</SectionItem>
<SectionItem style={{ marginTop: 20 }}>
<label>address</label>
<input
type="text"
onChange={updateAddress}
value={address}
style={{ width: 400, height: 30 }}
/>
</SectionItem>
<SectionItem style={{ marginTop: 20 }}>
<SectionButton onClick={testGetChatInfo}>
get chat info
</SectionButton>
</SectionItem>
</div>
<SectionItem>
<div>
{getChatInfoReponse ? (
<CodeFormatter>
{JSON.stringify(getChatInfoReponse, null, 4)}
</CodeFormatter>
) : null}
</div>
</SectionItem>
</Section>
</div>
);
};
export default GetChatInfoTest;