Skip to content

Commit

Permalink
Merge pull request #71 from bosonprotocol/fix-widgets-example
Browse files Browse the repository at this point in the history
fix: widgets example by adding config id dynamically depending on cur…
  • Loading branch information
albertfolch-redeemeum committed Oct 4, 2023
2 parents 6ba9e07 + 41701e6 commit 53effa2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
},
"scripts": {
"start": "react-app-rewired start",
"dev": "npm run start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-scripts eject",
Expand Down
7 changes: 7 additions & 0 deletions public/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,12 @@
<div>
<button type="button" id="boson-redeem" class="bosonButton" data-redeem-callback-url="http%3A%2F%2Flocalhost%3A3666" data-redeem-callback-headers='%7B%0A%20%20"authorization"%3A%20"Bearer%20eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"%2C%0A%20%20"another-header"%3A%20"%2A%2F%2A"%0A%7D'>Show Redeem (3rd-party backend)</button>
</div>
<script>
const searchParams = new URLSearchParams(window.location.search);
const configId = searchParams.get('configId');
document.querySelectorAll('button').forEach(($button)=>{
$button.setAttribute('data-config-id',configId);
})
</script>
</body>
</html>
9 changes: 8 additions & 1 deletion src/components/Index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import { getEnvConfigs } from "@bosonprotocol/react-kit";

import { CONFIG } from "../config";
import { FinanceDisplay } from "./widgets/finance/FinanceDisplay";
import { RedeemDisplay } from "./widgets/redeem/RedeemDisplay";

export const indexPath = "/";

const envConfigs = getEnvConfigs(CONFIG.envName);

export function Index() {
return (
<div>
<h1>Boson widgets</h1>
<FinanceDisplay />
<RedeemDisplay />
<a href="./example.html">Widget Integration Example</a>
<a href={`./example.html?configId=${envConfigs[0].configId}`}>
Widget Integration Example
</a>
</div>
);
}

0 comments on commit 53effa2

Please sign in to comment.