const rewards = require("../rewards");

function handleEvent(payload) {
  const event = payload.event;

  const rewardName = event.reward.title;

  console.log(`🎁 ${event.user_name} → ${rewardName}`);

  const handler = rewards.getReward(rewardName);

  if (!handler) {
    console.log("Unknown reward:", rewardName);
    return;
  }

  handler(event);
}

module.exports = { handleEvent };