@7365admin1/core 3.24.0 → 3.26.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/dist/index.js CHANGED
@@ -10378,6 +10378,7 @@ var MVerification = class {
10378
10378
  }
10379
10379
  }
10380
10380
  this.metadata = { ...value.metadata };
10381
+ this.roleName = value.roleName;
10381
10382
  this.status = value.status ?? "pending";
10382
10383
  this.createdAt = value.createdAt ?? /* @__PURE__ */ new Date();
10383
10384
  this.updatedAt = value.updatedAt ?? null;
@@ -10530,6 +10531,16 @@ function useVerificationRepo() {
10530
10531
  { $sort: sort },
10531
10532
  { $skip: page * limit },
10532
10533
  { $limit: limit },
10534
+ {
10535
+ $lookup: {
10536
+ from: "roles",
10537
+ localField: "metadata.role",
10538
+ foreignField: "_id",
10539
+ as: "roles",
10540
+ pipeline: [{ $project: { name: 1 } }]
10541
+ }
10542
+ },
10543
+ { $unwind: { path: "$roles", preserveNullAndEmptyArrays: true } },
10533
10544
  {
10534
10545
  $project: {
10535
10546
  _id: 1,
@@ -10537,6 +10548,7 @@ function useVerificationRepo() {
10537
10548
  email: 1,
10538
10549
  type: 1,
10539
10550
  metadata: 1,
10551
+ roleName: "$roles.name",
10540
10552
  status: 1
10541
10553
  }
10542
10554
  }
@@ -12508,19 +12520,22 @@ function useVerificationService() {
12508
12520
  orgId,
12509
12521
  siteId,
12510
12522
  siteName,
12523
+ app,
12511
12524
  inviteType
12512
12525
  }) {
12513
12526
  const schema2 = import_joi11.default.object({
12514
12527
  email: import_joi11.default.string().email().lowercase().required(),
12515
12528
  orgId: import_joi11.default.string().hex().length(24).required(),
12516
12529
  siteId: import_joi11.default.string().hex().length(24).required(),
12517
- siteName: import_joi11.default.string().required()
12530
+ siteName: import_joi11.default.string().required(),
12531
+ app: import_joi11.default.string().required()
12518
12532
  });
12519
12533
  const { error } = schema2.validate({
12520
12534
  email,
12521
12535
  orgId,
12522
12536
  siteId,
12523
- siteName
12537
+ siteName,
12538
+ app
12524
12539
  });
12525
12540
  if (error) {
12526
12541
  const messages = error.details.map((d) => d.message).join(", ");
@@ -12535,7 +12550,8 @@ function useVerificationService() {
12535
12550
  metadata: {
12536
12551
  siteId,
12537
12552
  siteName,
12538
- org: orgId
12553
+ org: orgId,
12554
+ app
12539
12555
  },
12540
12556
  expireAt: new Date(
12541
12557
  (/* @__PURE__ */ new Date()).getTime() + 72 * 60 * 60 * 1e3
@@ -12555,7 +12571,7 @@ function useVerificationService() {
12555
12571
  const res = await _add(value);
12556
12572
  const dir = __dirname;
12557
12573
  const filePath = (0, import_node_server_utils21.getDirectory)(dir, `./public/handlebars/${value.type}`);
12558
- const link = `${APP_MAIN}/verify/${value.type}/${res}`;
12574
+ const link = `${APP_MAIN}/verify/service-provider-invite/${res}`;
12559
12575
  const emailContent = (0, import_node_server_utils21.compileHandlebar)({
12560
12576
  context: {
12561
12577
  email,
@@ -15124,6 +15140,7 @@ function useVerificationController() {
15124
15140
  orgId: import_joi16.default.string().hex().required(),
15125
15141
  siteId: import_joi16.default.string().hex().required(),
15126
15142
  siteName: import_joi16.default.string().required(),
15143
+ app: import_joi16.default.string().required(),
15127
15144
  inviteType: import_joi16.default.string().valid("create-org", "organization-invite").required()
15128
15145
  });
15129
15146
  const { error } = validation.validate(payload);
@@ -15140,6 +15157,7 @@ function useVerificationController() {
15140
15157
  orgId,
15141
15158
  siteId,
15142
15159
  siteName,
15160
+ app,
15143
15161
  inviteType
15144
15162
  } = payload;
15145
15163
  try {
@@ -15148,6 +15166,7 @@ function useVerificationController() {
15148
15166
  orgId,
15149
15167
  siteId,
15150
15168
  siteName,
15169
+ app,
15151
15170
  inviteType
15152
15171
  });
15153
15172
  const cookieOptions = {
@@ -21503,7 +21522,8 @@ function MVisitorTransaction(value) {
21503
21522
  updatedBy: value.inviterId ?? ""
21504
21523
  } : null,
21505
21524
  arrivalTime: value.arrivalTime,
21506
- duration: value.duration
21525
+ duration: value.duration,
21526
+ members: value.members
21507
21527
  };
21508
21528
  }
21509
21529
 
@@ -22162,7 +22182,7 @@ function useVisitorTransactionRepo() {
22162
22182
  session,
22163
22183
  sort: { checkIn: -1 },
22164
22184
  returnDocument: "after",
22165
- projection: { _id: 1, site: 1 }
22185
+ projection: { _id: 1, site: 1, type: 1 }
22166
22186
  }
22167
22187
  );
22168
22188
  return result;
@@ -23761,7 +23781,7 @@ function useDahuaService() {
23761
23781
  try {
23762
23782
  const result = await _checkOutBySiteAndPlate(site, plateNumber2);
23763
23783
  console.log("checkOutBySiteAndPlate result", result);
23764
- if (onDetected2 && result?._id && result?.site) {
23784
+ if (onDetected2 && result?.type != "resident" && result?.site) {
23765
23785
  onDetected2({ reload: true, site: result?.site?.toString(), siteName: camera?.siteName, cameraDirection: camera?.direction, direction });
23766
23786
  }
23767
23787
  return result;
@@ -23835,7 +23855,7 @@ function useDahuaService() {
23835
23855
  loggerDahua.info(`${camera?.siteName}-${camera?.direction}] Unregistered vehicle with plate ${plateNumber2} and transaction ID ${insert?._id}`);
23836
23856
  }
23837
23857
  }
23838
- if (insert?._id && insert?.site && onDetected2) {
23858
+ if (insert?.status == "unregistered" /* UNREGISTERED */ && insert?.site && onDetected2) {
23839
23859
  onDetected2({ _id: insert?._id, site: insert?.site?.toString(), plateNumber: insert?.plateNumber, cameraDirection: camera?.direction, direction });
23840
23860
  }
23841
23861
  return insert;
@@ -34440,7 +34460,7 @@ var KeyRepo = class {
34440
34460
  findOptions
34441
34461
  );
34442
34462
  console.log("visitorId", visitorId.toString());
34443
- console.log("latestHistory.visitorId", latestHistory?.visitorId.toString());
34463
+ console.log("latestHistory.visitorId", latestHistory?.visitorId?.toString());
34444
34464
  if (latestHistory?.visitorId && latestHistory.visitorId?.toString() !== visitorId.toString()) {
34445
34465
  console.log("Not updating keyId", keyId);
34446
34466
  return;
@@ -34513,70 +34533,59 @@ var KeyRepo = class {
34513
34533
  return Promise.reject("Failed to delete key");
34514
34534
  }
34515
34535
  }
34516
- static async getById2(id) {
34517
- return this.collection().aggregate([
34518
- { $match: { _id: new import_mongodb62.ObjectId(id) } },
34519
- {
34520
- $lookup: {
34521
- from: "qr-code-templates",
34522
- localField: "template",
34523
- foreignField: "_id",
34524
- as: "QRTemplateInfo"
34525
- }
34526
- },
34527
- {
34528
- $unwind: {
34529
- path: "$QRTemplateInfo",
34530
- preserveNullAndEmptyArrays: true
34531
- }
34532
- },
34533
- {
34534
- $addFields: {
34535
- prefixPass: { $toUpper: "$QRTemplateInfo.prefixPass" },
34536
- prefixKey: { $toUpper: "$QRTemplateInfo.prefixKey" },
34537
- templateName: "$QRTemplateInfo.name"
34538
- }
34539
- },
34540
- {
34541
- $addFields: {
34542
- prefixAndName: {
34543
- $cond: {
34544
- if: { $or: [{ $not: "$prefixPass" }, { $not: "$prefixKey" }] },
34545
- then: "$name",
34546
- else: {
34547
- $cond: {
34548
- if: { $eq: ["$passType", "pass-key"] },
34549
- then: { $concat: ["$prefixKey", "$name"] },
34550
- else: { $concat: ["$prefixPass", "$name"] }
34536
+ static async getById2(id, session) {
34537
+ return this.collection().aggregate(
34538
+ [
34539
+ { $match: { _id: new import_mongodb62.ObjectId(id) } },
34540
+ {
34541
+ $lookup: {
34542
+ from: "qr-code-templates",
34543
+ localField: "template",
34544
+ foreignField: "_id",
34545
+ as: "QRTemplateInfo"
34546
+ }
34547
+ },
34548
+ {
34549
+ $unwind: {
34550
+ path: "$QRTemplateInfo",
34551
+ preserveNullAndEmptyArrays: true
34552
+ }
34553
+ },
34554
+ {
34555
+ $addFields: {
34556
+ prefixPass: { $toUpper: "$QRTemplateInfo.prefixPass" },
34557
+ prefixKey: { $toUpper: "$QRTemplateInfo.prefixKey" },
34558
+ templateName: "$QRTemplateInfo.name"
34559
+ }
34560
+ },
34561
+ {
34562
+ $addFields: {
34563
+ prefixAndName: {
34564
+ $cond: {
34565
+ if: { $or: [{ $not: "$prefixPass" }, { $not: "$prefixKey" }] },
34566
+ then: "$name",
34567
+ else: {
34568
+ $cond: {
34569
+ if: { $eq: ["$passType", "pass-key"] },
34570
+ then: { $concat: ["$prefixKey", "$name"] },
34571
+ else: { $concat: ["$prefixPass", "$name"] }
34572
+ }
34551
34573
  }
34552
34574
  }
34553
34575
  }
34554
34576
  }
34555
34577
  }
34556
- }
34557
- ]).toArray().then((results) => results.length ? results[0] : null);
34578
+ ],
34579
+ { session }
34580
+ ).toArray().then((results) => results.length ? results[0] : null);
34558
34581
  }
34559
- static async checkPassKeyAvailability(visitorPass, passKeys) {
34560
- if (Array.isArray(visitorPass) && visitorPass.length > 0) {
34561
- for (let i = 0; i < visitorPass.length; i++) {
34562
- let pass = await convertObjectIdUtil2(visitorPass[i].keyId, "Pass ID");
34563
- const getPass = await this.getById2(pass);
34564
- if (!getPass)
34565
- throw new Error("Pass not found");
34566
- if (getPass?.status && getPass?.status.toLowerCase() != "Available".toLowerCase())
34567
- throw new Error(`Pass ${getPass?.prefixAndName} is ${getPass?.status}`);
34568
- }
34569
- }
34570
- if (Array.isArray(passKeys) && passKeys.length > 0) {
34571
- for (let i = 0; i < passKeys.length; i++) {
34572
- let key = await convertObjectIdUtil2(passKeys[i].keyId, "Key ID");
34573
- const getPass = await this.getById2(key);
34574
- if (!getPass)
34575
- throw new Error(`Key not found`);
34576
- if (getPass?.status && getPass?.status.toLowerCase() != "Available".toLowerCase())
34577
- throw new Error(`Pass ${getPass?.prefixAndName} is ${getPass?.status}`);
34578
- }
34579
- }
34582
+ static async checkPassOrKeyAvailability(passOrKeyId, type, session) {
34583
+ let passOrKeyObjectId = await convertObjectIdUtil2(passOrKeyId, `${type} Id`);
34584
+ const getPassOrKey = await this.getById2(passOrKeyObjectId, session);
34585
+ if (!getPassOrKey)
34586
+ throw new Error(`${type} not found`);
34587
+ if (getPassOrKey?.status && getPassOrKey?.status.toLowerCase() != "Available".toLowerCase())
34588
+ throw new Error(`${type} ${getPassOrKey?.prefixAndName} is ${getPassOrKey?.status}`);
34580
34589
  }
34581
34590
  };
34582
34591
 
@@ -34941,9 +34950,6 @@ function useVisitorTransactionService() {
34941
34950
  } = value;
34942
34951
  for (let i = 0; i < value.members.length; i += chunkSize) {
34943
34952
  const chunk = value.members.slice(i, i + chunkSize);
34944
- for (const member of chunk) {
34945
- await KeyRepo.checkPassKeyAvailability(member.visitorPass, member.passKeys);
34946
- }
34947
34953
  await Promise.all(
34948
34954
  chunk.map(async (member) => {
34949
34955
  const clonedMember = structuredClone(member);
@@ -34984,6 +34990,7 @@ function useVisitorTransactionService() {
34984
34990
  );
34985
34991
  console.log("visitorId service", visitorId);
34986
34992
  for (const item of preparedVisitorPass) {
34993
+ await KeyRepo.checkPassOrKeyAvailability(item.keyId, "Pass", session);
34987
34994
  await KeyRepo.updateKeyById(
34988
34995
  item.keyId,
34989
34996
  {
@@ -34999,6 +35006,7 @@ function useVisitorTransactionService() {
34999
35006
  );
35000
35007
  }
35001
35008
  for (const item of preparedPassKeys) {
35009
+ await KeyRepo.checkPassOrKeyAvailability(item.keyId, "Key", session);
35002
35010
  await KeyRepo.updateKeyById(
35003
35011
  item.keyId,
35004
35012
  {
@@ -35041,7 +35049,6 @@ function useVisitorTransactionService() {
35041
35049
  if (found === 1)
35042
35050
  throw new import_node_server_utils107.BadRequestError("This plate number is blocklisted");
35043
35051
  }
35044
- await KeyRepo.checkPassKeyAvailability(value.visitorPass, value.passKeys);
35045
35052
  if (Array.isArray(value.visitorPass)) {
35046
35053
  for (const item of value.visitorPass) {
35047
35054
  item.receivedDate = /* @__PURE__ */ new Date();
@@ -35061,6 +35068,7 @@ function useVisitorTransactionService() {
35061
35068
  const result = await _add(value, session);
35062
35069
  if (Array.isArray(value.visitorPass)) {
35063
35070
  for (const item of value.visitorPass) {
35071
+ await KeyRepo.checkPassOrKeyAvailability(item.keyId, "Pass", session);
35064
35072
  await KeyRepo.updateKeyById(
35065
35073
  item.keyId,
35066
35074
  { status: "In Use" /* IN_USE */, updatedBy: value.createdBy },
@@ -35075,6 +35083,7 @@ function useVisitorTransactionService() {
35075
35083
  }
35076
35084
  if (Array.isArray(value.passKeys)) {
35077
35085
  for (const item of value.passKeys) {
35086
+ await KeyRepo.checkPassOrKeyAvailability(item.keyId, "Key", session);
35078
35087
  await KeyRepo.updateKeyById(
35079
35088
  item.keyId,
35080
35089
  { status: "In Use" /* IN_USE */, updatedBy: value.createdBy },
@@ -35171,6 +35180,12 @@ function useVisitorTransactionService() {
35171
35180
  if (value.site) {
35172
35181
  value.site = typeof value.site === "string" ? new import_mongodb63.ObjectId(value.site) : value.site;
35173
35182
  }
35183
+ if (value?.block) {
35184
+ value.block = await convertObjectIdUtil2(value.block, "block Id");
35185
+ }
35186
+ if (value?.level) {
35187
+ value.level = await convertObjectIdUtil2(value.level, "level Id");
35188
+ }
35174
35189
  if (value.unit) {
35175
35190
  value.unit = typeof value.unit === "string" ? new import_mongodb63.ObjectId(value.unit) : value.unit;
35176
35191
  const unit = await _getUnitById(value.unit);
@@ -35182,6 +35197,7 @@ function useVisitorTransactionService() {
35182
35197
  if (Array.isArray(value.visitorPass)) {
35183
35198
  for (const item of value.visitorPass) {
35184
35199
  if (item.add) {
35200
+ await KeyRepo.checkPassOrKeyAvailability(item.keyId, "Pass", session);
35185
35201
  await KeyRepo.updateKeyById(
35186
35202
  item.keyId,
35187
35203
  {
@@ -35230,6 +35246,7 @@ function useVisitorTransactionService() {
35230
35246
  if (Array.isArray(value.passKeys)) {
35231
35247
  for (const item of value.passKeys) {
35232
35248
  if (item.add) {
35249
+ await KeyRepo.checkPassOrKeyAvailability(item.keyId, "Key", session);
35233
35250
  await KeyRepo.updateKeyById(
35234
35251
  item.keyId,
35235
35252
  {
@@ -48916,22 +48933,52 @@ function useAccessManagementSvc() {
48916
48933
  }
48917
48934
  };
48918
48935
  const liftAccessLevelsSvc = async (params) => {
48936
+ const { getCache: getCache2, setCache: setCache2 } = (0, import_node_server_utils159.useCache)(namespace);
48937
+ const cacheKey = (0, import_node_server_utils159.makeCacheKey)(namespace, {
48938
+ user: params.user,
48939
+ resource: "lift-levels"
48940
+ });
48941
+ const cachedData = await getCache2(cacheKey);
48942
+ if (cachedData) {
48943
+ import_node_server_utils159.logger.info(`Cache hit for key: ${cacheKey}`);
48944
+ return cachedData;
48945
+ }
48919
48946
  try {
48920
48947
  const command = readTemplate("lift-levels");
48921
48948
  const response = await sendCommand(command, params.acm_url);
48922
48949
  const res = await (0, import_xml2js3.parseStringPromise)(response, { explicitArray: false });
48923
48950
  const format2 = await formatLiftAccessLevels(res);
48951
+ setCache2(cacheKey, format2, 60).then(() => {
48952
+ import_node_server_utils159.logger.info(`Cache set for key: ${cacheKey}`);
48953
+ }).catch((err) => {
48954
+ import_node_server_utils159.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
48955
+ });
48924
48956
  return format2;
48925
48957
  } catch (error) {
48926
48958
  throw new Error(error.message);
48927
48959
  }
48928
48960
  };
48929
48961
  const accessGroupsSvc = async (params) => {
48962
+ const { getCache: getCache2, setCache: setCache2 } = (0, import_node_server_utils159.useCache)(namespace);
48963
+ const cacheKey = (0, import_node_server_utils159.makeCacheKey)(namespace, {
48964
+ user: params.user,
48965
+ resource: "access-groups"
48966
+ });
48967
+ const cachedData = await getCache2(cacheKey);
48968
+ if (cachedData) {
48969
+ import_node_server_utils159.logger.info(`Cache hit for key: ${cacheKey}`);
48970
+ return cachedData;
48971
+ }
48930
48972
  try {
48931
48973
  const command = readTemplate("access-group");
48932
48974
  const response = await sendCommand(command, params.acm_url);
48933
48975
  const res = await (0, import_xml2js3.parseStringPromise)(response, { explicitArray: false });
48934
48976
  const format2 = await formatAccessGroup(res);
48977
+ setCache2(cacheKey, format2, 60).then(() => {
48978
+ import_node_server_utils159.logger.info(`Cache set for key: ${cacheKey}`);
48979
+ }).catch((err) => {
48980
+ import_node_server_utils159.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
48981
+ });
48935
48982
  return format2;
48936
48983
  } catch (err) {
48937
48984
  throw new Error(err.message);
@@ -52731,6 +52778,7 @@ function useStatementOfAccountService() {
52731
52778
  unit_billings = unit_billings.map((unit) => {
52732
52779
  try {
52733
52780
  unit._id = unit._id.toString();
52781
+ unit.paidBy = unit.paidBy.toString();
52734
52782
  } catch {
52735
52783
  throw new import_node_server_utils172.BadRequestError("Invalid unit id format/type");
52736
52784
  }
@@ -57771,12 +57819,9 @@ function useNewDashboardRepo() {
57771
57819
  function getDateRange(p) {
57772
57820
  const now = (0, import_moment.default)().tz("Asia/Singapore");
57773
57821
  if (p === "thisWeek" /* THIS_WEEK */) {
57774
- const rollingStart = now.clone().subtract(6, "days").startOf("day");
57775
- const monthStart = now.clone().startOf("month");
57776
- const start = import_moment.default.max(rollingStart, monthStart);
57777
57822
  return {
57778
- $gte: start.toDate(),
57779
- $lte: now.clone().endOf("day").toDate()
57823
+ $gte: now.clone().startOf("isoWeek").toDate(),
57824
+ $lte: now.clone().endOf("isoWeek").toDate()
57780
57825
  };
57781
57826
  }
57782
57827
  if (p === "thisMonth" /* THIS_MONTH */) {
@@ -57790,6 +57835,12 @@ function useNewDashboardRepo() {
57790
57835
  $lte: now.clone().endOf("day").toDate()
57791
57836
  };
57792
57837
  }
57838
+ function getSiteDayRange(date = import_moment.default.tz("Asia/Singapore")) {
57839
+ return {
57840
+ $gte: date.clone().startOf("day").toDate(),
57841
+ $lte: date.clone().endOf("day").toDate()
57842
+ };
57843
+ }
57793
57844
  const calculatePercentageChange = (currentCount, previousCount) => {
57794
57845
  if (previousCount === 0) {
57795
57846
  return currentCount > 0 ? 100 : 0;
@@ -58216,24 +58267,27 @@ function useNewDashboardRepo() {
58216
58267
  const siteIdObj = (0, import_node_server_utils201.toObjectId)(siteId);
58217
58268
  const startOfToday = import_moment.default.tz("Asia/Singapore").startOf("day").toDate();
58218
58269
  const endOfToday = import_moment.default.tz("Asia/Singapore").endOf("day").toDate();
58219
- const localTodayStr = import_moment.default.tz("Asia/Singapore").format("YYYY-MM-DD");
58220
- const facilityTodayStart = import_moment.default.utc(`${localTodayStr}T00:00:00.000Z`).toDate();
58221
- const facilityTodayEnd = import_moment.default.utc(`${localTodayStr}T23:59:59.999Z`).toDate();
58222
- const localYesterdayStr = import_moment.default.tz("Asia/Singapore").subtract(1, "day").format("YYYY-MM-DD");
58223
- const facilityYesterdayStart = import_moment.default.utc(`${localYesterdayStr}T00:00:00.000Z`).toDate();
58224
- const facilityYesterdayEnd = import_moment.default.utc(`${localYesterdayStr}T23:59:59.999Z`).toDate();
58225
- let facilityPeriodRange = { $gte: facilityTodayStart, $lte: facilityTodayEnd };
58270
+ const facilityTodayRange = getSiteDayRange();
58271
+ const facilityYesterdayRange = getSiteDayRange(
58272
+ import_moment.default.tz("Asia/Singapore").subtract(1, "day")
58273
+ );
58274
+ const facilityTodayStart = facilityTodayRange.$gte;
58275
+ const facilityTodayEnd = facilityTodayRange.$lte;
58276
+ const facilityYesterdayStart = facilityYesterdayRange.$gte;
58277
+ const facilityYesterdayEnd = facilityYesterdayRange.$lte;
58278
+ let facilityPeriodRange = {
58279
+ $gte: facilityTodayStart,
58280
+ $lte: facilityTodayEnd
58281
+ };
58226
58282
  if (period === "thisWeek" /* THIS_WEEK */) {
58227
- const startStr = import_moment.default.tz("Asia/Singapore").subtract(7, "days").format("YYYY-MM-DD");
58228
58283
  facilityPeriodRange = {
58229
- $gte: import_moment.default.utc(`${startStr}T00:00:00.000Z`).toDate(),
58230
- $lte: facilityTodayEnd
58284
+ $gte: import_moment.default.tz("Asia/Singapore").startOf("isoWeek").toDate(),
58285
+ $lte: import_moment.default.tz("Asia/Singapore").endOf("isoWeek").toDate()
58231
58286
  };
58232
58287
  } else if (period === "thisMonth" /* THIS_MONTH */) {
58233
- const startStr = import_moment.default.tz("Asia/Singapore").subtract(30, "days").format("YYYY-MM-DD");
58234
58288
  facilityPeriodRange = {
58235
- $gte: import_moment.default.utc(`${startStr}T00:00:00.000Z`).toDate(),
58236
- $lte: facilityTodayEnd
58289
+ $gte: import_moment.default.tz("Asia/Singapore").startOf("month").toDate(),
58290
+ $lte: import_moment.default.tz("Asia/Singapore").endOf("month").toDate()
58237
58291
  };
58238
58292
  }
58239
58293
  const upcomingEvents = await db.collection(events_namespace_collection).find({
@@ -58317,6 +58371,18 @@ function useNewDashboardRepo() {
58317
58371
  const facilityCollection = db.collection(
58318
58372
  facility_bookings_namespace_collection2
58319
58373
  );
58374
+ const facilityBookingStatuses = [
58375
+ "Pending",
58376
+ "Approved",
58377
+ "Ongoing",
58378
+ "For Review",
58379
+ "With Balance",
58380
+ "For Refund",
58381
+ "With Refund",
58382
+ "Completed",
58383
+ "Rejected",
58384
+ "Cancelled"
58385
+ ];
58320
58386
  const [
58321
58387
  workOrderReport,
58322
58388
  yesterdayWorkOrderReport,
@@ -58467,7 +58533,7 @@ function useNewDashboardRepo() {
58467
58533
  }
58468
58534
  }
58469
58535
  ],
58470
- status: { $nin: ["deleted", "Deleted"] }
58536
+ status: { $in: facilityBookingStatuses }
58471
58537
  }
58472
58538
  },
58473
58539
  {
@@ -58492,6 +58558,25 @@ function useNewDashboardRepo() {
58492
58558
  }
58493
58559
  },
58494
58560
  { $count: "count" }
58561
+ ],
58562
+ byStatus: [
58563
+ {
58564
+ $match: {
58565
+ status: { $in: facilityBookingStatuses }
58566
+ }
58567
+ },
58568
+ {
58569
+ $group: {
58570
+ _id: {
58571
+ $cond: [
58572
+ { $eq: ["$status", "For Refund"] },
58573
+ "With Refund",
58574
+ "$status"
58575
+ ]
58576
+ },
58577
+ count: { $sum: 1 }
58578
+ }
58579
+ }
58495
58580
  ]
58496
58581
  }
58497
58582
  }
@@ -58502,7 +58587,12 @@ function useNewDashboardRepo() {
58502
58587
  site: { $in: [siteIdObj, siteId] },
58503
58588
  ...facilityMatchObj,
58504
58589
  $or: [
58505
- { date: { $gte: facilityYesterdayStart, $lte: facilityYesterdayEnd } },
58590
+ {
58591
+ date: {
58592
+ $gte: facilityYesterdayStart,
58593
+ $lte: facilityYesterdayEnd
58594
+ }
58595
+ },
58506
58596
  {
58507
58597
  date: {
58508
58598
  $gte: facilityYesterdayStart.toISOString(),
@@ -58510,7 +58600,7 @@ function useNewDashboardRepo() {
58510
58600
  }
58511
58601
  }
58512
58602
  ],
58513
- status: { $nin: ["deleted", "Deleted"] }
58603
+ status: { $in: facilityBookingStatuses }
58514
58604
  }
58515
58605
  },
58516
58606
  { $count: "count" }
@@ -58529,7 +58619,7 @@ function useNewDashboardRepo() {
58529
58619
  }
58530
58620
  }
58531
58621
  ],
58532
- status: { $nin: ["deleted", "Deleted"] }
58622
+ status: { $in: facilityBookingStatuses }
58533
58623
  }
58534
58624
  },
58535
58625
  { $count: "count" }
@@ -58553,8 +58643,25 @@ function useNewDashboardRepo() {
58553
58643
  const fFacet = facilityReport[0] ?? {
58554
58644
  total: [],
58555
58645
  ongoing: [],
58556
- waitingApproval: []
58646
+ waitingApproval: [],
58647
+ byStatus: []
58557
58648
  };
58649
+ const facilityBookingStatusCounts = {
58650
+ Pending: 0,
58651
+ Approved: 0,
58652
+ Ongoing: 0,
58653
+ "For Review": 0,
58654
+ "With Balance": 0,
58655
+ "With Refund": 0,
58656
+ Completed: 0,
58657
+ Rejected: 0,
58658
+ Cancelled: 0
58659
+ };
58660
+ for (const item of fFacet.byStatus ?? []) {
58661
+ if (typeof item?._id === "string" && item._id in facilityBookingStatusCounts) {
58662
+ facilityBookingStatusCounts[item._id] = item.count ?? 0;
58663
+ }
58664
+ }
58558
58665
  const workOrderStatus = {
58559
58666
  pending: 0,
58560
58667
  inProgress: 0,
@@ -58601,6 +58708,7 @@ function useNewDashboardRepo() {
58601
58708
  count: fFacet.total[0]?.count ?? 0,
58602
58709
  ongoing: fFacet.ongoing[0]?.count ?? 0,
58603
58710
  waitingApproval: fFacet.waitingApproval[0]?.count ?? 0,
58711
+ byStatus: facilityBookingStatusCounts,
58604
58712
  percentage: calculatePercentageChange(
58605
58713
  todayFacilityReport[0]?.count ?? 0,
58606
58714
  yesterdayFacilityReport[0]?.count ?? 0
@@ -63331,9 +63439,12 @@ var useRedDotPaymentRepo = () => {
63331
63439
  }
63332
63440
  const now = /* @__PURE__ */ new Date();
63333
63441
  const unitUpdate = {
63442
+ method: payload.method,
63443
+ message: payload.message,
63334
63444
  updatedAt: now.toISOString(),
63335
63445
  paymentStatus: payload.paymentStatus,
63336
- transaction_id: payload.transaction_id
63446
+ transaction_id: payload.transaction_id,
63447
+ paidBy: paymentInfo.paidBy
63337
63448
  };
63338
63449
  const paymentUpdate = {
63339
63450
  updatedAt: now.toISOString(),
@@ -68164,6 +68275,7 @@ function useBidPrelovedService() {
68164
68275
  const { add: _addBid } = useBidPrelovedRepo();
68165
68276
  const { add: _addChannel, getByParticipants: _getByParticipants } = useChannelPrelovedRepo();
68166
68277
  const { add: _addChat } = useChatPrelovedRepo();
68278
+ const { updateStatus } = usePostPrelovedRepo();
68167
68279
  async function createBid(value) {
68168
68280
  const client = import_node_server_utils254.useAtlas.getClient();
68169
68281
  if (!client)
@@ -68209,6 +68321,9 @@ function useBidPrelovedService() {
68209
68321
  },
68210
68322
  session
68211
68323
  );
68324
+ if (value.type === "reserve") {
68325
+ await updateStatus(postId, "reserved" /* RESERVED */, session);
68326
+ }
68212
68327
  await session.commitTransaction();
68213
68328
  return { bidId };
68214
68329
  } catch (error) {