nodebb-plugin-calendar-onekite 11.1.13 → 11.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/admin.js CHANGED
@@ -59,13 +59,36 @@ admin.approveReservation = async function (req, res) {
59
59
  let paymentUrl = null;
60
60
  if (token) {
61
61
  const requester = await user.getUserData(r.uid);
62
+ // Determine amount from HelloAsso items (pricing comes from HelloAsso)
63
+ let totalAmount = 0;
64
+ try {
65
+ const items = await helloasso.listItems({
66
+ env,
67
+ token,
68
+ organizationSlug: settings.helloassoOrganizationSlug,
69
+ formType: settings.helloassoFormType,
70
+ formSlug: settings.helloassoFormSlug,
71
+ });
72
+ const normalized = (items || []).map((it) => ({
73
+ id: String(it.id || it.itemId || it.reference || it.name),
74
+ price: it.price || it.amount || it.unitPrice || 0,
75
+ })).filter(it => it.id);
76
+ const match = normalized.find(it => it.id === String(r.itemId));
77
+ totalAmount = match ? parseInt(match.price, 10) || 0 : 0;
78
+ } catch (e) {
79
+ totalAmount = 0;
80
+ }
81
+
82
+ if (!totalAmount) {
83
+ return res.status(400).json({ error: 'item-price-not-found' });
84
+ }
62
85
  paymentUrl = await helloasso.createCheckoutIntent({
63
86
  env,
64
87
  token,
65
88
  organizationSlug: settings.helloassoOrganizationSlug,
66
89
  formType: settings.helloassoFormType,
67
90
  formSlug: settings.helloassoFormSlug,
68
- totalAmount: parseInt(settings.defaultAmount || '0', 10) || 0,
91
+ totalAmount,
69
92
  payerEmail: requester && requester.email,
70
93
  });
71
94
  }
package/lib/db.js CHANGED
@@ -21,8 +21,11 @@ async function removeReservation(rid) {
21
21
  }
22
22
 
23
23
  async function listReservationIdsByStartRange(startTs, endTs, limit = 1000) {
24
- // NodeBB db supports sortedSetGetRangeByScore
25
- return await db.sortedSetGetRangeByScore(KEY_ZSET, startTs, endTs, 0, limit);
24
+ // NodeBB db method name is getSortedSetRangeByScore(set, start, stop, min, max)
25
+ // (start/stop are index offsets, min/max are score range)
26
+ const start = 0;
27
+ const stop = Math.max(0, (parseInt(limit, 10) || 1000) - 1);
28
+ return await db.getSortedSetRangeByScore(KEY_ZSET, start, stop, startTs, endTs);
26
29
  }
27
30
 
28
31
  async function listAllReservationIds(limit = 5000) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-calendar-onekite",
3
- "version": "11.1.13",
3
+ "version": "11.1.15",
4
4
  "description": "FullCalendar-based equipment reservation workflow with admin approval & HelloAsso payment for NodeBB",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
@@ -52,11 +52,6 @@
52
52
  <input class="form-control" name="helloassoFormSlug">
53
53
  </div>
54
54
 
55
- <div class="mb-3">
56
- <label class="form-label">Montant par défaut (centimes)</label>
57
- <input class="form-control" name="defaultAmount" type="number" min="0" value="0">
58
- </div>
59
-
60
55
  <button type="button" class="btn btn-primary" id="onekite-save">Enregistrer</button>
61
56
  </form>
62
57