Skip to content

Commit a7d772e

Browse files
Embed Kingsumo script on giveaway page (#758)
1 parent 4d0cbef commit a7d772e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/pages/dashboard/giveaway/index.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,23 @@ const GiveawayPage: React.FC = () => {
477477
setActiveTab("giveaway");
478478
}, []);
479479

480+
// Dynamically load Kingsumo embed script for giveaway page
481+
useEffect(() => {
482+
// Create a new script element
483+
const script = document.createElement("script");
484+
script.src = "https://kingsumo.com/js/embed.js"; // Script URL provided by Kingsumo
485+
script.async = true; // Load asynchronously to avoid blocking page render
486+
487+
// Append the script to the document body
488+
document.body.appendChild(script);
489+
490+
// Cleanup: remove the script when component unmounts to prevent duplicates
491+
return () => {
492+
document.body.removeChild(script);
493+
};
494+
}, []); // Empty dependency array ensures this runs only once when component mounts
495+
496+
480497
useEffect(() => {
481498
// Simulate fetching leaderboard data
482499
const fetchLeaderboard = async () => {
@@ -790,6 +807,7 @@ const GiveawayPage: React.FC = () => {
790807
<p>Fetching leaderboard data...</p>
791808
</div>
792809
) : (
810+
<>
793811
<div className="giveaway-leaderboard-grid">
794812
{leaderboard.map((entry, index) => (
795813
<motion.div
@@ -842,6 +860,8 @@ const GiveawayPage: React.FC = () => {
842860
</motion.div>
843861
))}
844862
</div>
863+
<div id="kingsumo-embed"></div>
864+
</>
845865
)}
846866
</motion.section>
847867
</div>

0 commit comments

Comments
 (0)