

Thank you for choosing us!
Please rate your experience
Please Share Your Valuable Feedback
WhatsApp Message QR Code Generator
Please enter WhatsApp No. with country code Ex: 911234512345
Contact Form
Lucky Spin Wheel
Create Your Wheel
🎰 Lucky Slot Machine 🎰
Create Your Slot Machine
?
?
?
{pdfUrl && Download Edited PDF}
);
}
import { useState } from “react”;
import { Wheel } from “react-custom-roulette”;
import { Input, Button, Card } from “@/components/ui/button”;
export default function BusinessSpinWheel() {
const [options, setOptions] = useState([
{ option: “10% Off”, probability: 50 },
{ option: “Free Product”, probability: 30 },
{ option: “No Win”, probability: 20 },
]);
const [mustSpin, setMustSpin] = useState(false);
const [prizeIndex, setPrizeIndex] = useState(0);
const handleSpin = () => {
const totalWeight = options.reduce((sum, opt) => sum + opt.probability, 0);
const rand = Math.random() * totalWeight;
let cumulative = 0;
let selectedIndex = 0;
for (let i = 0; i < options.length; i++) {
cumulative += options[i].probability;
if (rand < cumulative) {
selectedIndex = i;
break;
}
}
setPrizeIndex(selectedIndex);
setMustSpin(true);
};
const handleStop = () => setMustSpin(false);
const updateOption = (index, field, value) => {
const newOptions = […options];
newOptions[index][field] = field === “probability” ? Number(value) : value;
setOptions(newOptions);
};
return (
Customize Your Spin Wheel
{options.map((opt, index) => (
updateOption(index, “option”, e.target.value)}
placeholder=”Prize Name”
/>
updateOption(index, “probability”, e.target.value)}
placeholder=”Probability %”
/>
))}