Restore to commit 74e578279624c6045ca440a3459ebfa1f8d54191

This commit is contained in:
southseact-3d
2026-02-07 20:32:41 +00:00
commit ed67b7741b
252 changed files with 99814 additions and 0 deletions

View File

@@ -0,0 +1,172 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Request Withdrawal | Plugin Compass</title>
<link rel="icon" type="image/png" href="/assets/Plugin.png">
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
<script>
tailwind.config = { theme: { extend: { fontFamily: { sans: ['Inter', 'sans-serif'] } } } };
</script>
<!-- PostHog Analytics -->
<script src="/posthog.js"></script>
</head>
<body class="min-h-screen bg-amber-50 text-gray-900">
<nav class="sticky top-0 z-30 bg-amber-50/95 backdrop-blur border-b border-amber-200">
<div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 h-14 flex items-center justify-between">
<a href="/affiliate-dashboard" class="flex items-center gap-2 font-semibold">
<img src="/assets/Plugin.png" alt="Plugin Compass" class="w-8 h-8 rounded-lg">
<span>Plugin<span class="text-green-700">Compass</span></span>
</a>
<div class="flex items-center gap-3 text-sm">
<a href="/affiliate-dashboard" class="text-gray-700 hover:text-gray-900 hidden sm:inline">Dashboard</a>
</div>
</div>
</nav>
<main class="max-w-2xl mx-auto px-4 sm:px-6 lg:px-8 py-10">
<header class="mb-8">
<a href="/affiliate-dashboard" class="inline-flex items-center text-sm text-green-700 hover:underline mb-4">
<i class="fas fa-arrow-left mr-2"></i> Back to Dashboard
</a>
<h1 class="text-3xl font-bold">Request Withdrawal</h1>
<p class="text-gray-600 mt-2">Submit a withdrawal request to receive your earnings.</p>
</header>
<div class="bg-white border border-amber-200 rounded-2xl p-6 shadow-sm">
<div class="mb-6 p-4 bg-amber-50 border border-amber-200 rounded-xl">
<p class="text-sm text-gray-700">Available Balance</p>
<p class="text-3xl font-bold mt-1" id="available-balance">$0.00</p>
</div>
<form id="withdrawal-form" class="space-y-6">
<div>
<label class="block text-sm font-medium text-gray-900 mb-2">PayPal Email Address</label>
<input type="email" id="paypal-email" name="paypal-email" required
class="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-green-700 focus:border-transparent outline-none"
placeholder="your@email.com">
<p class="text-xs text-gray-500 mt-1">Enter the PayPal email where you want to receive your payout.</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-900 mb-2">Preferred Currency</label>
<select id="currency" name="currency" required
class="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-green-700 focus:border-transparent outline-none bg-white">
<option value="USD">USD - US Dollar</option>
<option value="EUR">EUR - Euro</option>
<option value="GBP">GBP - British Pound</option>
<option value="CAD">CAD - Canadian Dollar</option>
<option value="AUD">AUD - Australian Dollar</option>
<option value="JPY">JPY - Japanese Yen</option>
<option value="CHF">CHF - Swiss Franc</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-900 mb-2">Amount to Withdraw</label>
<input type="number" id="amount" name="amount" required min="0" step="0.01"
class="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-green-700 focus:border-transparent outline-none"
placeholder="0.00">
<p class="text-xs text-gray-500 mt-1">Enter the amount you want to withdraw.</p>
</div>
<div class="pt-4 border-t border-gray-200">
<button type="submit" id="submit-btn"
class="w-full px-6 py-3 rounded-xl bg-green-700 text-white font-semibold hover:bg-green-600 transition-colors">
Submit Withdrawal Request
</button>
</div>
<div id="status-message" class="hidden p-4 rounded-xl text-sm"></div>
</form>
</div>
</main>
<script>
const form = document.getElementById('withdrawal-form');
const amountInput = document.getElementById('amount');
const statusMessage = document.getElementById('status-message');
const submitBtn = document.getElementById('submit-btn');
const balanceEl = document.getElementById('available-balance');
let availableBalance = 0;
async function loadAffiliate() {
const res = await fetch('/api/affiliates/me');
if (res.status === 401) {
window.location.href = '/affiliate-login';
return;
}
const json = await res.json().catch(() => ({}));
const affiliate = json.affiliate || {};
availableBalance = Number(affiliate?.earnings?.total || 0);
balanceEl.textContent = `$${availableBalance.toFixed(2)}`;
amountInput.max = availableBalance;
}
function showMessage(message, isError = false) {
statusMessage.classList.remove('hidden', 'bg-green-50', 'text-green-800', 'border-green-200', 'bg-red-50', 'text-red-800', 'border-red-200');
statusMessage.classList.add(
isError ? 'bg-red-50 text-red-800 border border-red-200' : 'bg-green-50 text-green-800 border border-green-200'
);
statusMessage.textContent = message;
}
form.addEventListener('submit', async (e) => {
e.preventDefault();
const paypalEmail = document.getElementById('paypal-email').value.trim();
const currency = document.getElementById('currency').value;
const amount = parseFloat(amountInput.value);
if (!paypalEmail || !paypalEmail.includes('@')) {
showMessage('Please enter a valid PayPal email address.', true);
return;
}
if (amount <= 0) {
showMessage('Please enter a valid amount.', true);
return;
}
if (amount > availableBalance) {
showMessage('Amount exceeds available balance.', true);
return;
}
submitBtn.disabled = true;
submitBtn.textContent = 'Submitting...';
try {
const res = await fetch('/api/affiliates/withdrawals', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ paypalEmail, currency, amount })
});
const json = await res.json().catch(() => ({}));
if (res.ok) {
showMessage('Withdrawal request submitted successfully!');
form.reset();
setTimeout(() => {
window.location.href = '/affiliate-dashboard';
}, 2000);
} else {
showMessage(json.error || 'Failed to submit withdrawal request.', true);
}
} catch (err) {
showMessage('An error occurred. Please try again.', true);
} finally {
submitBtn.disabled = false;
submitBtn.textContent = 'Submit Withdrawal Request';
}
});
loadAffiliate();
</script>
</body>
</html>