Multi-Currency Implementation: - Add currency configuration with 10 supported currencies (NZD, USD, EUR, GBP, AUD, CAD, JPY, CHF, SGD, HKD) - Create client-side and server-side currency utilities for conversion and formatting - Implement currency selector UI component with auto-detection and localStorage persistence - Update Donation model to store multi-currency transactions with NZD equivalents - Update Koha service to handle currency conversion and exchange rate tracking - Update donation form UI to display prices in selected currency - Update transparency dashboard to show donations with currency indicators - Update Stripe setup documentation with currency_options configuration guide Privacy Policy: - Create comprehensive privacy policy page (GDPR compliant) - Add shared footer component with privacy policy link - Update all Koha pages with footer component Technical Details: - Exchange rates stored at donation time for historical accuracy - All donations tracked in both original currency and NZD for transparency - Base currency: NZD (New Zealand Dollar) - Uses Stripe currency_options for monthly subscriptions - Dynamic currency for one-time donations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
85 lines
2.8 KiB
JavaScript
85 lines
2.8 KiB
JavaScript
/**
|
|
* Currency Selector Component
|
|
* Dropdown for selecting donation currency
|
|
*/
|
|
|
|
(function() {
|
|
'use strict';
|
|
|
|
// Currency selector HTML
|
|
const selectorHTML = `
|
|
<div id="currency-selector" class="bg-white shadow rounded-lg p-4 mb-8">
|
|
<label for="currency-select" class="block text-sm font-medium text-gray-700 mb-2">
|
|
Select Currency
|
|
</label>
|
|
<select
|
|
id="currency-select"
|
|
class="w-full md:w-64 px-4 py-2 border-2 border-gray-300 rounded-lg focus:border-blue-600 focus:outline-none text-base"
|
|
aria-label="Select your preferred currency"
|
|
>
|
|
<option value="NZD">🇳🇿 NZD - NZ Dollar</option>
|
|
<option value="USD">🇺🇸 USD - US Dollar</option>
|
|
<option value="EUR">🇪🇺 EUR - Euro</option>
|
|
<option value="GBP">🇬🇧 GBP - British Pound</option>
|
|
<option value="AUD">🇦🇺 AUD - Australian Dollar</option>
|
|
<option value="CAD">🇨🇦 CAD - Canadian Dollar</option>
|
|
<option value="JPY">🇯🇵 JPY - Japanese Yen</option>
|
|
<option value="CHF">🇨🇭 CHF - Swiss Franc</option>
|
|
<option value="SGD">🇸🇬 SGD - Singapore Dollar</option>
|
|
<option value="HKD">🇭🇰 HKD - Hong Kong Dollar</option>
|
|
</select>
|
|
<p class="text-xs text-gray-500 mt-2">
|
|
Prices are automatically converted from NZD. Your selection is saved for future visits.
|
|
</p>
|
|
</div>
|
|
`;
|
|
|
|
// Initialize currency selector
|
|
function initCurrencySelector() {
|
|
// Find container (should have id="currency-selector-container")
|
|
const container = document.getElementById('currency-selector-container');
|
|
if (!container) {
|
|
console.warn('Currency selector container not found');
|
|
return;
|
|
}
|
|
|
|
// Insert selector HTML
|
|
container.innerHTML = selectorHTML;
|
|
|
|
// Get select element
|
|
const select = document.getElementById('currency-select');
|
|
|
|
// Set initial value from detected currency
|
|
const detectedCurrency = detectUserCurrency();
|
|
select.value = detectedCurrency;
|
|
|
|
// Trigger initial price update
|
|
if (typeof window.updatePricesForCurrency === 'function') {
|
|
window.updatePricesForCurrency(detectedCurrency);
|
|
}
|
|
|
|
// Listen for changes
|
|
select.addEventListener('change', function(e) {
|
|
const newCurrency = e.target.value;
|
|
|
|
// Save preference
|
|
saveCurrencyPreference(newCurrency);
|
|
|
|
// Update prices
|
|
if (typeof window.updatePricesForCurrency === 'function') {
|
|
window.updatePricesForCurrency(newCurrency);
|
|
}
|
|
});
|
|
}
|
|
|
|
// Auto-initialize when DOM is ready
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', initCurrencySelector);
|
|
} else {
|
|
initCurrencySelector();
|
|
}
|
|
|
|
// Expose init function globally
|
|
window.initCurrencySelector = initCurrencySelector;
|
|
|
|
})();
|