@7365admin1/module-hygiene 4.30.1 → 4.30.2
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/CHANGELOG.md +10 -0
- package/dist/index.js +34 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/require-photo-on-completion.test.mjs +63 -0
package/dist/index.mjs
CHANGED
|
@@ -3253,6 +3253,39 @@ import {
|
|
|
3253
3253
|
useAtlas as useAtlas6,
|
|
3254
3254
|
useCache as useCache5
|
|
3255
3255
|
} from "@7365admin1/node-server-utils";
|
|
3256
|
+
|
|
3257
|
+
// src/utils/completion-photo.util.ts
|
|
3258
|
+
var COMPLETION_PHOTO_MESSAGE = "A photo is required to complete this task. Take or upload at least one photo before marking it complete.";
|
|
3259
|
+
function readCompletion(units, unitId) {
|
|
3260
|
+
if (units.length === 0)
|
|
3261
|
+
return { completesSet: false, hasEvidence: false };
|
|
3262
|
+
const others = units.filter((unit) => String(unit.unit) !== String(unitId));
|
|
3263
|
+
return {
|
|
3264
|
+
completesSet: others.every(
|
|
3265
|
+
(unit) => unit.approve === true || unit.reject === true
|
|
3266
|
+
),
|
|
3267
|
+
hasEvidence: others.some(
|
|
3268
|
+
(unit) => Array.isArray(unit.attachment) && unit.attachment.length > 0
|
|
3269
|
+
)
|
|
3270
|
+
};
|
|
3271
|
+
}
|
|
3272
|
+
function requiresCompletionPhoto({
|
|
3273
|
+
decision,
|
|
3274
|
+
attachment,
|
|
3275
|
+
completesSet,
|
|
3276
|
+
hasEvidence
|
|
3277
|
+
}) {
|
|
3278
|
+
if (decision !== "approve")
|
|
3279
|
+
return false;
|
|
3280
|
+
if (!completesSet)
|
|
3281
|
+
return false;
|
|
3282
|
+
if (hasEvidence)
|
|
3283
|
+
return false;
|
|
3284
|
+
const carriesEvidence = Array.isArray(attachment) && attachment.some((id) => typeof id === "string" && id.trim().length > 0);
|
|
3285
|
+
return !carriesEvidence;
|
|
3286
|
+
}
|
|
3287
|
+
|
|
3288
|
+
// src/repositories/hygiene-area-checklist.repository.ts
|
|
3256
3289
|
function useAreaChecklistRepo() {
|
|
3257
3290
|
const db = useAtlas6.getDb();
|
|
3258
3291
|
if (!db) {
|
|
@@ -4097,18 +4130,7 @@ function useAreaChecklistRepo() {
|
|
|
4097
4130
|
const group = (doc?.checklist ?? []).find(
|
|
4098
4131
|
(entry) => entry.set === set
|
|
4099
4132
|
);
|
|
4100
|
-
|
|
4101
|
-
if (units.length === 0)
|
|
4102
|
-
return { completesSet: false, hasEvidence: false };
|
|
4103
|
-
const others = units.filter(
|
|
4104
|
-
(unit) => String(unit.unit) !== String(unitId)
|
|
4105
|
-
);
|
|
4106
|
-
return {
|
|
4107
|
-
completesSet: others.every((unit) => unit.status === "completed"),
|
|
4108
|
-
hasEvidence: others.some(
|
|
4109
|
-
(unit) => Array.isArray(unit.attachment) && unit.attachment.length > 0
|
|
4110
|
-
)
|
|
4111
|
-
};
|
|
4133
|
+
return readCompletion(group?.units ?? [], unitId);
|
|
4112
4134
|
}
|
|
4113
4135
|
async function updateAreaChecklist(_id, value, session) {
|
|
4114
4136
|
try {
|
|
@@ -4650,24 +4672,6 @@ import {
|
|
|
4650
4672
|
} from "@7365admin1/node-server-utils";
|
|
4651
4673
|
import { AppServiceType as AppServiceType10 } from "@7365admin1/core";
|
|
4652
4674
|
|
|
4653
|
-
// src/utils/completion-photo.util.ts
|
|
4654
|
-
var COMPLETION_PHOTO_MESSAGE = "A photo is required to complete this task. Take or upload at least one photo before marking it complete.";
|
|
4655
|
-
function requiresCompletionPhoto({
|
|
4656
|
-
decision,
|
|
4657
|
-
attachment,
|
|
4658
|
-
completesSet,
|
|
4659
|
-
hasEvidence
|
|
4660
|
-
}) {
|
|
4661
|
-
if (decision !== "approve")
|
|
4662
|
-
return false;
|
|
4663
|
-
if (!completesSet)
|
|
4664
|
-
return false;
|
|
4665
|
-
if (hasEvidence)
|
|
4666
|
-
return false;
|
|
4667
|
-
const carriesEvidence = Array.isArray(attachment) && attachment.some((id) => typeof id === "string" && id.trim().length > 0);
|
|
4668
|
-
return !carriesEvidence;
|
|
4669
|
-
}
|
|
4670
|
-
|
|
4671
4675
|
// src/services/hygiene-checklist-pdf.service.ts
|
|
4672
4676
|
import { launch } from "puppeteer";
|
|
4673
4677
|
import { InternalServerError as InternalServerError6, useAtlas as useAtlas8 } from "@7365admin1/node-server-utils";
|