goldstars-services 1.0.52 → 1.0.53

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.
@@ -64,6 +64,34 @@ var createReservation = /*#__PURE__*/function () {
64
64
  throw new Error('Timestamp inválido proporcionado para la reserva.');
65
65
  }
66
66
 
67
+ // --- BEGIN NEW VALIDATIONS ---
68
+
69
+ // 1. Check if user already has a reservation for this EXACT timestamp
70
+ var existingReservationSameSlot = yield _reservationModel.default.findOne({
71
+ userId,
72
+ timestamp: reservationTimestamp
73
+ });
74
+ if (existingReservationSameSlot) {
75
+ throw new Error('Ya tienes una reserva agendada para esta fecha y hora.');
76
+ }
77
+
78
+ // 2. Check if user already has an UPCOMING reservation
79
+ var now = new Date();
80
+ var existingUpcomingReservation = yield _reservationModel.default.findOne({
81
+ userId,
82
+ timestamp: {
83
+ $gte: now
84
+ } // Find reservations where the timestamp is now or in the future
85
+ });
86
+ if (existingUpcomingReservation) {
87
+ // Optional: Provide more details about the existing reservation if needed
88
+ // const existingTime = existingUpcomingReservation.timestamp.toLocaleString('es-VE');
89
+ // throw new Error(`Ya tienes una reserva activa para ${existingTime}. Debes esperar a que pase para agendar otra.`);
90
+ throw new Error('Ya tienes una reserva activa. Debes esperar a que pase para agendar otra.');
91
+ }
92
+
93
+ // --- END NEW VALIDATIONS ---
94
+
67
95
  // 1. Validate Bike
68
96
  var bike = yield _bikeModel.default.findById(bikeId);
69
97
  if (!bike) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goldstars-services",
3
- "version": "1.0.52",
3
+ "version": "1.0.53",
4
4
  "description": "This is the services layer for GoldStars",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {