goldstars-services 1.0.68 → 1.0.70

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.
@@ -39,10 +39,17 @@ var PlanSchema = new Schema({
39
39
  // Sedes donde el plan es válido
40
40
  required: true
41
41
  },
42
+ // Relación histórica con usuarios (se mantiene para compatibilidad pero ya no se muestra en UI)
42
43
  users: [{
43
44
  type: Schema.Types.ObjectId,
44
45
  ref: "User"
45
46
  }],
47
+ // Indica si el plan da acceso al área de bikes para el cliente
48
+ bikeAccess: {
49
+ type: Boolean,
50
+ required: true,
51
+ default: false
52
+ },
46
53
  status: {
47
54
  type: Boolean,
48
55
  required: true,
@@ -11,7 +11,8 @@ var reservationSchema = new _mongoose.default.Schema({
11
11
  type: _mongoose.default.Schema.Types.ObjectId,
12
12
  ref: 'User',
13
13
  // Assuming your user model is named 'User'
14
- required: true
14
+ // Ahora opcional para permitir reservas administrativas sin usuario asignado
15
+ required: false
15
16
  },
16
17
  bikeId: {
17
18
  type: _mongoose.default.Schema.Types.ObjectId,
@@ -66,28 +66,31 @@ var createReservation = /*#__PURE__*/function () {
66
66
 
67
67
  // --- BEGIN NEW VALIDATIONS ---
68
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
- }
69
+ // 1. Validaciones por usuario solo aplican cuando hay usuario asociado
70
+ if (userId) {
71
+ // 1.a Check if user already has a reservation for this EXACT timestamp
72
+ var existingReservationSameSlot = yield _reservationModel.default.findOne({
73
+ userId,
74
+ timestamp: reservationTimestamp
75
+ });
76
+ if (existingReservationSameSlot) {
77
+ throw new Error('Ya tienes una reserva agendada para esta fecha y hora.');
78
+ }
77
79
 
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.');
80
+ // 1.b Check if user already has an UPCOMING reservation
81
+ var now = new Date();
82
+ var existingUpcomingReservation = yield _reservationModel.default.findOne({
83
+ userId,
84
+ timestamp: {
85
+ $gte: now
86
+ } // Find reservations where the timestamp is now or in the future
87
+ });
88
+ if (existingUpcomingReservation) {
89
+ // Optional: Provide more details about the existing reservation if needed
90
+ // const existingTime = existingUpcomingReservation.timestamp.toLocaleString('es-VE');
91
+ // throw new Error(`Ya tienes una reserva activa para ${existingTime}. Debes esperar a que pase para agendar otra.`);
92
+ throw new Error('Ya tienes una reserva activa. Debes esperar a que pase para agendar otra.');
93
+ }
91
94
  }
92
95
 
93
96
  // --- END NEW VALIDATIONS ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goldstars-services",
3
- "version": "1.0.68",
3
+ "version": "1.0.70",
4
4
  "description": "This is the services layer for GoldStars",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {