Differential D11221 Diff 37475 subscriptions/templates/subscriptions/components/currency_selector.html
Changeset View
Changeset View
Standalone View
Standalone View
subscriptions/templates/subscriptions/components/currency_selector.html
- This file was added.
| <div class="input-group {% if small == 'true' %}input-group-sm{% endif %}"> | |||||
| <div class="input-group-prepend"> | |||||
| <label class="input-group-text" for="js-currency">Currency:</label> | |||||
| </div> | |||||
| <select class="custom-select select-outline" id="js-currency"> | |||||
| <option class="text-white bg-dark" value="EUR" {% if preferred_currency == 'EUR' %}selected{% endif %}>EUR | |||||
| </option> | |||||
| <option class="text-white bg-dark" value="USD" {% if preferred_currency == 'USD' %}selected{% endif %}>USD | |||||
| </option> | |||||
| </select> | |||||
| </div> | |||||
| <script> | |||||
| document.getElementById('js-currency').addEventListener('change', function () { | |||||
| const currency = this.options[this.selectedIndex].value; | |||||
| let data = new FormData(); | |||||
| data.set('preferred_currency', currency); | |||||
| ajax.post( | |||||
| '{% url "looper:preferred_currency" %}', data | |||||
| ).then(function () { | |||||
| window.location.reload(); | |||||
| }, function (error) { | |||||
| console.error('Error setting preferred currency:', error); | |||||
| }); | |||||
| }); | |||||
| </script> | |||||