-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a keypom trial accounts button on the landing page (#137)
* wip * added dropId * added custom VM component for trial acccount generation. * Added conditional rendering for the trial account generator * undo Avatar test changes * cleaned hero a bit
- Loading branch information
1 parent
5797923
commit a2daa53
Showing
5 changed files
with
104 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const { Button, Avatar } = VM.require("buildhub.near/widget/components") || { | ||
Button: () => <></>, | ||
Avatar: () => <></> | ||
}; | ||
|
||
|
||
const TaglineSmall = styled.h2` | ||
max-width: 700px; | ||
text-align: center; | ||
font-size: 1.1rem; | ||
font-style: normal; | ||
font-weight: 400; | ||
line-height: 130%; /* 57.6px */ | ||
margin: 0; | ||
text-wrap: balance; | ||
span.muted { | ||
color: rgba(255, 255, 255, 0.7); | ||
} | ||
@media screen and (max-width: 768px) { | ||
font-size: 1rem; | ||
} | ||
`; | ||
|
||
const { networkId, accountId } = context; | ||
// Check if the network is testnet | ||
const isTestnet = networkId === 'testnet'; | ||
|
||
const { currentGateway } = props; | ||
return ( | ||
<> | ||
{currentGateway && !isTestnet && accountId === null ? ( | ||
<> | ||
<TrialAccountGenerator | ||
trigger={({ onClick }) => ( | ||
<Button | ||
variant="primary" | ||
onClick={onClick}>Create Trial Account</Button> | ||
)} | ||
/> | ||
<TaglineSmall>Try out the builders gateway with a trial account. <br/>No crypto, no passphrase required.</TaglineSmall> | ||
</> | ||
) : null} | ||
</> | ||
); | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
export const TrialAccountGenerator = ({ trigger }) => { | ||
async function getTrialAccount() { | ||
try { | ||
const response = await fetch( | ||
`https://harmonicdevapim.azure-api.net/bd/KeyPomMain?dropId=1706695349746`, | ||
{ method: "POST" } | ||
); | ||
if (!response.ok) { | ||
// Handle HTTP errors | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
const body = await response.json(); // Correctly parse the JSON response body | ||
|
||
//To-do | ||
// Do I really need to get the trial account path like this? | ||
// It does help me make localhost work for local testing. Need to change to trial URL in app.js to make it work though. | ||
const path = body.url.split("https://www.nearbuilders.org")[1]; | ||
|
||
//This does not work right now because of keypom selector is implemented. | ||
//window.location.href = `${window.location.origin}${path}`; | ||
|
||
window.open(`${window.location.origin}${path}`, '_self'); | ||
window.location.reload(); | ||
} catch (error) { | ||
console.error("Failed to get trial account:", error); | ||
} | ||
} | ||
|
||
// Attach the getTrialAccount function to the onClick event | ||
return trigger({ onClick: getTrialAccount }); | ||
}; | ||
|
||
|
||
// Future TO-DO | ||
//1. Log on-chain errors (500) on the console for better debugging. | ||
//2. Log 429, too many requests. | ||
|
||
|