mirror of
https://github.com/ae-utbm/sith.git
synced 2026-06-05 15:49:21 +00:00
tweaks after rebase on clic-limit
This commit is contained in:
@@ -6,7 +6,9 @@ interface Basket {
|
||||
timeout: Date;
|
||||
}
|
||||
document.addEventListener("alpine:init", () => {
|
||||
Alpine.data("etransaction", (initialData, basket: Basket) => ({
|
||||
Alpine.data(
|
||||
"etransaction",
|
||||
(initialData: Record<string, string>, basket: Basket) => ({
|
||||
data: initialData,
|
||||
isCbAvailable: Object.keys(initialData).length > 0,
|
||||
isSithAvailable: true,
|
||||
@@ -14,10 +16,11 @@ document.addEventListener("alpine:init", () => {
|
||||
init() {
|
||||
const now = new Date();
|
||||
const timeout = basket.timeout.getTime() - now.getTime();
|
||||
if (timeout <= 0) {
|
||||
// basket was already outdated at initial page load
|
||||
this.timeoutBasket();
|
||||
} else {
|
||||
if (timeout > 0) {
|
||||
// if not going inside this condition, it means that
|
||||
// basket was already outdated at initial page load,
|
||||
// in which case disabling buttons and displaying
|
||||
// error message has been done at rendering time
|
||||
setTimeout(() => this.timeoutBasket(), timeout);
|
||||
}
|
||||
},
|
||||
@@ -35,7 +38,7 @@ document.addEventListener("alpine:init", () => {
|
||||
.getAll()
|
||||
.find(
|
||||
(n: Notification) =>
|
||||
n.tag === NotificationLevel.Error && n.message === message,
|
||||
n.tag === NotificationLevel.Error && n.text === message,
|
||||
);
|
||||
if (existingNotif === undefined) {
|
||||
this.$notifications.error(message);
|
||||
@@ -59,7 +62,7 @@ document.addEventListener("alpine:init", () => {
|
||||
path: { basket_id: basket.id },
|
||||
});
|
||||
if (res.response.ok) {
|
||||
this.data = res.data;
|
||||
this.data = res.data as Record<string, string>;
|
||||
this.isCbAvailable = true;
|
||||
} else if (res.response.status === 410) {
|
||||
// The basket is expired, so no payment method should be available at all.
|
||||
@@ -68,5 +71,6 @@ document.addEventListener("alpine:init", () => {
|
||||
this.timeoutBasket();
|
||||
}
|
||||
},
|
||||
}));
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -72,8 +72,18 @@
|
||||
we have a third dummy form, containing only the cgv button,
|
||||
which validation is triggered when one of the two other forms is submitted.
|
||||
If the validation of this form fails, the submit event will be cancelled. #}
|
||||
<div class="form-group margin-bottom">
|
||||
<input type="checkbox" id="cgv-checkbox" name="cgv" required>
|
||||
<div class="form-group">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="cgv-checkbox"
|
||||
name="cgv"
|
||||
required
|
||||
{% if basket.is_expired %}
|
||||
disabled="disabled"
|
||||
{% else %}
|
||||
:disabled="!isCbAvailable && !isSithAvailable"
|
||||
{% endif %}
|
||||
>
|
||||
<label for="cgv-checkbox">
|
||||
{% trans trimmed %}I have read and I accept{% endtrans %}
|
||||
<a href="{{ url('core:page', 'cgv') }}">{% trans %}the general terms and conditions{% endtrans%}</a>
|
||||
|
||||
Reference in New Issue
Block a user