import { CAMPAIGN_CONFIG } from "@components/common/CampaignBanners/campaignData";
import { useEligibleRewards } from "@components/common/CampaignBanners/hooks";
import { Stars } from "@components/common/Icons";
import { isCampaignExpired, isCampaignStarted } from "@utils/campaignExpiry";
import { NATIVE_TOKEN_ADDRESS } from "@utils/constants";

export const RewardDisplay = ({ label }: { label?: string }) => {
	// Campaign ID for the "Monad" campaign
	const campaignId = "monad-launch";
	const isStarted = isCampaignStarted(campaignId);
	const isExpired = isCampaignExpired(campaignId);

	const approvedSourceTokens = CAMPAIGN_CONFIG[campaignId]?.eligibleTokens
		.filter((token) => ["source", "both"].includes(token.side))
		.map((token) => `${token.address.toLowerCase()}:${token.chainId}` as const);

	const approvedDestinationTokens = CAMPAIGN_CONFIG[campaignId]?.eligibleTokens
		.filter((token) => ["destination", "both"].includes(token.side))
		.map((token) => `${token.address.toLowerCase()}:${token.chainId}` as const);

	const eligibleRewards = useEligibleRewards({
		sourceRequirement: null,
		destinationRequirement: null,
		minimumAmount: 100,
		minimumAmountType: "token",
		rewardCap: 20,
		routeType: "auto",
		approvedSourceTokens,
		approvedDestinationTokens,
		minimumEligibleAmountInUsd: 0,
		excemptedDestinationChains: [89999],
		excemptedSourceChains: [89999],
	});

	if (!eligibleRewards || isExpired || !isStarted) return null;

	const formattedValue = `+${eligibleRewards.toFixed(2)} mUSD`;

	return (
		<div className="bn-flex bn-items-center bn-gap-1 bn-bg-accent-3 bn-px-3 bn-py-2 bn-text-primary bn-text-sm bn-font-medium -bn-mx-4 -bn-mb-4">
			<Stars className="bn-text-accent-3" />
			{label ? (
				<span>{label}</span>
			) : (
				<span>
					You'll earn <span className="bn-text-accent-3">{formattedValue}</span>{" "}
					in rewards.
				</span>
			)}
		</div>
	);
};
