@7365admin1/core 3.32.2-staging.43 → 3.32.2-staging.45
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/index.d.ts +1 -1
- package/dist/index.js +41 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2713,7 +2713,7 @@ declare function useAttendanceSettingsController(): {
|
|
|
2713
2713
|
declare function useAttendanceRepository(): {
|
|
2714
2714
|
createIndex: () => Promise<void>;
|
|
2715
2715
|
checkInAttendance: (value: TAttendanceCheckIn, session?: ClientSession) => Promise<ObjectId>;
|
|
2716
|
-
getAllAttendances: ({ page, limit, search, site, serviceType, }: TGetAttendancesQuery) => Promise<{}>;
|
|
2716
|
+
getAllAttendances: ({ page, limit, search, site, startDate, endDate, serviceType, }: TGetAttendancesQuery) => Promise<{}>;
|
|
2717
2717
|
getAttendanceByUser: ({ page, limit, search, site, startDate, endDate, serviceType, user, }: TGetAttendancesByUserQuery) => Promise<{}>;
|
|
2718
2718
|
getAttendanceById: (_id: string | ObjectId, session?: ClientSession) => Promise<{}>;
|
|
2719
2719
|
getRawAttendanceById: (_id: string | ObjectId, session?: ClientSession) => Promise<TAttendance>;
|
package/dist/index.js
CHANGED
|
@@ -33236,6 +33236,8 @@ function useAttendanceRepository() {
|
|
|
33236
33236
|
limit = 10,
|
|
33237
33237
|
search = "",
|
|
33238
33238
|
site,
|
|
33239
|
+
startDate = "",
|
|
33240
|
+
endDate = "",
|
|
33239
33241
|
serviceType
|
|
33240
33242
|
}) {
|
|
33241
33243
|
page = page > 0 ? page - 1 : 0;
|
|
@@ -33255,6 +33257,37 @@ function useAttendanceRepository() {
|
|
|
33255
33257
|
if (search) {
|
|
33256
33258
|
cacheOptions.search = search;
|
|
33257
33259
|
}
|
|
33260
|
+
const singaporeTz = "Asia/Singapore";
|
|
33261
|
+
const normalizedStartDate = typeof startDate === "string" ? startDate : (0, import_moment_timezone2.default)(startDate).tz(singaporeTz).format("YYYY-MM-DD");
|
|
33262
|
+
const normalizedEndDate = typeof endDate === "string" ? endDate : (0, import_moment_timezone2.default)(endDate).tz(singaporeTz).format("YYYY-MM-DD");
|
|
33263
|
+
if (startDate && endDate) {
|
|
33264
|
+
const startOfDay = import_moment_timezone2.default.tz(normalizedStartDate, "YYYY-MM-DD", singaporeTz).startOf("day").toDate();
|
|
33265
|
+
const endOfDay = import_moment_timezone2.default.tz(normalizedEndDate, "YYYY-MM-DD", singaporeTz).endOf("day").toDate();
|
|
33266
|
+
query.$expr = {
|
|
33267
|
+
$and: [
|
|
33268
|
+
{ $gte: [{ $toDate: "$checkIn.timestamp" }, startOfDay] },
|
|
33269
|
+
{ $lte: [{ $toDate: "$checkIn.timestamp" }, endOfDay] }
|
|
33270
|
+
]
|
|
33271
|
+
};
|
|
33272
|
+
cacheOptions.startDate = normalizedStartDate;
|
|
33273
|
+
cacheOptions.endDate = normalizedEndDate;
|
|
33274
|
+
} else if (startDate) {
|
|
33275
|
+
query.$expr = {
|
|
33276
|
+
$gte: [
|
|
33277
|
+
{ $toDate: "$checkIn.timestamp" },
|
|
33278
|
+
import_moment_timezone2.default.tz(normalizedStartDate, "YYYY-MM-DD", singaporeTz).startOf("day").toDate()
|
|
33279
|
+
]
|
|
33280
|
+
};
|
|
33281
|
+
cacheOptions.startDate = normalizedStartDate;
|
|
33282
|
+
} else if (endDate) {
|
|
33283
|
+
query.$expr = {
|
|
33284
|
+
$lte: [
|
|
33285
|
+
{ $toDate: "$checkIn.timestamp" },
|
|
33286
|
+
import_moment_timezone2.default.tz(normalizedEndDate, "YYYY-MM-DD", singaporeTz).endOf("day").toDate()
|
|
33287
|
+
]
|
|
33288
|
+
};
|
|
33289
|
+
cacheOptions.endDate = normalizedEndDate;
|
|
33290
|
+
}
|
|
33258
33291
|
const cacheKey = (0, import_node_server_utils103.makeCacheKey)(namespace_collection, cacheOptions);
|
|
33259
33292
|
const cachedData = await getCache(cacheKey);
|
|
33260
33293
|
if (cachedData) {
|
|
@@ -33790,7 +33823,9 @@ function useAttendanceController() {
|
|
|
33790
33823
|
limit: import_joi56.default.number().min(1).optional().allow("", null),
|
|
33791
33824
|
search: import_joi56.default.string().optional().allow("", null),
|
|
33792
33825
|
site: import_joi56.default.string().hex().required(),
|
|
33793
|
-
serviceType: import_joi56.default.string().valid(...Object.values(AppServiceType)).required()
|
|
33826
|
+
serviceType: import_joi56.default.string().valid(...Object.values(AppServiceType)).required(),
|
|
33827
|
+
dateFrom: import_joi56.default.alternatives().try(import_joi56.default.date(), import_joi56.default.string()).optional().allow("", null),
|
|
33828
|
+
dateTo: import_joi56.default.alternatives().try(import_joi56.default.date(), import_joi56.default.string()).optional().allow("", null)
|
|
33794
33829
|
});
|
|
33795
33830
|
const { error } = validation.validate(query);
|
|
33796
33831
|
if (error) {
|
|
@@ -33803,13 +33838,17 @@ function useAttendanceController() {
|
|
|
33803
33838
|
const search = req.query.search ?? "";
|
|
33804
33839
|
const site = req.params.site ?? "";
|
|
33805
33840
|
const serviceType = req.query.serviceType ?? "";
|
|
33841
|
+
const startDate = req.query.dateFrom ?? "";
|
|
33842
|
+
const endDate = req.query.dateTo ?? "";
|
|
33806
33843
|
try {
|
|
33807
33844
|
const data = await _getAllAttendances({
|
|
33808
33845
|
page,
|
|
33809
33846
|
limit,
|
|
33810
33847
|
search,
|
|
33811
33848
|
site,
|
|
33812
|
-
serviceType
|
|
33849
|
+
serviceType,
|
|
33850
|
+
startDate,
|
|
33851
|
+
endDate
|
|
33813
33852
|
});
|
|
33814
33853
|
res.json(data);
|
|
33815
33854
|
return;
|