-
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
26 changed files
with
591 additions
and
202 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
packages/examples/sdk-frontend-react/src/app/SpaceTest/GetSpaceAccessTest.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,86 @@ | ||
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'; | ||
|
||
const GetSpaceAccessTest = () => { | ||
const { env } = useContext<any>(EnvContext); | ||
const [isLoading, setLoading] = useState(false); | ||
const [spaceId, setSpaceId] = useState<string>(''); | ||
const [did, setDid] = useState<string>(''); | ||
const [sendResponse, setSendResponse] = useState<any>(''); | ||
|
||
const updateSpaceId = (e: React.SyntheticEvent<HTMLElement>) => { | ||
setSpaceId((e.target as HTMLInputElement).value); | ||
}; | ||
|
||
const updateDid = (e: React.SyntheticEvent<HTMLElement>) => { | ||
setDid((e.target as HTMLInputElement).value); | ||
}; | ||
|
||
const testGetSpaceAccess = async () => { | ||
try { | ||
setLoading(true); | ||
|
||
const response = await PushAPI.space.getAccess({ | ||
spaceId: spaceId, | ||
did: did, | ||
env, | ||
}); | ||
setSendResponse(response); | ||
} catch (e) { | ||
console.error(e); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
<h2>Get Space Access Test Page</h2> | ||
|
||
<Loader show={isLoading} /> | ||
|
||
<Section> | ||
<SectionItem> | ||
<SectionButton onClick={testGetSpaceAccess}>get space access</SectionButton> | ||
</SectionItem> | ||
<SectionItem> | ||
<label>spaceId</label> | ||
<input | ||
type="text" | ||
onChange={updateSpaceId} | ||
value={spaceId} | ||
style={{ width: 400, height: 30 }} | ||
/> | ||
</SectionItem> | ||
<SectionItem> | ||
<label>did</label> | ||
<input | ||
type="text" | ||
onChange={updateDid} | ||
value={did} | ||
style={{ width: 400, height: 30 }} | ||
/> | ||
</SectionItem> | ||
<SectionItem> | ||
<div> | ||
{sendResponse ? ( | ||
<CodeFormatter> | ||
{JSON.stringify(sendResponse, null, 4)} | ||
</CodeFormatter> | ||
) : null} | ||
</div> | ||
</SectionItem> | ||
</Section> | ||
</div> | ||
); | ||
}; | ||
|
||
export default GetSpaceAccessTest; |
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
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
Oops, something went wrong.