@blackcode_sa/metaestetics-api 1.15.16 → 1.15.17-staging.1
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/dist/admin/index.d.mts +377 -222
- package/dist/admin/index.d.ts +377 -222
- package/dist/admin/index.js +625 -206
- package/dist/admin/index.mjs +624 -206
- package/dist/backoffice/index.d.mts +24 -0
- package/dist/backoffice/index.d.ts +24 -0
- package/dist/index.d.mts +292 -4
- package/dist/index.d.ts +292 -4
- package/dist/index.js +1142 -630
- package/dist/index.mjs +1137 -617
- package/package.json +2 -1
- package/src/__mocks__/firstore.ts +10 -10
- package/src/admin/aggregation/README.md +79 -79
- package/src/admin/aggregation/appointment/README.md +151 -129
- package/src/admin/aggregation/appointment/appointment.aggregation.service.ts +2137 -2091
- package/src/admin/aggregation/appointment/index.ts +1 -1
- package/src/admin/aggregation/clinic/README.md +52 -52
- package/src/admin/aggregation/clinic/clinic.aggregation.service.ts +966 -966
- package/src/admin/aggregation/clinic/index.ts +1 -1
- package/src/admin/aggregation/forms/README.md +13 -13
- package/src/admin/aggregation/forms/filled-forms.aggregation.service.ts +322 -322
- package/src/admin/aggregation/forms/index.ts +1 -1
- package/src/admin/aggregation/index.ts +8 -8
- package/src/admin/aggregation/patient/README.md +27 -27
- package/src/admin/aggregation/patient/index.ts +1 -1
- package/src/admin/aggregation/patient/patient.aggregation.service.ts +141 -141
- package/src/admin/aggregation/practitioner/README.md +42 -42
- package/src/admin/aggregation/practitioner/index.ts +1 -1
- package/src/admin/aggregation/practitioner/practitioner.aggregation.service.ts +433 -433
- package/src/admin/aggregation/practitioner-invite/index.ts +1 -1
- package/src/admin/aggregation/practitioner-invite/practitioner-invite.aggregation.service.ts +961 -961
- package/src/admin/aggregation/procedure/README.md +43 -43
- package/src/admin/aggregation/procedure/index.ts +1 -1
- package/src/admin/aggregation/procedure/procedure.aggregation.service.ts +702 -702
- package/src/admin/aggregation/reviews/index.ts +1 -1
- package/src/admin/aggregation/reviews/reviews.aggregation.service.ts +689 -689
- package/src/admin/analytics/analytics.admin.service.ts +278 -278
- package/src/admin/analytics/index.ts +2 -2
- package/src/admin/booking/README.md +184 -125
- package/src/admin/booking/booking.admin.ts +1330 -1073
- package/src/admin/booking/booking.calculator.ts +850 -712
- package/src/admin/booking/booking.types.ts +76 -59
- package/src/admin/booking/index.ts +3 -3
- package/src/admin/booking/timezones-problem.md +185 -185
- package/src/admin/calendar/README.md +62 -7
- package/src/admin/calendar/calendar.admin.service.ts +345 -345
- package/src/admin/calendar/index.ts +2 -1
- package/src/admin/calendar/resource-calendar.admin.ts +198 -0
- package/src/admin/documentation-templates/document-manager.admin.ts +260 -260
- package/src/admin/documentation-templates/index.ts +1 -1
- package/src/admin/free-consultation/free-consultation-utils.admin.ts +148 -148
- package/src/admin/free-consultation/index.ts +1 -1
- package/src/admin/index.ts +83 -83
- package/src/admin/logger/index.ts +78 -78
- package/src/admin/mailing/README.md +139 -139
- package/src/admin/mailing/appointment/appointment.mailing.service.ts +1253 -1253
- package/src/admin/mailing/appointment/index.ts +1 -1
- package/src/admin/mailing/appointment/templates/patient/appointment-confirmed.html +40 -40
- package/src/admin/mailing/base.mailing.service.ts +208 -208
- package/src/admin/mailing/clinicWelcome/clinicWelcome.mailing.ts +292 -292
- package/src/admin/mailing/clinicWelcome/index.ts +1 -1
- package/src/admin/mailing/clinicWelcome/templates/welcome.template.ts +225 -225
- package/src/admin/mailing/index.ts +5 -5
- package/src/admin/mailing/patientInvite/index.ts +2 -2
- package/src/admin/mailing/patientInvite/patientInvite.mailing.ts +415 -415
- package/src/admin/mailing/patientInvite/templates/invitation.template.ts +105 -105
- package/src/admin/mailing/practitionerInvite/existing-practitioner-invite.mailing.ts +611 -611
- package/src/admin/mailing/practitionerInvite/index.ts +2 -2
- package/src/admin/mailing/practitionerInvite/practitionerInvite.mailing.ts +395 -395
- package/src/admin/mailing/practitionerInvite/templates/existing-practitioner-invitation.template.ts +155 -155
- package/src/admin/mailing/practitionerInvite/templates/invitation.template.ts +101 -101
- package/src/admin/mailing/practitionerInvite/templates/invite-accepted-notification.template.ts +228 -228
- package/src/admin/mailing/practitionerInvite/templates/invite-rejected-notification.template.ts +242 -242
- package/src/admin/notifications/index.ts +1 -1
- package/src/admin/notifications/notifications.admin.ts +818 -818
- package/src/admin/requirements/README.md +128 -128
- package/src/admin/requirements/index.ts +1 -1
- package/src/admin/requirements/patient-requirements.admin.service.ts +475 -475
- package/src/admin/users/index.ts +1 -1
- package/src/admin/users/user-profile.admin.ts +405 -405
- package/src/backoffice/constants/certification.constants.ts +13 -13
- package/src/backoffice/constants/index.ts +1 -1
- package/src/backoffice/errors/backoffice.errors.ts +181 -181
- package/src/backoffice/errors/index.ts +1 -1
- package/src/backoffice/expo-safe/README.md +26 -26
- package/src/backoffice/expo-safe/index.ts +41 -41
- package/src/backoffice/index.ts +5 -5
- package/src/backoffice/services/FIXES_README.md +102 -102
- package/src/backoffice/services/README.md +57 -57
- package/src/backoffice/services/analytics.service.proposal.md +863 -863
- package/src/backoffice/services/analytics.service.summary.md +143 -143
- package/src/backoffice/services/brand.service.ts +260 -260
- package/src/backoffice/services/category.service.ts +384 -384
- package/src/backoffice/services/constants.service.ts +385 -385
- package/src/backoffice/services/documentation-template.service.ts +202 -202
- package/src/backoffice/services/index.ts +10 -10
- package/src/backoffice/services/migrate-products.ts +116 -116
- package/src/backoffice/services/product.service.ts +557 -557
- package/src/backoffice/services/requirement.service.ts +235 -235
- package/src/backoffice/services/subcategory.service.ts +461 -461
- package/src/backoffice/services/technology.service.ts +1153 -1153
- package/src/backoffice/types/README.md +12 -12
- package/src/backoffice/types/admin-constants.types.ts +69 -69
- package/src/backoffice/types/brand.types.ts +29 -29
- package/src/backoffice/types/category.types.ts +67 -67
- package/src/backoffice/types/documentation-templates.types.ts +28 -28
- package/src/backoffice/types/index.ts +10 -10
- package/src/backoffice/types/procedure-product.types.ts +38 -38
- package/src/backoffice/types/product.types.ts +239 -239
- package/src/backoffice/types/requirement.types.ts +63 -63
- package/src/backoffice/types/static/README.md +18 -18
- package/src/backoffice/types/static/blocking-condition.types.ts +21 -21
- package/src/backoffice/types/static/certification.types.ts +37 -37
- package/src/backoffice/types/static/contraindication.types.ts +19 -19
- package/src/backoffice/types/static/index.ts +6 -6
- package/src/backoffice/types/static/pricing.types.ts +16 -16
- package/src/backoffice/types/static/procedure-family.types.ts +14 -14
- package/src/backoffice/types/static/treatment-benefit.types.ts +22 -22
- package/src/backoffice/types/subcategory.types.ts +34 -34
- package/src/backoffice/types/technology.types.ts +168 -168
- package/src/backoffice/validations/index.ts +1 -1
- package/src/backoffice/validations/schemas.ts +164 -164
- package/src/config/__mocks__/firebase.ts +99 -99
- package/src/config/firebase.ts +78 -78
- package/src/config/index.ts +17 -17
- package/src/config/tiers.config.ts +255 -229
- package/src/errors/auth.error.ts +6 -6
- package/src/errors/auth.errors.ts +211 -211
- package/src/errors/clinic.errors.ts +32 -32
- package/src/errors/firebase.errors.ts +47 -47
- package/src/errors/user.errors.ts +99 -99
- package/src/index.backup.ts +407 -407
- package/src/index.ts +6 -6
- package/src/locales/en.ts +31 -31
- package/src/recommender/admin/index.ts +1 -1
- package/src/recommender/admin/services/recommender.service.admin.ts +5 -5
- package/src/recommender/front/index.ts +1 -1
- package/src/recommender/front/services/onboarding.service.ts +5 -5
- package/src/recommender/front/services/recommender.service.ts +3 -3
- package/src/recommender/index.ts +1 -1
- package/src/services/PATIENTAUTH.MD +197 -197
- package/src/services/README.md +106 -106
- package/src/services/__tests__/auth/auth.mock.test.ts +17 -17
- package/src/services/__tests__/auth/auth.setup.ts +298 -298
- package/src/services/__tests__/auth.service.test.ts +310 -310
- package/src/services/__tests__/base.service.test.ts +36 -36
- package/src/services/__tests__/user.service.test.ts +530 -530
- package/src/services/analytics/ARCHITECTURE.md +199 -199
- package/src/services/analytics/CLOUD_FUNCTIONS.md +225 -225
- package/src/services/analytics/GROUPED_ANALYTICS.md +501 -501
- package/src/services/analytics/QUICK_START.md +393 -393
- package/src/services/analytics/README.md +304 -304
- package/src/services/analytics/SUMMARY.md +141 -141
- package/src/services/analytics/TRENDS.md +380 -380
- package/src/services/analytics/USAGE_GUIDE.md +518 -518
- package/src/services/analytics/analytics-cloud.service.ts +222 -222
- package/src/services/analytics/analytics.service.ts +2148 -2148
- package/src/services/analytics/index.ts +4 -4
- package/src/services/analytics/review-analytics.service.ts +941 -941
- package/src/services/analytics/utils/appointment-filtering.utils.ts +138 -138
- package/src/services/analytics/utils/cost-calculation.utils.ts +182 -182
- package/src/services/analytics/utils/grouping.utils.ts +434 -434
- package/src/services/analytics/utils/stored-analytics.utils.ts +347 -347
- package/src/services/analytics/utils/time-calculation.utils.ts +186 -186
- package/src/services/analytics/utils/trend-calculation.utils.ts +200 -200
- package/src/services/appointment/README.md +17 -17
- package/src/services/appointment/appointment.service.ts +2943 -2941
- package/src/services/appointment/index.ts +1 -1
- package/src/services/appointment/utils/appointment.utils.ts +620 -620
- package/src/services/appointment/utils/extended-procedure.utils.ts +354 -354
- package/src/services/appointment/utils/form-initialization.utils.ts +516 -516
- package/src/services/appointment/utils/recommended-procedure.utils.ts +195 -195
- package/src/services/appointment/utils/zone-management.utils.ts +468 -468
- package/src/services/appointment/utils/zone-photo.utils.ts +302 -302
- package/src/services/auth/auth.service.ts +1435 -1435
- package/src/services/auth/auth.v2.service.ts +961 -961
- package/src/services/auth/index.ts +7 -7
- package/src/services/auth/utils/error.utils.ts +90 -90
- package/src/services/auth/utils/firebase.utils.ts +49 -49
- package/src/services/auth/utils/index.ts +21 -21
- package/src/services/auth/utils/practitioner.utils.ts +125 -125
- package/src/services/base.service.ts +41 -41
- package/src/services/calendar/calendar.service.ts +1077 -1077
- package/src/services/calendar/calendar.v2.service.ts +1693 -1693
- package/src/services/calendar/calendar.v3.service.ts +313 -313
- package/src/services/calendar/externalCalendar.service.ts +178 -178
- package/src/services/calendar/index.ts +5 -5
- package/src/services/calendar/synced-calendars.service.ts +743 -743
- package/src/services/calendar/utils/appointment.utils.ts +265 -265
- package/src/services/calendar/utils/calendar-event.utils.ts +676 -676
- package/src/services/calendar/utils/clinic.utils.ts +237 -237
- package/src/services/calendar/utils/docs.utils.ts +157 -157
- package/src/services/calendar/utils/google-calendar.utils.ts +697 -697
- package/src/services/calendar/utils/index.ts +8 -8
- package/src/services/calendar/utils/patient.utils.ts +198 -198
- package/src/services/calendar/utils/practitioner.utils.ts +221 -221
- package/src/services/calendar/utils/synced-calendar.utils.ts +472 -472
- package/src/services/clinic/README.md +204 -204
- package/src/services/clinic/__tests__/clinic-admin.service.test.ts +265 -265
- package/src/services/clinic/__tests__/clinic-group.service.test.ts +222 -222
- package/src/services/clinic/__tests__/clinic.service.test.ts +302 -302
- package/src/services/clinic/billing-transactions.service.ts +217 -217
- package/src/services/clinic/clinic-admin.service.ts +202 -202
- package/src/services/clinic/clinic-group.service.ts +310 -310
- package/src/services/clinic/clinic.service.ts +720 -720
- package/src/services/clinic/index.ts +5 -5
- package/src/services/clinic/practitioner-invite.service.ts +519 -519
- package/src/services/clinic/utils/admin.utils.ts +551 -551
- package/src/services/clinic/utils/clinic-group.utils.ts +646 -646
- package/src/services/clinic/utils/clinic.utils.ts +1023 -1023
- package/src/services/clinic/utils/filter.utils.d.ts +23 -23
- package/src/services/clinic/utils/filter.utils.ts +462 -462
- package/src/services/clinic/utils/index.ts +10 -10
- package/src/services/clinic/utils/photos.utils.ts +188 -188
- package/src/services/clinic/utils/search.utils.ts +83 -83
- package/src/services/clinic/utils/tag.utils.ts +124 -124
- package/src/services/documentation-templates/documentation-template.service.ts +537 -537
- package/src/services/documentation-templates/filled-document.service.ts +597 -597
- package/src/services/documentation-templates/index.ts +2 -2
- package/src/services/index.ts +16 -15
- package/src/services/media/index.ts +1 -1
- package/src/services/media/media.service.ts +418 -418
- package/src/services/notifications/__tests__/notification.service.test.ts +242 -242
- package/src/services/notifications/index.ts +1 -1
- package/src/services/notifications/notification.service.ts +215 -215
- package/src/services/patient/README.md +48 -48
- package/src/services/patient/To-Do.md +43 -43
- package/src/services/patient/__tests__/patient.service.test.ts +286 -286
- package/src/services/patient/index.ts +2 -2
- package/src/services/patient/patient.service.ts +1021 -1021
- package/src/services/patient/patientRequirements.service.ts +309 -309
- package/src/services/patient/utils/aesthetic-analysis.utils.ts +176 -176
- package/src/services/patient/utils/body-assessment.utils.ts +159 -159
- package/src/services/patient/utils/clinic.utils.ts +159 -159
- package/src/services/patient/utils/docs.utils.ts +142 -142
- package/src/services/patient/utils/hair-scalp-assessment.utils.ts +158 -158
- package/src/services/patient/utils/index.ts +9 -9
- package/src/services/patient/utils/location.utils.ts +126 -126
- package/src/services/patient/utils/medical-stuff.utils.ts +143 -143
- package/src/services/patient/utils/medical.utils.ts +458 -458
- package/src/services/patient/utils/practitioner.utils.ts +260 -260
- package/src/services/patient/utils/pre-surgical-assessment.utils.ts +161 -161
- package/src/services/patient/utils/profile.utils.ts +510 -510
- package/src/services/patient/utils/sensitive.utils.ts +260 -260
- package/src/services/patient/utils/skin-quality-assessment.utils.ts +160 -160
- package/src/services/patient/utils/token.utils.ts +211 -211
- package/src/services/practitioner/README.md +145 -145
- package/src/services/practitioner/index.ts +1 -1
- package/src/services/practitioner/practitioner.service.ts +2355 -2354
- package/src/services/procedure/README.md +163 -163
- package/src/services/procedure/index.ts +1 -1
- package/src/services/procedure/procedure.service.ts +2521 -2521
- package/src/services/resource/README.md +119 -0
- package/src/services/resource/index.ts +1 -0
- package/src/services/resource/resource.service.ts +555 -0
- package/src/services/reviews/index.ts +1 -1
- package/src/services/reviews/reviews.service.ts +745 -745
- package/src/services/tier-enforcement.ts +240 -240
- package/src/services/user/index.ts +1 -1
- package/src/services/user/user.service.ts +533 -533
- package/src/services/user/user.v2.service.ts +467 -467
- package/src/types/analytics/analytics.types.ts +597 -597
- package/src/types/analytics/grouped-analytics.types.ts +173 -173
- package/src/types/analytics/index.ts +4 -4
- package/src/types/analytics/stored-analytics.types.ts +137 -137
- package/src/types/appointment/index.ts +524 -517
- package/src/types/calendar/index.ts +261 -260
- package/src/types/calendar/synced-calendar.types.ts +66 -66
- package/src/types/clinic/index.ts +530 -529
- package/src/types/clinic/practitioner-invite.types.ts +91 -91
- package/src/types/clinic/preferences.types.ts +159 -159
- package/src/types/clinic/rbac.types.ts +64 -63
- package/src/types/clinic/to-do +3 -3
- package/src/types/documentation-templates/index.ts +308 -308
- package/src/types/index.ts +50 -47
- package/src/types/notifications/README.md +77 -77
- package/src/types/notifications/index.ts +300 -300
- package/src/types/patient/aesthetic-analysis.types.ts +66 -66
- package/src/types/patient/allergies.ts +58 -58
- package/src/types/patient/body-assessment.types.ts +93 -93
- package/src/types/patient/hair-scalp-assessment.types.ts +98 -98
- package/src/types/patient/index.ts +279 -279
- package/src/types/patient/medical-info.types.ts +152 -152
- package/src/types/patient/patient-requirements.ts +92 -92
- package/src/types/patient/pre-surgical-assessment.types.ts +95 -95
- package/src/types/patient/skin-quality-assessment.types.ts +105 -105
- package/src/types/patient/token.types.ts +61 -61
- package/src/types/practitioner/index.ts +208 -208
- package/src/types/procedure/index.ts +189 -183
- package/src/types/profile/index.ts +39 -39
- package/src/types/resource/README.md +153 -0
- package/src/types/resource/index.ts +199 -0
- package/src/types/reviews/index.ts +132 -132
- package/src/types/tz-lookup.d.ts +4 -4
- package/src/types/user/index.ts +60 -60
- package/src/utils/TIMESTAMPS.md +176 -176
- package/src/utils/TimestampUtils.ts +241 -241
- package/src/utils/index.ts +1 -1
- package/src/validations/README.md +94 -0
- package/src/validations/appointment.schema.ts +589 -589
- package/src/validations/calendar.schema.ts +225 -225
- package/src/validations/clinic.schema.ts +494 -494
- package/src/validations/common.schema.ts +25 -25
- package/src/validations/documentation-templates/index.ts +1 -1
- package/src/validations/documentation-templates/template.schema.ts +220 -220
- package/src/validations/documentation-templates.schema.ts +10 -10
- package/src/validations/index.ts +21 -20
- package/src/validations/media.schema.ts +10 -10
- package/src/validations/notification.schema.ts +90 -90
- package/src/validations/patient/aesthetic-analysis.schema.ts +55 -55
- package/src/validations/patient/body-assessment.schema.ts +82 -82
- package/src/validations/patient/hair-scalp-assessment.schema.ts +70 -70
- package/src/validations/patient/medical-info.schema.ts +177 -177
- package/src/validations/patient/patient-requirements.schema.ts +84 -84
- package/src/validations/patient/pre-surgical-assessment.schema.ts +78 -78
- package/src/validations/patient/skin-quality-assessment.schema.ts +70 -70
- package/src/validations/patient/token.schema.ts +29 -29
- package/src/validations/patient.schema.ts +217 -217
- package/src/validations/practitioner.schema.ts +224 -224
- package/src/validations/procedure-product.schema.ts +41 -41
- package/src/validations/procedure.schema.ts +136 -124
- package/src/validations/profile-info.schema.ts +41 -41
- package/src/validations/resource.schema.ts +57 -0
- package/src/validations/reviews.schema.ts +195 -195
- package/src/validations/schemas.ts +109 -109
- package/src/validations/shared.schema.ts +78 -78
package/dist/index.mjs
CHANGED
|
@@ -509,6 +509,7 @@ var BillingTransactionType = /* @__PURE__ */ ((BillingTransactionType2) => {
|
|
|
509
509
|
BillingTransactionType2["SUBSCRIPTION_CANCELED"] = "subscription_canceled";
|
|
510
510
|
BillingTransactionType2["SUBSCRIPTION_REACTIVATED"] = "subscription_reactivated";
|
|
511
511
|
BillingTransactionType2["SUBSCRIPTION_DELETED"] = "subscription_deleted";
|
|
512
|
+
BillingTransactionType2["ADDON_PURCHASED"] = "addon_purchased";
|
|
512
513
|
return BillingTransactionType2;
|
|
513
514
|
})(BillingTransactionType || {});
|
|
514
515
|
|
|
@@ -1106,12 +1107,12 @@ var ReviewAnalyticsService = class extends BaseService {
|
|
|
1106
1107
|
q = query(q, where("createdAt", ">=", startTimestamp), where("createdAt", "<=", endTimestamp));
|
|
1107
1108
|
}
|
|
1108
1109
|
const snapshot = await getDocs(q);
|
|
1109
|
-
const reviews = snapshot.docs.map((
|
|
1110
|
+
const reviews = snapshot.docs.map((doc53) => {
|
|
1110
1111
|
var _a, _b;
|
|
1111
|
-
const data =
|
|
1112
|
+
const data = doc53.data();
|
|
1112
1113
|
return {
|
|
1113
1114
|
...data,
|
|
1114
|
-
id:
|
|
1115
|
+
id: doc53.id,
|
|
1115
1116
|
createdAt: ((_a = data.createdAt) == null ? void 0 : _a.toDate) ? data.createdAt.toDate() : new Date(data.createdAt),
|
|
1116
1117
|
updatedAt: ((_b = data.updatedAt) == null ? void 0 : _b.toDate) ? data.updatedAt.toDate() : new Date(data.updatedAt)
|
|
1117
1118
|
};
|
|
@@ -1128,10 +1129,10 @@ var ReviewAnalyticsService = class extends BaseService {
|
|
|
1128
1129
|
where("id", "in", batch)
|
|
1129
1130
|
);
|
|
1130
1131
|
const appointmentSnapshot = await getDocs(appointmentsQuery);
|
|
1131
|
-
appointmentSnapshot.docs.forEach((
|
|
1132
|
-
const appointment =
|
|
1132
|
+
appointmentSnapshot.docs.forEach((doc53) => {
|
|
1133
|
+
const appointment = doc53.data();
|
|
1133
1134
|
if (appointment.clinicBranchId === filters.clinicBranchId) {
|
|
1134
|
-
validAppointmentIds.add(
|
|
1135
|
+
validAppointmentIds.add(doc53.id);
|
|
1135
1136
|
}
|
|
1136
1137
|
});
|
|
1137
1138
|
}
|
|
@@ -4351,7 +4352,7 @@ var MediaService = class extends BaseService {
|
|
|
4351
4352
|
try {
|
|
4352
4353
|
const querySnapshot = await getDocs3(finalQuery);
|
|
4353
4354
|
const mediaList = querySnapshot.docs.map(
|
|
4354
|
-
(
|
|
4355
|
+
(doc53) => doc53.data()
|
|
4355
4356
|
);
|
|
4356
4357
|
console.log(`[MediaService] Found ${mediaList.length} media items.`);
|
|
4357
4358
|
return mediaList;
|
|
@@ -4415,6 +4416,7 @@ var CalendarEventType = /* @__PURE__ */ ((CalendarEventType3) => {
|
|
|
4415
4416
|
CalendarEventType3["BLOCKING"] = "blocking";
|
|
4416
4417
|
CalendarEventType3["BREAK"] = "break";
|
|
4417
4418
|
CalendarEventType3["FREE_DAY"] = "free_day";
|
|
4419
|
+
CalendarEventType3["RESOURCE_BOOKING"] = "resource_booking";
|
|
4418
4420
|
CalendarEventType3["OTHER"] = "other";
|
|
4419
4421
|
return CalendarEventType3;
|
|
4420
4422
|
})(CalendarEventType || {});
|
|
@@ -4638,6 +4640,25 @@ var PatientTokenStatus = /* @__PURE__ */ ((PatientTokenStatus2) => {
|
|
|
4638
4640
|
return PatientTokenStatus2;
|
|
4639
4641
|
})(PatientTokenStatus || {});
|
|
4640
4642
|
|
|
4643
|
+
// src/types/resource/index.ts
|
|
4644
|
+
var RESOURCES_COLLECTION = "resources";
|
|
4645
|
+
var RESOURCE_INSTANCES_SUBCOLLECTION = "instances";
|
|
4646
|
+
var RESOURCE_CALENDAR_SUBCOLLECTION = "calendar";
|
|
4647
|
+
var ResourceCategory = /* @__PURE__ */ ((ResourceCategory2) => {
|
|
4648
|
+
ResourceCategory2["MEDICAL_DEVICE"] = "medical_device";
|
|
4649
|
+
ResourceCategory2["ROOM"] = "room";
|
|
4650
|
+
ResourceCategory2["SURGERY_SUITE"] = "surgery_suite";
|
|
4651
|
+
ResourceCategory2["EQUIPMENT"] = "equipment";
|
|
4652
|
+
ResourceCategory2["OTHER"] = "other";
|
|
4653
|
+
return ResourceCategory2;
|
|
4654
|
+
})(ResourceCategory || {});
|
|
4655
|
+
var ResourceStatus = /* @__PURE__ */ ((ResourceStatus2) => {
|
|
4656
|
+
ResourceStatus2["ACTIVE"] = "active";
|
|
4657
|
+
ResourceStatus2["INACTIVE"] = "inactive";
|
|
4658
|
+
ResourceStatus2["MAINTENANCE"] = "maintenance";
|
|
4659
|
+
return ResourceStatus2;
|
|
4660
|
+
})(ResourceStatus || {});
|
|
4661
|
+
|
|
4641
4662
|
// src/validations/patient.schema.ts
|
|
4642
4663
|
import { z as z6 } from "zod";
|
|
4643
4664
|
import { Timestamp as Timestamp6 } from "firebase/firestore";
|
|
@@ -5196,8 +5217,8 @@ var getPatientsByPractitionerUtil = async (db, practitionerId, options) => {
|
|
|
5196
5217
|
}
|
|
5197
5218
|
const patientsSnapshot = await getDocs4(q);
|
|
5198
5219
|
const patients = [];
|
|
5199
|
-
patientsSnapshot.forEach((
|
|
5200
|
-
patients.push(
|
|
5220
|
+
patientsSnapshot.forEach((doc53) => {
|
|
5221
|
+
patients.push(doc53.data());
|
|
5201
5222
|
});
|
|
5202
5223
|
console.log(
|
|
5203
5224
|
`[getPatientsByPractitionerUtil] Found ${patients.length} patients for practitioner ID: ${practitionerId}`
|
|
@@ -6025,7 +6046,7 @@ async function getClinicAdminsByGroup(db, clinicGroupId) {
|
|
|
6025
6046
|
where5("clinicGroupId", "==", clinicGroupId)
|
|
6026
6047
|
);
|
|
6027
6048
|
const querySnapshot = await getDocs5(q);
|
|
6028
|
-
return querySnapshot.docs.map((
|
|
6049
|
+
return querySnapshot.docs.map((doc53) => doc53.data());
|
|
6029
6050
|
}
|
|
6030
6051
|
async function updateClinicAdmin(db, adminId, data) {
|
|
6031
6052
|
const admin = await getClinicAdmin(db, adminId);
|
|
@@ -6612,7 +6633,7 @@ async function searchAppointmentsUtil(db, params) {
|
|
|
6612
6633
|
}
|
|
6613
6634
|
const q = query7(collection7(db, APPOINTMENTS_COLLECTION), ...constraints);
|
|
6614
6635
|
const querySnapshot = await getDocs7(q);
|
|
6615
|
-
const appointments = querySnapshot.docs.map((
|
|
6636
|
+
const appointments = querySnapshot.docs.map((doc53) => doc53.data());
|
|
6616
6637
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
6617
6638
|
return { appointments, lastDoc };
|
|
6618
6639
|
} catch (error) {
|
|
@@ -7652,7 +7673,8 @@ var AppointmentService = class extends BaseService {
|
|
|
7652
7673
|
if (!currentUser) {
|
|
7653
7674
|
throw new Error("User must be authenticated to get available booking slots");
|
|
7654
7675
|
}
|
|
7655
|
-
const
|
|
7676
|
+
const projectId = this.app.options.projectId;
|
|
7677
|
+
const functionUrl = `https://europe-west6-${projectId}.cloudfunctions.net/bookingApi/getAvailableBookingSlots`;
|
|
7656
7678
|
const idToken = await currentUser.getIdToken();
|
|
7657
7679
|
console.log(`[APPOINTMENT_SERVICE] Got user token, user ID: ${currentUser.uid}`);
|
|
7658
7680
|
const requestData = {
|
|
@@ -7721,7 +7743,8 @@ var AppointmentService = class extends BaseService {
|
|
|
7721
7743
|
throw new Error("User must be authenticated to create an appointment");
|
|
7722
7744
|
}
|
|
7723
7745
|
const idToken = await currentUser.getIdToken();
|
|
7724
|
-
const
|
|
7746
|
+
const projectId = this.app.options.projectId;
|
|
7747
|
+
const functionUrl = `https://europe-west6-${projectId}.cloudfunctions.net/bookingApi/orchestrateAppointmentCreation`;
|
|
7725
7748
|
const requestData = {
|
|
7726
7749
|
patientId: data.patientId,
|
|
7727
7750
|
procedureId: data.procedureId,
|
|
@@ -8306,7 +8329,7 @@ var AppointmentService = class extends BaseService {
|
|
|
8306
8329
|
}
|
|
8307
8330
|
const q = query9(collection9(this.db, APPOINTMENTS_COLLECTION), ...constraints);
|
|
8308
8331
|
const querySnapshot = await getDocs9(q);
|
|
8309
|
-
const appointments = querySnapshot.docs.map((
|
|
8332
|
+
const appointments = querySnapshot.docs.map((doc53) => doc53.data());
|
|
8310
8333
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
8311
8334
|
console.log(
|
|
8312
8335
|
`[APPOINTMENT_SERVICE] Found ${appointments.length} upcoming appointments for patient ${patientId}`
|
|
@@ -8362,7 +8385,7 @@ var AppointmentService = class extends BaseService {
|
|
|
8362
8385
|
}
|
|
8363
8386
|
const q = query9(collection9(this.db, APPOINTMENTS_COLLECTION), ...constraints);
|
|
8364
8387
|
const querySnapshot = await getDocs9(q);
|
|
8365
|
-
const appointments = querySnapshot.docs.map((
|
|
8388
|
+
const appointments = querySnapshot.docs.map((doc53) => doc53.data());
|
|
8366
8389
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
8367
8390
|
console.log(
|
|
8368
8391
|
`[APPOINTMENT_SERVICE] Found ${appointments.length} past appointments for patient ${patientId}`
|
|
@@ -9642,7 +9665,7 @@ var AppointmentService = class extends BaseService {
|
|
|
9642
9665
|
);
|
|
9643
9666
|
const proceduresSnapshot = await getDocs9(proceduresQuery);
|
|
9644
9667
|
availableProcedureIds = new Set(
|
|
9645
|
-
proceduresSnapshot.docs.map((
|
|
9668
|
+
proceduresSnapshot.docs.map((doc53) => doc53.id)
|
|
9646
9669
|
);
|
|
9647
9670
|
console.log(
|
|
9648
9671
|
`[APPOINTMENT_SERVICE] Found ${availableProcedureIds.size} procedures available at clinic ${options.clinicBranchId}`
|
|
@@ -9918,8 +9941,8 @@ var getPatientsByClinicUtil = async (db, clinicId, options) => {
|
|
|
9918
9941
|
}
|
|
9919
9942
|
const patientsSnapshot = await getDocs10(q);
|
|
9920
9943
|
const patients = [];
|
|
9921
|
-
patientsSnapshot.forEach((
|
|
9922
|
-
patients.push(
|
|
9944
|
+
patientsSnapshot.forEach((doc53) => {
|
|
9945
|
+
patients.push(doc53.data());
|
|
9923
9946
|
});
|
|
9924
9947
|
console.log(
|
|
9925
9948
|
`[getPatientsByClinicUtil] Found ${patients.length} patients for clinic ID: ${clinicId}`
|
|
@@ -10294,9 +10317,9 @@ var updateAllergyUtil = async (db, patientId, data, requesterId, requesterRoles)
|
|
|
10294
10317
|
};
|
|
10295
10318
|
var removeAllergyUtil = async (db, patientId, allergyIndex, requesterId, requesterRoles) => {
|
|
10296
10319
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
10297
|
-
const
|
|
10298
|
-
if (!
|
|
10299
|
-
const medicalInfo =
|
|
10320
|
+
const doc53 = await getDoc17(getMedicalInfoDocRef(db, patientId));
|
|
10321
|
+
if (!doc53.exists()) throw new Error("Medical info not found");
|
|
10322
|
+
const medicalInfo = doc53.data();
|
|
10300
10323
|
if (allergyIndex >= medicalInfo.allergies.length) {
|
|
10301
10324
|
throw new Error("Invalid allergy index");
|
|
10302
10325
|
}
|
|
@@ -10323,9 +10346,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, requesterId, reque
|
|
|
10323
10346
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
10324
10347
|
const validatedData = updateBlockingConditionSchema.parse(data);
|
|
10325
10348
|
const { conditionIndex, ...updateData } = validatedData;
|
|
10326
|
-
const
|
|
10327
|
-
if (!
|
|
10328
|
-
const medicalInfo =
|
|
10349
|
+
const doc53 = await getDoc17(getMedicalInfoDocRef(db, patientId));
|
|
10350
|
+
if (!doc53.exists()) throw new Error("Medical info not found");
|
|
10351
|
+
const medicalInfo = doc53.data();
|
|
10329
10352
|
if (conditionIndex >= medicalInfo.blockingConditions.length) {
|
|
10330
10353
|
throw new Error("Invalid blocking condition index");
|
|
10331
10354
|
}
|
|
@@ -10342,9 +10365,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, requesterId, reque
|
|
|
10342
10365
|
};
|
|
10343
10366
|
var removeBlockingConditionUtil = async (db, patientId, conditionIndex, requesterId, requesterRoles) => {
|
|
10344
10367
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
10345
|
-
const
|
|
10346
|
-
if (!
|
|
10347
|
-
const medicalInfo =
|
|
10368
|
+
const doc53 = await getDoc17(getMedicalInfoDocRef(db, patientId));
|
|
10369
|
+
if (!doc53.exists()) throw new Error("Medical info not found");
|
|
10370
|
+
const medicalInfo = doc53.data();
|
|
10348
10371
|
if (conditionIndex >= medicalInfo.blockingConditions.length) {
|
|
10349
10372
|
throw new Error("Invalid blocking condition index");
|
|
10350
10373
|
}
|
|
@@ -10371,9 +10394,9 @@ var updateContraindicationUtil = async (db, patientId, data, requesterId, reques
|
|
|
10371
10394
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
10372
10395
|
const validatedData = updateContraindicationSchema.parse(data);
|
|
10373
10396
|
const { contraindicationIndex, ...updateData } = validatedData;
|
|
10374
|
-
const
|
|
10375
|
-
if (!
|
|
10376
|
-
const medicalInfo =
|
|
10397
|
+
const doc53 = await getDoc17(getMedicalInfoDocRef(db, patientId));
|
|
10398
|
+
if (!doc53.exists()) throw new Error("Medical info not found");
|
|
10399
|
+
const medicalInfo = doc53.data();
|
|
10377
10400
|
if (contraindicationIndex >= medicalInfo.contraindications.length) {
|
|
10378
10401
|
throw new Error("Invalid contraindication index");
|
|
10379
10402
|
}
|
|
@@ -10390,9 +10413,9 @@ var updateContraindicationUtil = async (db, patientId, data, requesterId, reques
|
|
|
10390
10413
|
};
|
|
10391
10414
|
var removeContraindicationUtil = async (db, patientId, contraindicationIndex, requesterId, requesterRoles) => {
|
|
10392
10415
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
10393
|
-
const
|
|
10394
|
-
if (!
|
|
10395
|
-
const medicalInfo =
|
|
10416
|
+
const doc53 = await getDoc17(getMedicalInfoDocRef(db, patientId));
|
|
10417
|
+
if (!doc53.exists()) throw new Error("Medical info not found");
|
|
10418
|
+
const medicalInfo = doc53.data();
|
|
10396
10419
|
if (contraindicationIndex >= medicalInfo.contraindications.length) {
|
|
10397
10420
|
throw new Error("Invalid contraindication index");
|
|
10398
10421
|
}
|
|
@@ -10419,9 +10442,9 @@ var updateMedicationUtil = async (db, patientId, data, requesterId, requesterRol
|
|
|
10419
10442
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
10420
10443
|
const validatedData = updateMedicationSchema.parse(data);
|
|
10421
10444
|
const { medicationIndex, ...updateData } = validatedData;
|
|
10422
|
-
const
|
|
10423
|
-
if (!
|
|
10424
|
-
const medicalInfo =
|
|
10445
|
+
const doc53 = await getDoc17(getMedicalInfoDocRef(db, patientId));
|
|
10446
|
+
if (!doc53.exists()) throw new Error("Medical info not found");
|
|
10447
|
+
const medicalInfo = doc53.data();
|
|
10425
10448
|
if (medicationIndex >= medicalInfo.currentMedications.length) {
|
|
10426
10449
|
throw new Error("Invalid medication index");
|
|
10427
10450
|
}
|
|
@@ -10438,9 +10461,9 @@ var updateMedicationUtil = async (db, patientId, data, requesterId, requesterRol
|
|
|
10438
10461
|
};
|
|
10439
10462
|
var removeMedicationUtil = async (db, patientId, medicationIndex, requesterId, requesterRoles) => {
|
|
10440
10463
|
await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
|
|
10441
|
-
const
|
|
10442
|
-
if (!
|
|
10443
|
-
const medicalInfo =
|
|
10464
|
+
const doc53 = await getDoc17(getMedicalInfoDocRef(db, patientId));
|
|
10465
|
+
if (!doc53.exists()) throw new Error("Medical info not found");
|
|
10466
|
+
const medicalInfo = doc53.data();
|
|
10444
10467
|
if (medicationIndex >= medicalInfo.currentMedications.length) {
|
|
10445
10468
|
throw new Error("Invalid medication index");
|
|
10446
10469
|
}
|
|
@@ -10743,7 +10766,7 @@ var searchPatientsUtil = async (db, params, requester) => {
|
|
|
10743
10766
|
const finalQuery = query11(patientsCollectionRef, ...constraints);
|
|
10744
10767
|
const querySnapshot = await getDocs11(finalQuery);
|
|
10745
10768
|
const patients = querySnapshot.docs.map(
|
|
10746
|
-
(
|
|
10769
|
+
(doc53) => doc53.data()
|
|
10747
10770
|
);
|
|
10748
10771
|
console.log(
|
|
10749
10772
|
`[searchPatientsUtil] Found ${patients.length} patients matching criteria.`
|
|
@@ -10775,8 +10798,8 @@ var getAllPatientsUtil = async (db, options) => {
|
|
|
10775
10798
|
}
|
|
10776
10799
|
const patientsSnapshot = await getDocs11(q);
|
|
10777
10800
|
const patients = [];
|
|
10778
|
-
patientsSnapshot.forEach((
|
|
10779
|
-
patients.push(
|
|
10801
|
+
patientsSnapshot.forEach((doc53) => {
|
|
10802
|
+
patients.push(doc53.data());
|
|
10780
10803
|
});
|
|
10781
10804
|
console.log(`[getAllPatientsUtil] Found ${patients.length} patients`);
|
|
10782
10805
|
return patients;
|
|
@@ -10909,7 +10932,7 @@ var getActiveInviteTokensByClinicUtil = async (db, clinicId) => {
|
|
|
10909
10932
|
if (querySnapshot.empty) {
|
|
10910
10933
|
return [];
|
|
10911
10934
|
}
|
|
10912
|
-
return querySnapshot.docs.map((
|
|
10935
|
+
return querySnapshot.docs.map((doc53) => doc53.data());
|
|
10913
10936
|
};
|
|
10914
10937
|
var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
|
|
10915
10938
|
const tokensRef = collection12(
|
|
@@ -10927,7 +10950,7 @@ var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
|
|
|
10927
10950
|
if (querySnapshot.empty) {
|
|
10928
10951
|
return [];
|
|
10929
10952
|
}
|
|
10930
|
-
return querySnapshot.docs.map((
|
|
10953
|
+
return querySnapshot.docs.map((doc53) => doc53.data());
|
|
10931
10954
|
};
|
|
10932
10955
|
|
|
10933
10956
|
// src/services/patient/utils/aesthetic-analysis.utils.ts
|
|
@@ -12733,6 +12756,11 @@ var PERMISSION_KEYS = {
|
|
|
12733
12756
|
"procedures.create": true,
|
|
12734
12757
|
"procedures.edit": true,
|
|
12735
12758
|
"procedures.delete": true,
|
|
12759
|
+
// Resources
|
|
12760
|
+
"resources.view": true,
|
|
12761
|
+
"resources.create": true,
|
|
12762
|
+
"resources.edit": true,
|
|
12763
|
+
"resources.delete": true,
|
|
12736
12764
|
// Patients
|
|
12737
12765
|
"patients.view": true,
|
|
12738
12766
|
"patients.edit": true,
|
|
@@ -12790,6 +12818,10 @@ var DEFAULT_ROLE_PERMISSIONS = {
|
|
|
12790
12818
|
"procedures.create": true,
|
|
12791
12819
|
"procedures.edit": true,
|
|
12792
12820
|
"procedures.delete": true,
|
|
12821
|
+
"resources.view": true,
|
|
12822
|
+
"resources.create": true,
|
|
12823
|
+
"resources.edit": true,
|
|
12824
|
+
"resources.delete": true,
|
|
12793
12825
|
"patients.view": true,
|
|
12794
12826
|
"patients.edit": true,
|
|
12795
12827
|
"providers.view": true,
|
|
@@ -12812,6 +12844,10 @@ var DEFAULT_ROLE_PERMISSIONS = {
|
|
|
12812
12844
|
"procedures.create": true,
|
|
12813
12845
|
"procedures.edit": true,
|
|
12814
12846
|
"procedures.delete": true,
|
|
12847
|
+
"resources.view": true,
|
|
12848
|
+
"resources.create": true,
|
|
12849
|
+
"resources.edit": true,
|
|
12850
|
+
"resources.delete": true,
|
|
12815
12851
|
"patients.view": true,
|
|
12816
12852
|
"patients.edit": true,
|
|
12817
12853
|
"providers.view": true,
|
|
@@ -12834,6 +12870,10 @@ var DEFAULT_ROLE_PERMISSIONS = {
|
|
|
12834
12870
|
"procedures.create": false,
|
|
12835
12871
|
"procedures.edit": false,
|
|
12836
12872
|
"procedures.delete": false,
|
|
12873
|
+
"resources.view": true,
|
|
12874
|
+
"resources.create": false,
|
|
12875
|
+
"resources.edit": false,
|
|
12876
|
+
"resources.delete": false,
|
|
12837
12877
|
"patients.view": true,
|
|
12838
12878
|
"patients.edit": true,
|
|
12839
12879
|
"providers.view": true,
|
|
@@ -12856,6 +12896,10 @@ var DEFAULT_ROLE_PERMISSIONS = {
|
|
|
12856
12896
|
"procedures.create": false,
|
|
12857
12897
|
"procedures.edit": false,
|
|
12858
12898
|
"procedures.delete": false,
|
|
12899
|
+
"resources.view": true,
|
|
12900
|
+
"resources.create": false,
|
|
12901
|
+
"resources.edit": false,
|
|
12902
|
+
"resources.delete": false,
|
|
12859
12903
|
"patients.view": true,
|
|
12860
12904
|
"patients.edit": false,
|
|
12861
12905
|
"providers.view": true,
|
|
@@ -12878,6 +12922,10 @@ var DEFAULT_ROLE_PERMISSIONS = {
|
|
|
12878
12922
|
"procedures.create": false,
|
|
12879
12923
|
"procedures.edit": false,
|
|
12880
12924
|
"procedures.delete": false,
|
|
12925
|
+
"resources.view": true,
|
|
12926
|
+
"resources.create": false,
|
|
12927
|
+
"resources.edit": false,
|
|
12928
|
+
"resources.delete": false,
|
|
12881
12929
|
"patients.view": true,
|
|
12882
12930
|
"patients.edit": false,
|
|
12883
12931
|
"providers.view": true,
|
|
@@ -13542,7 +13590,7 @@ var PractitionerService = class extends BaseService {
|
|
|
13542
13590
|
}
|
|
13543
13591
|
const q = query14(tokensRef, ...conditions);
|
|
13544
13592
|
const querySnapshot = await getDocs14(q);
|
|
13545
|
-
return querySnapshot.docs.map((
|
|
13593
|
+
return querySnapshot.docs.map((doc53) => doc53.data());
|
|
13546
13594
|
}
|
|
13547
13595
|
/**
|
|
13548
13596
|
* Gets a token by its string value and validates it
|
|
@@ -13754,20 +13802,20 @@ var PractitionerService = class extends BaseService {
|
|
|
13754
13802
|
const debugSnapshot = await getDocs14(debugQ);
|
|
13755
13803
|
console.log("[PRACTITIONER] Debug: Found practitioners with this email (any status):", {
|
|
13756
13804
|
count: debugSnapshot.size,
|
|
13757
|
-
practitioners: debugSnapshot.docs.map((
|
|
13805
|
+
practitioners: debugSnapshot.docs.map((doc53) => {
|
|
13758
13806
|
var _a;
|
|
13759
13807
|
return {
|
|
13760
|
-
id:
|
|
13761
|
-
email: (_a =
|
|
13762
|
-
status:
|
|
13763
|
-
userRef:
|
|
13808
|
+
id: doc53.id,
|
|
13809
|
+
email: (_a = doc53.data().basicInfo) == null ? void 0 : _a.email,
|
|
13810
|
+
status: doc53.data().status,
|
|
13811
|
+
userRef: doc53.data().userRef
|
|
13764
13812
|
};
|
|
13765
13813
|
})
|
|
13766
13814
|
});
|
|
13767
13815
|
return [];
|
|
13768
13816
|
}
|
|
13769
13817
|
const draftPractitioners = querySnapshot.docs.map(
|
|
13770
|
-
(
|
|
13818
|
+
(doc53) => doc53.data()
|
|
13771
13819
|
);
|
|
13772
13820
|
console.log("[PRACTITIONER] Found draft practitioners", {
|
|
13773
13821
|
email: normalizedEmail,
|
|
@@ -13980,7 +14028,7 @@ var PractitionerService = class extends BaseService {
|
|
|
13980
14028
|
where14("status", "==", "active" /* ACTIVE */)
|
|
13981
14029
|
);
|
|
13982
14030
|
const querySnapshot = await getDocs14(q);
|
|
13983
|
-
return querySnapshot.docs.map((
|
|
14031
|
+
return querySnapshot.docs.map((doc53) => doc53.data());
|
|
13984
14032
|
}
|
|
13985
14033
|
/**
|
|
13986
14034
|
* Dohvata sve zdravstvene radnike za određenu kliniku
|
|
@@ -13992,7 +14040,7 @@ var PractitionerService = class extends BaseService {
|
|
|
13992
14040
|
where14("isActive", "==", true)
|
|
13993
14041
|
);
|
|
13994
14042
|
const querySnapshot = await getDocs14(q);
|
|
13995
|
-
return querySnapshot.docs.map((
|
|
14043
|
+
return querySnapshot.docs.map((doc53) => doc53.data());
|
|
13996
14044
|
}
|
|
13997
14045
|
/**
|
|
13998
14046
|
* Dohvata sve draft zdravstvene radnike za određenu kliniku sa statusom DRAFT
|
|
@@ -14004,7 +14052,7 @@ var PractitionerService = class extends BaseService {
|
|
|
14004
14052
|
where14("status", "==", "draft" /* DRAFT */)
|
|
14005
14053
|
);
|
|
14006
14054
|
const querySnapshot = await getDocs14(q);
|
|
14007
|
-
return querySnapshot.docs.map((
|
|
14055
|
+
return querySnapshot.docs.map((doc53) => doc53.data());
|
|
14008
14056
|
}
|
|
14009
14057
|
/**
|
|
14010
14058
|
* Updates a practitioner
|
|
@@ -14221,7 +14269,7 @@ var PractitionerService = class extends BaseService {
|
|
|
14221
14269
|
);
|
|
14222
14270
|
const querySnapshot = await getDocs14(q);
|
|
14223
14271
|
const practitioners = querySnapshot.docs.map(
|
|
14224
|
-
(
|
|
14272
|
+
(doc53) => doc53.data()
|
|
14225
14273
|
);
|
|
14226
14274
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
14227
14275
|
return {
|
|
@@ -14319,7 +14367,7 @@ var PractitionerService = class extends BaseService {
|
|
|
14319
14367
|
);
|
|
14320
14368
|
const querySnapshot = await getDocs14(q);
|
|
14321
14369
|
let practitioners = querySnapshot.docs.map(
|
|
14322
|
-
(
|
|
14370
|
+
(doc53) => ({ ...doc53.data(), id: doc53.id })
|
|
14323
14371
|
);
|
|
14324
14372
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
14325
14373
|
if (filters.location && filters.radiusInKm && filters.radiusInKm > 0) {
|
|
@@ -14397,7 +14445,7 @@ var PractitionerService = class extends BaseService {
|
|
|
14397
14445
|
);
|
|
14398
14446
|
const querySnapshot = await getDocs14(q);
|
|
14399
14447
|
let practitioners = querySnapshot.docs.map(
|
|
14400
|
-
(
|
|
14448
|
+
(doc53) => ({ ...doc53.data(), id: doc53.id })
|
|
14401
14449
|
);
|
|
14402
14450
|
if (filters.location && filters.radiusInKm && filters.radiusInKm > 0) {
|
|
14403
14451
|
const location = filters.location;
|
|
@@ -14441,7 +14489,7 @@ var PractitionerService = class extends BaseService {
|
|
|
14441
14489
|
);
|
|
14442
14490
|
const querySnapshot = await getDocs14(q);
|
|
14443
14491
|
let practitioners = querySnapshot.docs.map(
|
|
14444
|
-
(
|
|
14492
|
+
(doc53) => ({ ...doc53.data(), id: doc53.id })
|
|
14445
14493
|
);
|
|
14446
14494
|
practitioners = this.applyInMemoryFilters(practitioners, filters);
|
|
14447
14495
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
@@ -14471,7 +14519,7 @@ var PractitionerService = class extends BaseService {
|
|
|
14471
14519
|
);
|
|
14472
14520
|
const querySnapshot = await getDocs14(q);
|
|
14473
14521
|
let practitioners = querySnapshot.docs.map(
|
|
14474
|
-
(
|
|
14522
|
+
(doc53) => ({ ...doc53.data(), id: doc53.id })
|
|
14475
14523
|
);
|
|
14476
14524
|
practitioners = this.applyInMemoryFilters(practitioners, filters);
|
|
14477
14525
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
@@ -14775,7 +14823,8 @@ var PractitionerService = class extends BaseService {
|
|
|
14775
14823
|
"User must be authenticated to ensure free consultation infrastructure"
|
|
14776
14824
|
);
|
|
14777
14825
|
}
|
|
14778
|
-
const
|
|
14826
|
+
const projectId = this.app.options.projectId;
|
|
14827
|
+
const functionUrl = `https://europe-west6-${projectId}.cloudfunctions.net/bookingApi/ensureFreeConsultationInfrastructure`;
|
|
14779
14828
|
const idToken = await currentUser.getIdToken();
|
|
14780
14829
|
console.log(
|
|
14781
14830
|
`[PRACTITIONER_SERVICE] Making fetch request to ${functionUrl}`
|
|
@@ -15099,7 +15148,7 @@ var UserService = class extends BaseService {
|
|
|
15099
15148
|
const constraints = [where15("roles", "array-contains", role)];
|
|
15100
15149
|
const q = query15(collection15(this.db, USERS_COLLECTION), ...constraints);
|
|
15101
15150
|
const querySnapshot = await getDocs15(q);
|
|
15102
|
-
const users = querySnapshot.docs.map((
|
|
15151
|
+
const users = querySnapshot.docs.map((doc53) => doc53.data());
|
|
15103
15152
|
return users.map((userData) => userSchema.parse(userData));
|
|
15104
15153
|
}
|
|
15105
15154
|
/**
|
|
@@ -15288,9 +15337,9 @@ var BillingTransactionsService = class extends BaseService {
|
|
|
15288
15337
|
const querySnapshot = await getDocs16(q);
|
|
15289
15338
|
const docs = querySnapshot.docs;
|
|
15290
15339
|
const hasMore = docs.length > queryLimit;
|
|
15291
|
-
const transactions = docs.slice(0, queryLimit).map((
|
|
15292
|
-
id:
|
|
15293
|
-
...
|
|
15340
|
+
const transactions = docs.slice(0, queryLimit).map((doc53) => ({
|
|
15341
|
+
id: doc53.id,
|
|
15342
|
+
...doc53.data()
|
|
15294
15343
|
}));
|
|
15295
15344
|
const lastDoc = transactions.length > 0 ? docs[transactions.length - 1] : null;
|
|
15296
15345
|
return {
|
|
@@ -15366,9 +15415,9 @@ var BillingTransactionsService = class extends BaseService {
|
|
|
15366
15415
|
const querySnapshot = await getDocs16(q);
|
|
15367
15416
|
const docs = querySnapshot.docs;
|
|
15368
15417
|
const hasMore = docs.length > queryLimit;
|
|
15369
|
-
const transactions = docs.slice(0, queryLimit).map((
|
|
15370
|
-
id:
|
|
15371
|
-
...
|
|
15418
|
+
const transactions = docs.slice(0, queryLimit).map((doc53) => ({
|
|
15419
|
+
id: doc53.id,
|
|
15420
|
+
...doc53.data()
|
|
15372
15421
|
}));
|
|
15373
15422
|
const lastDoc = transactions.length > 0 ? docs[transactions.length - 1] : null;
|
|
15374
15423
|
return {
|
|
@@ -15633,7 +15682,7 @@ async function getAllActiveGroups(db) {
|
|
|
15633
15682
|
where17("isActive", "==", true)
|
|
15634
15683
|
);
|
|
15635
15684
|
const querySnapshot = await getDocs17(q);
|
|
15636
|
-
return querySnapshot.docs.map((
|
|
15685
|
+
return querySnapshot.docs.map((doc53) => doc53.data());
|
|
15637
15686
|
}
|
|
15638
15687
|
async function updateClinicGroup(db, groupId, data, app) {
|
|
15639
15688
|
console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
|
|
@@ -16124,8 +16173,8 @@ async function getClinicsByGroup(db, groupId, excludeDraftPractitioners = false)
|
|
|
16124
16173
|
where18("isActive", "==", true)
|
|
16125
16174
|
);
|
|
16126
16175
|
const querySnapshot = await getDocs18(q);
|
|
16127
|
-
return querySnapshot.docs.map((
|
|
16128
|
-
const clinicData =
|
|
16176
|
+
return querySnapshot.docs.map((doc53) => {
|
|
16177
|
+
const clinicData = doc53.data();
|
|
16129
16178
|
return filterClinicEmbeddedArrays(clinicData, excludeDraftPractitioners);
|
|
16130
16179
|
});
|
|
16131
16180
|
}
|
|
@@ -16323,7 +16372,7 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
|
|
|
16323
16372
|
}
|
|
16324
16373
|
const q = query18(collection18(db, CLINICS_COLLECTION), ...constraints);
|
|
16325
16374
|
const querySnapshot = await getDocs18(q);
|
|
16326
|
-
return querySnapshot.docs.map((
|
|
16375
|
+
return querySnapshot.docs.map((doc53) => doc53.data());
|
|
16327
16376
|
}
|
|
16328
16377
|
async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
|
|
16329
16378
|
return getClinicsByAdmin(
|
|
@@ -16369,11 +16418,11 @@ async function getAllClinics(db, pagination, lastDoc, excludeDraftPractitioners
|
|
|
16369
16418
|
}
|
|
16370
16419
|
const clinicsSnapshot = await getDocs18(clinicsQuery);
|
|
16371
16420
|
const lastVisible = clinicsSnapshot.docs[clinicsSnapshot.docs.length - 1];
|
|
16372
|
-
const clinics = clinicsSnapshot.docs.map((
|
|
16373
|
-
const data =
|
|
16421
|
+
const clinics = clinicsSnapshot.docs.map((doc53) => {
|
|
16422
|
+
const data = doc53.data();
|
|
16374
16423
|
const clinicWithId = {
|
|
16375
16424
|
...data,
|
|
16376
|
-
id:
|
|
16425
|
+
id: doc53.id
|
|
16377
16426
|
};
|
|
16378
16427
|
return filterClinicEmbeddedArrays(clinicWithId, excludeDraftPractitioners);
|
|
16379
16428
|
});
|
|
@@ -16401,8 +16450,8 @@ async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc,
|
|
|
16401
16450
|
];
|
|
16402
16451
|
const q = query18(collection18(db, CLINICS_COLLECTION), ...constraints);
|
|
16403
16452
|
const querySnapshot = await getDocs18(q);
|
|
16404
|
-
for (const
|
|
16405
|
-
const clinic =
|
|
16453
|
+
for (const doc53 of querySnapshot.docs) {
|
|
16454
|
+
const clinic = doc53.data();
|
|
16406
16455
|
const distance = distanceBetween2(
|
|
16407
16456
|
[center.latitude, center.longitude],
|
|
16408
16457
|
[clinic.location.latitude, clinic.location.longitude]
|
|
@@ -16525,8 +16574,8 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
|
|
|
16525
16574
|
}
|
|
16526
16575
|
const q = query19(collection19(db, CLINICS_COLLECTION), ...constraints);
|
|
16527
16576
|
const querySnapshot = await getDocs19(q);
|
|
16528
|
-
for (const
|
|
16529
|
-
const clinic =
|
|
16577
|
+
for (const doc53 of querySnapshot.docs) {
|
|
16578
|
+
const clinic = doc53.data();
|
|
16530
16579
|
const distance = distanceBetween3(
|
|
16531
16580
|
[center.latitude, center.longitude],
|
|
16532
16581
|
[clinic.location.latitude, clinic.location.longitude]
|
|
@@ -16658,7 +16707,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16658
16707
|
constraints.push(limit10(filters.pagination || 5));
|
|
16659
16708
|
const q = query20(collection20(db, CLINICS_COLLECTION), ...constraints);
|
|
16660
16709
|
const querySnapshot = await getDocs20(q);
|
|
16661
|
-
let clinics = querySnapshot.docs.map((
|
|
16710
|
+
let clinics = querySnapshot.docs.map((doc53) => ({ ...doc53.data(), id: doc53.id }));
|
|
16662
16711
|
const excludeDrafts = filters.excludeDraftPractitioners === true;
|
|
16663
16712
|
console.log(`[CLINIC_SERVICE] getClinicsByFilters - excludeDraftPractitioners from filters: ${filters.excludeDraftPractitioners}, resolved to: ${excludeDrafts}`);
|
|
16664
16713
|
clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
|
|
@@ -16693,7 +16742,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16693
16742
|
constraints.push(limit10(filters.pagination || 5));
|
|
16694
16743
|
const q = query20(collection20(db, CLINICS_COLLECTION), ...constraints);
|
|
16695
16744
|
const querySnapshot = await getDocs20(q);
|
|
16696
|
-
let clinics = querySnapshot.docs.map((
|
|
16745
|
+
let clinics = querySnapshot.docs.map((doc53) => ({ ...doc53.data(), id: doc53.id }));
|
|
16697
16746
|
const excludeDrafts = filters.excludeDraftPractitioners === true;
|
|
16698
16747
|
console.log(`[CLINIC_SERVICE] getClinicsByFilters - excludeDraftPractitioners from filters: ${filters.excludeDraftPractitioners}, resolved to: ${excludeDrafts}`);
|
|
16699
16748
|
clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
|
|
@@ -16726,7 +16775,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16726
16775
|
constraints.push(limit10(filters.pagination || 5));
|
|
16727
16776
|
const q = query20(collection20(db, CLINICS_COLLECTION), ...constraints);
|
|
16728
16777
|
const querySnapshot = await getDocs20(q);
|
|
16729
|
-
let clinics = querySnapshot.docs.map((
|
|
16778
|
+
let clinics = querySnapshot.docs.map((doc53) => ({ ...doc53.data(), id: doc53.id }));
|
|
16730
16779
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
16731
16780
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
16732
16781
|
console.log(`[CLINIC_SERVICE] Strategy 3 success: ${clinics.length} clinics`);
|
|
@@ -16746,7 +16795,7 @@ async function getClinicsByFilters(db, filters) {
|
|
|
16746
16795
|
];
|
|
16747
16796
|
const q = query20(collection20(db, CLINICS_COLLECTION), ...constraints);
|
|
16748
16797
|
const querySnapshot = await getDocs20(q);
|
|
16749
|
-
let clinics = querySnapshot.docs.map((
|
|
16798
|
+
let clinics = querySnapshot.docs.map((doc53) => ({ ...doc53.data(), id: doc53.id }));
|
|
16750
16799
|
clinics = applyInMemoryFilters(clinics, filters);
|
|
16751
16800
|
const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
|
|
16752
16801
|
console.log(`[CLINIC_SERVICE] Strategy 4 success: ${clinics.length} clinics`);
|
|
@@ -17323,11 +17372,11 @@ var ClinicService = class extends BaseService {
|
|
|
17323
17372
|
async getClinicsForMap() {
|
|
17324
17373
|
const clinicsRef = collection21(this.db, CLINICS_COLLECTION);
|
|
17325
17374
|
const snapshot = await getDocs21(clinicsRef);
|
|
17326
|
-
const clinicsForMap = snapshot.docs.map((
|
|
17375
|
+
const clinicsForMap = snapshot.docs.map((doc53) => {
|
|
17327
17376
|
var _a, _b, _c;
|
|
17328
|
-
const data =
|
|
17377
|
+
const data = doc53.data();
|
|
17329
17378
|
return {
|
|
17330
|
-
id:
|
|
17379
|
+
id: doc53.id,
|
|
17331
17380
|
name: data.name,
|
|
17332
17381
|
address: ((_a = data.location) == null ? void 0 : _a.address) || "",
|
|
17333
17382
|
latitude: (_b = data.location) == null ? void 0 : _b.latitude,
|
|
@@ -18879,7 +18928,7 @@ async function searchCalendarEventsUtil(db, params) {
|
|
|
18879
18928
|
const finalQuery = query26(collectionRef, ...constraints);
|
|
18880
18929
|
const querySnapshot = await getDocs26(finalQuery);
|
|
18881
18930
|
let events = querySnapshot.docs.map(
|
|
18882
|
-
(
|
|
18931
|
+
(doc53) => ({ id: doc53.id, ...doc53.data() })
|
|
18883
18932
|
);
|
|
18884
18933
|
if (filters.dateRange) {
|
|
18885
18934
|
events = events.filter((event) => {
|
|
@@ -18990,7 +19039,7 @@ async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
|
|
|
18990
19039
|
);
|
|
18991
19040
|
const q = query27(calendarsRef, orderBy12("createdAt", "desc"));
|
|
18992
19041
|
const querySnapshot = await getDocs27(q);
|
|
18993
|
-
return querySnapshot.docs.map((
|
|
19042
|
+
return querySnapshot.docs.map((doc53) => doc53.data());
|
|
18994
19043
|
}
|
|
18995
19044
|
async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
|
|
18996
19045
|
const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
|
|
@@ -19007,7 +19056,7 @@ async function getPatientSyncedCalendarsUtil(db, patientId) {
|
|
|
19007
19056
|
);
|
|
19008
19057
|
const q = query27(calendarsRef, orderBy12("createdAt", "desc"));
|
|
19009
19058
|
const querySnapshot = await getDocs27(q);
|
|
19010
|
-
return querySnapshot.docs.map((
|
|
19059
|
+
return querySnapshot.docs.map((doc53) => doc53.data());
|
|
19011
19060
|
}
|
|
19012
19061
|
async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
|
|
19013
19062
|
const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
|
|
@@ -19024,7 +19073,7 @@ async function getClinicSyncedCalendarsUtil(db, clinicId) {
|
|
|
19024
19073
|
);
|
|
19025
19074
|
const q = query27(calendarsRef, orderBy12("createdAt", "desc"));
|
|
19026
19075
|
const querySnapshot = await getDocs27(q);
|
|
19027
|
-
return querySnapshot.docs.map((
|
|
19076
|
+
return querySnapshot.docs.map((doc53) => doc53.data());
|
|
19028
19077
|
}
|
|
19029
19078
|
async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
|
|
19030
19079
|
const calendarRef = getPractitionerSyncedCalendarDocRef(
|
|
@@ -20379,9 +20428,9 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
20379
20428
|
where28("eventTime.start", "<=", Timestamp30.fromDate(endDate))
|
|
20380
20429
|
);
|
|
20381
20430
|
const eventsSnapshot = await getDocs28(q);
|
|
20382
|
-
const events = eventsSnapshot.docs.map((
|
|
20383
|
-
id:
|
|
20384
|
-
...
|
|
20431
|
+
const events = eventsSnapshot.docs.map((doc53) => ({
|
|
20432
|
+
id: doc53.id,
|
|
20433
|
+
...doc53.data()
|
|
20385
20434
|
}));
|
|
20386
20435
|
const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
|
|
20387
20436
|
doctorId
|
|
@@ -21025,7 +21074,7 @@ var CalendarServiceV2 = class extends BaseService {
|
|
|
21025
21074
|
])
|
|
21026
21075
|
);
|
|
21027
21076
|
const querySnapshot = await getDocs28(q);
|
|
21028
|
-
return querySnapshot.docs.map((
|
|
21077
|
+
return querySnapshot.docs.map((doc53) => doc53.data());
|
|
21029
21078
|
}
|
|
21030
21079
|
/**
|
|
21031
21080
|
* Calculates available time slots based on working hours, schedule and existing appointments
|
|
@@ -21570,7 +21619,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
21570
21619
|
...constraints
|
|
21571
21620
|
);
|
|
21572
21621
|
const querySnapshot = await getDocs29(q);
|
|
21573
|
-
return querySnapshot.docs.map((
|
|
21622
|
+
return querySnapshot.docs.map((doc53) => doc53.data());
|
|
21574
21623
|
} catch (error) {
|
|
21575
21624
|
console.error(
|
|
21576
21625
|
"[PractitionerInviteService] Error getting doctor invites:",
|
|
@@ -21599,7 +21648,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
21599
21648
|
...constraints
|
|
21600
21649
|
);
|
|
21601
21650
|
const querySnapshot = await getDocs29(q);
|
|
21602
|
-
return querySnapshot.docs.map((
|
|
21651
|
+
return querySnapshot.docs.map((doc53) => doc53.data());
|
|
21603
21652
|
} catch (error) {
|
|
21604
21653
|
console.error(
|
|
21605
21654
|
"[PractitionerInviteService] Error getting clinic invites:",
|
|
@@ -21755,7 +21804,7 @@ var PractitionerInviteService = class extends BaseService {
|
|
|
21755
21804
|
);
|
|
21756
21805
|
const querySnapshot = await getDocs29(q);
|
|
21757
21806
|
let invites = querySnapshot.docs.map(
|
|
21758
|
-
(
|
|
21807
|
+
(doc53) => doc53.data()
|
|
21759
21808
|
);
|
|
21760
21809
|
if (filters.fromDate) {
|
|
21761
21810
|
invites = invites.filter(
|
|
@@ -22026,8 +22075,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22026
22075
|
const q = query30(versionsCollectionRef, orderBy14("version", "desc"));
|
|
22027
22076
|
const querySnapshot = await getDocs30(q);
|
|
22028
22077
|
const versions = [];
|
|
22029
|
-
querySnapshot.forEach((
|
|
22030
|
-
versions.push(
|
|
22078
|
+
querySnapshot.forEach((doc53) => {
|
|
22079
|
+
versions.push(doc53.data());
|
|
22031
22080
|
});
|
|
22032
22081
|
return versions;
|
|
22033
22082
|
}
|
|
@@ -22058,9 +22107,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22058
22107
|
const querySnapshot = await getDocs30(q);
|
|
22059
22108
|
const templates = [];
|
|
22060
22109
|
let lastVisible = null;
|
|
22061
|
-
querySnapshot.forEach((
|
|
22062
|
-
templates.push(
|
|
22063
|
-
lastVisible =
|
|
22110
|
+
querySnapshot.forEach((doc53) => {
|
|
22111
|
+
templates.push(doc53.data());
|
|
22112
|
+
lastVisible = doc53;
|
|
22064
22113
|
});
|
|
22065
22114
|
return {
|
|
22066
22115
|
templates,
|
|
@@ -22102,9 +22151,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22102
22151
|
const querySnapshot = await getDocs30(q);
|
|
22103
22152
|
const templates = [];
|
|
22104
22153
|
let lastVisible = null;
|
|
22105
|
-
querySnapshot.forEach((
|
|
22106
|
-
templates.push(
|
|
22107
|
-
lastVisible =
|
|
22154
|
+
querySnapshot.forEach((doc53) => {
|
|
22155
|
+
templates.push(doc53.data());
|
|
22156
|
+
lastVisible = doc53;
|
|
22108
22157
|
});
|
|
22109
22158
|
return {
|
|
22110
22159
|
templates,
|
|
@@ -22144,8 +22193,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22144
22193
|
);
|
|
22145
22194
|
const querySnapshot = await getDocs30(q);
|
|
22146
22195
|
const templates = [];
|
|
22147
|
-
querySnapshot.forEach((
|
|
22148
|
-
templates.push(
|
|
22196
|
+
querySnapshot.forEach((doc53) => {
|
|
22197
|
+
templates.push(doc53.data());
|
|
22149
22198
|
});
|
|
22150
22199
|
return templates;
|
|
22151
22200
|
}
|
|
@@ -22170,9 +22219,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22170
22219
|
const querySnapshot = await getDocs30(q);
|
|
22171
22220
|
const templates = [];
|
|
22172
22221
|
let lastVisible = null;
|
|
22173
|
-
querySnapshot.forEach((
|
|
22174
|
-
templates.push(
|
|
22175
|
-
lastVisible =
|
|
22222
|
+
querySnapshot.forEach((doc53) => {
|
|
22223
|
+
templates.push(doc53.data());
|
|
22224
|
+
lastVisible = doc53;
|
|
22176
22225
|
});
|
|
22177
22226
|
return {
|
|
22178
22227
|
templates,
|
|
@@ -22199,9 +22248,9 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22199
22248
|
const querySnapshot = await getDocs30(q);
|
|
22200
22249
|
const templates = [];
|
|
22201
22250
|
let lastVisible = null;
|
|
22202
|
-
querySnapshot.forEach((
|
|
22203
|
-
templates.push(
|
|
22204
|
-
lastVisible =
|
|
22251
|
+
querySnapshot.forEach((doc53) => {
|
|
22252
|
+
templates.push(doc53.data());
|
|
22253
|
+
lastVisible = doc53;
|
|
22205
22254
|
});
|
|
22206
22255
|
return {
|
|
22207
22256
|
templates,
|
|
@@ -22227,8 +22276,8 @@ var DocumentationTemplateService = class extends BaseService {
|
|
|
22227
22276
|
}
|
|
22228
22277
|
const querySnapshot = await getDocs30(q);
|
|
22229
22278
|
const templates = [];
|
|
22230
|
-
querySnapshot.forEach((
|
|
22231
|
-
templates.push(
|
|
22279
|
+
querySnapshot.forEach((doc53) => {
|
|
22280
|
+
templates.push(doc53.data());
|
|
22232
22281
|
});
|
|
22233
22282
|
return templates;
|
|
22234
22283
|
}
|
|
@@ -22666,9 +22715,9 @@ var NotificationService = class extends BaseService {
|
|
|
22666
22715
|
orderBy16("notificationTime", "desc")
|
|
22667
22716
|
);
|
|
22668
22717
|
const querySnapshot = await getDocs32(q);
|
|
22669
|
-
return querySnapshot.docs.map((
|
|
22670
|
-
id:
|
|
22671
|
-
...
|
|
22718
|
+
return querySnapshot.docs.map((doc53) => ({
|
|
22719
|
+
id: doc53.id,
|
|
22720
|
+
...doc53.data()
|
|
22672
22721
|
}));
|
|
22673
22722
|
}
|
|
22674
22723
|
/**
|
|
@@ -22682,9 +22731,9 @@ var NotificationService = class extends BaseService {
|
|
|
22682
22731
|
orderBy16("notificationTime", "desc")
|
|
22683
22732
|
);
|
|
22684
22733
|
const querySnapshot = await getDocs32(q);
|
|
22685
|
-
return querySnapshot.docs.map((
|
|
22686
|
-
id:
|
|
22687
|
-
...
|
|
22734
|
+
return querySnapshot.docs.map((doc53) => ({
|
|
22735
|
+
id: doc53.id,
|
|
22736
|
+
...doc53.data()
|
|
22688
22737
|
}));
|
|
22689
22738
|
}
|
|
22690
22739
|
/**
|
|
@@ -22756,9 +22805,9 @@ var NotificationService = class extends BaseService {
|
|
|
22756
22805
|
orderBy16("notificationTime", "desc")
|
|
22757
22806
|
);
|
|
22758
22807
|
const querySnapshot = await getDocs32(q);
|
|
22759
|
-
return querySnapshot.docs.map((
|
|
22760
|
-
id:
|
|
22761
|
-
...
|
|
22808
|
+
return querySnapshot.docs.map((doc53) => ({
|
|
22809
|
+
id: doc53.id,
|
|
22810
|
+
...doc53.data()
|
|
22762
22811
|
}));
|
|
22763
22812
|
}
|
|
22764
22813
|
/**
|
|
@@ -22771,9 +22820,9 @@ var NotificationService = class extends BaseService {
|
|
|
22771
22820
|
orderBy16("notificationTime", "desc")
|
|
22772
22821
|
);
|
|
22773
22822
|
const querySnapshot = await getDocs32(q);
|
|
22774
|
-
return querySnapshot.docs.map((
|
|
22775
|
-
id:
|
|
22776
|
-
...
|
|
22823
|
+
return querySnapshot.docs.map((doc53) => ({
|
|
22824
|
+
id: doc53.id,
|
|
22825
|
+
...doc53.data()
|
|
22777
22826
|
}));
|
|
22778
22827
|
}
|
|
22779
22828
|
};
|
|
@@ -23028,6 +23077,11 @@ var procedureProductDataSchema = z29.object({
|
|
|
23028
23077
|
});
|
|
23029
23078
|
|
|
23030
23079
|
// src/validations/procedure.schema.ts
|
|
23080
|
+
var resourceRequirementSchema = z30.object({
|
|
23081
|
+
resourceId: z30.string().min(1),
|
|
23082
|
+
resourceName: z30.string().min(1),
|
|
23083
|
+
resourceCategory: z30.nativeEnum(ResourceCategory)
|
|
23084
|
+
});
|
|
23031
23085
|
var storedProcedureProductSchema = z30.object({
|
|
23032
23086
|
/**
|
|
23033
23087
|
* The full product object used in the procedure.
|
|
@@ -23070,7 +23124,8 @@ var createProcedureSchema = z30.object({
|
|
|
23070
23124
|
// Max 8 hours
|
|
23071
23125
|
practitionerId: z30.string().min(1),
|
|
23072
23126
|
clinicBranchId: z30.string().min(1),
|
|
23073
|
-
photos: z30.array(mediaResourceSchema).optional()
|
|
23127
|
+
photos: z30.array(mediaResourceSchema).optional(),
|
|
23128
|
+
resourceRequirements: z30.array(resourceRequirementSchema).optional()
|
|
23074
23129
|
});
|
|
23075
23130
|
var updateProcedureSchema = z30.object({
|
|
23076
23131
|
name: z30.string().min(3).max(100).optional(),
|
|
@@ -23089,7 +23144,8 @@ var updateProcedureSchema = z30.object({
|
|
|
23089
23144
|
technologyId: z30.string().optional(),
|
|
23090
23145
|
productId: z30.string().optional(),
|
|
23091
23146
|
clinicBranchId: z30.string().optional(),
|
|
23092
|
-
photos: z30.array(mediaResourceSchema).optional()
|
|
23147
|
+
photos: z30.array(mediaResourceSchema).optional(),
|
|
23148
|
+
resourceRequirements: z30.array(resourceRequirementSchema).optional()
|
|
23093
23149
|
});
|
|
23094
23150
|
var procedureSchema = z30.object({
|
|
23095
23151
|
id: z30.string().min(1),
|
|
@@ -23365,7 +23421,7 @@ var ProcedureService = class extends BaseService {
|
|
|
23365
23421
|
where34("isActive", "==", true)
|
|
23366
23422
|
);
|
|
23367
23423
|
const existingProceduresSnapshot = await getDocs34(existingProceduresQuery);
|
|
23368
|
-
const existingProcedures = existingProceduresSnapshot.docs.map((
|
|
23424
|
+
const existingProcedures = existingProceduresSnapshot.docs.map((doc53) => doc53.data());
|
|
23369
23425
|
const hasSameTechnology = existingProcedures.some(
|
|
23370
23426
|
(proc) => {
|
|
23371
23427
|
var _a2;
|
|
@@ -23553,7 +23609,7 @@ var ProcedureService = class extends BaseService {
|
|
|
23553
23609
|
where34("isActive", "==", true)
|
|
23554
23610
|
);
|
|
23555
23611
|
const existingProceduresSnapshot = await getDocs34(existingProceduresQuery);
|
|
23556
|
-
const existingProcedures = existingProceduresSnapshot.docs.map((
|
|
23612
|
+
const existingProcedures = existingProceduresSnapshot.docs.map((doc53) => doc53.data());
|
|
23557
23613
|
const hasSameTechnology = existingProcedures.some(
|
|
23558
23614
|
(proc) => {
|
|
23559
23615
|
var _a2, _b2;
|
|
@@ -23650,7 +23706,7 @@ var ProcedureService = class extends BaseService {
|
|
|
23650
23706
|
where34("isActive", "==", true)
|
|
23651
23707
|
);
|
|
23652
23708
|
const existingProceduresSnapshot = await getDocs34(existingProceduresQuery);
|
|
23653
|
-
const existingProcedures = existingProceduresSnapshot.docs.map((
|
|
23709
|
+
const existingProcedures = existingProceduresSnapshot.docs.map((doc53) => doc53.data());
|
|
23654
23710
|
const hasSameTechnology = existingProcedures.some(
|
|
23655
23711
|
(proc) => {
|
|
23656
23712
|
var _a2;
|
|
@@ -23791,8 +23847,8 @@ var ProcedureService = class extends BaseService {
|
|
|
23791
23847
|
where34(documentId2(), "in", chunk)
|
|
23792
23848
|
);
|
|
23793
23849
|
const practitionersSnapshot = await getDocs34(practitionersQuery);
|
|
23794
|
-
practitionersSnapshot.docs.forEach((
|
|
23795
|
-
practitionersMap.set(
|
|
23850
|
+
practitionersSnapshot.docs.forEach((doc53) => {
|
|
23851
|
+
practitionersMap.set(doc53.id, doc53.data());
|
|
23796
23852
|
});
|
|
23797
23853
|
}
|
|
23798
23854
|
if (practitionersMap.size !== practitionerIds.length) {
|
|
@@ -23810,7 +23866,7 @@ var ProcedureService = class extends BaseService {
|
|
|
23810
23866
|
where34("isActive", "==", true)
|
|
23811
23867
|
);
|
|
23812
23868
|
const existingProceduresSnapshot = await getDocs34(existingProceduresQuery);
|
|
23813
|
-
const existingProcedures = existingProceduresSnapshot.docs.map((
|
|
23869
|
+
const existingProcedures = existingProceduresSnapshot.docs.map((doc53) => doc53.data());
|
|
23814
23870
|
const hasSameTechnology = existingProcedures.some(
|
|
23815
23871
|
(proc) => {
|
|
23816
23872
|
var _a2;
|
|
@@ -23921,8 +23977,8 @@ var ProcedureService = class extends BaseService {
|
|
|
23921
23977
|
const chunk = createdProcedureIds.slice(i, i + 30);
|
|
23922
23978
|
const q = query34(collection34(this.db, PROCEDURES_COLLECTION), where34(documentId2(), "in", chunk));
|
|
23923
23979
|
const snapshot = await getDocs34(q);
|
|
23924
|
-
snapshot.forEach((
|
|
23925
|
-
fetchedProcedures.push(
|
|
23980
|
+
snapshot.forEach((doc53) => {
|
|
23981
|
+
fetchedProcedures.push(doc53.data());
|
|
23926
23982
|
});
|
|
23927
23983
|
}
|
|
23928
23984
|
return fetchedProcedures;
|
|
@@ -23953,7 +24009,7 @@ var ProcedureService = class extends BaseService {
|
|
|
23953
24009
|
where34("isActive", "==", true)
|
|
23954
24010
|
);
|
|
23955
24011
|
const snapshot = await getDocs34(q);
|
|
23956
|
-
const procedures = snapshot.docs.map((
|
|
24012
|
+
const procedures = snapshot.docs.map((doc53) => doc53.data());
|
|
23957
24013
|
if (excludeDraftPractitioners) {
|
|
23958
24014
|
return await this.filterDraftPractitionerProcedures(procedures);
|
|
23959
24015
|
}
|
|
@@ -23979,7 +24035,7 @@ var ProcedureService = class extends BaseService {
|
|
|
23979
24035
|
...constraints
|
|
23980
24036
|
);
|
|
23981
24037
|
const snapshot = await getDocs34(q);
|
|
23982
|
-
const procedures = snapshot.docs.map((
|
|
24038
|
+
const procedures = snapshot.docs.map((doc53) => doc53.data());
|
|
23983
24039
|
if (excludeDraftPractitioners && this.practitionerService) {
|
|
23984
24040
|
try {
|
|
23985
24041
|
const practitioner = await this.practitionerService.getPractitioner(practitionerId);
|
|
@@ -24005,7 +24061,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24005
24061
|
where34("isActive", "==", false)
|
|
24006
24062
|
);
|
|
24007
24063
|
const snapshot = await getDocs34(q);
|
|
24008
|
-
return snapshot.docs.map((
|
|
24064
|
+
return snapshot.docs.map((doc53) => doc53.data());
|
|
24009
24065
|
}
|
|
24010
24066
|
/**
|
|
24011
24067
|
* Updates a procedure
|
|
@@ -24224,11 +24280,11 @@ var ProcedureService = class extends BaseService {
|
|
|
24224
24280
|
proceduresQuery = query34(proceduresCollection, orderBy18("name"));
|
|
24225
24281
|
}
|
|
24226
24282
|
const proceduresSnapshot = await getDocs34(proceduresQuery);
|
|
24227
|
-
let procedures = proceduresSnapshot.docs.map((
|
|
24228
|
-
const data =
|
|
24283
|
+
let procedures = proceduresSnapshot.docs.map((doc53) => {
|
|
24284
|
+
const data = doc53.data();
|
|
24229
24285
|
return {
|
|
24230
24286
|
...data,
|
|
24231
|
-
id:
|
|
24287
|
+
id: doc53.id
|
|
24232
24288
|
// Ensure ID is present
|
|
24233
24289
|
};
|
|
24234
24290
|
});
|
|
@@ -24253,10 +24309,10 @@ var ProcedureService = class extends BaseService {
|
|
|
24253
24309
|
* @param orderByField - The field used in orderBy clause
|
|
24254
24310
|
* @returns Serializable cursor object with values needed for startAfter
|
|
24255
24311
|
*/
|
|
24256
|
-
createSerializableCursor(
|
|
24257
|
-
if (!
|
|
24258
|
-
const data = typeof
|
|
24259
|
-
const docId =
|
|
24312
|
+
createSerializableCursor(doc53, orderByField = "createdAt") {
|
|
24313
|
+
if (!doc53) return null;
|
|
24314
|
+
const data = typeof doc53.data === "function" ? doc53.data() : doc53;
|
|
24315
|
+
const docId = doc53.id || (data == null ? void 0 : data.id);
|
|
24260
24316
|
if (!docId) return null;
|
|
24261
24317
|
let orderByValue = data == null ? void 0 : data[orderByField];
|
|
24262
24318
|
if (orderByValue && typeof orderByValue.toDate === "function") {
|
|
@@ -24416,7 +24472,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24416
24472
|
const q = query34(collection34(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
24417
24473
|
const querySnapshot = await getDocs34(q);
|
|
24418
24474
|
let procedures = querySnapshot.docs.map(
|
|
24419
|
-
(
|
|
24475
|
+
(doc53) => ({ ...doc53.data(), id: doc53.id })
|
|
24420
24476
|
);
|
|
24421
24477
|
if (hasNestedFilters) {
|
|
24422
24478
|
procedures = this.applyInMemoryFilters(procedures, filters);
|
|
@@ -24458,7 +24514,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24458
24514
|
const q = query34(collection34(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
24459
24515
|
const querySnapshot = await getDocs34(q);
|
|
24460
24516
|
let procedures = querySnapshot.docs.map(
|
|
24461
|
-
(
|
|
24517
|
+
(doc53) => ({ ...doc53.data(), id: doc53.id })
|
|
24462
24518
|
);
|
|
24463
24519
|
if (hasNestedFilters) {
|
|
24464
24520
|
procedures = this.applyInMemoryFilters(procedures, filters);
|
|
@@ -24532,7 +24588,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24532
24588
|
const q = query34(collection34(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
24533
24589
|
const querySnapshot = await getDocs34(q);
|
|
24534
24590
|
let procedures = querySnapshot.docs.map(
|
|
24535
|
-
(
|
|
24591
|
+
(doc53) => ({ ...doc53.data(), id: doc53.id })
|
|
24536
24592
|
);
|
|
24537
24593
|
console.log("[PROCEDURE_SERVICE] Before applyInMemoryFilters (Strategy 3):", {
|
|
24538
24594
|
procedureCount: procedures.length,
|
|
@@ -24585,7 +24641,7 @@ var ProcedureService = class extends BaseService {
|
|
|
24585
24641
|
const q = query34(collection34(this.db, PROCEDURES_COLLECTION), ...constraints);
|
|
24586
24642
|
const querySnapshot = await getDocs34(q);
|
|
24587
24643
|
let procedures = querySnapshot.docs.map(
|
|
24588
|
-
(
|
|
24644
|
+
(doc53) => ({ ...doc53.data(), id: doc53.id })
|
|
24589
24645
|
);
|
|
24590
24646
|
procedures = this.applyInMemoryFilters(procedures, filters);
|
|
24591
24647
|
if (filters.excludeDraftPractitioners) {
|
|
@@ -24922,9 +24978,9 @@ var ProcedureService = class extends BaseService {
|
|
|
24922
24978
|
async getProceduresForMap() {
|
|
24923
24979
|
const proceduresRef = collection34(this.db, PROCEDURES_COLLECTION);
|
|
24924
24980
|
const snapshot = await getDocs34(proceduresRef);
|
|
24925
|
-
let procedures = snapshot.docs.map((
|
|
24926
|
-
id:
|
|
24927
|
-
...
|
|
24981
|
+
let procedures = snapshot.docs.map((doc53) => ({
|
|
24982
|
+
id: doc53.id,
|
|
24983
|
+
...doc53.data()
|
|
24928
24984
|
}));
|
|
24929
24985
|
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
24930
24986
|
const proceduresForMap = procedures.map((procedure) => {
|
|
@@ -24973,28 +25029,486 @@ var ProcedureService = class extends BaseService {
|
|
|
24973
25029
|
orderBy18("name", "asc")
|
|
24974
25030
|
);
|
|
24975
25031
|
const querySnapshot = await getDocs34(proceduresQuery);
|
|
24976
|
-
let procedures = querySnapshot.docs.map((
|
|
24977
|
-
id:
|
|
24978
|
-
...
|
|
25032
|
+
let procedures = querySnapshot.docs.map((doc53) => ({
|
|
25033
|
+
id: doc53.id,
|
|
25034
|
+
...doc53.data()
|
|
24979
25035
|
}));
|
|
24980
25036
|
procedures = await this.filterDraftPractitionerProcedures(procedures);
|
|
24981
25037
|
return procedures;
|
|
24982
25038
|
}
|
|
24983
25039
|
};
|
|
24984
25040
|
|
|
24985
|
-
// src/services/
|
|
25041
|
+
// src/services/resource/resource.service.ts
|
|
24986
25042
|
import {
|
|
24987
25043
|
collection as collection35,
|
|
24988
25044
|
doc as doc45,
|
|
24989
25045
|
getDoc as getDoc46,
|
|
24990
25046
|
getDocs as getDocs35,
|
|
24991
|
-
query as query35,
|
|
24992
|
-
where as where35,
|
|
24993
25047
|
setDoc as setDoc32,
|
|
24994
25048
|
deleteDoc as deleteDoc20,
|
|
24995
|
-
|
|
25049
|
+
query as query35,
|
|
25050
|
+
where as where35,
|
|
25051
|
+
orderBy as orderBy19,
|
|
25052
|
+
writeBatch as writeBatch7,
|
|
25053
|
+
updateDoc as updateDoc41,
|
|
25054
|
+
serverTimestamp as serverTimestamp36,
|
|
25055
|
+
Timestamp as Timestamp37
|
|
24996
25056
|
} from "firebase/firestore";
|
|
25057
|
+
|
|
25058
|
+
// src/validations/resource.schema.ts
|
|
24997
25059
|
import { z as z31 } from "zod";
|
|
25060
|
+
var createResourceSchema = z31.object({
|
|
25061
|
+
clinicBranchId: z31.string().min(1),
|
|
25062
|
+
name: z31.string().min(1).max(200),
|
|
25063
|
+
category: z31.nativeEnum(ResourceCategory),
|
|
25064
|
+
description: z31.string().max(1e3).optional(),
|
|
25065
|
+
quantity: z31.number().int().min(1).max(100)
|
|
25066
|
+
});
|
|
25067
|
+
var updateResourceSchema = z31.object({
|
|
25068
|
+
name: z31.string().min(1).max(200).optional(),
|
|
25069
|
+
category: z31.nativeEnum(ResourceCategory).optional(),
|
|
25070
|
+
description: z31.string().max(1e3).optional(),
|
|
25071
|
+
quantity: z31.number().int().min(1).max(100).optional(),
|
|
25072
|
+
status: z31.nativeEnum(ResourceStatus).optional()
|
|
25073
|
+
});
|
|
25074
|
+
var createResourceBlockingEventSchema = z31.object({
|
|
25075
|
+
clinicBranchId: z31.string().min(1),
|
|
25076
|
+
resourceId: z31.string().min(1),
|
|
25077
|
+
resourceInstanceId: z31.string().min(1),
|
|
25078
|
+
eventName: z31.string().min(1).max(200),
|
|
25079
|
+
eventTime: z31.object({
|
|
25080
|
+
start: z31.any(),
|
|
25081
|
+
end: z31.any()
|
|
25082
|
+
}),
|
|
25083
|
+
description: z31.string().max(1e3).optional()
|
|
25084
|
+
});
|
|
25085
|
+
var updateResourceBlockingEventSchema = z31.object({
|
|
25086
|
+
clinicBranchId: z31.string().min(1),
|
|
25087
|
+
resourceId: z31.string().min(1),
|
|
25088
|
+
resourceInstanceId: z31.string().min(1),
|
|
25089
|
+
eventId: z31.string().min(1),
|
|
25090
|
+
eventName: z31.string().min(1).max(200).optional(),
|
|
25091
|
+
eventTime: z31.object({
|
|
25092
|
+
start: z31.any(),
|
|
25093
|
+
end: z31.any()
|
|
25094
|
+
}).optional(),
|
|
25095
|
+
description: z31.string().max(1e3).optional()
|
|
25096
|
+
});
|
|
25097
|
+
|
|
25098
|
+
// src/services/resource/resource.service.ts
|
|
25099
|
+
var ResourceService = class extends BaseService {
|
|
25100
|
+
/**
|
|
25101
|
+
* Gets reference to a clinic's resources collection
|
|
25102
|
+
*/
|
|
25103
|
+
getResourcesRef(clinicBranchId) {
|
|
25104
|
+
return collection35(this.db, "clinics", clinicBranchId, RESOURCES_COLLECTION);
|
|
25105
|
+
}
|
|
25106
|
+
/**
|
|
25107
|
+
* Gets reference to a specific resource document
|
|
25108
|
+
*/
|
|
25109
|
+
getResourceDocRef(clinicBranchId, resourceId) {
|
|
25110
|
+
return doc45(
|
|
25111
|
+
this.db,
|
|
25112
|
+
"clinics",
|
|
25113
|
+
clinicBranchId,
|
|
25114
|
+
RESOURCES_COLLECTION,
|
|
25115
|
+
resourceId
|
|
25116
|
+
);
|
|
25117
|
+
}
|
|
25118
|
+
/**
|
|
25119
|
+
* Gets reference to a resource's instances subcollection
|
|
25120
|
+
*/
|
|
25121
|
+
getInstancesRef(clinicBranchId, resourceId) {
|
|
25122
|
+
return collection35(
|
|
25123
|
+
this.db,
|
|
25124
|
+
"clinics",
|
|
25125
|
+
clinicBranchId,
|
|
25126
|
+
RESOURCES_COLLECTION,
|
|
25127
|
+
resourceId,
|
|
25128
|
+
RESOURCE_INSTANCES_SUBCOLLECTION
|
|
25129
|
+
);
|
|
25130
|
+
}
|
|
25131
|
+
/**
|
|
25132
|
+
* Gets reference to an instance's calendar subcollection
|
|
25133
|
+
*/
|
|
25134
|
+
getInstanceCalendarRef(clinicBranchId, resourceId, instanceId) {
|
|
25135
|
+
return collection35(
|
|
25136
|
+
this.db,
|
|
25137
|
+
"clinics",
|
|
25138
|
+
clinicBranchId,
|
|
25139
|
+
RESOURCES_COLLECTION,
|
|
25140
|
+
resourceId,
|
|
25141
|
+
RESOURCE_INSTANCES_SUBCOLLECTION,
|
|
25142
|
+
instanceId,
|
|
25143
|
+
RESOURCE_CALENDAR_SUBCOLLECTION
|
|
25144
|
+
);
|
|
25145
|
+
}
|
|
25146
|
+
/**
|
|
25147
|
+
* Creates a new resource with its instances.
|
|
25148
|
+
* Creates the resource document and N instance subdocuments in a single batch.
|
|
25149
|
+
*/
|
|
25150
|
+
async createResource(data) {
|
|
25151
|
+
const batch = writeBatch7(this.db);
|
|
25152
|
+
const resourceRef = doc45(this.getResourcesRef(data.clinicBranchId));
|
|
25153
|
+
const resourceId = resourceRef.id;
|
|
25154
|
+
const now = serverTimestamp36();
|
|
25155
|
+
const resourceData = {
|
|
25156
|
+
id: resourceId,
|
|
25157
|
+
clinicBranchId: data.clinicBranchId,
|
|
25158
|
+
name: data.name,
|
|
25159
|
+
nameLower: data.name.toLowerCase(),
|
|
25160
|
+
category: data.category,
|
|
25161
|
+
description: data.description || void 0,
|
|
25162
|
+
quantity: data.quantity,
|
|
25163
|
+
status: "active" /* ACTIVE */,
|
|
25164
|
+
linkedProcedureIds: [],
|
|
25165
|
+
createdAt: now,
|
|
25166
|
+
updatedAt: now
|
|
25167
|
+
};
|
|
25168
|
+
batch.set(resourceRef, resourceData);
|
|
25169
|
+
for (let i = 1; i <= data.quantity; i++) {
|
|
25170
|
+
const instanceRef = doc45(
|
|
25171
|
+
this.getInstancesRef(data.clinicBranchId, resourceId)
|
|
25172
|
+
);
|
|
25173
|
+
const instanceData = {
|
|
25174
|
+
id: instanceRef.id,
|
|
25175
|
+
resourceId,
|
|
25176
|
+
clinicBranchId: data.clinicBranchId,
|
|
25177
|
+
label: `${data.name} #${i}`,
|
|
25178
|
+
index: i,
|
|
25179
|
+
status: "active" /* ACTIVE */,
|
|
25180
|
+
createdAt: now,
|
|
25181
|
+
updatedAt: now
|
|
25182
|
+
};
|
|
25183
|
+
batch.set(instanceRef, instanceData);
|
|
25184
|
+
}
|
|
25185
|
+
await batch.commit();
|
|
25186
|
+
const created = await this.getResource(data.clinicBranchId, resourceId);
|
|
25187
|
+
if (!created) throw new Error("Failed to read created resource");
|
|
25188
|
+
return created;
|
|
25189
|
+
}
|
|
25190
|
+
/**
|
|
25191
|
+
* Gets a single resource by ID
|
|
25192
|
+
*/
|
|
25193
|
+
async getResource(clinicBranchId, resourceId) {
|
|
25194
|
+
const docRef = this.getResourceDocRef(clinicBranchId, resourceId);
|
|
25195
|
+
const docSnap = await getDoc46(docRef);
|
|
25196
|
+
if (!docSnap.exists()) return null;
|
|
25197
|
+
return { id: docSnap.id, ...docSnap.data() };
|
|
25198
|
+
}
|
|
25199
|
+
/**
|
|
25200
|
+
* Gets all resources for a clinic branch
|
|
25201
|
+
*/
|
|
25202
|
+
async getResourcesByClinic(clinicBranchId) {
|
|
25203
|
+
const q = query35(
|
|
25204
|
+
this.getResourcesRef(clinicBranchId),
|
|
25205
|
+
orderBy19("nameLower")
|
|
25206
|
+
);
|
|
25207
|
+
const snapshot = await getDocs35(q);
|
|
25208
|
+
return snapshot.docs.map(
|
|
25209
|
+
(d) => ({ id: d.id, ...d.data() })
|
|
25210
|
+
);
|
|
25211
|
+
}
|
|
25212
|
+
/**
|
|
25213
|
+
* Gets all active resources for a clinic branch
|
|
25214
|
+
*/
|
|
25215
|
+
async getActiveResourcesByClinic(clinicBranchId) {
|
|
25216
|
+
const q = query35(
|
|
25217
|
+
this.getResourcesRef(clinicBranchId),
|
|
25218
|
+
where35("status", "==", "active" /* ACTIVE */),
|
|
25219
|
+
orderBy19("nameLower")
|
|
25220
|
+
);
|
|
25221
|
+
const snapshot = await getDocs35(q);
|
|
25222
|
+
return snapshot.docs.map(
|
|
25223
|
+
(d) => ({ id: d.id, ...d.data() })
|
|
25224
|
+
);
|
|
25225
|
+
}
|
|
25226
|
+
/**
|
|
25227
|
+
* Updates a resource. Handles quantity changes:
|
|
25228
|
+
* - Increasing quantity: creates new instances
|
|
25229
|
+
* - Decreasing quantity: blocked if affected instances have future bookings
|
|
25230
|
+
*/
|
|
25231
|
+
async updateResource(clinicBranchId, resourceId, data) {
|
|
25232
|
+
const existing = await this.getResource(clinicBranchId, resourceId);
|
|
25233
|
+
if (!existing) throw new Error(`Resource ${resourceId} not found`);
|
|
25234
|
+
const updateData = {
|
|
25235
|
+
updatedAt: serverTimestamp36()
|
|
25236
|
+
};
|
|
25237
|
+
if (data.name !== void 0) {
|
|
25238
|
+
updateData.name = data.name;
|
|
25239
|
+
updateData.nameLower = data.name.toLowerCase();
|
|
25240
|
+
}
|
|
25241
|
+
if (data.category !== void 0) updateData.category = data.category;
|
|
25242
|
+
if (data.description !== void 0)
|
|
25243
|
+
updateData.description = data.description;
|
|
25244
|
+
if (data.status !== void 0) updateData.status = data.status;
|
|
25245
|
+
if (data.quantity !== void 0 && data.quantity !== existing.quantity) {
|
|
25246
|
+
if (data.quantity > existing.quantity) {
|
|
25247
|
+
const batch = writeBatch7(this.db);
|
|
25248
|
+
const now = serverTimestamp36();
|
|
25249
|
+
const resourceName = data.name || existing.name;
|
|
25250
|
+
for (let i = existing.quantity + 1; i <= data.quantity; i++) {
|
|
25251
|
+
const instanceRef = doc45(
|
|
25252
|
+
this.getInstancesRef(clinicBranchId, resourceId)
|
|
25253
|
+
);
|
|
25254
|
+
const instanceData = {
|
|
25255
|
+
id: instanceRef.id,
|
|
25256
|
+
resourceId,
|
|
25257
|
+
clinicBranchId,
|
|
25258
|
+
label: `${resourceName} #${i}`,
|
|
25259
|
+
index: i,
|
|
25260
|
+
status: "active" /* ACTIVE */,
|
|
25261
|
+
createdAt: now,
|
|
25262
|
+
updatedAt: now
|
|
25263
|
+
};
|
|
25264
|
+
batch.set(instanceRef, instanceData);
|
|
25265
|
+
}
|
|
25266
|
+
updateData.quantity = data.quantity;
|
|
25267
|
+
const resourceDocRef2 = this.getResourceDocRef(
|
|
25268
|
+
clinicBranchId,
|
|
25269
|
+
resourceId
|
|
25270
|
+
);
|
|
25271
|
+
batch.update(resourceDocRef2, updateData);
|
|
25272
|
+
await batch.commit();
|
|
25273
|
+
const updated2 = await this.getResource(clinicBranchId, resourceId);
|
|
25274
|
+
if (!updated2) throw new Error("Failed to read updated resource");
|
|
25275
|
+
return updated2;
|
|
25276
|
+
} else {
|
|
25277
|
+
const instances = await this.getResourceInstances(
|
|
25278
|
+
clinicBranchId,
|
|
25279
|
+
resourceId
|
|
25280
|
+
);
|
|
25281
|
+
const instancesToRemove = instances.filter((inst) => inst.index > data.quantity).filter((inst) => inst.status === "active" /* ACTIVE */);
|
|
25282
|
+
for (const instance of instancesToRemove) {
|
|
25283
|
+
const hasFutureBookings = await this.instanceHasFutureBookings(
|
|
25284
|
+
clinicBranchId,
|
|
25285
|
+
resourceId,
|
|
25286
|
+
instance.id
|
|
25287
|
+
);
|
|
25288
|
+
if (hasFutureBookings) {
|
|
25289
|
+
throw new Error(
|
|
25290
|
+
`Cannot reduce quantity: instance "${instance.label}" has future bookings. Cancel those bookings first.`
|
|
25291
|
+
);
|
|
25292
|
+
}
|
|
25293
|
+
}
|
|
25294
|
+
const batch = writeBatch7(this.db);
|
|
25295
|
+
for (const instance of instancesToRemove) {
|
|
25296
|
+
const instanceRef = doc45(
|
|
25297
|
+
this.getInstancesRef(clinicBranchId, resourceId),
|
|
25298
|
+
instance.id
|
|
25299
|
+
);
|
|
25300
|
+
batch.update(instanceRef, {
|
|
25301
|
+
status: "inactive" /* INACTIVE */,
|
|
25302
|
+
updatedAt: serverTimestamp36()
|
|
25303
|
+
});
|
|
25304
|
+
}
|
|
25305
|
+
updateData.quantity = data.quantity;
|
|
25306
|
+
const resourceDocRef2 = this.getResourceDocRef(
|
|
25307
|
+
clinicBranchId,
|
|
25308
|
+
resourceId
|
|
25309
|
+
);
|
|
25310
|
+
batch.update(resourceDocRef2, updateData);
|
|
25311
|
+
await batch.commit();
|
|
25312
|
+
const updated2 = await this.getResource(clinicBranchId, resourceId);
|
|
25313
|
+
if (!updated2) throw new Error("Failed to read updated resource");
|
|
25314
|
+
return updated2;
|
|
25315
|
+
}
|
|
25316
|
+
}
|
|
25317
|
+
const resourceDocRef = this.getResourceDocRef(clinicBranchId, resourceId);
|
|
25318
|
+
await updateDoc41(resourceDocRef, updateData);
|
|
25319
|
+
const updated = await this.getResource(clinicBranchId, resourceId);
|
|
25320
|
+
if (!updated) throw new Error("Failed to read updated resource");
|
|
25321
|
+
return updated;
|
|
25322
|
+
}
|
|
25323
|
+
/**
|
|
25324
|
+
* Soft deletes a resource by setting status to INACTIVE
|
|
25325
|
+
*/
|
|
25326
|
+
async deleteResource(clinicBranchId, resourceId) {
|
|
25327
|
+
await this.updateResource(clinicBranchId, resourceId, {
|
|
25328
|
+
status: "inactive" /* INACTIVE */
|
|
25329
|
+
});
|
|
25330
|
+
}
|
|
25331
|
+
/**
|
|
25332
|
+
* Gets all instances for a resource
|
|
25333
|
+
*/
|
|
25334
|
+
async getResourceInstances(clinicBranchId, resourceId) {
|
|
25335
|
+
const q = query35(
|
|
25336
|
+
this.getInstancesRef(clinicBranchId, resourceId),
|
|
25337
|
+
orderBy19("index")
|
|
25338
|
+
);
|
|
25339
|
+
const snapshot = await getDocs35(q);
|
|
25340
|
+
return snapshot.docs.map(
|
|
25341
|
+
(d) => ({ id: d.id, ...d.data() })
|
|
25342
|
+
);
|
|
25343
|
+
}
|
|
25344
|
+
/**
|
|
25345
|
+
* Gets active instances for a resource
|
|
25346
|
+
*/
|
|
25347
|
+
async getActiveResourceInstances(clinicBranchId, resourceId) {
|
|
25348
|
+
const q = query35(
|
|
25349
|
+
this.getInstancesRef(clinicBranchId, resourceId),
|
|
25350
|
+
where35("status", "==", "active" /* ACTIVE */),
|
|
25351
|
+
orderBy19("index")
|
|
25352
|
+
);
|
|
25353
|
+
const snapshot = await getDocs35(q);
|
|
25354
|
+
return snapshot.docs.map(
|
|
25355
|
+
(d) => ({ id: d.id, ...d.data() })
|
|
25356
|
+
);
|
|
25357
|
+
}
|
|
25358
|
+
/**
|
|
25359
|
+
* Gets calendar events for a specific resource instance within a time range
|
|
25360
|
+
*/
|
|
25361
|
+
async getResourceCalendarEvents(clinicBranchId, resourceId, instanceId, start, end) {
|
|
25362
|
+
const calendarRef = this.getInstanceCalendarRef(
|
|
25363
|
+
clinicBranchId,
|
|
25364
|
+
resourceId,
|
|
25365
|
+
instanceId
|
|
25366
|
+
);
|
|
25367
|
+
const q = query35(
|
|
25368
|
+
calendarRef,
|
|
25369
|
+
where35("eventTime.start", ">=", start),
|
|
25370
|
+
where35("eventTime.start", "<=", end),
|
|
25371
|
+
orderBy19("eventTime.start")
|
|
25372
|
+
);
|
|
25373
|
+
const snapshot = await getDocs35(q);
|
|
25374
|
+
return snapshot.docs.map(
|
|
25375
|
+
(d) => ({ id: d.id, ...d.data() })
|
|
25376
|
+
);
|
|
25377
|
+
}
|
|
25378
|
+
/**
|
|
25379
|
+
* Checks if a resource instance has any future active bookings
|
|
25380
|
+
*/
|
|
25381
|
+
async instanceHasFutureBookings(clinicBranchId, resourceId, instanceId) {
|
|
25382
|
+
const now = Timestamp37.now();
|
|
25383
|
+
const calendarRef = this.getInstanceCalendarRef(
|
|
25384
|
+
clinicBranchId,
|
|
25385
|
+
resourceId,
|
|
25386
|
+
instanceId
|
|
25387
|
+
);
|
|
25388
|
+
const q = query35(
|
|
25389
|
+
calendarRef,
|
|
25390
|
+
where35("eventTime.start", ">=", now),
|
|
25391
|
+
where35("status", "in", ["pending", "confirmed"])
|
|
25392
|
+
);
|
|
25393
|
+
const snapshot = await getDocs35(q);
|
|
25394
|
+
return !snapshot.empty;
|
|
25395
|
+
}
|
|
25396
|
+
// --- Resource Instance Blocking Events ---
|
|
25397
|
+
/**
|
|
25398
|
+
* Creates a blocking event on a resource instance's calendar.
|
|
25399
|
+
* Blocking events prevent the instance from being booked during the specified time.
|
|
25400
|
+
*/
|
|
25401
|
+
async createResourceBlockingEvent(params) {
|
|
25402
|
+
createResourceBlockingEventSchema.parse(params);
|
|
25403
|
+
const calendarRef = this.getInstanceCalendarRef(
|
|
25404
|
+
params.clinicBranchId,
|
|
25405
|
+
params.resourceId,
|
|
25406
|
+
params.resourceInstanceId
|
|
25407
|
+
);
|
|
25408
|
+
const eventRef = doc45(calendarRef);
|
|
25409
|
+
const now = serverTimestamp36();
|
|
25410
|
+
const eventData = {
|
|
25411
|
+
id: eventRef.id,
|
|
25412
|
+
resourceId: params.resourceId,
|
|
25413
|
+
resourceInstanceId: params.resourceInstanceId,
|
|
25414
|
+
clinicBranchId: params.clinicBranchId,
|
|
25415
|
+
eventType: "blocking" /* BLOCKING */,
|
|
25416
|
+
eventName: params.eventName,
|
|
25417
|
+
eventTime: params.eventTime,
|
|
25418
|
+
status: "confirmed" /* CONFIRMED */,
|
|
25419
|
+
description: params.description || "",
|
|
25420
|
+
createdAt: now,
|
|
25421
|
+
updatedAt: now
|
|
25422
|
+
};
|
|
25423
|
+
await setDoc32(eventRef, eventData);
|
|
25424
|
+
return {
|
|
25425
|
+
...eventData,
|
|
25426
|
+
createdAt: Timestamp37.now(),
|
|
25427
|
+
updatedAt: Timestamp37.now()
|
|
25428
|
+
};
|
|
25429
|
+
}
|
|
25430
|
+
/**
|
|
25431
|
+
* Updates an existing blocking event on a resource instance's calendar.
|
|
25432
|
+
* Only provided fields are updated.
|
|
25433
|
+
*/
|
|
25434
|
+
async updateResourceBlockingEvent(params) {
|
|
25435
|
+
updateResourceBlockingEventSchema.parse(params);
|
|
25436
|
+
const calendarRef = this.getInstanceCalendarRef(
|
|
25437
|
+
params.clinicBranchId,
|
|
25438
|
+
params.resourceId,
|
|
25439
|
+
params.resourceInstanceId
|
|
25440
|
+
);
|
|
25441
|
+
const eventRef = doc45(calendarRef, params.eventId);
|
|
25442
|
+
const eventSnap = await getDoc46(eventRef);
|
|
25443
|
+
if (!eventSnap.exists()) {
|
|
25444
|
+
throw new Error(`Blocking event ${params.eventId} not found`);
|
|
25445
|
+
}
|
|
25446
|
+
const updateData = {
|
|
25447
|
+
updatedAt: serverTimestamp36()
|
|
25448
|
+
};
|
|
25449
|
+
if (params.eventName !== void 0) {
|
|
25450
|
+
updateData.eventName = params.eventName;
|
|
25451
|
+
}
|
|
25452
|
+
if (params.eventTime !== void 0) {
|
|
25453
|
+
updateData.eventTime = params.eventTime;
|
|
25454
|
+
}
|
|
25455
|
+
if (params.description !== void 0) {
|
|
25456
|
+
updateData.description = params.description;
|
|
25457
|
+
}
|
|
25458
|
+
await updateDoc41(eventRef, updateData);
|
|
25459
|
+
const updatedSnap = await getDoc46(eventRef);
|
|
25460
|
+
return { id: updatedSnap.id, ...updatedSnap.data() };
|
|
25461
|
+
}
|
|
25462
|
+
/**
|
|
25463
|
+
* Deletes a blocking event from a resource instance's calendar (hard delete).
|
|
25464
|
+
*/
|
|
25465
|
+
async deleteResourceBlockingEvent(clinicBranchId, resourceId, instanceId, eventId) {
|
|
25466
|
+
const calendarRef = this.getInstanceCalendarRef(
|
|
25467
|
+
clinicBranchId,
|
|
25468
|
+
resourceId,
|
|
25469
|
+
instanceId
|
|
25470
|
+
);
|
|
25471
|
+
const eventRef = doc45(calendarRef, eventId);
|
|
25472
|
+
const eventSnap = await getDoc46(eventRef);
|
|
25473
|
+
if (!eventSnap.exists()) {
|
|
25474
|
+
throw new Error(`Blocking event ${eventId} not found`);
|
|
25475
|
+
}
|
|
25476
|
+
await deleteDoc20(eventRef);
|
|
25477
|
+
}
|
|
25478
|
+
/**
|
|
25479
|
+
* Gets all blocking events for a resource instance, ordered by start time.
|
|
25480
|
+
*/
|
|
25481
|
+
async getResourceInstanceBlockingEvents(clinicBranchId, resourceId, instanceId) {
|
|
25482
|
+
const calendarRef = this.getInstanceCalendarRef(
|
|
25483
|
+
clinicBranchId,
|
|
25484
|
+
resourceId,
|
|
25485
|
+
instanceId
|
|
25486
|
+
);
|
|
25487
|
+
const q = query35(
|
|
25488
|
+
calendarRef,
|
|
25489
|
+
where35("eventType", "==", "blocking" /* BLOCKING */),
|
|
25490
|
+
orderBy19("eventTime.start")
|
|
25491
|
+
);
|
|
25492
|
+
const snapshot = await getDocs35(q);
|
|
25493
|
+
return snapshot.docs.map(
|
|
25494
|
+
(d) => ({ id: d.id, ...d.data() })
|
|
25495
|
+
);
|
|
25496
|
+
}
|
|
25497
|
+
};
|
|
25498
|
+
|
|
25499
|
+
// src/services/reviews/reviews.service.ts
|
|
25500
|
+
import {
|
|
25501
|
+
collection as collection36,
|
|
25502
|
+
doc as doc46,
|
|
25503
|
+
getDoc as getDoc47,
|
|
25504
|
+
getDocs as getDocs36,
|
|
25505
|
+
query as query36,
|
|
25506
|
+
where as where36,
|
|
25507
|
+
setDoc as setDoc33,
|
|
25508
|
+
deleteDoc as deleteDoc21,
|
|
25509
|
+
serverTimestamp as serverTimestamp37
|
|
25510
|
+
} from "firebase/firestore";
|
|
25511
|
+
import { z as z32 } from "zod";
|
|
24998
25512
|
var ReviewService = class extends BaseService {
|
|
24999
25513
|
constructor(db, auth, app) {
|
|
25000
25514
|
super(db, auth, app);
|
|
@@ -25146,16 +25660,16 @@ var ReviewService = class extends BaseService {
|
|
|
25146
25660
|
reviewSchema.parse(review);
|
|
25147
25661
|
const firestoreData = {
|
|
25148
25662
|
...review,
|
|
25149
|
-
createdAt:
|
|
25150
|
-
updatedAt:
|
|
25663
|
+
createdAt: serverTimestamp37(),
|
|
25664
|
+
updatedAt: serverTimestamp37()
|
|
25151
25665
|
};
|
|
25152
25666
|
Object.keys(firestoreData).forEach((key) => {
|
|
25153
25667
|
if (firestoreData[key] === void 0) {
|
|
25154
25668
|
delete firestoreData[key];
|
|
25155
25669
|
}
|
|
25156
25670
|
});
|
|
25157
|
-
const docRef =
|
|
25158
|
-
await
|
|
25671
|
+
const docRef = doc46(this.db, REVIEWS_COLLECTION, reviewId);
|
|
25672
|
+
await setDoc33(docRef, firestoreData);
|
|
25159
25673
|
console.log("\u2705 ReviewService.createReview - Review saved to Firestore:", {
|
|
25160
25674
|
reviewId,
|
|
25161
25675
|
practitionerId: (_e = review.practitionerReview) == null ? void 0 : _e.practitionerId,
|
|
@@ -25165,7 +25679,7 @@ var ReviewService = class extends BaseService {
|
|
|
25165
25679
|
});
|
|
25166
25680
|
return review;
|
|
25167
25681
|
} catch (error) {
|
|
25168
|
-
if (error instanceof
|
|
25682
|
+
if (error instanceof z32.ZodError) {
|
|
25169
25683
|
throw new Error(`Invalid review data: ${error.message}`);
|
|
25170
25684
|
}
|
|
25171
25685
|
throw error;
|
|
@@ -25179,16 +25693,16 @@ var ReviewService = class extends BaseService {
|
|
|
25179
25693
|
async getReview(reviewId) {
|
|
25180
25694
|
var _a, _b, _c, _d, _e;
|
|
25181
25695
|
console.log("\u{1F50D} ReviewService.getReview - Getting review:", reviewId);
|
|
25182
|
-
const docRef =
|
|
25183
|
-
const docSnap = await
|
|
25696
|
+
const docRef = doc46(this.db, REVIEWS_COLLECTION, reviewId);
|
|
25697
|
+
const docSnap = await getDoc47(docRef);
|
|
25184
25698
|
if (!docSnap.exists()) {
|
|
25185
25699
|
console.log("\u274C ReviewService.getReview - Review not found:", reviewId);
|
|
25186
25700
|
return null;
|
|
25187
25701
|
}
|
|
25188
25702
|
const review = { ...this.convertDocToReview(docSnap.data()), id: reviewId };
|
|
25189
25703
|
try {
|
|
25190
|
-
const appointmentDoc = await
|
|
25191
|
-
|
|
25704
|
+
const appointmentDoc = await getDoc47(
|
|
25705
|
+
doc46(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
|
|
25192
25706
|
);
|
|
25193
25707
|
if (appointmentDoc.exists()) {
|
|
25194
25708
|
const appointment = appointmentDoc.data();
|
|
@@ -25248,14 +25762,14 @@ var ReviewService = class extends BaseService {
|
|
|
25248
25762
|
* @returns Array of reviews for the patient with clinic, practitioner, and procedure names
|
|
25249
25763
|
*/
|
|
25250
25764
|
async getReviewsByPatient(patientId) {
|
|
25251
|
-
const q =
|
|
25252
|
-
const snapshot = await
|
|
25253
|
-
const reviews = snapshot.docs.map((
|
|
25765
|
+
const q = query36(collection36(this.db, REVIEWS_COLLECTION), where36("patientId", "==", patientId));
|
|
25766
|
+
const snapshot = await getDocs36(q);
|
|
25767
|
+
const reviews = snapshot.docs.map((doc53) => this.convertDocToReview(doc53.data()));
|
|
25254
25768
|
const enhancedReviews = await Promise.all(
|
|
25255
25769
|
reviews.map(async (review) => {
|
|
25256
25770
|
try {
|
|
25257
|
-
const appointmentDoc = await
|
|
25258
|
-
|
|
25771
|
+
const appointmentDoc = await getDoc47(
|
|
25772
|
+
doc46(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
|
|
25259
25773
|
);
|
|
25260
25774
|
if (appointmentDoc.exists()) {
|
|
25261
25775
|
const appointment = appointmentDoc.data();
|
|
@@ -25299,14 +25813,14 @@ var ReviewService = class extends BaseService {
|
|
|
25299
25813
|
*/
|
|
25300
25814
|
async getReviewsByClinic(clinicId) {
|
|
25301
25815
|
console.log("\u{1F50D} ReviewService.getReviewsByClinic - Querying for clinic:", clinicId);
|
|
25302
|
-
const q =
|
|
25303
|
-
|
|
25304
|
-
|
|
25816
|
+
const q = query36(
|
|
25817
|
+
collection36(this.db, REVIEWS_COLLECTION),
|
|
25818
|
+
where36("clinicReview.clinicId", "==", clinicId)
|
|
25305
25819
|
);
|
|
25306
|
-
const snapshot = await
|
|
25307
|
-
const reviews = snapshot.docs.map((
|
|
25308
|
-
const review = this.convertDocToReview(
|
|
25309
|
-
return { ...review, id:
|
|
25820
|
+
const snapshot = await getDocs36(q);
|
|
25821
|
+
const reviews = snapshot.docs.map((doc53) => {
|
|
25822
|
+
const review = this.convertDocToReview(doc53.data());
|
|
25823
|
+
return { ...review, id: doc53.id };
|
|
25310
25824
|
});
|
|
25311
25825
|
console.log("\u{1F50D} ReviewService.getReviewsByClinic - Found reviews before enhancement:", {
|
|
25312
25826
|
clinicId,
|
|
@@ -25316,8 +25830,8 @@ var ReviewService = class extends BaseService {
|
|
|
25316
25830
|
const enhancedReviews = await Promise.all(
|
|
25317
25831
|
reviews.map(async (review) => {
|
|
25318
25832
|
try {
|
|
25319
|
-
const appointmentDoc = await
|
|
25320
|
-
|
|
25833
|
+
const appointmentDoc = await getDoc47(
|
|
25834
|
+
doc46(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
|
|
25321
25835
|
);
|
|
25322
25836
|
if (appointmentDoc.exists()) {
|
|
25323
25837
|
const appointment = appointmentDoc.data();
|
|
@@ -25375,14 +25889,14 @@ var ReviewService = class extends BaseService {
|
|
|
25375
25889
|
"\u{1F50D} ReviewService.getReviewsByPractitioner - Querying for practitioner:",
|
|
25376
25890
|
practitionerId
|
|
25377
25891
|
);
|
|
25378
|
-
const q =
|
|
25379
|
-
|
|
25380
|
-
|
|
25892
|
+
const q = query36(
|
|
25893
|
+
collection36(this.db, REVIEWS_COLLECTION),
|
|
25894
|
+
where36("practitionerReview.practitionerId", "==", practitionerId)
|
|
25381
25895
|
);
|
|
25382
|
-
const snapshot = await
|
|
25383
|
-
const reviews = snapshot.docs.map((
|
|
25384
|
-
const review = this.convertDocToReview(
|
|
25385
|
-
return { ...review, id:
|
|
25896
|
+
const snapshot = await getDocs36(q);
|
|
25897
|
+
const reviews = snapshot.docs.map((doc53) => {
|
|
25898
|
+
const review = this.convertDocToReview(doc53.data());
|
|
25899
|
+
return { ...review, id: doc53.id };
|
|
25386
25900
|
});
|
|
25387
25901
|
console.log("\u{1F50D} ReviewService.getReviewsByPractitioner - Found reviews before enhancement:", {
|
|
25388
25902
|
practitionerId,
|
|
@@ -25392,8 +25906,8 @@ var ReviewService = class extends BaseService {
|
|
|
25392
25906
|
const enhancedReviews = await Promise.all(
|
|
25393
25907
|
reviews.map(async (review) => {
|
|
25394
25908
|
try {
|
|
25395
|
-
const appointmentDoc = await
|
|
25396
|
-
|
|
25909
|
+
const appointmentDoc = await getDoc47(
|
|
25910
|
+
doc46(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
|
|
25397
25911
|
);
|
|
25398
25912
|
if (appointmentDoc.exists()) {
|
|
25399
25913
|
const appointment = appointmentDoc.data();
|
|
@@ -25448,14 +25962,14 @@ var ReviewService = class extends BaseService {
|
|
|
25448
25962
|
*/
|
|
25449
25963
|
async getReviewsByProcedure(procedureId) {
|
|
25450
25964
|
console.log("\u{1F50D} ReviewService.getReviewsByProcedure - Querying for procedure:", procedureId);
|
|
25451
|
-
const q =
|
|
25452
|
-
|
|
25453
|
-
|
|
25965
|
+
const q = query36(
|
|
25966
|
+
collection36(this.db, REVIEWS_COLLECTION),
|
|
25967
|
+
where36("procedureReview.procedureId", "==", procedureId)
|
|
25454
25968
|
);
|
|
25455
|
-
const snapshot = await
|
|
25456
|
-
const reviews = snapshot.docs.map((
|
|
25457
|
-
const data =
|
|
25458
|
-
return { ...data, id:
|
|
25969
|
+
const snapshot = await getDocs36(q);
|
|
25970
|
+
const reviews = snapshot.docs.map((doc53) => {
|
|
25971
|
+
const data = doc53.data();
|
|
25972
|
+
return { ...data, id: doc53.id };
|
|
25459
25973
|
});
|
|
25460
25974
|
console.log("\u{1F50D} ReviewService.getReviewsByProcedure - Found reviews before enhancement:", {
|
|
25461
25975
|
procedureId,
|
|
@@ -25465,8 +25979,8 @@ var ReviewService = class extends BaseService {
|
|
|
25465
25979
|
const enhancedReviews = await Promise.all(
|
|
25466
25980
|
reviews.map(async (review) => {
|
|
25467
25981
|
try {
|
|
25468
|
-
const appointmentDoc = await
|
|
25469
|
-
|
|
25982
|
+
const appointmentDoc = await getDoc47(
|
|
25983
|
+
doc46(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
|
|
25470
25984
|
);
|
|
25471
25985
|
if (appointmentDoc.exists()) {
|
|
25472
25986
|
const appointment = appointmentDoc.data();
|
|
@@ -25520,11 +26034,11 @@ var ReviewService = class extends BaseService {
|
|
|
25520
26034
|
* @returns The review for the appointment if found, null otherwise
|
|
25521
26035
|
*/
|
|
25522
26036
|
async getReviewByAppointment(appointmentId) {
|
|
25523
|
-
const q =
|
|
25524
|
-
|
|
25525
|
-
|
|
26037
|
+
const q = query36(
|
|
26038
|
+
collection36(this.db, REVIEWS_COLLECTION),
|
|
26039
|
+
where36("appointmentId", "==", appointmentId)
|
|
25526
26040
|
);
|
|
25527
|
-
const snapshot = await
|
|
26041
|
+
const snapshot = await getDocs36(q);
|
|
25528
26042
|
if (snapshot.empty) {
|
|
25529
26043
|
return null;
|
|
25530
26044
|
}
|
|
@@ -25539,7 +26053,7 @@ var ReviewService = class extends BaseService {
|
|
|
25539
26053
|
if (!review) {
|
|
25540
26054
|
throw new Error(`Review with ID ${reviewId} not found`);
|
|
25541
26055
|
}
|
|
25542
|
-
await
|
|
26056
|
+
await deleteDoc21(doc46(this.db, REVIEWS_COLLECTION, reviewId));
|
|
25543
26057
|
}
|
|
25544
26058
|
/**
|
|
25545
26059
|
* Calculates the average of an array of numbers
|
|
@@ -25612,15 +26126,15 @@ var getFirebaseFunctions = async () => {
|
|
|
25612
26126
|
// src/backoffice/services/brand.service.ts
|
|
25613
26127
|
import {
|
|
25614
26128
|
addDoc as addDoc4,
|
|
25615
|
-
collection as
|
|
25616
|
-
doc as
|
|
25617
|
-
getDoc as
|
|
25618
|
-
getDocs as
|
|
25619
|
-
query as
|
|
25620
|
-
updateDoc as
|
|
25621
|
-
where as
|
|
26129
|
+
collection as collection37,
|
|
26130
|
+
doc as doc47,
|
|
26131
|
+
getDoc as getDoc48,
|
|
26132
|
+
getDocs as getDocs37,
|
|
26133
|
+
query as query37,
|
|
26134
|
+
updateDoc as updateDoc42,
|
|
26135
|
+
where as where37,
|
|
25622
26136
|
limit as limit17,
|
|
25623
|
-
orderBy as
|
|
26137
|
+
orderBy as orderBy20,
|
|
25624
26138
|
startAfter as startAfter15,
|
|
25625
26139
|
getCountFromServer as getCountFromServer3
|
|
25626
26140
|
} from "firebase/firestore";
|
|
@@ -25634,7 +26148,7 @@ var BrandService = class extends BaseService {
|
|
|
25634
26148
|
* Gets reference to brands collection
|
|
25635
26149
|
*/
|
|
25636
26150
|
getBrandsRef() {
|
|
25637
|
-
return
|
|
26151
|
+
return collection37(this.db, BRANDS_COLLECTION);
|
|
25638
26152
|
}
|
|
25639
26153
|
/**
|
|
25640
26154
|
* Creates a new brand
|
|
@@ -25659,26 +26173,26 @@ var BrandService = class extends BaseService {
|
|
|
25659
26173
|
*/
|
|
25660
26174
|
async getAll(rowsPerPage, searchTerm, lastVisible) {
|
|
25661
26175
|
const constraints = [
|
|
25662
|
-
|
|
25663
|
-
|
|
26176
|
+
where37("isActive", "==", true),
|
|
26177
|
+
orderBy20("name_lowercase")
|
|
25664
26178
|
];
|
|
25665
26179
|
if (searchTerm) {
|
|
25666
26180
|
const lowercasedSearchTerm = searchTerm.toLowerCase();
|
|
25667
|
-
constraints.push(
|
|
26181
|
+
constraints.push(where37("name_lowercase", ">=", lowercasedSearchTerm));
|
|
25668
26182
|
constraints.push(
|
|
25669
|
-
|
|
26183
|
+
where37("name_lowercase", "<=", lowercasedSearchTerm + "\uF8FF")
|
|
25670
26184
|
);
|
|
25671
26185
|
}
|
|
25672
26186
|
if (lastVisible) {
|
|
25673
26187
|
constraints.push(startAfter15(lastVisible));
|
|
25674
26188
|
}
|
|
25675
26189
|
constraints.push(limit17(rowsPerPage));
|
|
25676
|
-
const q =
|
|
25677
|
-
const snapshot = await
|
|
26190
|
+
const q = query37(this.getBrandsRef(), ...constraints);
|
|
26191
|
+
const snapshot = await getDocs37(q);
|
|
25678
26192
|
const brands = snapshot.docs.map(
|
|
25679
|
-
(
|
|
25680
|
-
id:
|
|
25681
|
-
...
|
|
26193
|
+
(doc53) => ({
|
|
26194
|
+
id: doc53.id,
|
|
26195
|
+
...doc53.data()
|
|
25682
26196
|
})
|
|
25683
26197
|
);
|
|
25684
26198
|
const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
|
|
@@ -25689,15 +26203,15 @@ var BrandService = class extends BaseService {
|
|
|
25689
26203
|
* @param searchTerm - An optional string to filter brand names by (starts-with search).
|
|
25690
26204
|
*/
|
|
25691
26205
|
async getBrandsCount(searchTerm) {
|
|
25692
|
-
const constraints = [
|
|
26206
|
+
const constraints = [where37("isActive", "==", true)];
|
|
25693
26207
|
if (searchTerm) {
|
|
25694
26208
|
const lowercasedSearchTerm = searchTerm.toLowerCase();
|
|
25695
|
-
constraints.push(
|
|
26209
|
+
constraints.push(where37("name_lowercase", ">=", lowercasedSearchTerm));
|
|
25696
26210
|
constraints.push(
|
|
25697
|
-
|
|
26211
|
+
where37("name_lowercase", "<=", lowercasedSearchTerm + "\uF8FF")
|
|
25698
26212
|
);
|
|
25699
26213
|
}
|
|
25700
|
-
const q =
|
|
26214
|
+
const q = query37(this.getBrandsRef(), ...constraints);
|
|
25701
26215
|
const snapshot = await getCountFromServer3(q);
|
|
25702
26216
|
return snapshot.data().count;
|
|
25703
26217
|
}
|
|
@@ -25705,16 +26219,16 @@ var BrandService = class extends BaseService {
|
|
|
25705
26219
|
* Gets all active brands for filter dropdowns (not paginated).
|
|
25706
26220
|
*/
|
|
25707
26221
|
async getAllForFilter() {
|
|
25708
|
-
const q =
|
|
26222
|
+
const q = query37(
|
|
25709
26223
|
this.getBrandsRef(),
|
|
25710
|
-
|
|
25711
|
-
|
|
26224
|
+
where37("isActive", "==", true),
|
|
26225
|
+
orderBy20("name")
|
|
25712
26226
|
);
|
|
25713
|
-
const snapshot = await
|
|
26227
|
+
const snapshot = await getDocs37(q);
|
|
25714
26228
|
return snapshot.docs.map(
|
|
25715
|
-
(
|
|
25716
|
-
id:
|
|
25717
|
-
...
|
|
26229
|
+
(doc53) => ({
|
|
26230
|
+
id: doc53.id,
|
|
26231
|
+
...doc53.data()
|
|
25718
26232
|
})
|
|
25719
26233
|
);
|
|
25720
26234
|
}
|
|
@@ -25729,8 +26243,8 @@ var BrandService = class extends BaseService {
|
|
|
25729
26243
|
if (brand.name) {
|
|
25730
26244
|
updateData.name_lowercase = brand.name.toLowerCase();
|
|
25731
26245
|
}
|
|
25732
|
-
const docRef =
|
|
25733
|
-
await
|
|
26246
|
+
const docRef = doc47(this.getBrandsRef(), brandId);
|
|
26247
|
+
await updateDoc42(docRef, updateData);
|
|
25734
26248
|
return this.getById(brandId);
|
|
25735
26249
|
}
|
|
25736
26250
|
/**
|
|
@@ -25745,8 +26259,8 @@ var BrandService = class extends BaseService {
|
|
|
25745
26259
|
* Gets a brand by ID
|
|
25746
26260
|
*/
|
|
25747
26261
|
async getById(brandId) {
|
|
25748
|
-
const docRef =
|
|
25749
|
-
const docSnap = await
|
|
26262
|
+
const docRef = doc47(this.getBrandsRef(), brandId);
|
|
26263
|
+
const docSnap = await getDoc48(docRef);
|
|
25750
26264
|
if (!docSnap.exists()) return null;
|
|
25751
26265
|
return {
|
|
25752
26266
|
id: docSnap.id,
|
|
@@ -25776,14 +26290,14 @@ var BrandService = class extends BaseService {
|
|
|
25776
26290
|
let cursor;
|
|
25777
26291
|
const baseConstraints = [];
|
|
25778
26292
|
if (!includeInactive) {
|
|
25779
|
-
baseConstraints.push(
|
|
26293
|
+
baseConstraints.push(where37("isActive", "==", true));
|
|
25780
26294
|
}
|
|
25781
|
-
baseConstraints.push(
|
|
26295
|
+
baseConstraints.push(orderBy20("name_lowercase"));
|
|
25782
26296
|
while (true) {
|
|
25783
26297
|
const constraints = [...baseConstraints, limit17(PAGE_SIZE)];
|
|
25784
26298
|
if (cursor) constraints.push(startAfter15(cursor));
|
|
25785
|
-
const q =
|
|
25786
|
-
const snapshot = await
|
|
26299
|
+
const q = query37(this.getBrandsRef(), ...constraints);
|
|
26300
|
+
const snapshot = await getDocs37(q);
|
|
25787
26301
|
if (snapshot.empty) break;
|
|
25788
26302
|
for (const d of snapshot.docs) {
|
|
25789
26303
|
const brand = { id: d.id, ...d.data() };
|
|
@@ -25825,16 +26339,16 @@ var BrandService = class extends BaseService {
|
|
|
25825
26339
|
// src/backoffice/services/category.service.ts
|
|
25826
26340
|
import {
|
|
25827
26341
|
addDoc as addDoc5,
|
|
25828
|
-
collection as
|
|
25829
|
-
doc as
|
|
25830
|
-
getDoc as
|
|
25831
|
-
getDocs as
|
|
26342
|
+
collection as collection38,
|
|
26343
|
+
doc as doc48,
|
|
26344
|
+
getDoc as getDoc49,
|
|
26345
|
+
getDocs as getDocs38,
|
|
25832
26346
|
limit as limit18,
|
|
25833
|
-
orderBy as
|
|
25834
|
-
query as
|
|
26347
|
+
orderBy as orderBy21,
|
|
26348
|
+
query as query38,
|
|
25835
26349
|
startAfter as startAfter16,
|
|
25836
|
-
updateDoc as
|
|
25837
|
-
where as
|
|
26350
|
+
updateDoc as updateDoc43,
|
|
26351
|
+
where as where38
|
|
25838
26352
|
} from "firebase/firestore";
|
|
25839
26353
|
|
|
25840
26354
|
// src/backoffice/types/category.types.ts
|
|
@@ -25855,7 +26369,7 @@ var CategoryService = class extends BaseService {
|
|
|
25855
26369
|
* Referenca na Firestore kolekciju kategorija
|
|
25856
26370
|
*/
|
|
25857
26371
|
get categoriesRef() {
|
|
25858
|
-
return
|
|
26372
|
+
return collection38(this.db, CATEGORIES_COLLECTION);
|
|
25859
26373
|
}
|
|
25860
26374
|
/**
|
|
25861
26375
|
* Kreira novu kategoriju u sistemu
|
|
@@ -25882,13 +26396,13 @@ var CategoryService = class extends BaseService {
|
|
|
25882
26396
|
const counts = {};
|
|
25883
26397
|
const families = Object.values(ProcedureFamily);
|
|
25884
26398
|
for (const family of families) {
|
|
25885
|
-
const q =
|
|
26399
|
+
const q = query38(
|
|
25886
26400
|
this.categoriesRef,
|
|
25887
|
-
|
|
25888
|
-
|
|
26401
|
+
where38("family", "==", family),
|
|
26402
|
+
where38("isActive", "==", active)
|
|
25889
26403
|
);
|
|
25890
|
-
const snapshot = await
|
|
25891
|
-
const filteredDocs = snapshot.docs.filter((
|
|
26404
|
+
const snapshot = await getDocs38(q);
|
|
26405
|
+
const filteredDocs = snapshot.docs.filter((doc53) => doc53.id !== EXCLUDED_CATEGORY_ID);
|
|
25892
26406
|
counts[family] = filteredDocs.length;
|
|
25893
26407
|
}
|
|
25894
26408
|
return counts;
|
|
@@ -25898,12 +26412,12 @@ var CategoryService = class extends BaseService {
|
|
|
25898
26412
|
* @returns Lista svih aktivnih kategorija
|
|
25899
26413
|
*/
|
|
25900
26414
|
async getAllForFilter() {
|
|
25901
|
-
const q =
|
|
25902
|
-
const snapshot = await
|
|
26415
|
+
const q = query38(this.categoriesRef, where38("isActive", "==", true));
|
|
26416
|
+
const snapshot = await getDocs38(q);
|
|
25903
26417
|
const categories = snapshot.docs.map(
|
|
25904
|
-
(
|
|
25905
|
-
id:
|
|
25906
|
-
...
|
|
26418
|
+
(doc53) => ({
|
|
26419
|
+
id: doc53.id,
|
|
26420
|
+
...doc53.data()
|
|
25907
26421
|
})
|
|
25908
26422
|
);
|
|
25909
26423
|
return this.filterExcludedCategories(categories);
|
|
@@ -25914,17 +26428,17 @@ var CategoryService = class extends BaseService {
|
|
|
25914
26428
|
* @returns Lista aktivnih kategorija koje pripadaju traženoj familiji
|
|
25915
26429
|
*/
|
|
25916
26430
|
async getAllForFilterByFamily(family) {
|
|
25917
|
-
const q =
|
|
26431
|
+
const q = query38(
|
|
25918
26432
|
this.categoriesRef,
|
|
25919
|
-
|
|
25920
|
-
|
|
25921
|
-
|
|
26433
|
+
where38("family", "==", family),
|
|
26434
|
+
where38("isActive", "==", true),
|
|
26435
|
+
orderBy21("name")
|
|
25922
26436
|
);
|
|
25923
|
-
const snapshot = await
|
|
26437
|
+
const snapshot = await getDocs38(q);
|
|
25924
26438
|
const categories = snapshot.docs.map(
|
|
25925
|
-
(
|
|
25926
|
-
id:
|
|
25927
|
-
...
|
|
26439
|
+
(doc53) => ({
|
|
26440
|
+
id: doc53.id,
|
|
26441
|
+
...doc53.data()
|
|
25928
26442
|
})
|
|
25929
26443
|
);
|
|
25930
26444
|
return this.filterExcludedCategories(categories);
|
|
@@ -25937,17 +26451,17 @@ var CategoryService = class extends BaseService {
|
|
|
25937
26451
|
async getAll(options = {}) {
|
|
25938
26452
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
25939
26453
|
const constraints = [
|
|
25940
|
-
|
|
25941
|
-
|
|
26454
|
+
where38("isActive", "==", active),
|
|
26455
|
+
orderBy21("name"),
|
|
25942
26456
|
queryLimit ? limit18(queryLimit) : void 0,
|
|
25943
26457
|
lastVisible ? startAfter16(lastVisible) : void 0
|
|
25944
26458
|
].filter((c) => !!c);
|
|
25945
|
-
const q =
|
|
25946
|
-
const snapshot = await
|
|
26459
|
+
const q = query38(this.categoriesRef, ...constraints);
|
|
26460
|
+
const snapshot = await getDocs38(q);
|
|
25947
26461
|
const categories = snapshot.docs.map(
|
|
25948
|
-
(
|
|
25949
|
-
id:
|
|
25950
|
-
...
|
|
26462
|
+
(doc53) => ({
|
|
26463
|
+
id: doc53.id,
|
|
26464
|
+
...doc53.data()
|
|
25951
26465
|
})
|
|
25952
26466
|
);
|
|
25953
26467
|
const filteredCategories = this.filterExcludedCategories(categories);
|
|
@@ -25963,18 +26477,18 @@ var CategoryService = class extends BaseService {
|
|
|
25963
26477
|
async getAllByFamily(family, options = {}) {
|
|
25964
26478
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
25965
26479
|
const constraints = [
|
|
25966
|
-
|
|
25967
|
-
|
|
25968
|
-
|
|
26480
|
+
where38("family", "==", family),
|
|
26481
|
+
where38("isActive", "==", active),
|
|
26482
|
+
orderBy21("name"),
|
|
25969
26483
|
queryLimit ? limit18(queryLimit) : void 0,
|
|
25970
26484
|
lastVisible ? startAfter16(lastVisible) : void 0
|
|
25971
26485
|
].filter((c) => !!c);
|
|
25972
|
-
const q =
|
|
25973
|
-
const snapshot = await
|
|
26486
|
+
const q = query38(this.categoriesRef, ...constraints);
|
|
26487
|
+
const snapshot = await getDocs38(q);
|
|
25974
26488
|
const categories = snapshot.docs.map(
|
|
25975
|
-
(
|
|
25976
|
-
id:
|
|
25977
|
-
...
|
|
26489
|
+
(doc53) => ({
|
|
26490
|
+
id: doc53.id,
|
|
26491
|
+
...doc53.data()
|
|
25978
26492
|
})
|
|
25979
26493
|
);
|
|
25980
26494
|
const filteredCategories = this.filterExcludedCategories(categories);
|
|
@@ -25992,8 +26506,8 @@ var CategoryService = class extends BaseService {
|
|
|
25992
26506
|
...category,
|
|
25993
26507
|
updatedAt: /* @__PURE__ */ new Date()
|
|
25994
26508
|
};
|
|
25995
|
-
const docRef =
|
|
25996
|
-
await
|
|
26509
|
+
const docRef = doc48(this.categoriesRef, id);
|
|
26510
|
+
await updateDoc43(docRef, updateData);
|
|
25997
26511
|
return this.getById(id);
|
|
25998
26512
|
}
|
|
25999
26513
|
/**
|
|
@@ -26017,8 +26531,8 @@ var CategoryService = class extends BaseService {
|
|
|
26017
26531
|
*/
|
|
26018
26532
|
async getById(id) {
|
|
26019
26533
|
if (id === EXCLUDED_CATEGORY_ID) return null;
|
|
26020
|
-
const docRef =
|
|
26021
|
-
const docSnap = await
|
|
26534
|
+
const docRef = doc48(this.categoriesRef, id);
|
|
26535
|
+
const docSnap = await getDoc49(docRef);
|
|
26022
26536
|
if (!docSnap.exists()) return null;
|
|
26023
26537
|
return {
|
|
26024
26538
|
id: docSnap.id,
|
|
@@ -26032,8 +26546,8 @@ var CategoryService = class extends BaseService {
|
|
|
26032
26546
|
* @returns Category or null if not found
|
|
26033
26547
|
*/
|
|
26034
26548
|
async getByIdInternal(id) {
|
|
26035
|
-
const docRef =
|
|
26036
|
-
const docSnap = await
|
|
26549
|
+
const docRef = doc48(this.categoriesRef, id);
|
|
26550
|
+
const docSnap = await getDoc49(docRef);
|
|
26037
26551
|
if (!docSnap.exists()) return null;
|
|
26038
26552
|
return {
|
|
26039
26553
|
id: docSnap.id,
|
|
@@ -26048,19 +26562,19 @@ var CategoryService = class extends BaseService {
|
|
|
26048
26562
|
* @returns Category if found, null otherwise
|
|
26049
26563
|
*/
|
|
26050
26564
|
async findByNameAndFamily(name, family) {
|
|
26051
|
-
const q =
|
|
26565
|
+
const q = query38(
|
|
26052
26566
|
this.categoriesRef,
|
|
26053
|
-
|
|
26054
|
-
|
|
26055
|
-
|
|
26567
|
+
where38("name", "==", name),
|
|
26568
|
+
where38("family", "==", family),
|
|
26569
|
+
where38("isActive", "==", true)
|
|
26056
26570
|
);
|
|
26057
|
-
const snapshot = await
|
|
26571
|
+
const snapshot = await getDocs38(q);
|
|
26058
26572
|
if (snapshot.empty) return null;
|
|
26059
|
-
const
|
|
26060
|
-
if (
|
|
26573
|
+
const doc53 = snapshot.docs[0];
|
|
26574
|
+
if (doc53.id === EXCLUDED_CATEGORY_ID) return null;
|
|
26061
26575
|
return {
|
|
26062
|
-
id:
|
|
26063
|
-
...
|
|
26576
|
+
id: doc53.id,
|
|
26577
|
+
...doc53.data()
|
|
26064
26578
|
};
|
|
26065
26579
|
}
|
|
26066
26580
|
/**
|
|
@@ -26085,14 +26599,14 @@ var CategoryService = class extends BaseService {
|
|
|
26085
26599
|
let cursor;
|
|
26086
26600
|
const constraints = [];
|
|
26087
26601
|
if (!includeInactive) {
|
|
26088
|
-
constraints.push(
|
|
26602
|
+
constraints.push(where38("isActive", "==", true));
|
|
26089
26603
|
}
|
|
26090
|
-
constraints.push(
|
|
26604
|
+
constraints.push(orderBy21("name"));
|
|
26091
26605
|
while (true) {
|
|
26092
26606
|
const queryConstraints = [...constraints, limit18(PAGE_SIZE)];
|
|
26093
26607
|
if (cursor) queryConstraints.push(startAfter16(cursor));
|
|
26094
|
-
const q =
|
|
26095
|
-
const snapshot = await
|
|
26608
|
+
const q = query38(this.categoriesRef, ...queryConstraints);
|
|
26609
|
+
const snapshot = await getDocs38(q);
|
|
26096
26610
|
if (snapshot.empty) break;
|
|
26097
26611
|
for (const d of snapshot.docs) {
|
|
26098
26612
|
if (d.id === EXCLUDED_CATEGORY_ID) continue;
|
|
@@ -26134,19 +26648,19 @@ var CategoryService = class extends BaseService {
|
|
|
26134
26648
|
// src/backoffice/services/subcategory.service.ts
|
|
26135
26649
|
import {
|
|
26136
26650
|
addDoc as addDoc6,
|
|
26137
|
-
collection as
|
|
26651
|
+
collection as collection39,
|
|
26138
26652
|
collectionGroup as collectionGroup2,
|
|
26139
|
-
deleteDoc as
|
|
26140
|
-
doc as
|
|
26141
|
-
getDoc as
|
|
26142
|
-
getDocs as
|
|
26653
|
+
deleteDoc as deleteDoc22,
|
|
26654
|
+
doc as doc49,
|
|
26655
|
+
getDoc as getDoc50,
|
|
26656
|
+
getDocs as getDocs39,
|
|
26143
26657
|
limit as limit19,
|
|
26144
|
-
orderBy as
|
|
26145
|
-
query as
|
|
26146
|
-
setDoc as
|
|
26658
|
+
orderBy as orderBy22,
|
|
26659
|
+
query as query39,
|
|
26660
|
+
setDoc as setDoc34,
|
|
26147
26661
|
startAfter as startAfter17,
|
|
26148
|
-
updateDoc as
|
|
26149
|
-
where as
|
|
26662
|
+
updateDoc as updateDoc44,
|
|
26663
|
+
where as where39
|
|
26150
26664
|
} from "firebase/firestore";
|
|
26151
26665
|
|
|
26152
26666
|
// src/backoffice/types/subcategory.types.ts
|
|
@@ -26168,7 +26682,7 @@ var SubcategoryService = class extends BaseService {
|
|
|
26168
26682
|
* @param categoryId - ID roditeljske kategorije
|
|
26169
26683
|
*/
|
|
26170
26684
|
getSubcategoriesRef(categoryId) {
|
|
26171
|
-
return
|
|
26685
|
+
return collection39(
|
|
26172
26686
|
this.db,
|
|
26173
26687
|
CATEGORIES_COLLECTION,
|
|
26174
26688
|
categoryId,
|
|
@@ -26202,15 +26716,15 @@ var SubcategoryService = class extends BaseService {
|
|
|
26202
26716
|
* @returns A record mapping category ID to subcategory count.
|
|
26203
26717
|
*/
|
|
26204
26718
|
async getSubcategoryCounts(active = true) {
|
|
26205
|
-
const categoriesRef =
|
|
26206
|
-
const categoriesSnapshot = await
|
|
26719
|
+
const categoriesRef = collection39(this.db, CATEGORIES_COLLECTION);
|
|
26720
|
+
const categoriesSnapshot = await getDocs39(categoriesRef);
|
|
26207
26721
|
const counts = {};
|
|
26208
26722
|
for (const categoryDoc of categoriesSnapshot.docs) {
|
|
26209
26723
|
const categoryId = categoryDoc.id;
|
|
26210
26724
|
const subcategoriesRef = this.getSubcategoriesRef(categoryId);
|
|
26211
|
-
const q =
|
|
26212
|
-
const snapshot = await
|
|
26213
|
-
const filteredDocs = snapshot.docs.filter((
|
|
26725
|
+
const q = query39(subcategoriesRef, where39("isActive", "==", active));
|
|
26726
|
+
const snapshot = await getDocs39(q);
|
|
26727
|
+
const filteredDocs = snapshot.docs.filter((doc53) => doc53.id !== EXCLUDED_SUBCATEGORY_ID);
|
|
26214
26728
|
counts[categoryId] = filteredDocs.length;
|
|
26215
26729
|
}
|
|
26216
26730
|
return counts;
|
|
@@ -26224,17 +26738,17 @@ var SubcategoryService = class extends BaseService {
|
|
|
26224
26738
|
async getAllByCategoryId(categoryId, options = {}) {
|
|
26225
26739
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
26226
26740
|
const constraints = [
|
|
26227
|
-
|
|
26228
|
-
|
|
26741
|
+
where39("isActive", "==", active),
|
|
26742
|
+
orderBy22("name"),
|
|
26229
26743
|
queryLimit ? limit19(queryLimit) : void 0,
|
|
26230
26744
|
lastVisible ? startAfter17(lastVisible) : void 0
|
|
26231
26745
|
].filter((c) => !!c);
|
|
26232
|
-
const q =
|
|
26233
|
-
const querySnapshot = await
|
|
26746
|
+
const q = query39(this.getSubcategoriesRef(categoryId), ...constraints);
|
|
26747
|
+
const querySnapshot = await getDocs39(q);
|
|
26234
26748
|
const subcategories = querySnapshot.docs.map(
|
|
26235
|
-
(
|
|
26236
|
-
id:
|
|
26237
|
-
...
|
|
26749
|
+
(doc53) => ({
|
|
26750
|
+
id: doc53.id,
|
|
26751
|
+
...doc53.data()
|
|
26238
26752
|
})
|
|
26239
26753
|
);
|
|
26240
26754
|
const filteredSubcategories = this.filterExcludedSubcategories(subcategories);
|
|
@@ -26252,20 +26766,20 @@ var SubcategoryService = class extends BaseService {
|
|
|
26252
26766
|
async getAll(options = {}) {
|
|
26253
26767
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
26254
26768
|
const constraints = [
|
|
26255
|
-
|
|
26256
|
-
|
|
26769
|
+
where39("isActive", "==", active),
|
|
26770
|
+
orderBy22("name"),
|
|
26257
26771
|
queryLimit ? limit19(queryLimit) : void 0,
|
|
26258
26772
|
lastVisible ? startAfter17(lastVisible) : void 0
|
|
26259
26773
|
].filter((c) => !!c);
|
|
26260
|
-
const q =
|
|
26774
|
+
const q = query39(
|
|
26261
26775
|
collectionGroup2(this.db, SUBCATEGORIES_COLLECTION),
|
|
26262
26776
|
...constraints
|
|
26263
26777
|
);
|
|
26264
|
-
const querySnapshot = await
|
|
26778
|
+
const querySnapshot = await getDocs39(q);
|
|
26265
26779
|
const subcategories = querySnapshot.docs.map(
|
|
26266
|
-
(
|
|
26267
|
-
id:
|
|
26268
|
-
...
|
|
26780
|
+
(doc53) => ({
|
|
26781
|
+
id: doc53.id,
|
|
26782
|
+
...doc53.data()
|
|
26269
26783
|
})
|
|
26270
26784
|
);
|
|
26271
26785
|
const filteredSubcategories = this.filterExcludedSubcategories(subcategories);
|
|
@@ -26278,15 +26792,15 @@ var SubcategoryService = class extends BaseService {
|
|
|
26278
26792
|
* @returns Lista svih aktivnih subkategorija
|
|
26279
26793
|
*/
|
|
26280
26794
|
async getAllForFilterByCategoryId(categoryId) {
|
|
26281
|
-
const q =
|
|
26795
|
+
const q = query39(
|
|
26282
26796
|
this.getSubcategoriesRef(categoryId),
|
|
26283
|
-
|
|
26797
|
+
where39("isActive", "==", true)
|
|
26284
26798
|
);
|
|
26285
|
-
const querySnapshot = await
|
|
26799
|
+
const querySnapshot = await getDocs39(q);
|
|
26286
26800
|
const subcategories = querySnapshot.docs.map(
|
|
26287
|
-
(
|
|
26288
|
-
id:
|
|
26289
|
-
...
|
|
26801
|
+
(doc53) => ({
|
|
26802
|
+
id: doc53.id,
|
|
26803
|
+
...doc53.data()
|
|
26290
26804
|
})
|
|
26291
26805
|
);
|
|
26292
26806
|
return this.filterExcludedSubcategories(subcategories);
|
|
@@ -26296,15 +26810,15 @@ var SubcategoryService = class extends BaseService {
|
|
|
26296
26810
|
* @returns Lista svih aktivnih subkategorija
|
|
26297
26811
|
*/
|
|
26298
26812
|
async getAllForFilter() {
|
|
26299
|
-
const q =
|
|
26813
|
+
const q = query39(
|
|
26300
26814
|
collectionGroup2(this.db, SUBCATEGORIES_COLLECTION),
|
|
26301
|
-
|
|
26815
|
+
where39("isActive", "==", true)
|
|
26302
26816
|
);
|
|
26303
|
-
const querySnapshot = await
|
|
26817
|
+
const querySnapshot = await getDocs39(q);
|
|
26304
26818
|
const subcategories = querySnapshot.docs.map(
|
|
26305
|
-
(
|
|
26306
|
-
id:
|
|
26307
|
-
...
|
|
26819
|
+
(doc53) => ({
|
|
26820
|
+
id: doc53.id,
|
|
26821
|
+
...doc53.data()
|
|
26308
26822
|
})
|
|
26309
26823
|
);
|
|
26310
26824
|
return this.filterExcludedSubcategories(subcategories);
|
|
@@ -26319,11 +26833,11 @@ var SubcategoryService = class extends BaseService {
|
|
|
26319
26833
|
async update(categoryId, subcategoryId, subcategory) {
|
|
26320
26834
|
const newCategoryId = subcategory.categoryId;
|
|
26321
26835
|
if (newCategoryId && newCategoryId !== categoryId) {
|
|
26322
|
-
const oldDocRef =
|
|
26836
|
+
const oldDocRef = doc49(
|
|
26323
26837
|
this.getSubcategoriesRef(categoryId),
|
|
26324
26838
|
subcategoryId
|
|
26325
26839
|
);
|
|
26326
|
-
const docSnap = await
|
|
26840
|
+
const docSnap = await getDoc50(oldDocRef);
|
|
26327
26841
|
if (!docSnap.exists()) {
|
|
26328
26842
|
throw new Error("Subcategory to update does not exist.");
|
|
26329
26843
|
}
|
|
@@ -26337,20 +26851,20 @@ var SubcategoryService = class extends BaseService {
|
|
|
26337
26851
|
// Preserve original creation date
|
|
26338
26852
|
updatedAt: /* @__PURE__ */ new Date()
|
|
26339
26853
|
};
|
|
26340
|
-
const newDocRef =
|
|
26854
|
+
const newDocRef = doc49(
|
|
26341
26855
|
this.getSubcategoriesRef(newCategoryId),
|
|
26342
26856
|
subcategoryId
|
|
26343
26857
|
);
|
|
26344
|
-
await
|
|
26345
|
-
await
|
|
26858
|
+
await setDoc34(newDocRef, newData);
|
|
26859
|
+
await deleteDoc22(oldDocRef);
|
|
26346
26860
|
return { id: subcategoryId, ...newData };
|
|
26347
26861
|
} else {
|
|
26348
26862
|
const updateData = {
|
|
26349
26863
|
...subcategory,
|
|
26350
26864
|
updatedAt: /* @__PURE__ */ new Date()
|
|
26351
26865
|
};
|
|
26352
|
-
const docRef =
|
|
26353
|
-
await
|
|
26866
|
+
const docRef = doc49(this.getSubcategoriesRef(categoryId), subcategoryId);
|
|
26867
|
+
await updateDoc44(docRef, updateData);
|
|
26354
26868
|
return this.getById(categoryId, subcategoryId);
|
|
26355
26869
|
}
|
|
26356
26870
|
}
|
|
@@ -26378,8 +26892,8 @@ var SubcategoryService = class extends BaseService {
|
|
|
26378
26892
|
*/
|
|
26379
26893
|
async getById(categoryId, subcategoryId) {
|
|
26380
26894
|
if (subcategoryId === EXCLUDED_SUBCATEGORY_ID) return null;
|
|
26381
|
-
const docRef =
|
|
26382
|
-
const docSnap = await
|
|
26895
|
+
const docRef = doc49(this.getSubcategoriesRef(categoryId), subcategoryId);
|
|
26896
|
+
const docSnap = await getDoc50(docRef);
|
|
26383
26897
|
if (!docSnap.exists()) return null;
|
|
26384
26898
|
return {
|
|
26385
26899
|
id: docSnap.id,
|
|
@@ -26394,8 +26908,8 @@ var SubcategoryService = class extends BaseService {
|
|
|
26394
26908
|
* @returns Subcategory or null if not found
|
|
26395
26909
|
*/
|
|
26396
26910
|
async getByIdInternal(categoryId, subcategoryId) {
|
|
26397
|
-
const docRef =
|
|
26398
|
-
const docSnap = await
|
|
26911
|
+
const docRef = doc49(this.getSubcategoriesRef(categoryId), subcategoryId);
|
|
26912
|
+
const docSnap = await getDoc50(docRef);
|
|
26399
26913
|
if (!docSnap.exists()) return null;
|
|
26400
26914
|
return {
|
|
26401
26915
|
id: docSnap.id,
|
|
@@ -26410,18 +26924,18 @@ var SubcategoryService = class extends BaseService {
|
|
|
26410
26924
|
* @returns Subcategory if found, null otherwise
|
|
26411
26925
|
*/
|
|
26412
26926
|
async findByNameAndCategory(name, categoryId) {
|
|
26413
|
-
const q =
|
|
26927
|
+
const q = query39(
|
|
26414
26928
|
this.getSubcategoriesRef(categoryId),
|
|
26415
|
-
|
|
26416
|
-
|
|
26929
|
+
where39("name", "==", name),
|
|
26930
|
+
where39("isActive", "==", true)
|
|
26417
26931
|
);
|
|
26418
|
-
const querySnapshot = await
|
|
26932
|
+
const querySnapshot = await getDocs39(q);
|
|
26419
26933
|
if (querySnapshot.empty) return null;
|
|
26420
|
-
const
|
|
26421
|
-
if (
|
|
26934
|
+
const doc53 = querySnapshot.docs[0];
|
|
26935
|
+
if (doc53.id === EXCLUDED_SUBCATEGORY_ID) return null;
|
|
26422
26936
|
return {
|
|
26423
|
-
id:
|
|
26424
|
-
...
|
|
26937
|
+
id: doc53.id,
|
|
26938
|
+
...doc53.data()
|
|
26425
26939
|
};
|
|
26426
26940
|
}
|
|
26427
26941
|
/**
|
|
@@ -26446,17 +26960,17 @@ var SubcategoryService = class extends BaseService {
|
|
|
26446
26960
|
let cursor;
|
|
26447
26961
|
const constraints = [];
|
|
26448
26962
|
if (!includeInactive) {
|
|
26449
|
-
constraints.push(
|
|
26963
|
+
constraints.push(where39("isActive", "==", true));
|
|
26450
26964
|
}
|
|
26451
|
-
constraints.push(
|
|
26965
|
+
constraints.push(orderBy22("name"));
|
|
26452
26966
|
while (true) {
|
|
26453
26967
|
const queryConstraints = [...constraints, limit19(PAGE_SIZE)];
|
|
26454
26968
|
if (cursor) queryConstraints.push(startAfter17(cursor));
|
|
26455
|
-
const q =
|
|
26969
|
+
const q = query39(
|
|
26456
26970
|
collectionGroup2(this.db, SUBCATEGORIES_COLLECTION),
|
|
26457
26971
|
...queryConstraints
|
|
26458
26972
|
);
|
|
26459
|
-
const snapshot = await
|
|
26973
|
+
const snapshot = await getDocs39(q);
|
|
26460
26974
|
if (snapshot.empty) break;
|
|
26461
26975
|
for (const d of snapshot.docs) {
|
|
26462
26976
|
if (d.id === EXCLUDED_SUBCATEGORY_ID) continue;
|
|
@@ -26498,19 +27012,19 @@ var SubcategoryService = class extends BaseService {
|
|
|
26498
27012
|
// src/backoffice/services/technology.service.ts
|
|
26499
27013
|
import {
|
|
26500
27014
|
addDoc as addDoc7,
|
|
26501
|
-
collection as
|
|
26502
|
-
doc as
|
|
26503
|
-
getDoc as
|
|
26504
|
-
getDocs as
|
|
27015
|
+
collection as collection40,
|
|
27016
|
+
doc as doc50,
|
|
27017
|
+
getDoc as getDoc51,
|
|
27018
|
+
getDocs as getDocs40,
|
|
26505
27019
|
limit as limit20,
|
|
26506
|
-
orderBy as
|
|
26507
|
-
query as
|
|
27020
|
+
orderBy as orderBy23,
|
|
27021
|
+
query as query40,
|
|
26508
27022
|
startAfter as startAfter18,
|
|
26509
|
-
updateDoc as
|
|
26510
|
-
where as
|
|
27023
|
+
updateDoc as updateDoc45,
|
|
27024
|
+
where as where40,
|
|
26511
27025
|
arrayUnion as arrayUnion9,
|
|
26512
27026
|
arrayRemove as arrayRemove8,
|
|
26513
|
-
writeBatch as
|
|
27027
|
+
writeBatch as writeBatch8
|
|
26514
27028
|
} from "firebase/firestore";
|
|
26515
27029
|
|
|
26516
27030
|
// src/backoffice/types/product.types.ts
|
|
@@ -26535,7 +27049,7 @@ var TechnologyService = class extends BaseService {
|
|
|
26535
27049
|
* Reference to the Firestore collection of technologies.
|
|
26536
27050
|
*/
|
|
26537
27051
|
get technologiesRef() {
|
|
26538
|
-
return
|
|
27052
|
+
return collection40(this.db, TECHNOLOGIES_COLLECTION);
|
|
26539
27053
|
}
|
|
26540
27054
|
/**
|
|
26541
27055
|
* Creates a new technology.
|
|
@@ -26575,12 +27089,12 @@ var TechnologyService = class extends BaseService {
|
|
|
26575
27089
|
* @returns A record mapping subcategory ID to technology count.
|
|
26576
27090
|
*/
|
|
26577
27091
|
async getTechnologyCounts(active = true) {
|
|
26578
|
-
const q =
|
|
26579
|
-
const snapshot = await
|
|
27092
|
+
const q = query40(this.technologiesRef, where40("isActive", "==", active));
|
|
27093
|
+
const snapshot = await getDocs40(q);
|
|
26580
27094
|
const counts = {};
|
|
26581
|
-
snapshot.docs.forEach((
|
|
26582
|
-
if (
|
|
26583
|
-
const tech =
|
|
27095
|
+
snapshot.docs.forEach((doc53) => {
|
|
27096
|
+
if (doc53.id === EXCLUDED_TECHNOLOGY_ID) return;
|
|
27097
|
+
const tech = doc53.data();
|
|
26584
27098
|
counts[tech.subcategoryId] = (counts[tech.subcategoryId] || 0) + 1;
|
|
26585
27099
|
});
|
|
26586
27100
|
return counts;
|
|
@@ -26591,12 +27105,12 @@ var TechnologyService = class extends BaseService {
|
|
|
26591
27105
|
* @returns A record mapping category ID to technology count.
|
|
26592
27106
|
*/
|
|
26593
27107
|
async getTechnologyCountsByCategory(active = true) {
|
|
26594
|
-
const q =
|
|
26595
|
-
const snapshot = await
|
|
27108
|
+
const q = query40(this.technologiesRef, where40("isActive", "==", active));
|
|
27109
|
+
const snapshot = await getDocs40(q);
|
|
26596
27110
|
const counts = {};
|
|
26597
|
-
snapshot.docs.forEach((
|
|
26598
|
-
if (
|
|
26599
|
-
const tech =
|
|
27111
|
+
snapshot.docs.forEach((doc53) => {
|
|
27112
|
+
if (doc53.id === EXCLUDED_TECHNOLOGY_ID) return;
|
|
27113
|
+
const tech = doc53.data();
|
|
26600
27114
|
counts[tech.categoryId] = (counts[tech.categoryId] || 0) + 1;
|
|
26601
27115
|
});
|
|
26602
27116
|
return counts;
|
|
@@ -26609,17 +27123,17 @@ var TechnologyService = class extends BaseService {
|
|
|
26609
27123
|
async getAll(options = {}) {
|
|
26610
27124
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
26611
27125
|
const constraints = [
|
|
26612
|
-
|
|
26613
|
-
|
|
27126
|
+
where40("isActive", "==", active),
|
|
27127
|
+
orderBy23("name"),
|
|
26614
27128
|
queryLimit ? limit20(queryLimit) : void 0,
|
|
26615
27129
|
lastVisible ? startAfter18(lastVisible) : void 0
|
|
26616
27130
|
].filter((c) => !!c);
|
|
26617
|
-
const q =
|
|
26618
|
-
const snapshot = await
|
|
27131
|
+
const q = query40(this.technologiesRef, ...constraints);
|
|
27132
|
+
const snapshot = await getDocs40(q);
|
|
26619
27133
|
const technologies = snapshot.docs.map(
|
|
26620
|
-
(
|
|
26621
|
-
id:
|
|
26622
|
-
...
|
|
27134
|
+
(doc53) => ({
|
|
27135
|
+
id: doc53.id,
|
|
27136
|
+
...doc53.data()
|
|
26623
27137
|
})
|
|
26624
27138
|
);
|
|
26625
27139
|
const filteredTechnologies = this.filterExcludedTechnologies(technologies);
|
|
@@ -26635,18 +27149,18 @@ var TechnologyService = class extends BaseService {
|
|
|
26635
27149
|
async getAllByCategoryId(categoryId, options = {}) {
|
|
26636
27150
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
26637
27151
|
const constraints = [
|
|
26638
|
-
|
|
26639
|
-
|
|
26640
|
-
|
|
27152
|
+
where40("categoryId", "==", categoryId),
|
|
27153
|
+
where40("isActive", "==", active),
|
|
27154
|
+
orderBy23("name"),
|
|
26641
27155
|
queryLimit ? limit20(queryLimit) : void 0,
|
|
26642
27156
|
lastVisible ? startAfter18(lastVisible) : void 0
|
|
26643
27157
|
].filter((c) => !!c);
|
|
26644
|
-
const q =
|
|
26645
|
-
const snapshot = await
|
|
27158
|
+
const q = query40(this.technologiesRef, ...constraints);
|
|
27159
|
+
const snapshot = await getDocs40(q);
|
|
26646
27160
|
const technologies = snapshot.docs.map(
|
|
26647
|
-
(
|
|
26648
|
-
id:
|
|
26649
|
-
...
|
|
27161
|
+
(doc53) => ({
|
|
27162
|
+
id: doc53.id,
|
|
27163
|
+
...doc53.data()
|
|
26650
27164
|
})
|
|
26651
27165
|
);
|
|
26652
27166
|
const filteredTechnologies = this.filterExcludedTechnologies(technologies);
|
|
@@ -26662,18 +27176,18 @@ var TechnologyService = class extends BaseService {
|
|
|
26662
27176
|
async getAllBySubcategoryId(subcategoryId, options = {}) {
|
|
26663
27177
|
const { active = true, limit: queryLimit = 10, lastVisible } = options;
|
|
26664
27178
|
const constraints = [
|
|
26665
|
-
|
|
26666
|
-
|
|
26667
|
-
|
|
27179
|
+
where40("subcategoryId", "==", subcategoryId),
|
|
27180
|
+
where40("isActive", "==", active),
|
|
27181
|
+
orderBy23("name"),
|
|
26668
27182
|
queryLimit ? limit20(queryLimit) : void 0,
|
|
26669
27183
|
lastVisible ? startAfter18(lastVisible) : void 0
|
|
26670
27184
|
].filter((c) => !!c);
|
|
26671
|
-
const q =
|
|
26672
|
-
const snapshot = await
|
|
27185
|
+
const q = query40(this.technologiesRef, ...constraints);
|
|
27186
|
+
const snapshot = await getDocs40(q);
|
|
26673
27187
|
const technologies = snapshot.docs.map(
|
|
26674
|
-
(
|
|
26675
|
-
id:
|
|
26676
|
-
...
|
|
27188
|
+
(doc53) => ({
|
|
27189
|
+
id: doc53.id,
|
|
27190
|
+
...doc53.data()
|
|
26677
27191
|
})
|
|
26678
27192
|
);
|
|
26679
27193
|
const filteredTechnologies = this.filterExcludedTechnologies(technologies);
|
|
@@ -26701,9 +27215,9 @@ var TechnologyService = class extends BaseService {
|
|
|
26701
27215
|
}
|
|
26702
27216
|
}
|
|
26703
27217
|
updateData.updatedAt = /* @__PURE__ */ new Date();
|
|
26704
|
-
const docRef =
|
|
27218
|
+
const docRef = doc50(this.technologiesRef, id);
|
|
26705
27219
|
const beforeTech = await this.getById(id);
|
|
26706
|
-
await
|
|
27220
|
+
await updateDoc45(docRef, updateData);
|
|
26707
27221
|
const categoryChanged = beforeTech && updateData.categoryId && beforeTech.categoryId !== updateData.categoryId;
|
|
26708
27222
|
const subcategoryChanged = beforeTech && updateData.subcategoryId && beforeTech.subcategoryId !== updateData.subcategoryId;
|
|
26709
27223
|
const nameChanged = beforeTech && updateData.name && beforeTech.name !== updateData.name;
|
|
@@ -26737,8 +27251,8 @@ var TechnologyService = class extends BaseService {
|
|
|
26737
27251
|
*/
|
|
26738
27252
|
async getById(id) {
|
|
26739
27253
|
if (id === EXCLUDED_TECHNOLOGY_ID) return null;
|
|
26740
|
-
const docRef =
|
|
26741
|
-
const docSnap = await
|
|
27254
|
+
const docRef = doc50(this.technologiesRef, id);
|
|
27255
|
+
const docSnap = await getDoc51(docRef);
|
|
26742
27256
|
if (!docSnap.exists()) return null;
|
|
26743
27257
|
return {
|
|
26744
27258
|
id: docSnap.id,
|
|
@@ -26752,8 +27266,8 @@ var TechnologyService = class extends BaseService {
|
|
|
26752
27266
|
* @returns The technology or null if it doesn't exist
|
|
26753
27267
|
*/
|
|
26754
27268
|
async getByIdInternal(id) {
|
|
26755
|
-
const docRef =
|
|
26756
|
-
const docSnap = await
|
|
27269
|
+
const docRef = doc50(this.technologiesRef, id);
|
|
27270
|
+
const docSnap = await getDoc51(docRef);
|
|
26757
27271
|
if (!docSnap.exists()) return null;
|
|
26758
27272
|
return {
|
|
26759
27273
|
id: docSnap.id,
|
|
@@ -26767,18 +27281,18 @@ var TechnologyService = class extends BaseService {
|
|
|
26767
27281
|
* @returns Technology if found, null otherwise
|
|
26768
27282
|
*/
|
|
26769
27283
|
async findByName(name) {
|
|
26770
|
-
const q =
|
|
27284
|
+
const q = query40(
|
|
26771
27285
|
this.technologiesRef,
|
|
26772
|
-
|
|
26773
|
-
|
|
27286
|
+
where40("name", "==", name),
|
|
27287
|
+
where40("isActive", "==", true)
|
|
26774
27288
|
);
|
|
26775
|
-
const snapshot = await
|
|
27289
|
+
const snapshot = await getDocs40(q);
|
|
26776
27290
|
if (snapshot.empty) return null;
|
|
26777
|
-
const
|
|
26778
|
-
if (
|
|
27291
|
+
const doc53 = snapshot.docs[0];
|
|
27292
|
+
if (doc53.id === EXCLUDED_TECHNOLOGY_ID) return null;
|
|
26779
27293
|
return {
|
|
26780
|
-
id:
|
|
26781
|
-
...
|
|
27294
|
+
id: doc53.id,
|
|
27295
|
+
...doc53.data()
|
|
26782
27296
|
};
|
|
26783
27297
|
}
|
|
26784
27298
|
/**
|
|
@@ -26788,9 +27302,9 @@ var TechnologyService = class extends BaseService {
|
|
|
26788
27302
|
* @returns Ažurirana tehnologija sa novim zahtevom
|
|
26789
27303
|
*/
|
|
26790
27304
|
async addRequirement(technologyId, requirement) {
|
|
26791
|
-
const docRef =
|
|
27305
|
+
const docRef = doc50(this.technologiesRef, technologyId);
|
|
26792
27306
|
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
26793
|
-
await
|
|
27307
|
+
await updateDoc45(docRef, {
|
|
26794
27308
|
[requirementType]: arrayUnion9(requirement),
|
|
26795
27309
|
updatedAt: /* @__PURE__ */ new Date()
|
|
26796
27310
|
});
|
|
@@ -26803,9 +27317,9 @@ var TechnologyService = class extends BaseService {
|
|
|
26803
27317
|
* @returns Ažurirana tehnologija bez uklonjenog zahteva
|
|
26804
27318
|
*/
|
|
26805
27319
|
async removeRequirement(technologyId, requirement) {
|
|
26806
|
-
const docRef =
|
|
27320
|
+
const docRef = doc50(this.technologiesRef, technologyId);
|
|
26807
27321
|
const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
|
|
26808
|
-
await
|
|
27322
|
+
await updateDoc45(docRef, {
|
|
26809
27323
|
[requirementType]: arrayRemove8(requirement),
|
|
26810
27324
|
updatedAt: /* @__PURE__ */ new Date()
|
|
26811
27325
|
});
|
|
@@ -26843,8 +27357,8 @@ var TechnologyService = class extends BaseService {
|
|
|
26843
27357
|
* @returns Ažurirana tehnologija
|
|
26844
27358
|
*/
|
|
26845
27359
|
async addBlockingCondition(technologyId, condition) {
|
|
26846
|
-
const docRef =
|
|
26847
|
-
await
|
|
27360
|
+
const docRef = doc50(this.technologiesRef, technologyId);
|
|
27361
|
+
await updateDoc45(docRef, {
|
|
26848
27362
|
blockingConditions: arrayUnion9(condition),
|
|
26849
27363
|
updatedAt: /* @__PURE__ */ new Date()
|
|
26850
27364
|
});
|
|
@@ -26857,8 +27371,8 @@ var TechnologyService = class extends BaseService {
|
|
|
26857
27371
|
* @returns Ažurirana tehnologija
|
|
26858
27372
|
*/
|
|
26859
27373
|
async removeBlockingCondition(technologyId, condition) {
|
|
26860
|
-
const docRef =
|
|
26861
|
-
await
|
|
27374
|
+
const docRef = doc50(this.technologiesRef, technologyId);
|
|
27375
|
+
await updateDoc45(docRef, {
|
|
26862
27376
|
blockingConditions: arrayRemove8(condition),
|
|
26863
27377
|
updatedAt: /* @__PURE__ */ new Date()
|
|
26864
27378
|
});
|
|
@@ -26871,7 +27385,7 @@ var TechnologyService = class extends BaseService {
|
|
|
26871
27385
|
* @returns Ažurirana tehnologija
|
|
26872
27386
|
*/
|
|
26873
27387
|
async addContraindication(technologyId, contraindication) {
|
|
26874
|
-
const docRef =
|
|
27388
|
+
const docRef = doc50(this.technologiesRef, technologyId);
|
|
26875
27389
|
const technology = await this.getById(technologyId);
|
|
26876
27390
|
if (!technology) {
|
|
26877
27391
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
@@ -26880,7 +27394,7 @@ var TechnologyService = class extends BaseService {
|
|
|
26880
27394
|
if (existingContraindications.some((c) => c.id === contraindication.id)) {
|
|
26881
27395
|
return technology;
|
|
26882
27396
|
}
|
|
26883
|
-
await
|
|
27397
|
+
await updateDoc45(docRef, {
|
|
26884
27398
|
contraindications: [...existingContraindications, contraindication],
|
|
26885
27399
|
updatedAt: /* @__PURE__ */ new Date()
|
|
26886
27400
|
});
|
|
@@ -26893,7 +27407,7 @@ var TechnologyService = class extends BaseService {
|
|
|
26893
27407
|
* @returns Ažurirana tehnologija
|
|
26894
27408
|
*/
|
|
26895
27409
|
async removeContraindication(technologyId, contraindication) {
|
|
26896
|
-
const docRef =
|
|
27410
|
+
const docRef = doc50(this.technologiesRef, technologyId);
|
|
26897
27411
|
const technology = await this.getById(technologyId);
|
|
26898
27412
|
if (!technology) {
|
|
26899
27413
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
@@ -26901,7 +27415,7 @@ var TechnologyService = class extends BaseService {
|
|
|
26901
27415
|
const updatedContraindications = (technology.contraindications || []).filter(
|
|
26902
27416
|
(c) => c.id !== contraindication.id
|
|
26903
27417
|
);
|
|
26904
|
-
await
|
|
27418
|
+
await updateDoc45(docRef, {
|
|
26905
27419
|
contraindications: updatedContraindications,
|
|
26906
27420
|
updatedAt: /* @__PURE__ */ new Date()
|
|
26907
27421
|
});
|
|
@@ -26915,7 +27429,7 @@ var TechnologyService = class extends BaseService {
|
|
|
26915
27429
|
* @returns The updated technology
|
|
26916
27430
|
*/
|
|
26917
27431
|
async updateContraindication(technologyId, contraindication) {
|
|
26918
|
-
const docRef =
|
|
27432
|
+
const docRef = doc50(this.technologiesRef, technologyId);
|
|
26919
27433
|
const technology = await this.getById(technologyId);
|
|
26920
27434
|
if (!technology) {
|
|
26921
27435
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
@@ -26930,7 +27444,7 @@ var TechnologyService = class extends BaseService {
|
|
|
26930
27444
|
}
|
|
26931
27445
|
const updatedContraindications = [...contraindications];
|
|
26932
27446
|
updatedContraindications[index] = contraindication;
|
|
26933
|
-
await
|
|
27447
|
+
await updateDoc45(docRef, {
|
|
26934
27448
|
contraindications: updatedContraindications,
|
|
26935
27449
|
updatedAt: /* @__PURE__ */ new Date()
|
|
26936
27450
|
});
|
|
@@ -26943,7 +27457,7 @@ var TechnologyService = class extends BaseService {
|
|
|
26943
27457
|
* @returns Ažurirana tehnologija
|
|
26944
27458
|
*/
|
|
26945
27459
|
async addBenefit(technologyId, benefit) {
|
|
26946
|
-
const docRef =
|
|
27460
|
+
const docRef = doc50(this.technologiesRef, technologyId);
|
|
26947
27461
|
const technology = await this.getById(technologyId);
|
|
26948
27462
|
if (!technology) {
|
|
26949
27463
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
@@ -26952,7 +27466,7 @@ var TechnologyService = class extends BaseService {
|
|
|
26952
27466
|
if (existingBenefits.some((b) => b.id === benefit.id)) {
|
|
26953
27467
|
return technology;
|
|
26954
27468
|
}
|
|
26955
|
-
await
|
|
27469
|
+
await updateDoc45(docRef, {
|
|
26956
27470
|
benefits: [...existingBenefits, benefit],
|
|
26957
27471
|
updatedAt: /* @__PURE__ */ new Date()
|
|
26958
27472
|
});
|
|
@@ -26965,13 +27479,13 @@ var TechnologyService = class extends BaseService {
|
|
|
26965
27479
|
* @returns Ažurirana tehnologija
|
|
26966
27480
|
*/
|
|
26967
27481
|
async removeBenefit(technologyId, benefit) {
|
|
26968
|
-
const docRef =
|
|
27482
|
+
const docRef = doc50(this.technologiesRef, technologyId);
|
|
26969
27483
|
const technology = await this.getById(technologyId);
|
|
26970
27484
|
if (!technology) {
|
|
26971
27485
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
26972
27486
|
}
|
|
26973
27487
|
const updatedBenefits = (technology.benefits || []).filter((b) => b.id !== benefit.id);
|
|
26974
|
-
await
|
|
27488
|
+
await updateDoc45(docRef, {
|
|
26975
27489
|
benefits: updatedBenefits,
|
|
26976
27490
|
updatedAt: /* @__PURE__ */ new Date()
|
|
26977
27491
|
});
|
|
@@ -26985,7 +27499,7 @@ var TechnologyService = class extends BaseService {
|
|
|
26985
27499
|
* @returns The updated technology
|
|
26986
27500
|
*/
|
|
26987
27501
|
async updateBenefit(technologyId, benefit) {
|
|
26988
|
-
const docRef =
|
|
27502
|
+
const docRef = doc50(this.technologiesRef, technologyId);
|
|
26989
27503
|
const technology = await this.getById(technologyId);
|
|
26990
27504
|
if (!technology) {
|
|
26991
27505
|
throw new Error(`Technology with id ${technologyId} not found`);
|
|
@@ -27000,7 +27514,7 @@ var TechnologyService = class extends BaseService {
|
|
|
27000
27514
|
}
|
|
27001
27515
|
const updatedBenefits = [...benefits];
|
|
27002
27516
|
updatedBenefits[index] = benefit;
|
|
27003
|
-
await
|
|
27517
|
+
await updateDoc45(docRef, {
|
|
27004
27518
|
benefits: updatedBenefits,
|
|
27005
27519
|
updatedAt: /* @__PURE__ */ new Date()
|
|
27006
27520
|
});
|
|
@@ -27040,8 +27554,8 @@ var TechnologyService = class extends BaseService {
|
|
|
27040
27554
|
* @returns Ažurirana tehnologija
|
|
27041
27555
|
*/
|
|
27042
27556
|
async updateCertificationRequirement(technologyId, certificationRequirement) {
|
|
27043
|
-
const docRef =
|
|
27044
|
-
await
|
|
27557
|
+
const docRef = doc50(this.technologiesRef, technologyId);
|
|
27558
|
+
await updateDoc45(docRef, {
|
|
27045
27559
|
certificationRequirement,
|
|
27046
27560
|
updatedAt: /* @__PURE__ */ new Date()
|
|
27047
27561
|
});
|
|
@@ -27134,17 +27648,17 @@ var TechnologyService = class extends BaseService {
|
|
|
27134
27648
|
* @param subcategoryId - The ID of the subcategory.
|
|
27135
27649
|
*/
|
|
27136
27650
|
async getAllForFilterBySubcategory(subcategoryId) {
|
|
27137
|
-
const q =
|
|
27138
|
-
|
|
27139
|
-
|
|
27140
|
-
|
|
27141
|
-
|
|
27651
|
+
const q = query40(
|
|
27652
|
+
collection40(this.db, TECHNOLOGIES_COLLECTION),
|
|
27653
|
+
where40("isActive", "==", true),
|
|
27654
|
+
where40("subcategoryId", "==", subcategoryId),
|
|
27655
|
+
orderBy23("name")
|
|
27142
27656
|
);
|
|
27143
|
-
const snapshot = await
|
|
27657
|
+
const snapshot = await getDocs40(q);
|
|
27144
27658
|
const technologies = snapshot.docs.map(
|
|
27145
|
-
(
|
|
27146
|
-
id:
|
|
27147
|
-
...
|
|
27659
|
+
(doc53) => ({
|
|
27660
|
+
id: doc53.id,
|
|
27661
|
+
...doc53.data()
|
|
27148
27662
|
})
|
|
27149
27663
|
);
|
|
27150
27664
|
return this.filterExcludedTechnologies(technologies);
|
|
@@ -27155,18 +27669,18 @@ var TechnologyService = class extends BaseService {
|
|
|
27155
27669
|
* @param subcategoryId - The ID of the subcategory.
|
|
27156
27670
|
*/
|
|
27157
27671
|
async getAllForFilterBySubcategoryId(categoryId, subcategoryId) {
|
|
27158
|
-
const q =
|
|
27159
|
-
|
|
27160
|
-
|
|
27161
|
-
|
|
27162
|
-
|
|
27163
|
-
|
|
27672
|
+
const q = query40(
|
|
27673
|
+
collection40(this.db, TECHNOLOGIES_COLLECTION),
|
|
27674
|
+
where40("isActive", "==", true),
|
|
27675
|
+
where40("categoryId", "==", categoryId),
|
|
27676
|
+
where40("subcategoryId", "==", subcategoryId),
|
|
27677
|
+
orderBy23("name")
|
|
27164
27678
|
);
|
|
27165
|
-
const snapshot = await
|
|
27679
|
+
const snapshot = await getDocs40(q);
|
|
27166
27680
|
const technologies = snapshot.docs.map(
|
|
27167
|
-
(
|
|
27168
|
-
id:
|
|
27169
|
-
...
|
|
27681
|
+
(doc53) => ({
|
|
27682
|
+
id: doc53.id,
|
|
27683
|
+
...doc53.data()
|
|
27170
27684
|
})
|
|
27171
27685
|
);
|
|
27172
27686
|
return this.filterExcludedTechnologies(technologies);
|
|
@@ -27175,16 +27689,16 @@ var TechnologyService = class extends BaseService {
|
|
|
27175
27689
|
* Gets all active technologies for filter dropdowns.
|
|
27176
27690
|
*/
|
|
27177
27691
|
async getAllForFilter() {
|
|
27178
|
-
const q =
|
|
27179
|
-
|
|
27180
|
-
|
|
27181
|
-
|
|
27692
|
+
const q = query40(
|
|
27693
|
+
collection40(this.db, TECHNOLOGIES_COLLECTION),
|
|
27694
|
+
where40("isActive", "==", true),
|
|
27695
|
+
orderBy23("name")
|
|
27182
27696
|
);
|
|
27183
|
-
const snapshot = await
|
|
27697
|
+
const snapshot = await getDocs40(q);
|
|
27184
27698
|
const technologies = snapshot.docs.map(
|
|
27185
|
-
(
|
|
27186
|
-
id:
|
|
27187
|
-
...
|
|
27699
|
+
(doc53) => ({
|
|
27700
|
+
id: doc53.id,
|
|
27701
|
+
...doc53.data()
|
|
27188
27702
|
})
|
|
27189
27703
|
);
|
|
27190
27704
|
return this.filterExcludedTechnologies(technologies);
|
|
@@ -27197,9 +27711,9 @@ var TechnologyService = class extends BaseService {
|
|
|
27197
27711
|
* Updates each product's assignedTechnologyIds array
|
|
27198
27712
|
*/
|
|
27199
27713
|
async assignProducts(technologyId, productIds) {
|
|
27200
|
-
const batch =
|
|
27714
|
+
const batch = writeBatch8(this.db);
|
|
27201
27715
|
for (const productId of productIds) {
|
|
27202
|
-
const productRef =
|
|
27716
|
+
const productRef = doc50(this.db, PRODUCTS_COLLECTION, productId);
|
|
27203
27717
|
batch.update(productRef, {
|
|
27204
27718
|
assignedTechnologyIds: arrayUnion9(technologyId),
|
|
27205
27719
|
updatedAt: /* @__PURE__ */ new Date()
|
|
@@ -27212,9 +27726,9 @@ var TechnologyService = class extends BaseService {
|
|
|
27212
27726
|
* Updates each product's assignedTechnologyIds array
|
|
27213
27727
|
*/
|
|
27214
27728
|
async unassignProducts(technologyId, productIds) {
|
|
27215
|
-
const batch =
|
|
27729
|
+
const batch = writeBatch8(this.db);
|
|
27216
27730
|
for (const productId of productIds) {
|
|
27217
|
-
const productRef =
|
|
27731
|
+
const productRef = doc50(this.db, PRODUCTS_COLLECTION, productId);
|
|
27218
27732
|
batch.update(productRef, {
|
|
27219
27733
|
assignedTechnologyIds: arrayRemove8(technologyId),
|
|
27220
27734
|
updatedAt: /* @__PURE__ */ new Date()
|
|
@@ -27227,17 +27741,17 @@ var TechnologyService = class extends BaseService {
|
|
|
27227
27741
|
* Reads from top-level collection for immediate consistency (Cloud Functions may lag)
|
|
27228
27742
|
*/
|
|
27229
27743
|
async getAssignedProducts(technologyId) {
|
|
27230
|
-
const q =
|
|
27231
|
-
|
|
27232
|
-
|
|
27233
|
-
|
|
27234
|
-
|
|
27744
|
+
const q = query40(
|
|
27745
|
+
collection40(this.db, PRODUCTS_COLLECTION),
|
|
27746
|
+
where40("assignedTechnologyIds", "array-contains", technologyId),
|
|
27747
|
+
where40("isActive", "==", true),
|
|
27748
|
+
orderBy23("name")
|
|
27235
27749
|
);
|
|
27236
|
-
const snapshot = await
|
|
27750
|
+
const snapshot = await getDocs40(q);
|
|
27237
27751
|
return snapshot.docs.map(
|
|
27238
|
-
(
|
|
27239
|
-
id:
|
|
27240
|
-
...
|
|
27752
|
+
(doc53) => ({
|
|
27753
|
+
id: doc53.id,
|
|
27754
|
+
...doc53.data()
|
|
27241
27755
|
})
|
|
27242
27756
|
);
|
|
27243
27757
|
}
|
|
@@ -27245,16 +27759,16 @@ var TechnologyService = class extends BaseService {
|
|
|
27245
27759
|
* Gets products NOT assigned to a specific technology
|
|
27246
27760
|
*/
|
|
27247
27761
|
async getUnassignedProducts(technologyId) {
|
|
27248
|
-
const q =
|
|
27249
|
-
|
|
27250
|
-
|
|
27251
|
-
|
|
27762
|
+
const q = query40(
|
|
27763
|
+
collection40(this.db, PRODUCTS_COLLECTION),
|
|
27764
|
+
where40("isActive", "==", true),
|
|
27765
|
+
orderBy23("name")
|
|
27252
27766
|
);
|
|
27253
|
-
const snapshot = await
|
|
27767
|
+
const snapshot = await getDocs40(q);
|
|
27254
27768
|
const allProducts = snapshot.docs.map(
|
|
27255
|
-
(
|
|
27256
|
-
id:
|
|
27257
|
-
...
|
|
27769
|
+
(doc53) => ({
|
|
27770
|
+
id: doc53.id,
|
|
27771
|
+
...doc53.data()
|
|
27258
27772
|
})
|
|
27259
27773
|
);
|
|
27260
27774
|
return allProducts.filter(
|
|
@@ -27285,12 +27799,12 @@ var TechnologyService = class extends BaseService {
|
|
|
27285
27799
|
* @param updates - Fields to update (categoryId, subcategoryId, technologyName)
|
|
27286
27800
|
*/
|
|
27287
27801
|
async updateProductsInSubcollection(technologyId, updates) {
|
|
27288
|
-
const productsRef =
|
|
27289
|
-
const productsSnapshot = await
|
|
27802
|
+
const productsRef = collection40(this.db, TECHNOLOGIES_COLLECTION, technologyId, PRODUCTS_COLLECTION);
|
|
27803
|
+
const productsSnapshot = await getDocs40(productsRef);
|
|
27290
27804
|
if (productsSnapshot.empty) {
|
|
27291
27805
|
return;
|
|
27292
27806
|
}
|
|
27293
|
-
const batch =
|
|
27807
|
+
const batch = writeBatch8(this.db);
|
|
27294
27808
|
for (const productDoc of productsSnapshot.docs) {
|
|
27295
27809
|
const productRef = productDoc.ref;
|
|
27296
27810
|
const updateFields = {};
|
|
@@ -27344,14 +27858,14 @@ var TechnologyService = class extends BaseService {
|
|
|
27344
27858
|
let cursor;
|
|
27345
27859
|
const constraints = [];
|
|
27346
27860
|
if (!includeInactive) {
|
|
27347
|
-
constraints.push(
|
|
27861
|
+
constraints.push(where40("isActive", "==", true));
|
|
27348
27862
|
}
|
|
27349
|
-
constraints.push(
|
|
27863
|
+
constraints.push(orderBy23("name"));
|
|
27350
27864
|
while (true) {
|
|
27351
27865
|
const queryConstraints = [...constraints, limit20(PAGE_SIZE)];
|
|
27352
27866
|
if (cursor) queryConstraints.push(startAfter18(cursor));
|
|
27353
|
-
const q =
|
|
27354
|
-
const snapshot = await
|
|
27867
|
+
const q = query40(this.technologiesRef, ...queryConstraints);
|
|
27868
|
+
const snapshot = await getDocs40(q);
|
|
27355
27869
|
if (snapshot.empty) break;
|
|
27356
27870
|
for (const d of snapshot.docs) {
|
|
27357
27871
|
if (d.id === EXCLUDED_TECHNOLOGY_ID) continue;
|
|
@@ -27370,11 +27884,11 @@ var TechnologyService = class extends BaseService {
|
|
|
27370
27884
|
*/
|
|
27371
27885
|
async getProductNamesForTechnology(technologyId) {
|
|
27372
27886
|
try {
|
|
27373
|
-
const productsRef =
|
|
27374
|
-
const q =
|
|
27375
|
-
const snapshot = await
|
|
27376
|
-
return snapshot.docs.map((
|
|
27377
|
-
const product =
|
|
27887
|
+
const productsRef = collection40(this.db, TECHNOLOGIES_COLLECTION, technologyId, PRODUCTS_COLLECTION);
|
|
27888
|
+
const q = query40(productsRef, where40("isActive", "==", true));
|
|
27889
|
+
const snapshot = await getDocs40(q);
|
|
27890
|
+
return snapshot.docs.map((doc53) => {
|
|
27891
|
+
const product = doc53.data();
|
|
27378
27892
|
return product.name || "";
|
|
27379
27893
|
}).filter((name) => name);
|
|
27380
27894
|
} catch (error) {
|
|
@@ -27415,16 +27929,16 @@ var TechnologyService = class extends BaseService {
|
|
|
27415
27929
|
// src/backoffice/services/product.service.ts
|
|
27416
27930
|
import {
|
|
27417
27931
|
addDoc as addDoc8,
|
|
27418
|
-
collection as
|
|
27932
|
+
collection as collection41,
|
|
27419
27933
|
collectionGroup as collectionGroup3,
|
|
27420
|
-
doc as
|
|
27421
|
-
getDoc as
|
|
27422
|
-
getDocs as
|
|
27423
|
-
query as
|
|
27424
|
-
updateDoc as
|
|
27425
|
-
where as
|
|
27934
|
+
doc as doc51,
|
|
27935
|
+
getDoc as getDoc52,
|
|
27936
|
+
getDocs as getDocs41,
|
|
27937
|
+
query as query41,
|
|
27938
|
+
updateDoc as updateDoc46,
|
|
27939
|
+
where as where41,
|
|
27426
27940
|
limit as limit21,
|
|
27427
|
-
orderBy as
|
|
27941
|
+
orderBy as orderBy24,
|
|
27428
27942
|
startAfter as startAfter19,
|
|
27429
27943
|
getCountFromServer as getCountFromServer7,
|
|
27430
27944
|
arrayUnion as arrayUnion10,
|
|
@@ -27436,7 +27950,7 @@ var ProductService = class extends BaseService {
|
|
|
27436
27950
|
* @returns Firestore collection reference
|
|
27437
27951
|
*/
|
|
27438
27952
|
getTopLevelProductsRef() {
|
|
27439
|
-
return
|
|
27953
|
+
return collection41(this.db, PRODUCTS_COLLECTION);
|
|
27440
27954
|
}
|
|
27441
27955
|
/**
|
|
27442
27956
|
* Gets reference to products collection under a technology (backward compatibility)
|
|
@@ -27444,7 +27958,7 @@ var ProductService = class extends BaseService {
|
|
|
27444
27958
|
* @returns Firestore collection reference
|
|
27445
27959
|
*/
|
|
27446
27960
|
getProductsRef(technologyId) {
|
|
27447
|
-
return
|
|
27961
|
+
return collection41(this.db, TECHNOLOGIES_COLLECTION, technologyId, PRODUCTS_COLLECTION);
|
|
27448
27962
|
}
|
|
27449
27963
|
/**
|
|
27450
27964
|
* Creates a new product under technology
|
|
@@ -27469,26 +27983,26 @@ var ProductService = class extends BaseService {
|
|
|
27469
27983
|
*/
|
|
27470
27984
|
async getAll(options) {
|
|
27471
27985
|
const { rowsPerPage, lastVisible, categoryId, subcategoryId, technologyId } = options;
|
|
27472
|
-
const constraints = [
|
|
27986
|
+
const constraints = [where41("isActive", "==", true), orderBy24("name")];
|
|
27473
27987
|
if (categoryId) {
|
|
27474
|
-
constraints.push(
|
|
27988
|
+
constraints.push(where41("categoryId", "==", categoryId));
|
|
27475
27989
|
}
|
|
27476
27990
|
if (subcategoryId) {
|
|
27477
|
-
constraints.push(
|
|
27991
|
+
constraints.push(where41("subcategoryId", "==", subcategoryId));
|
|
27478
27992
|
}
|
|
27479
27993
|
if (technologyId) {
|
|
27480
|
-
constraints.push(
|
|
27994
|
+
constraints.push(where41("technologyId", "==", technologyId));
|
|
27481
27995
|
}
|
|
27482
27996
|
if (lastVisible) {
|
|
27483
27997
|
constraints.push(startAfter19(lastVisible));
|
|
27484
27998
|
}
|
|
27485
27999
|
constraints.push(limit21(rowsPerPage));
|
|
27486
|
-
const q =
|
|
27487
|
-
const snapshot = await
|
|
28000
|
+
const q = query41(collectionGroup3(this.db, PRODUCTS_COLLECTION), ...constraints);
|
|
28001
|
+
const snapshot = await getDocs41(q);
|
|
27488
28002
|
const products = snapshot.docs.map(
|
|
27489
|
-
(
|
|
27490
|
-
id:
|
|
27491
|
-
...
|
|
28003
|
+
(doc53) => ({
|
|
28004
|
+
id: doc53.id,
|
|
28005
|
+
...doc53.data()
|
|
27492
28006
|
})
|
|
27493
28007
|
);
|
|
27494
28008
|
const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
|
|
@@ -27499,17 +28013,17 @@ var ProductService = class extends BaseService {
|
|
|
27499
28013
|
*/
|
|
27500
28014
|
async getProductsCount(options) {
|
|
27501
28015
|
const { categoryId, subcategoryId, technologyId } = options;
|
|
27502
|
-
const constraints = [
|
|
28016
|
+
const constraints = [where41("isActive", "==", true)];
|
|
27503
28017
|
if (categoryId) {
|
|
27504
|
-
constraints.push(
|
|
28018
|
+
constraints.push(where41("categoryId", "==", categoryId));
|
|
27505
28019
|
}
|
|
27506
28020
|
if (subcategoryId) {
|
|
27507
|
-
constraints.push(
|
|
28021
|
+
constraints.push(where41("subcategoryId", "==", subcategoryId));
|
|
27508
28022
|
}
|
|
27509
28023
|
if (technologyId) {
|
|
27510
|
-
constraints.push(
|
|
28024
|
+
constraints.push(where41("technologyId", "==", technologyId));
|
|
27511
28025
|
}
|
|
27512
|
-
const q =
|
|
28026
|
+
const q = query41(collectionGroup3(this.db, PRODUCTS_COLLECTION), ...constraints);
|
|
27513
28027
|
const snapshot = await getCountFromServer7(q);
|
|
27514
28028
|
return snapshot.data().count;
|
|
27515
28029
|
}
|
|
@@ -27523,10 +28037,10 @@ var ProductService = class extends BaseService {
|
|
|
27523
28037
|
bySubcategory: {},
|
|
27524
28038
|
byTechnology: {}
|
|
27525
28039
|
};
|
|
27526
|
-
const q =
|
|
27527
|
-
const snapshot = await
|
|
27528
|
-
snapshot.docs.forEach((
|
|
27529
|
-
const product =
|
|
28040
|
+
const q = query41(collectionGroup3(this.db, PRODUCTS_COLLECTION), where41("isActive", "==", true));
|
|
28041
|
+
const snapshot = await getDocs41(q);
|
|
28042
|
+
snapshot.docs.forEach((doc53) => {
|
|
28043
|
+
const product = doc53.data();
|
|
27530
28044
|
if (product.categoryId) {
|
|
27531
28045
|
counts.byCategory[product.categoryId] = (counts.byCategory[product.categoryId] || 0) + 1;
|
|
27532
28046
|
}
|
|
@@ -27543,16 +28057,16 @@ var ProductService = class extends BaseService {
|
|
|
27543
28057
|
* Gets all products for a specific technology (non-paginated, for filters/dropdowns)
|
|
27544
28058
|
*/
|
|
27545
28059
|
async getAllByTechnology(technologyId) {
|
|
27546
|
-
const q =
|
|
28060
|
+
const q = query41(
|
|
27547
28061
|
this.getProductsRef(technologyId),
|
|
27548
|
-
|
|
27549
|
-
|
|
28062
|
+
where41("isActive", "==", true),
|
|
28063
|
+
orderBy24("name")
|
|
27550
28064
|
);
|
|
27551
|
-
const snapshot = await
|
|
28065
|
+
const snapshot = await getDocs41(q);
|
|
27552
28066
|
return snapshot.docs.map(
|
|
27553
|
-
(
|
|
27554
|
-
id:
|
|
27555
|
-
...
|
|
28067
|
+
(doc53) => ({
|
|
28068
|
+
id: doc53.id,
|
|
28069
|
+
...doc53.data()
|
|
27556
28070
|
})
|
|
27557
28071
|
);
|
|
27558
28072
|
}
|
|
@@ -27560,21 +28074,21 @@ var ProductService = class extends BaseService {
|
|
|
27560
28074
|
* Gets all products for a brand by filtering through all technologies
|
|
27561
28075
|
*/
|
|
27562
28076
|
async getAllByBrand(brandId) {
|
|
27563
|
-
const allTechnologiesRef =
|
|
27564
|
-
const technologiesSnapshot = await
|
|
28077
|
+
const allTechnologiesRef = collection41(this.db, TECHNOLOGIES_COLLECTION);
|
|
28078
|
+
const technologiesSnapshot = await getDocs41(allTechnologiesRef);
|
|
27565
28079
|
const products = [];
|
|
27566
28080
|
for (const techDoc of technologiesSnapshot.docs) {
|
|
27567
|
-
const q =
|
|
28081
|
+
const q = query41(
|
|
27568
28082
|
this.getProductsRef(techDoc.id),
|
|
27569
|
-
|
|
27570
|
-
|
|
28083
|
+
where41("brandId", "==", brandId),
|
|
28084
|
+
where41("isActive", "==", true)
|
|
27571
28085
|
);
|
|
27572
|
-
const snapshot = await
|
|
28086
|
+
const snapshot = await getDocs41(q);
|
|
27573
28087
|
products.push(
|
|
27574
28088
|
...snapshot.docs.map(
|
|
27575
|
-
(
|
|
27576
|
-
id:
|
|
27577
|
-
...
|
|
28089
|
+
(doc53) => ({
|
|
28090
|
+
id: doc53.id,
|
|
28091
|
+
...doc53.data()
|
|
27578
28092
|
})
|
|
27579
28093
|
)
|
|
27580
28094
|
);
|
|
@@ -27589,8 +28103,8 @@ var ProductService = class extends BaseService {
|
|
|
27589
28103
|
...product,
|
|
27590
28104
|
updatedAt: /* @__PURE__ */ new Date()
|
|
27591
28105
|
};
|
|
27592
|
-
const docRef =
|
|
27593
|
-
await
|
|
28106
|
+
const docRef = doc51(this.getProductsRef(technologyId), productId);
|
|
28107
|
+
await updateDoc46(docRef, updateData);
|
|
27594
28108
|
return this.getById(technologyId, productId);
|
|
27595
28109
|
}
|
|
27596
28110
|
/**
|
|
@@ -27605,8 +28119,8 @@ var ProductService = class extends BaseService {
|
|
|
27605
28119
|
* Gets a product by ID
|
|
27606
28120
|
*/
|
|
27607
28121
|
async getById(technologyId, productId) {
|
|
27608
|
-
const docRef =
|
|
27609
|
-
const docSnap = await
|
|
28122
|
+
const docRef = doc51(this.getProductsRef(technologyId), productId);
|
|
28123
|
+
const docSnap = await getDoc52(docRef);
|
|
27610
28124
|
if (!docSnap.exists()) return null;
|
|
27611
28125
|
return {
|
|
27612
28126
|
id: docSnap.id,
|
|
@@ -27642,25 +28156,25 @@ var ProductService = class extends BaseService {
|
|
|
27642
28156
|
brandId: brandId || "none",
|
|
27643
28157
|
category: category || "none"
|
|
27644
28158
|
});
|
|
27645
|
-
const constraints = [
|
|
28159
|
+
const constraints = [where41("isActive", "==", true), orderBy24("name")];
|
|
27646
28160
|
if (brandId) {
|
|
27647
28161
|
console.log("[ProductService.getAllTopLevel] Adding brandId filter:", brandId);
|
|
27648
|
-
constraints.push(
|
|
28162
|
+
constraints.push(where41("brandId", "==", brandId));
|
|
27649
28163
|
}
|
|
27650
28164
|
if (category) {
|
|
27651
28165
|
console.log("[ProductService.getAllTopLevel] Adding category filter:", category);
|
|
27652
|
-
constraints.push(
|
|
28166
|
+
constraints.push(where41("category", "==", category));
|
|
27653
28167
|
}
|
|
27654
28168
|
if (lastVisible) {
|
|
27655
28169
|
constraints.push(startAfter19(lastVisible));
|
|
27656
28170
|
}
|
|
27657
28171
|
constraints.push(limit21(rowsPerPage));
|
|
27658
|
-
const q =
|
|
27659
|
-
const snapshot = await
|
|
28172
|
+
const q = query41(this.getTopLevelProductsRef(), ...constraints);
|
|
28173
|
+
const snapshot = await getDocs41(q);
|
|
27660
28174
|
const products = snapshot.docs.map(
|
|
27661
|
-
(
|
|
27662
|
-
id:
|
|
27663
|
-
...
|
|
28175
|
+
(doc53) => ({
|
|
28176
|
+
id: doc53.id,
|
|
28177
|
+
...doc53.data()
|
|
27664
28178
|
})
|
|
27665
28179
|
);
|
|
27666
28180
|
const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
|
|
@@ -27670,8 +28184,8 @@ var ProductService = class extends BaseService {
|
|
|
27670
28184
|
* Gets a product by ID from the top-level collection
|
|
27671
28185
|
*/
|
|
27672
28186
|
async getByIdTopLevel(productId) {
|
|
27673
|
-
const docRef =
|
|
27674
|
-
const docSnap = await
|
|
28187
|
+
const docRef = doc51(this.getTopLevelProductsRef(), productId);
|
|
28188
|
+
const docSnap = await getDoc52(docRef);
|
|
27675
28189
|
if (!docSnap.exists()) return null;
|
|
27676
28190
|
return {
|
|
27677
28191
|
id: docSnap.id,
|
|
@@ -27686,8 +28200,8 @@ var ProductService = class extends BaseService {
|
|
|
27686
28200
|
...product,
|
|
27687
28201
|
updatedAt: /* @__PURE__ */ new Date()
|
|
27688
28202
|
};
|
|
27689
|
-
const docRef =
|
|
27690
|
-
await
|
|
28203
|
+
const docRef = doc51(this.getTopLevelProductsRef(), productId);
|
|
28204
|
+
await updateDoc46(docRef, updateData);
|
|
27691
28205
|
return this.getByIdTopLevel(productId);
|
|
27692
28206
|
}
|
|
27693
28207
|
/**
|
|
@@ -27702,8 +28216,8 @@ var ProductService = class extends BaseService {
|
|
|
27702
28216
|
* Assigns a product to a technology
|
|
27703
28217
|
*/
|
|
27704
28218
|
async assignToTechnology(productId, technologyId) {
|
|
27705
|
-
const docRef =
|
|
27706
|
-
await
|
|
28219
|
+
const docRef = doc51(this.getTopLevelProductsRef(), productId);
|
|
28220
|
+
await updateDoc46(docRef, {
|
|
27707
28221
|
assignedTechnologyIds: arrayUnion10(technologyId),
|
|
27708
28222
|
updatedAt: /* @__PURE__ */ new Date()
|
|
27709
28223
|
});
|
|
@@ -27712,8 +28226,8 @@ var ProductService = class extends BaseService {
|
|
|
27712
28226
|
* Unassigns a product from a technology
|
|
27713
28227
|
*/
|
|
27714
28228
|
async unassignFromTechnology(productId, technologyId) {
|
|
27715
|
-
const docRef =
|
|
27716
|
-
await
|
|
28229
|
+
const docRef = doc51(this.getTopLevelProductsRef(), productId);
|
|
28230
|
+
await updateDoc46(docRef, {
|
|
27717
28231
|
assignedTechnologyIds: arrayRemove9(technologyId),
|
|
27718
28232
|
updatedAt: /* @__PURE__ */ new Date()
|
|
27719
28233
|
});
|
|
@@ -27722,17 +28236,17 @@ var ProductService = class extends BaseService {
|
|
|
27722
28236
|
* Gets products assigned to a specific technology
|
|
27723
28237
|
*/
|
|
27724
28238
|
async getAssignedProducts(technologyId) {
|
|
27725
|
-
const q =
|
|
28239
|
+
const q = query41(
|
|
27726
28240
|
this.getTopLevelProductsRef(),
|
|
27727
|
-
|
|
27728
|
-
|
|
27729
|
-
|
|
28241
|
+
where41("assignedTechnologyIds", "array-contains", technologyId),
|
|
28242
|
+
where41("isActive", "==", true),
|
|
28243
|
+
orderBy24("name")
|
|
27730
28244
|
);
|
|
27731
|
-
const snapshot = await
|
|
28245
|
+
const snapshot = await getDocs41(q);
|
|
27732
28246
|
return snapshot.docs.map(
|
|
27733
|
-
(
|
|
27734
|
-
id:
|
|
27735
|
-
...
|
|
28247
|
+
(doc53) => ({
|
|
28248
|
+
id: doc53.id,
|
|
28249
|
+
...doc53.data()
|
|
27736
28250
|
})
|
|
27737
28251
|
);
|
|
27738
28252
|
}
|
|
@@ -27740,16 +28254,16 @@ var ProductService = class extends BaseService {
|
|
|
27740
28254
|
* Gets products NOT assigned to a specific technology
|
|
27741
28255
|
*/
|
|
27742
28256
|
async getUnassignedProducts(technologyId) {
|
|
27743
|
-
const q =
|
|
28257
|
+
const q = query41(
|
|
27744
28258
|
this.getTopLevelProductsRef(),
|
|
27745
|
-
|
|
27746
|
-
|
|
28259
|
+
where41("isActive", "==", true),
|
|
28260
|
+
orderBy24("name")
|
|
27747
28261
|
);
|
|
27748
|
-
const snapshot = await
|
|
28262
|
+
const snapshot = await getDocs41(q);
|
|
27749
28263
|
const allProducts = snapshot.docs.map(
|
|
27750
|
-
(
|
|
27751
|
-
id:
|
|
27752
|
-
...
|
|
28264
|
+
(doc53) => ({
|
|
28265
|
+
id: doc53.id,
|
|
28266
|
+
...doc53.data()
|
|
27753
28267
|
})
|
|
27754
28268
|
);
|
|
27755
28269
|
return allProducts.filter(
|
|
@@ -27763,17 +28277,17 @@ var ProductService = class extends BaseService {
|
|
|
27763
28277
|
* Gets all products for a brand (from top-level collection)
|
|
27764
28278
|
*/
|
|
27765
28279
|
async getByBrand(brandId) {
|
|
27766
|
-
const q =
|
|
28280
|
+
const q = query41(
|
|
27767
28281
|
this.getTopLevelProductsRef(),
|
|
27768
|
-
|
|
27769
|
-
|
|
27770
|
-
|
|
28282
|
+
where41("brandId", "==", brandId),
|
|
28283
|
+
where41("isActive", "==", true),
|
|
28284
|
+
orderBy24("name")
|
|
27771
28285
|
);
|
|
27772
|
-
const snapshot = await
|
|
28286
|
+
const snapshot = await getDocs41(q);
|
|
27773
28287
|
return snapshot.docs.map(
|
|
27774
|
-
(
|
|
27775
|
-
id:
|
|
27776
|
-
...
|
|
28288
|
+
(doc53) => ({
|
|
28289
|
+
id: doc53.id,
|
|
28290
|
+
...doc53.data()
|
|
27777
28291
|
})
|
|
27778
28292
|
);
|
|
27779
28293
|
}
|
|
@@ -27803,14 +28317,14 @@ var ProductService = class extends BaseService {
|
|
|
27803
28317
|
let cursor;
|
|
27804
28318
|
const constraints = [];
|
|
27805
28319
|
if (!includeInactive) {
|
|
27806
|
-
constraints.push(
|
|
28320
|
+
constraints.push(where41("isActive", "==", true));
|
|
27807
28321
|
}
|
|
27808
|
-
constraints.push(
|
|
28322
|
+
constraints.push(orderBy24("name"));
|
|
27809
28323
|
while (true) {
|
|
27810
28324
|
const queryConstraints = [...constraints, limit21(PAGE_SIZE)];
|
|
27811
28325
|
if (cursor) queryConstraints.push(startAfter19(cursor));
|
|
27812
|
-
const q =
|
|
27813
|
-
const snapshot = await
|
|
28326
|
+
const q = query41(this.getTopLevelProductsRef(), ...queryConstraints);
|
|
28327
|
+
const snapshot = await getDocs41(q);
|
|
27814
28328
|
if (snapshot.empty) break;
|
|
27815
28329
|
for (const d of snapshot.docs) {
|
|
27816
28330
|
const product = { id: d.id, ...d.data() };
|
|
@@ -27856,10 +28370,10 @@ var ProductService = class extends BaseService {
|
|
|
27856
28370
|
import {
|
|
27857
28371
|
arrayRemove as arrayRemove10,
|
|
27858
28372
|
arrayUnion as arrayUnion11,
|
|
27859
|
-
doc as
|
|
27860
|
-
getDoc as
|
|
27861
|
-
setDoc as
|
|
27862
|
-
updateDoc as
|
|
28373
|
+
doc as doc52,
|
|
28374
|
+
getDoc as getDoc53,
|
|
28375
|
+
setDoc as setDoc35,
|
|
28376
|
+
updateDoc as updateDoc47
|
|
27863
28377
|
} from "firebase/firestore";
|
|
27864
28378
|
var ADMIN_CONSTANTS_COLLECTION = "admin-constants";
|
|
27865
28379
|
var TREATMENT_BENEFITS_DOC = "treatment-benefits";
|
|
@@ -27871,7 +28385,7 @@ var ConstantsService = class extends BaseService {
|
|
|
27871
28385
|
* @type {DocumentReference}
|
|
27872
28386
|
*/
|
|
27873
28387
|
get treatmentBenefitsDocRef() {
|
|
27874
|
-
return
|
|
28388
|
+
return doc52(this.db, ADMIN_CONSTANTS_COLLECTION, TREATMENT_BENEFITS_DOC);
|
|
27875
28389
|
}
|
|
27876
28390
|
/**
|
|
27877
28391
|
* @description Gets the reference to the document holding contraindications.
|
|
@@ -27879,7 +28393,7 @@ var ConstantsService = class extends BaseService {
|
|
|
27879
28393
|
* @type {DocumentReference}
|
|
27880
28394
|
*/
|
|
27881
28395
|
get contraindicationsDocRef() {
|
|
27882
|
-
return
|
|
28396
|
+
return doc52(this.db, ADMIN_CONSTANTS_COLLECTION, CONTRAINDICATIONS_DOC);
|
|
27883
28397
|
}
|
|
27884
28398
|
// =================================================================
|
|
27885
28399
|
// Treatment Benefits
|
|
@@ -27889,7 +28403,7 @@ var ConstantsService = class extends BaseService {
|
|
|
27889
28403
|
* @returns {Promise<TreatmentBenefitDynamic[]>} An array of all treatment benefits.
|
|
27890
28404
|
*/
|
|
27891
28405
|
async getAllBenefitsForFilter() {
|
|
27892
|
-
const docSnap = await
|
|
28406
|
+
const docSnap = await getDoc53(this.treatmentBenefitsDocRef);
|
|
27893
28407
|
if (!docSnap.exists()) {
|
|
27894
28408
|
return [];
|
|
27895
28409
|
}
|
|
@@ -27918,11 +28432,11 @@ var ConstantsService = class extends BaseService {
|
|
|
27918
28432
|
id: this.generateId(),
|
|
27919
28433
|
...benefit
|
|
27920
28434
|
};
|
|
27921
|
-
const docSnap = await
|
|
28435
|
+
const docSnap = await getDoc53(this.treatmentBenefitsDocRef);
|
|
27922
28436
|
if (!docSnap.exists()) {
|
|
27923
|
-
await
|
|
28437
|
+
await setDoc35(this.treatmentBenefitsDocRef, { benefits: [newBenefit] });
|
|
27924
28438
|
} else {
|
|
27925
|
-
await
|
|
28439
|
+
await updateDoc47(this.treatmentBenefitsDocRef, {
|
|
27926
28440
|
benefits: arrayUnion11(newBenefit)
|
|
27927
28441
|
});
|
|
27928
28442
|
}
|
|
@@ -27962,7 +28476,7 @@ var ConstantsService = class extends BaseService {
|
|
|
27962
28476
|
throw new Error("Treatment benefit not found.");
|
|
27963
28477
|
}
|
|
27964
28478
|
benefits[benefitIndex] = benefit;
|
|
27965
|
-
await
|
|
28479
|
+
await updateDoc47(this.treatmentBenefitsDocRef, { benefits });
|
|
27966
28480
|
return benefit;
|
|
27967
28481
|
}
|
|
27968
28482
|
/**
|
|
@@ -27976,7 +28490,7 @@ var ConstantsService = class extends BaseService {
|
|
|
27976
28490
|
if (!benefitToRemove) {
|
|
27977
28491
|
return;
|
|
27978
28492
|
}
|
|
27979
|
-
await
|
|
28493
|
+
await updateDoc47(this.treatmentBenefitsDocRef, {
|
|
27980
28494
|
benefits: arrayRemove10(benefitToRemove)
|
|
27981
28495
|
});
|
|
27982
28496
|
}
|
|
@@ -27988,7 +28502,7 @@ var ConstantsService = class extends BaseService {
|
|
|
27988
28502
|
* @returns {Promise<ContraindicationDynamic[]>} An array of all contraindications.
|
|
27989
28503
|
*/
|
|
27990
28504
|
async getAllContraindicationsForFilter() {
|
|
27991
|
-
const docSnap = await
|
|
28505
|
+
const docSnap = await getDoc53(this.contraindicationsDocRef);
|
|
27992
28506
|
if (!docSnap.exists()) {
|
|
27993
28507
|
return [];
|
|
27994
28508
|
}
|
|
@@ -28023,13 +28537,13 @@ var ConstantsService = class extends BaseService {
|
|
|
28023
28537
|
id: this.generateId(),
|
|
28024
28538
|
...contraindication
|
|
28025
28539
|
};
|
|
28026
|
-
const docSnap = await
|
|
28540
|
+
const docSnap = await getDoc53(this.contraindicationsDocRef);
|
|
28027
28541
|
if (!docSnap.exists()) {
|
|
28028
|
-
await
|
|
28542
|
+
await setDoc35(this.contraindicationsDocRef, {
|
|
28029
28543
|
contraindications: [newContraindication]
|
|
28030
28544
|
});
|
|
28031
28545
|
} else {
|
|
28032
|
-
await
|
|
28546
|
+
await updateDoc47(this.contraindicationsDocRef, {
|
|
28033
28547
|
contraindications: arrayUnion11(newContraindication)
|
|
28034
28548
|
});
|
|
28035
28549
|
}
|
|
@@ -28071,7 +28585,7 @@ var ConstantsService = class extends BaseService {
|
|
|
28071
28585
|
throw new Error("Contraindication not found.");
|
|
28072
28586
|
}
|
|
28073
28587
|
contraindications[index] = contraindication;
|
|
28074
|
-
await
|
|
28588
|
+
await updateDoc47(this.contraindicationsDocRef, { contraindications });
|
|
28075
28589
|
return contraindication;
|
|
28076
28590
|
}
|
|
28077
28591
|
/**
|
|
@@ -28085,7 +28599,7 @@ var ConstantsService = class extends BaseService {
|
|
|
28085
28599
|
if (!toRemove) {
|
|
28086
28600
|
return;
|
|
28087
28601
|
}
|
|
28088
|
-
await
|
|
28602
|
+
await updateDoc47(this.contraindicationsDocRef, {
|
|
28089
28603
|
contraindications: arrayRemove10(toRemove)
|
|
28090
28604
|
});
|
|
28091
28605
|
}
|
|
@@ -28302,9 +28816,15 @@ export {
|
|
|
28302
28816
|
ProcedureService,
|
|
28303
28817
|
ProductService,
|
|
28304
28818
|
REGISTER_TOKENS_COLLECTION,
|
|
28819
|
+
RESOURCES_COLLECTION,
|
|
28820
|
+
RESOURCE_CALENDAR_SUBCOLLECTION,
|
|
28821
|
+
RESOURCE_INSTANCES_SUBCOLLECTION,
|
|
28305
28822
|
REVENUE_ANALYTICS_SUBCOLLECTION,
|
|
28306
28823
|
REVIEWS_COLLECTION,
|
|
28307
28824
|
RequirementType,
|
|
28825
|
+
ResourceCategory,
|
|
28826
|
+
ResourceService,
|
|
28827
|
+
ResourceStatus,
|
|
28308
28828
|
ReviewAnalyticsService,
|
|
28309
28829
|
ReviewService,
|
|
28310
28830
|
SKIN_QUALITY_ASSESSMENT_COLLECTION,
|