diff options
| author | Max Nanis | 2025-05-28 04:41:37 +0100 |
|---|---|---|
| committer | Max Nanis | 2025-05-28 04:41:37 +0100 |
| commit | 8caa77413ea372e5cbd2980a9922d701af359c04 (patch) | |
| tree | 9341e2f70fab6b2678fdff53c002954ef69c7b3e /src/main.tsx | |
| download | panel-ui-8caa77413ea372e5cbd2980a9922d701af359c04.tar.gz panel-ui-8caa77413ea372e5cbd2980a9922d701af359c04.zip | |
initial commit
Diffstat (limited to 'src/main.tsx')
| -rw-r--r-- | src/main.tsx | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/main.tsx b/src/main.tsx new file mode 100644 index 0000000..a6cc146 --- /dev/null +++ b/src/main.tsx @@ -0,0 +1,52 @@ +import {createRoot} from 'react-dom/client' +import {Widget} from './Widget' +import {App} from "@/models/app.ts" +import {Provider} from 'react-redux' +import React from 'react' + +import {store} from './store' +import {setApp} from "@/models/appSlice.ts"; + +(function () { + + // Finding the script tag on the page.. + const scriptTags = document.querySelectorAll('script[data-bpuid]'); + let currentScript: HTMLScriptElement | null = null; + for (const tag of scriptTags) { + currentScript = tag as HTMLScriptElement; + } + + // GRL Snippet configuration options + const settings: App = { + targetId: currentScript?.getAttribute("data-target") || 'grl-widget', + bpid: currentScript?.getAttribute("data-bpid") || "invalid-bpid-from-snippet", + bpuid: currentScript?.getAttribute("data-bpuid") || "invalid-bpuid-from-snippet", + offerwall: currentScript?.getAttribute("data-offerwall") || "37d1da64", + walletMode: Boolean(currentScript?.getAttribute("data-wallet")) || true, + panelName: currentScript?.getAttribute("data-panel") || null, + leaderboard: Boolean(currentScript?.getAttribute("data-leaderboard")) || false, + + currentPage: "offerwall" + } + store.dispatch(setApp(settings)) + + // Avoid adding the widget multiple times + const container: HTMLElement | null = document.getElementById(settings.targetId) + if (container) { + // ensure that it's empty? + } else { + let container = document.createElement('div') + container.id = settings.targetId + document.body.appendChild(container) + } + + const root = createRoot(container) + root.render( + <React.StrictMode> + <Provider store={store}> + <Widget/> + </Provider> + </React.StrictMode> + ); + +})()
\ No newline at end of file |
