-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Merge branch 'main' into deployment
- Loading branch information
Showing
232 changed files
with
16,740 additions
and
1,080 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -288,3 +288,4 @@ buck-out/ | |
packages/restapi/yarn.lock | ||
yarn.lock | ||
*.env | ||
**/.next |
106 changes: 106 additions & 0 deletions
106
packages/demoreact/src/app/ChatTest/AddAdminsToGroupTest.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { useState, useContext } from 'react'; | ||
import { | ||
Section, | ||
SectionItem, | ||
CodeFormatter, | ||
SectionButton, | ||
} from '../components/StyledComponents'; | ||
import Loader from '../components/Loader'; | ||
import { Web3Context, EnvContext } from '../context'; | ||
import * as PushAPI from '@pushprotocol/restapi'; | ||
import ChatTest from './ChatTest'; | ||
|
||
const AddAdminsToGroupTest = () => { | ||
const { account: acc, library } = useContext<any>(Web3Context); | ||
const { env } = useContext<any>(EnvContext); | ||
const [isLoading, setLoading] = useState(false); | ||
const [chatId, setChatId] = useState<string>(''); | ||
const [memberAddress, setMemberAddress] = useState<string>(''); | ||
const [sendResponse, setSendResponse] = useState<any>(''); | ||
const [account, setAccount] = useState<string>(acc); | ||
|
||
const updateChatId = (e: React.SyntheticEvent<HTMLElement>) => { | ||
setChatId((e.target as HTMLInputElement).value); | ||
}; | ||
|
||
const updateMemberId = (e: React.SyntheticEvent<HTMLElement>) => { | ||
setMemberAddress((e.target as HTMLInputElement).value); | ||
}; | ||
|
||
const updateAccount = (e: React.SyntheticEvent<HTMLElement>) => { | ||
setAccount((e.target as HTMLInputElement).value); | ||
}; | ||
|
||
const addAdminsToGroupTest = async () => { | ||
try { | ||
setLoading(true); | ||
const librarySigner = await library.getSigner(); | ||
const response = await PushAPI.chat.addAdmins({ | ||
chatId: chatId, | ||
admins: memberAddress ? memberAddress.split(',') : [], | ||
env, | ||
account: account, | ||
signer: librarySigner, | ||
}); | ||
setSendResponse(response); | ||
|
||
} catch (e) { | ||
console.error(e); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
<ChatTest /> | ||
<h2>Add Admins to Group Test page</h2> | ||
|
||
<Loader show={isLoading} /> | ||
|
||
<Section> | ||
<SectionItem> | ||
<SectionButton onClick={addAdminsToGroupTest}>Add Admins to Group</SectionButton> | ||
</SectionItem> | ||
<SectionItem> | ||
<label>chatId</label> | ||
<input | ||
type="text" | ||
onChange={updateChatId} | ||
value={chatId} | ||
style={{ width: 400, height: 30 }} | ||
/> | ||
</SectionItem> | ||
<SectionItem> | ||
<label>members (comma separated)</label> | ||
<input | ||
type="text" | ||
onChange={updateMemberId} | ||
value={memberAddress} | ||
style={{ width: 400, height: 30 }} | ||
/> | ||
</SectionItem> | ||
<SectionItem style={{ marginTop: 20 }}> | ||
<label>Account</label> | ||
<input | ||
type="text" | ||
onChange={updateAccount} | ||
value={account} | ||
style={{ width: 400, height: 30 }} | ||
/> | ||
</SectionItem> | ||
<SectionItem> | ||
<div> | ||
{sendResponse ? ( | ||
<CodeFormatter> | ||
{JSON.stringify(sendResponse, null, 4)} | ||
</CodeFormatter> | ||
) : null} | ||
</div> | ||
</SectionItem> | ||
</Section> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AddAdminsToGroupTest; |
108 changes: 108 additions & 0 deletions
108
packages/demoreact/src/app/ChatTest/AddMembersToGroupTest.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { useState, useContext } from 'react'; | ||
import { | ||
Section, | ||
SectionItem, | ||
CodeFormatter, | ||
SectionButton, | ||
} from '../components/StyledComponents'; | ||
import Loader from '../components/Loader'; | ||
import { Web3Context, EnvContext } from '../context'; | ||
import * as PushAPI from '@pushprotocol/restapi'; | ||
import ChatTest from './ChatTest'; | ||
|
||
const AddMembersToGroupTest = () => { | ||
const { account: acc, library } = useContext<any>(Web3Context); | ||
const { env } = useContext<any>(EnvContext); | ||
const [isLoading, setLoading] = useState(false); | ||
const [chatId, setChatId] = useState<string>(''); | ||
const [memberAddress, setMemberAddress] = useState<string>(''); | ||
const [sendResponse, setSendResponse] = useState<any>(''); | ||
const [account, setAccount] = useState<string>(acc); | ||
|
||
const updateChatId = (e: React.SyntheticEvent<HTMLElement>) => { | ||
setChatId((e.target as HTMLInputElement).value); | ||
}; | ||
|
||
const updateMemberId = (e: React.SyntheticEvent<HTMLElement>) => { | ||
setMemberAddress((e.target as HTMLInputElement).value); | ||
}; | ||
|
||
const updateAccount = (e: React.SyntheticEvent<HTMLElement>) => { | ||
setAccount((e.target as HTMLInputElement).value); | ||
}; | ||
|
||
const addMembersToGroupTest = async () => { | ||
try { | ||
setLoading(true); | ||
const librarySigner = await library.getSigner(); | ||
const response = await PushAPI.chat.addMembers({ | ||
chatId: chatId, | ||
members: memberAddress ? memberAddress.split(',') : [], | ||
env, | ||
account: account, | ||
signer: librarySigner, | ||
}); | ||
setSendResponse(response); | ||
|
||
} catch (e) { | ||
console.error(e); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
|
||
|
||
return ( | ||
<div> | ||
<ChatTest /> | ||
<h2>Add Member to Group Test page</h2> | ||
|
||
<Loader show={isLoading} /> | ||
|
||
<Section> | ||
<SectionItem> | ||
<SectionButton onClick={addMembersToGroupTest}>Add Member to Group</SectionButton> | ||
</SectionItem> | ||
<SectionItem> | ||
<label>chatId</label> | ||
<input | ||
type="text" | ||
onChange={updateChatId} | ||
value={chatId} | ||
style={{ width: 400, height: 30 }} | ||
/> | ||
</SectionItem> | ||
<SectionItem> | ||
<label>members (comma separated)</label> | ||
<input | ||
type="text" | ||
onChange={updateMemberId} | ||
value={memberAddress} | ||
style={{ width: 400, height: 30 }} | ||
/> | ||
</SectionItem> | ||
<SectionItem style={{ marginTop: 20 }}> | ||
<label>Account</label> | ||
<input | ||
type="text" | ||
onChange={updateAccount} | ||
value={account} | ||
style={{ width: 400, height: 30 }} | ||
/> | ||
</SectionItem> | ||
<SectionItem> | ||
<div> | ||
{sendResponse ? ( | ||
<CodeFormatter> | ||
{JSON.stringify(sendResponse, null, 4)} | ||
</CodeFormatter> | ||
) : null} | ||
</div> | ||
</SectionItem> | ||
</Section> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AddMembersToGroupTest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
packages/demoreact/src/app/ChatTest/RemoveAdminsFromGroupTest.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { useState, useContext } from 'react'; | ||
import { | ||
Section, | ||
SectionItem, | ||
CodeFormatter, | ||
SectionButton, | ||
} from '../components/StyledComponents'; | ||
import Loader from '../components/Loader'; | ||
import { Web3Context, EnvContext } from '../context'; | ||
import * as PushAPI from '@pushprotocol/restapi'; | ||
import ChatTest from './ChatTest'; | ||
|
||
const RemoveAdminsFromGroupTest = () => { | ||
const { account: acc, library } = useContext<any>(Web3Context); | ||
const { env } = useContext<any>(EnvContext); | ||
const [isLoading, setLoading] = useState(false); | ||
const [chatId, setChatId] = useState<string>(''); | ||
const [memberAddress, setMemberAddress] = useState<string>(''); | ||
const [sendResponse, setSendResponse] = useState<any>(''); | ||
const [account, setAccount] = useState<string>(acc); | ||
|
||
const updateChatId = (e: React.SyntheticEvent<HTMLElement>) => { | ||
setChatId((e.target as HTMLInputElement).value); | ||
}; | ||
|
||
const updateMemberId = (e: React.SyntheticEvent<HTMLElement>) => { | ||
setMemberAddress((e.target as HTMLInputElement).value); | ||
}; | ||
|
||
const updateAccount = (e: React.SyntheticEvent<HTMLElement>) => { | ||
setAccount((e.target as HTMLInputElement).value); | ||
}; | ||
|
||
const removeAdminsFromGroupTest = async () => { | ||
try { | ||
setLoading(true); | ||
const librarySigner = await library.getSigner(); | ||
const response = await PushAPI.chat.removeAdmins({ | ||
chatId: chatId, | ||
admins: memberAddress ? memberAddress.split(',') : [], | ||
env, | ||
account: account, | ||
signer: librarySigner, | ||
}); | ||
setSendResponse(response); | ||
|
||
} catch (e) { | ||
console.error(e); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
<ChatTest /> | ||
<h2>Remove Admins from Group Test page</h2> | ||
|
||
<Loader show={isLoading} /> | ||
|
||
<Section> | ||
<SectionItem> | ||
<SectionButton onClick={removeAdminsFromGroupTest}>Remove Admins from Group</SectionButton> | ||
</SectionItem> | ||
<SectionItem> | ||
<label>chatId</label> | ||
<input | ||
type="text" | ||
onChange={updateChatId} | ||
value={chatId} | ||
style={{ width: 400, height: 30 }} | ||
/> | ||
</SectionItem> | ||
<SectionItem> | ||
<label>members (comma separated)</label> | ||
<input | ||
type="text" | ||
onChange={updateMemberId} | ||
value={memberAddress} | ||
style={{ width: 400, height: 30 }} | ||
/> | ||
</SectionItem> | ||
<SectionItem style={{ marginTop: 20 }}> | ||
<label>Account</label> | ||
<input | ||
type="text" | ||
onChange={updateAccount} | ||
value={account} | ||
style={{ width: 400, height: 30 }} | ||
/> | ||
</SectionItem> | ||
<SectionItem> | ||
<div> | ||
{sendResponse ? ( | ||
<CodeFormatter> | ||
{JSON.stringify(sendResponse, null, 4)} | ||
</CodeFormatter> | ||
) : null} | ||
</div> | ||
</SectionItem> | ||
</Section> | ||
</div> | ||
); | ||
}; | ||
|
||
export default RemoveAdminsFromGroupTest; |
Oops, something went wrong.