@7365admin1/core 3.32.2-staging.9 → 3.34.0
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 +12 -0
- package/dist/index.d.ts +1 -3
- package/dist/index.js +42 -134
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -178
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/.changeset/invite-payload-logging.md +0 -5
- package/.github/workflows/publish-staging.yml +0 -36
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @iservice365/core
|
|
2
2
|
|
|
3
|
+
## 3.34.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 36c0873: Add `MAILER_FROM_EMAIL` config so the mailer's SMTP auth login and display sender can differ, needed for relaying through Brevo (or any provider whose SMTP login differs from the desired sender address). Falls back to the existing behavior when unset.
|
|
8
|
+
|
|
9
|
+
## 3.33.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- fd94267: release api changes
|
|
14
|
+
|
|
3
15
|
## 3.32.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -2622,8 +2622,6 @@ type TGetAttendancesQuery = {
|
|
|
2622
2622
|
page?: number;
|
|
2623
2623
|
limit?: number;
|
|
2624
2624
|
search?: string;
|
|
2625
|
-
startDate?: string | Date;
|
|
2626
|
-
endDate?: string | Date;
|
|
2627
2625
|
} & Pick<TAttendance, "site" | "serviceType">;
|
|
2628
2626
|
type TGetAttendancesByUserQuery = Pick<TGetAttendancesQuery, "page" | "limit" | "search" | "site" | "serviceType"> & Pick<TAttendance, "user">;
|
|
2629
2627
|
declare const attendanceSchema: Joi.ObjectSchema<any>;
|
|
@@ -2684,7 +2682,7 @@ declare function useAttendanceSettingsController(): {
|
|
|
2684
2682
|
declare function useAttendanceRepository(): {
|
|
2685
2683
|
createIndex: () => Promise<void>;
|
|
2686
2684
|
checkInAttendance: (value: TAttendanceCheckIn, session?: ClientSession) => Promise<ObjectId>;
|
|
2687
|
-
getAllAttendances: ({ page, limit, search, site,
|
|
2685
|
+
getAllAttendances: ({ page, limit, search, site, serviceType, }: TGetAttendancesQuery) => Promise<{}>;
|
|
2688
2686
|
getAttendanceByUser: ({ page, limit, search, site, serviceType, user, }: TGetAttendancesByUserQuery) => Promise<{}>;
|
|
2689
2687
|
getAttendanceById: (_id: string | ObjectId, session?: ClientSession) => Promise<{}>;
|
|
2690
2688
|
getRawAttendanceById: (_id: string | ObjectId, session?: ClientSession) => Promise<TAttendance>;
|
package/dist/index.js
CHANGED
|
@@ -15062,10 +15062,6 @@ function useVerificationController() {
|
|
|
15062
15062
|
}
|
|
15063
15063
|
async function createSimpleUserInvite(req, res, next) {
|
|
15064
15064
|
const payload = { ...req.body };
|
|
15065
|
-
import_node_server_utils32.logger.log({
|
|
15066
|
-
level: "info",
|
|
15067
|
-
message: `[invite/user] payload: ${JSON.stringify(payload)}`
|
|
15068
|
-
});
|
|
15069
15065
|
const validation = import_joi16.default.object({
|
|
15070
15066
|
email: import_joi16.default.string().email().required(),
|
|
15071
15067
|
app: import_joi16.default.array().items(import_joi16.default.string()).min(1).required(),
|
|
@@ -15105,21 +15101,16 @@ function useVerificationController() {
|
|
|
15105
15101
|
siteName
|
|
15106
15102
|
}
|
|
15107
15103
|
});
|
|
15108
|
-
|
|
15104
|
+
res.status(201).json({
|
|
15109
15105
|
message: "Successfully invited user.",
|
|
15110
15106
|
totalInvites: verificationIds.length,
|
|
15111
15107
|
verificationIds
|
|
15112
|
-
};
|
|
15113
|
-
import_node_server_utils32.logger.log({
|
|
15114
|
-
level: "info",
|
|
15115
|
-
message: `[invite/user] response: ${JSON.stringify(responseBody)}`
|
|
15116
15108
|
});
|
|
15117
|
-
res.status(201).json(responseBody);
|
|
15118
15109
|
return;
|
|
15119
15110
|
} catch (error2) {
|
|
15120
15111
|
import_node_server_utils32.logger.log({
|
|
15121
15112
|
level: "error",
|
|
15122
|
-
message:
|
|
15113
|
+
message: `${error2.message}`
|
|
15123
15114
|
});
|
|
15124
15115
|
next(error2);
|
|
15125
15116
|
return;
|
|
@@ -15127,10 +15118,6 @@ function useVerificationController() {
|
|
|
15127
15118
|
}
|
|
15128
15119
|
async function createSimpleMemberInvite(req, res, next) {
|
|
15129
15120
|
const payload = { ...req.body };
|
|
15130
|
-
import_node_server_utils32.logger.log({
|
|
15131
|
-
level: "info",
|
|
15132
|
-
message: `[invite/member] payload: ${JSON.stringify(payload)}`
|
|
15133
|
-
});
|
|
15134
15121
|
const validation = import_joi16.default.object({
|
|
15135
15122
|
email: import_joi16.default.string().email().required(),
|
|
15136
15123
|
app: import_joi16.default.string().optional().allow("", null),
|
|
@@ -15168,19 +15155,14 @@ function useVerificationController() {
|
|
|
15168
15155
|
siteName
|
|
15169
15156
|
}
|
|
15170
15157
|
});
|
|
15171
|
-
|
|
15158
|
+
res.status(201).json({
|
|
15172
15159
|
message: "Successfully invited member."
|
|
15173
|
-
};
|
|
15174
|
-
import_node_server_utils32.logger.log({
|
|
15175
|
-
level: "info",
|
|
15176
|
-
message: `[invite/member] response: ${JSON.stringify(responseBody)}`
|
|
15177
15160
|
});
|
|
15178
|
-
res.status(201).json(responseBody);
|
|
15179
15161
|
return;
|
|
15180
15162
|
} catch (error2) {
|
|
15181
15163
|
import_node_server_utils32.logger.log({
|
|
15182
15164
|
level: "error",
|
|
15183
|
-
message:
|
|
15165
|
+
message: `${error2.message}`
|
|
15184
15166
|
});
|
|
15185
15167
|
next(error2);
|
|
15186
15168
|
return;
|
|
@@ -15188,10 +15170,6 @@ function useVerificationController() {
|
|
|
15188
15170
|
}
|
|
15189
15171
|
async function createServiceProviderInvite(req, res, next) {
|
|
15190
15172
|
const payload = req.body;
|
|
15191
|
-
import_node_server_utils32.logger.log({
|
|
15192
|
-
level: "info",
|
|
15193
|
-
message: `[service-providers/invite] payload: ${JSON.stringify(payload)}`
|
|
15194
|
-
});
|
|
15195
15173
|
const validation = import_joi16.default.object({
|
|
15196
15174
|
email: import_joi16.default.string().email().required(),
|
|
15197
15175
|
orgId: import_joi16.default.string().hex().required(),
|
|
@@ -15231,19 +15209,14 @@ function useVerificationController() {
|
|
|
15231
15209
|
secure: true,
|
|
15232
15210
|
maxAge: 4 * 60 * 60 * 1e3
|
|
15233
15211
|
};
|
|
15234
|
-
|
|
15212
|
+
res.cookie("service-provider-email", email, cookieOptions).json({
|
|
15235
15213
|
message: "Successfully invited service provider."
|
|
15236
|
-
};
|
|
15237
|
-
import_node_server_utils32.logger.log({
|
|
15238
|
-
level: "info",
|
|
15239
|
-
message: `[service-providers/invite] response: ${JSON.stringify(responseBody)}`
|
|
15240
15214
|
});
|
|
15241
|
-
res.cookie("service-provider-email", email, cookieOptions).json(responseBody);
|
|
15242
15215
|
return;
|
|
15243
15216
|
} catch (error2) {
|
|
15244
15217
|
import_node_server_utils32.logger.log({
|
|
15245
15218
|
level: "error",
|
|
15246
|
-
message: `
|
|
15219
|
+
message: `controller - ${error2.message}`
|
|
15247
15220
|
});
|
|
15248
15221
|
next(error2);
|
|
15249
15222
|
return;
|
|
@@ -27030,8 +27003,7 @@ function useVehicleService() {
|
|
|
27030
27003
|
throw new Error("Unable to start session for vehicle service.");
|
|
27031
27004
|
}
|
|
27032
27005
|
}
|
|
27033
|
-
const
|
|
27034
|
-
const [_vehiclePlateNumber] = plateNumbers;
|
|
27006
|
+
const [_vehiclePlateNumber] = value.plateNumber;
|
|
27035
27007
|
const [existingPlateNumber, org] = await Promise.all([
|
|
27036
27008
|
_getVehicleByPlateNumber(_vehiclePlateNumber),
|
|
27037
27009
|
_getById(value.org)
|
|
@@ -27096,6 +27068,7 @@ function useVehicleService() {
|
|
|
27096
27068
|
}
|
|
27097
27069
|
}
|
|
27098
27070
|
const owner = value.name;
|
|
27071
|
+
const plateNumbers = value.plateNumber;
|
|
27099
27072
|
try {
|
|
27100
27073
|
if (!isExternalSession) {
|
|
27101
27074
|
session.startTransaction();
|
|
@@ -27312,10 +27285,7 @@ function useVehicleService() {
|
|
|
27312
27285
|
const dahuaResponse = await _addPlateNumber(dahuaPayload);
|
|
27313
27286
|
if (dahuaResponse?.statusCode != 200) {
|
|
27314
27287
|
console.log("dahuaResponse", dahuaResponse);
|
|
27315
|
-
console.log(
|
|
27316
|
-
"approveVehicleById dahuaResponse dahuaResponse?.statusCode != 200",
|
|
27317
|
-
dahuaResponse?.statusCode
|
|
27318
|
-
);
|
|
27288
|
+
console.log("approveVehicleById dahuaResponse dahuaResponse?.statusCode != 200", dahuaResponse?.statusCode);
|
|
27319
27289
|
throw new import_node_server_utils78.BadRequestError("Failed to add plate number to ANPR");
|
|
27320
27290
|
}
|
|
27321
27291
|
const responseData = dahuaResponse?.data.toString("utf-8");
|
|
@@ -27522,19 +27492,7 @@ function useVehicleService() {
|
|
|
27522
27492
|
if (value.peopleId) {
|
|
27523
27493
|
value.peopleId = new import_mongodb49.ObjectId(value.peopleId);
|
|
27524
27494
|
}
|
|
27525
|
-
const {
|
|
27526
|
-
name,
|
|
27527
|
-
plateNumber,
|
|
27528
|
-
start,
|
|
27529
|
-
end,
|
|
27530
|
-
recNo,
|
|
27531
|
-
type,
|
|
27532
|
-
unit,
|
|
27533
|
-
site,
|
|
27534
|
-
block,
|
|
27535
|
-
level,
|
|
27536
|
-
...rest
|
|
27537
|
-
} = value;
|
|
27495
|
+
const { name, plateNumber, start, end, recNo, type, unit, site, block, level, ...rest } = value;
|
|
27538
27496
|
if (_name != name || _plateNumber != plateNumber) {
|
|
27539
27497
|
const startDahua = value.start ? formatDahuaDate(new Date(value.start)) : formatDahuaDate(new Date(_start));
|
|
27540
27498
|
const endDahua = value.end ? formatDahuaDate(new Date(value.end)) : formatDahuaDate(new Date(_end));
|
|
@@ -27561,11 +27519,7 @@ function useVehicleService() {
|
|
|
27561
27519
|
for (const camera of siteCameras) {
|
|
27562
27520
|
const { host, username, password } = camera;
|
|
27563
27521
|
if (_plateNumber != plateNumber) {
|
|
27564
|
-
console.log(
|
|
27565
|
-
"updateVehicleById _plateNumber != plateNumber",
|
|
27566
|
-
_plateNumber,
|
|
27567
|
-
plateNumber
|
|
27568
|
-
);
|
|
27522
|
+
console.log("updateVehicleById _plateNumber != plateNumber", _plateNumber, plateNumber);
|
|
27569
27523
|
const removePlateNumber = {
|
|
27570
27524
|
host,
|
|
27571
27525
|
username,
|
|
@@ -27612,11 +27566,7 @@ function useVehicleService() {
|
|
|
27612
27566
|
);
|
|
27613
27567
|
}
|
|
27614
27568
|
} else {
|
|
27615
|
-
console.log(
|
|
27616
|
-
"updateVehicleById _plateNumber == plateNumber",
|
|
27617
|
-
_plateNumber,
|
|
27618
|
-
plateNumber
|
|
27619
|
-
);
|
|
27569
|
+
console.log("updateVehicleById _plateNumber == plateNumber", _plateNumber, plateNumber);
|
|
27620
27570
|
const dahuaPayload = {
|
|
27621
27571
|
host,
|
|
27622
27572
|
username,
|
|
@@ -33006,7 +32956,6 @@ function MAttendance(value) {
|
|
|
33006
32956
|
// src/repositories/attendance.repository.ts
|
|
33007
32957
|
var import_mongodb60 = require("mongodb");
|
|
33008
32958
|
var import_node_server_utils103 = require("@7365admin1/node-server-utils");
|
|
33009
|
-
var import_moment = __toESM(require("moment"));
|
|
33010
32959
|
function useAttendanceRepository() {
|
|
33011
32960
|
const db = import_node_server_utils103.useAtlas.getDb();
|
|
33012
32961
|
if (!db) {
|
|
@@ -33048,8 +32997,6 @@ function useAttendanceRepository() {
|
|
|
33048
32997
|
limit = 10,
|
|
33049
32998
|
search = "",
|
|
33050
32999
|
site,
|
|
33051
|
-
startDate = "",
|
|
33052
|
-
endDate = "",
|
|
33053
33000
|
serviceType
|
|
33054
33001
|
}) {
|
|
33055
33002
|
page = page > 0 ? page - 1 : 0;
|
|
@@ -33069,37 +33016,6 @@ function useAttendanceRepository() {
|
|
|
33069
33016
|
if (search) {
|
|
33070
33017
|
cacheOptions.search = search;
|
|
33071
33018
|
}
|
|
33072
|
-
const singaporeTz = "Asia/Singapore";
|
|
33073
|
-
const normalizedStartDate = typeof startDate === "string" ? startDate : (0, import_moment.default)(startDate).tz(singaporeTz).format("YYYY-MM-DD");
|
|
33074
|
-
const normalizedEndDate = typeof endDate === "string" ? endDate : (0, import_moment.default)(endDate).tz(singaporeTz).format("YYYY-MM-DD");
|
|
33075
|
-
if (startDate && endDate) {
|
|
33076
|
-
const startOfDay = import_moment.default.tz(normalizedStartDate, "YYYY-MM-DD", singaporeTz).startOf("day").toDate();
|
|
33077
|
-
const endOfDay = import_moment.default.tz(normalizedEndDate, "YYYY-MM-DD", singaporeTz).endOf("day").toDate();
|
|
33078
|
-
query.$expr = {
|
|
33079
|
-
$and: [
|
|
33080
|
-
{ $gte: [{ $toDate: "$checkIn.timestamp" }, startOfDay] },
|
|
33081
|
-
{ $lte: [{ $toDate: "$checkIn.timestamp" }, endOfDay] }
|
|
33082
|
-
]
|
|
33083
|
-
};
|
|
33084
|
-
cacheOptions.startDate = normalizedStartDate;
|
|
33085
|
-
cacheOptions.endDate = normalizedEndDate;
|
|
33086
|
-
} else if (startDate) {
|
|
33087
|
-
query.$expr = {
|
|
33088
|
-
$gte: [
|
|
33089
|
-
{ $toDate: "$checkIn.timestamp" },
|
|
33090
|
-
import_moment.default.tz(normalizedStartDate, "YYYY-MM-DD", singaporeTz).startOf("day").toDate()
|
|
33091
|
-
]
|
|
33092
|
-
};
|
|
33093
|
-
cacheOptions.startDate = normalizedStartDate;
|
|
33094
|
-
} else if (endDate) {
|
|
33095
|
-
query.$expr = {
|
|
33096
|
-
$lte: [
|
|
33097
|
-
{ $toDate: "$checkIn.timestamp" },
|
|
33098
|
-
import_moment.default.tz(normalizedEndDate, "YYYY-MM-DD", singaporeTz).endOf("day").toDate()
|
|
33099
|
-
]
|
|
33100
|
-
};
|
|
33101
|
-
cacheOptions.endDate = normalizedEndDate;
|
|
33102
|
-
}
|
|
33103
33019
|
const cacheKey = (0, import_node_server_utils103.makeCacheKey)(namespace_collection, cacheOptions);
|
|
33104
33020
|
const cachedData = await getCache(cacheKey);
|
|
33105
33021
|
if (cachedData) {
|
|
@@ -33601,9 +33517,7 @@ function useAttendanceController() {
|
|
|
33601
33517
|
limit: import_joi56.default.number().min(1).optional().allow("", null),
|
|
33602
33518
|
search: import_joi56.default.string().optional().allow("", null),
|
|
33603
33519
|
site: import_joi56.default.string().hex().required(),
|
|
33604
|
-
serviceType: import_joi56.default.string().valid(...Object.values(AppServiceType)).required()
|
|
33605
|
-
dateFrom: import_joi56.default.alternatives().try(import_joi56.default.date(), import_joi56.default.string()).optional().allow("", null),
|
|
33606
|
-
dateTo: import_joi56.default.alternatives().try(import_joi56.default.date(), import_joi56.default.string()).optional().allow("", null)
|
|
33520
|
+
serviceType: import_joi56.default.string().valid(...Object.values(AppServiceType)).required()
|
|
33607
33521
|
});
|
|
33608
33522
|
const { error } = validation.validate(query);
|
|
33609
33523
|
if (error) {
|
|
@@ -33616,17 +33530,13 @@ function useAttendanceController() {
|
|
|
33616
33530
|
const search = req.query.search ?? "";
|
|
33617
33531
|
const site = req.params.site ?? "";
|
|
33618
33532
|
const serviceType = req.query.serviceType ?? "";
|
|
33619
|
-
const startDate = req.query.dateFrom ?? "";
|
|
33620
|
-
const endDate = req.query.dateTo ?? "";
|
|
33621
33533
|
try {
|
|
33622
33534
|
const data = await _getAllAttendances({
|
|
33623
33535
|
page,
|
|
33624
33536
|
limit,
|
|
33625
33537
|
search,
|
|
33626
33538
|
site,
|
|
33627
|
-
serviceType
|
|
33628
|
-
startDate,
|
|
33629
|
-
endDate
|
|
33539
|
+
serviceType
|
|
33630
33540
|
});
|
|
33631
33541
|
res.json(data);
|
|
33632
33542
|
return;
|
|
@@ -58794,7 +58704,6 @@ function useNfcPatrolLogController() {
|
|
|
58794
58704
|
const query = {
|
|
58795
58705
|
site: req.query.site,
|
|
58796
58706
|
date: req.query.date,
|
|
58797
|
-
type: req.query.type,
|
|
58798
58707
|
route: {
|
|
58799
58708
|
_id: req.query["route._id"],
|
|
58800
58709
|
startTime: req.query["route.startTime"]
|
|
@@ -58809,14 +58718,13 @@ function useNfcPatrolLogController() {
|
|
|
58809
58718
|
next(new import_node_server_utils200.BadRequestError(messages));
|
|
58810
58719
|
return;
|
|
58811
58720
|
}
|
|
58812
|
-
const { page, limit, site, date,
|
|
58721
|
+
const { page, limit, site, date, route } = value;
|
|
58813
58722
|
try {
|
|
58814
58723
|
const data = await _getAllBySite({
|
|
58815
58724
|
page,
|
|
58816
58725
|
limit,
|
|
58817
58726
|
site,
|
|
58818
58727
|
date,
|
|
58819
|
-
type,
|
|
58820
58728
|
route
|
|
58821
58729
|
});
|
|
58822
58730
|
res.status(200).json(data);
|
|
@@ -58878,7 +58786,7 @@ function useNfcPatrolLogController() {
|
|
|
58878
58786
|
// src/repositories/new-dashboard.repo.ts
|
|
58879
58787
|
var import_node_server_utils201 = require("@7365admin1/node-server-utils");
|
|
58880
58788
|
var import_mongodb122 = require("mongodb");
|
|
58881
|
-
var
|
|
58789
|
+
var import_moment = __toESM(require("moment"));
|
|
58882
58790
|
var Period = /* @__PURE__ */ ((Period2) => {
|
|
58883
58791
|
Period2["TODAY"] = "today";
|
|
58884
58792
|
Period2["THIS_WEEK"] = "thisWeek";
|
|
@@ -58915,7 +58823,7 @@ function useNewDashboardRepo() {
|
|
|
58915
58823
|
const dateWithoutTimezone = date.replace(/\s*\+\d{2}:\d{2}$/, "");
|
|
58916
58824
|
date = new Date(dateWithoutTimezone);
|
|
58917
58825
|
}
|
|
58918
|
-
const singaporeMoment =
|
|
58826
|
+
const singaporeMoment = import_moment.default.tz(date, "Asia/Singapore");
|
|
58919
58827
|
singaporeMoment.set({
|
|
58920
58828
|
hour: 23,
|
|
58921
58829
|
minute: 59,
|
|
@@ -58925,7 +58833,7 @@ function useNewDashboardRepo() {
|
|
|
58925
58833
|
return singaporeMoment.toDate();
|
|
58926
58834
|
}
|
|
58927
58835
|
function getDateRange(p) {
|
|
58928
|
-
const now = (0,
|
|
58836
|
+
const now = (0, import_moment.default)().tz("Asia/Singapore");
|
|
58929
58837
|
if (p === "thisWeek" /* THIS_WEEK */) {
|
|
58930
58838
|
return {
|
|
58931
58839
|
$gte: now.clone().startOf("isoWeek").toDate(),
|
|
@@ -58943,7 +58851,7 @@ function useNewDashboardRepo() {
|
|
|
58943
58851
|
$lte: now.clone().endOf("day").toDate()
|
|
58944
58852
|
};
|
|
58945
58853
|
}
|
|
58946
|
-
function getSiteDayRange(date =
|
|
58854
|
+
function getSiteDayRange(date = import_moment.default.tz("Asia/Singapore")) {
|
|
58947
58855
|
return {
|
|
58948
58856
|
$gte: date.clone().startOf("day").toDate(),
|
|
58949
58857
|
$lte: date.clone().endOf("day").toDate()
|
|
@@ -59214,8 +59122,8 @@ function useNewDashboardRepo() {
|
|
|
59214
59122
|
const todayCompliance = tTotal > 0 ? tCompleted / tTotal * 100 : 0;
|
|
59215
59123
|
let activePatrolItems = [];
|
|
59216
59124
|
if (period === "today" /* TODAY */) {
|
|
59217
|
-
const todayString =
|
|
59218
|
-
const dayIndex =
|
|
59125
|
+
const todayString = import_moment.default.tz("Asia/Singapore").format("YYYY-MM-DD");
|
|
59126
|
+
const dayIndex = import_moment.default.tz("Asia/Singapore").day();
|
|
59219
59127
|
const repeatDay = dayIndex === 0 ? 7 : dayIndex;
|
|
59220
59128
|
const routes = await db.collection("patrol.route").find({
|
|
59221
59129
|
site: { $in: [siteIdObj, siteId] },
|
|
@@ -59267,12 +59175,12 @@ function useNewDashboardRepo() {
|
|
|
59267
59175
|
status = "completed";
|
|
59268
59176
|
}
|
|
59269
59177
|
} else {
|
|
59270
|
-
const routeTime =
|
|
59178
|
+
const routeTime = import_moment.default.tz(
|
|
59271
59179
|
`${todayString} ${startTime}`,
|
|
59272
59180
|
"YYYY-MM-DD HH:mm",
|
|
59273
59181
|
"Asia/Singapore"
|
|
59274
59182
|
);
|
|
59275
|
-
const nowSg =
|
|
59183
|
+
const nowSg = import_moment.default.tz("Asia/Singapore");
|
|
59276
59184
|
const diffMinutes = nowSg.diff(routeTime, "minutes");
|
|
59277
59185
|
if (diffMinutes >= 0) {
|
|
59278
59186
|
if (diffMinutes <= 120) {
|
|
@@ -59320,8 +59228,8 @@ function useNewDashboardRepo() {
|
|
|
59320
59228
|
if (log.status) {
|
|
59321
59229
|
status = Array.isArray(log.status) ? log.status.join(", ") : log.status;
|
|
59322
59230
|
}
|
|
59323
|
-
const logTime = (0,
|
|
59324
|
-
const logDate = (0,
|
|
59231
|
+
const logTime = (0, import_moment.default)(log.createdAt).tz("Asia/Singapore").format("HH:mm");
|
|
59232
|
+
const logDate = (0, import_moment.default)(log.createdAt).tz("Asia/Singapore").format("DD/MM/YYYY");
|
|
59325
59233
|
return {
|
|
59326
59234
|
id: log._id.toString(),
|
|
59327
59235
|
title: log.name,
|
|
@@ -59373,11 +59281,11 @@ function useNewDashboardRepo() {
|
|
|
59373
59281
|
}
|
|
59374
59282
|
async function getPropertyManagementDashboard(siteId, period = "today" /* TODAY */, type, facility) {
|
|
59375
59283
|
const siteIdObj = (0, import_node_server_utils201.toObjectId)(siteId);
|
|
59376
|
-
const startOfToday =
|
|
59377
|
-
const endOfToday =
|
|
59284
|
+
const startOfToday = import_moment.default.tz("Asia/Singapore").startOf("day").toDate();
|
|
59285
|
+
const endOfToday = import_moment.default.tz("Asia/Singapore").endOf("day").toDate();
|
|
59378
59286
|
const facilityTodayRange = getSiteDayRange();
|
|
59379
59287
|
const facilityYesterdayRange = getSiteDayRange(
|
|
59380
|
-
|
|
59288
|
+
import_moment.default.tz("Asia/Singapore").subtract(1, "day")
|
|
59381
59289
|
);
|
|
59382
59290
|
const facilityTodayStart = facilityTodayRange.$gte;
|
|
59383
59291
|
const facilityTodayEnd = facilityTodayRange.$lte;
|
|
@@ -59389,13 +59297,13 @@ function useNewDashboardRepo() {
|
|
|
59389
59297
|
};
|
|
59390
59298
|
if (period === "thisWeek" /* THIS_WEEK */) {
|
|
59391
59299
|
facilityPeriodRange = {
|
|
59392
|
-
$gte:
|
|
59393
|
-
$lte:
|
|
59300
|
+
$gte: import_moment.default.tz("Asia/Singapore").startOf("isoWeek").toDate(),
|
|
59301
|
+
$lte: import_moment.default.tz("Asia/Singapore").endOf("isoWeek").toDate()
|
|
59394
59302
|
};
|
|
59395
59303
|
} else if (period === "thisMonth" /* THIS_MONTH */) {
|
|
59396
59304
|
facilityPeriodRange = {
|
|
59397
|
-
$gte:
|
|
59398
|
-
$lte:
|
|
59305
|
+
$gte: import_moment.default.tz("Asia/Singapore").startOf("month").toDate(),
|
|
59306
|
+
$lte: import_moment.default.tz("Asia/Singapore").endOf("month").toDate()
|
|
59399
59307
|
};
|
|
59400
59308
|
}
|
|
59401
59309
|
const upcomingEvents = await db.collection(events_namespace_collection).find({
|
|
@@ -60027,28 +59935,28 @@ function useNewDashboardRepo() {
|
|
|
60027
59935
|
let labels = [];
|
|
60028
59936
|
let getIntervalIndex;
|
|
60029
59937
|
if (period === "today" /* TODAY */) {
|
|
60030
|
-
rangeStart =
|
|
60031
|
-
rangeEnd =
|
|
59938
|
+
rangeStart = import_moment.default.tz("Asia/Singapore").startOf("day").toDate();
|
|
59939
|
+
rangeEnd = import_moment.default.tz("Asia/Singapore").endOf("day").toDate();
|
|
60032
59940
|
labels = ["12 AM", "4 AM", "8 AM", "12 PM", "4 PM", "8 PM"];
|
|
60033
59941
|
getIntervalIndex = (date) => {
|
|
60034
|
-
const hour = (0,
|
|
59942
|
+
const hour = (0, import_moment.default)(date).tz("Asia/Singapore").hour();
|
|
60035
59943
|
return Math.floor(hour / 4);
|
|
60036
59944
|
};
|
|
60037
59945
|
} else if (period === "thisWeek" /* THIS_WEEK */) {
|
|
60038
|
-
rangeStart =
|
|
60039
|
-
rangeEnd =
|
|
59946
|
+
rangeStart = import_moment.default.tz("Asia/Singapore").startOf("isoWeek").toDate();
|
|
59947
|
+
rangeEnd = import_moment.default.tz("Asia/Singapore").endOf("isoWeek").toDate();
|
|
60040
59948
|
labels = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
|
|
60041
59949
|
getIntervalIndex = (date) => {
|
|
60042
|
-
const day = (0,
|
|
59950
|
+
const day = (0, import_moment.default)(date).tz("Asia/Singapore").isoWeekday();
|
|
60043
59951
|
return day - 1;
|
|
60044
59952
|
};
|
|
60045
59953
|
} else if (period === "thisMonth" /* THIS_MONTH */) {
|
|
60046
|
-
rangeStart =
|
|
60047
|
-
rangeEnd =
|
|
60048
|
-
const daysInMonth =
|
|
59954
|
+
rangeStart = import_moment.default.tz("Asia/Singapore").startOf("month").toDate();
|
|
59955
|
+
rangeEnd = import_moment.default.tz("Asia/Singapore").endOf("month").toDate();
|
|
59956
|
+
const daysInMonth = import_moment.default.tz("Asia/Singapore").daysInMonth();
|
|
60049
59957
|
labels = Array.from({ length: daysInMonth }, (_, i) => String(i + 1));
|
|
60050
59958
|
getIntervalIndex = (date) => {
|
|
60051
|
-
return (0,
|
|
59959
|
+
return (0, import_moment.default)(date).tz("Asia/Singapore").date() - 1;
|
|
60052
59960
|
};
|
|
60053
59961
|
} else {
|
|
60054
59962
|
throw new import_node_server_utils201.BadRequestError("Invalid period.");
|