@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.mjs CHANGED
@@ -9947,6 +9947,7 @@ var MVerification = class {
9947
9947
  }
9948
9948
  }
9949
9949
  this.metadata = { ...value.metadata };
9950
+ this.roleName = value.roleName;
9950
9951
  this.status = value.status ?? "pending";
9951
9952
  this.createdAt = value.createdAt ?? /* @__PURE__ */ new Date();
9952
9953
  this.updatedAt = value.updatedAt ?? null;
@@ -10099,6 +10100,16 @@ function useVerificationRepo() {
10099
10100
  { $sort: sort },
10100
10101
  { $skip: page * limit },
10101
10102
  { $limit: limit },
10103
+ {
10104
+ $lookup: {
10105
+ from: "roles",
10106
+ localField: "metadata.role",
10107
+ foreignField: "_id",
10108
+ as: "roles",
10109
+ pipeline: [{ $project: { name: 1 } }]
10110
+ }
10111
+ },
10112
+ { $unwind: { path: "$roles", preserveNullAndEmptyArrays: true } },
10102
10113
  {
10103
10114
  $project: {
10104
10115
  _id: 1,
@@ -10106,6 +10117,7 @@ function useVerificationRepo() {
10106
10117
  email: 1,
10107
10118
  type: 1,
10108
10119
  metadata: 1,
10120
+ roleName: "$roles.name",
10109
10121
  status: 1
10110
10122
  }
10111
10123
  }
@@ -12110,19 +12122,22 @@ function useVerificationService() {
12110
12122
  orgId,
12111
12123
  siteId,
12112
12124
  siteName,
12125
+ app,
12113
12126
  inviteType
12114
12127
  }) {
12115
12128
  const schema2 = Joi11.object({
12116
12129
  email: Joi11.string().email().lowercase().required(),
12117
12130
  orgId: Joi11.string().hex().length(24).required(),
12118
12131
  siteId: Joi11.string().hex().length(24).required(),
12119
- siteName: Joi11.string().required()
12132
+ siteName: Joi11.string().required(),
12133
+ app: Joi11.string().required()
12120
12134
  });
12121
12135
  const { error } = schema2.validate({
12122
12136
  email,
12123
12137
  orgId,
12124
12138
  siteId,
12125
- siteName
12139
+ siteName,
12140
+ app
12126
12141
  });
12127
12142
  if (error) {
12128
12143
  const messages = error.details.map((d) => d.message).join(", ");
@@ -12137,7 +12152,8 @@ function useVerificationService() {
12137
12152
  metadata: {
12138
12153
  siteId,
12139
12154
  siteName,
12140
- org: orgId
12155
+ org: orgId,
12156
+ app
12141
12157
  },
12142
12158
  expireAt: new Date(
12143
12159
  (/* @__PURE__ */ new Date()).getTime() + 72 * 60 * 60 * 1e3
@@ -12157,7 +12173,7 @@ function useVerificationService() {
12157
12173
  const res = await _add(value);
12158
12174
  const dir = __dirname;
12159
12175
  const filePath = getDirectory(dir, `./public/handlebars/${value.type}`);
12160
- const link = `${APP_MAIN}/verify/${value.type}/${res}`;
12176
+ const link = `${APP_MAIN}/verify/service-provider-invite/${res}`;
12161
12177
  const emailContent = compileHandlebar({
12162
12178
  context: {
12163
12179
  email,
@@ -14751,6 +14767,7 @@ function useVerificationController() {
14751
14767
  orgId: Joi16.string().hex().required(),
14752
14768
  siteId: Joi16.string().hex().required(),
14753
14769
  siteName: Joi16.string().required(),
14770
+ app: Joi16.string().required(),
14754
14771
  inviteType: Joi16.string().valid("create-org", "organization-invite").required()
14755
14772
  });
14756
14773
  const { error } = validation.validate(payload);
@@ -14767,6 +14784,7 @@ function useVerificationController() {
14767
14784
  orgId,
14768
14785
  siteId,
14769
14786
  siteName,
14787
+ app,
14770
14788
  inviteType
14771
14789
  } = payload;
14772
14790
  try {
@@ -14775,6 +14793,7 @@ function useVerificationController() {
14775
14793
  orgId,
14776
14794
  siteId,
14777
14795
  siteName,
14796
+ app,
14778
14797
  inviteType
14779
14798
  });
14780
14799
  const cookieOptions = {
@@ -21240,7 +21259,8 @@ function MVisitorTransaction(value) {
21240
21259
  updatedBy: value.inviterId ?? ""
21241
21260
  } : null,
21242
21261
  arrivalTime: value.arrivalTime,
21243
- duration: value.duration
21262
+ duration: value.duration,
21263
+ members: value.members
21244
21264
  };
21245
21265
  }
21246
21266
 
@@ -21899,7 +21919,7 @@ function useVisitorTransactionRepo() {
21899
21919
  session,
21900
21920
  sort: { checkIn: -1 },
21901
21921
  returnDocument: "after",
21902
- projection: { _id: 1, site: 1 }
21922
+ projection: { _id: 1, site: 1, type: 1 }
21903
21923
  }
21904
21924
  );
21905
21925
  return result;
@@ -23507,7 +23527,7 @@ function useDahuaService() {
23507
23527
  try {
23508
23528
  const result = await _checkOutBySiteAndPlate(site, plateNumber2);
23509
23529
  console.log("checkOutBySiteAndPlate result", result);
23510
- if (onDetected2 && result?._id && result?.site) {
23530
+ if (onDetected2 && result?.type != "resident" && result?.site) {
23511
23531
  onDetected2({ reload: true, site: result?.site?.toString(), siteName: camera?.siteName, cameraDirection: camera?.direction, direction });
23512
23532
  }
23513
23533
  return result;
@@ -23581,7 +23601,7 @@ function useDahuaService() {
23581
23601
  loggerDahua.info(`${camera?.siteName}-${camera?.direction}] Unregistered vehicle with plate ${plateNumber2} and transaction ID ${insert?._id}`);
23582
23602
  }
23583
23603
  }
23584
- if (insert?._id && insert?.site && onDetected2) {
23604
+ if (insert?.status == "unregistered" /* UNREGISTERED */ && insert?.site && onDetected2) {
23585
23605
  onDetected2({ _id: insert?._id, site: insert?.site?.toString(), plateNumber: insert?.plateNumber, cameraDirection: camera?.direction, direction });
23586
23606
  }
23587
23607
  return insert;
@@ -34285,7 +34305,7 @@ var KeyRepo = class {
34285
34305
  findOptions
34286
34306
  );
34287
34307
  console.log("visitorId", visitorId.toString());
34288
- console.log("latestHistory.visitorId", latestHistory?.visitorId.toString());
34308
+ console.log("latestHistory.visitorId", latestHistory?.visitorId?.toString());
34289
34309
  if (latestHistory?.visitorId && latestHistory.visitorId?.toString() !== visitorId.toString()) {
34290
34310
  console.log("Not updating keyId", keyId);
34291
34311
  return;
@@ -34358,70 +34378,59 @@ var KeyRepo = class {
34358
34378
  return Promise.reject("Failed to delete key");
34359
34379
  }
34360
34380
  }
34361
- static async getById2(id) {
34362
- return this.collection().aggregate([
34363
- { $match: { _id: new ObjectId62(id) } },
34364
- {
34365
- $lookup: {
34366
- from: "qr-code-templates",
34367
- localField: "template",
34368
- foreignField: "_id",
34369
- as: "QRTemplateInfo"
34370
- }
34371
- },
34372
- {
34373
- $unwind: {
34374
- path: "$QRTemplateInfo",
34375
- preserveNullAndEmptyArrays: true
34376
- }
34377
- },
34378
- {
34379
- $addFields: {
34380
- prefixPass: { $toUpper: "$QRTemplateInfo.prefixPass" },
34381
- prefixKey: { $toUpper: "$QRTemplateInfo.prefixKey" },
34382
- templateName: "$QRTemplateInfo.name"
34383
- }
34384
- },
34385
- {
34386
- $addFields: {
34387
- prefixAndName: {
34388
- $cond: {
34389
- if: { $or: [{ $not: "$prefixPass" }, { $not: "$prefixKey" }] },
34390
- then: "$name",
34391
- else: {
34392
- $cond: {
34393
- if: { $eq: ["$passType", "pass-key"] },
34394
- then: { $concat: ["$prefixKey", "$name"] },
34395
- else: { $concat: ["$prefixPass", "$name"] }
34381
+ static async getById2(id, session) {
34382
+ return this.collection().aggregate(
34383
+ [
34384
+ { $match: { _id: new ObjectId62(id) } },
34385
+ {
34386
+ $lookup: {
34387
+ from: "qr-code-templates",
34388
+ localField: "template",
34389
+ foreignField: "_id",
34390
+ as: "QRTemplateInfo"
34391
+ }
34392
+ },
34393
+ {
34394
+ $unwind: {
34395
+ path: "$QRTemplateInfo",
34396
+ preserveNullAndEmptyArrays: true
34397
+ }
34398
+ },
34399
+ {
34400
+ $addFields: {
34401
+ prefixPass: { $toUpper: "$QRTemplateInfo.prefixPass" },
34402
+ prefixKey: { $toUpper: "$QRTemplateInfo.prefixKey" },
34403
+ templateName: "$QRTemplateInfo.name"
34404
+ }
34405
+ },
34406
+ {
34407
+ $addFields: {
34408
+ prefixAndName: {
34409
+ $cond: {
34410
+ if: { $or: [{ $not: "$prefixPass" }, { $not: "$prefixKey" }] },
34411
+ then: "$name",
34412
+ else: {
34413
+ $cond: {
34414
+ if: { $eq: ["$passType", "pass-key"] },
34415
+ then: { $concat: ["$prefixKey", "$name"] },
34416
+ else: { $concat: ["$prefixPass", "$name"] }
34417
+ }
34396
34418
  }
34397
34419
  }
34398
34420
  }
34399
34421
  }
34400
34422
  }
34401
- }
34402
- ]).toArray().then((results) => results.length ? results[0] : null);
34423
+ ],
34424
+ { session }
34425
+ ).toArray().then((results) => results.length ? results[0] : null);
34403
34426
  }
34404
- static async checkPassKeyAvailability(visitorPass, passKeys) {
34405
- if (Array.isArray(visitorPass) && visitorPass.length > 0) {
34406
- for (let i = 0; i < visitorPass.length; i++) {
34407
- let pass = await convertObjectIdUtil2(visitorPass[i].keyId, "Pass ID");
34408
- const getPass = await this.getById2(pass);
34409
- if (!getPass)
34410
- throw new Error("Pass not found");
34411
- if (getPass?.status && getPass?.status.toLowerCase() != "Available".toLowerCase())
34412
- throw new Error(`Pass ${getPass?.prefixAndName} is ${getPass?.status}`);
34413
- }
34414
- }
34415
- if (Array.isArray(passKeys) && passKeys.length > 0) {
34416
- for (let i = 0; i < passKeys.length; i++) {
34417
- let key = await convertObjectIdUtil2(passKeys[i].keyId, "Key ID");
34418
- const getPass = await this.getById2(key);
34419
- if (!getPass)
34420
- throw new Error(`Key not found`);
34421
- if (getPass?.status && getPass?.status.toLowerCase() != "Available".toLowerCase())
34422
- throw new Error(`Pass ${getPass?.prefixAndName} is ${getPass?.status}`);
34423
- }
34424
- }
34427
+ static async checkPassOrKeyAvailability(passOrKeyId, type, session) {
34428
+ let passOrKeyObjectId = await convertObjectIdUtil2(passOrKeyId, `${type} Id`);
34429
+ const getPassOrKey = await this.getById2(passOrKeyObjectId, session);
34430
+ if (!getPassOrKey)
34431
+ throw new Error(`${type} not found`);
34432
+ if (getPassOrKey?.status && getPassOrKey?.status.toLowerCase() != "Available".toLowerCase())
34433
+ throw new Error(`${type} ${getPassOrKey?.prefixAndName} is ${getPassOrKey?.status}`);
34425
34434
  }
34426
34435
  };
34427
34436
 
@@ -34786,9 +34795,6 @@ function useVisitorTransactionService() {
34786
34795
  } = value;
34787
34796
  for (let i = 0; i < value.members.length; i += chunkSize) {
34788
34797
  const chunk = value.members.slice(i, i + chunkSize);
34789
- for (const member of chunk) {
34790
- await KeyRepo.checkPassKeyAvailability(member.visitorPass, member.passKeys);
34791
- }
34792
34798
  await Promise.all(
34793
34799
  chunk.map(async (member) => {
34794
34800
  const clonedMember = structuredClone(member);
@@ -34829,6 +34835,7 @@ function useVisitorTransactionService() {
34829
34835
  );
34830
34836
  console.log("visitorId service", visitorId);
34831
34837
  for (const item of preparedVisitorPass) {
34838
+ await KeyRepo.checkPassOrKeyAvailability(item.keyId, "Pass", session);
34832
34839
  await KeyRepo.updateKeyById(
34833
34840
  item.keyId,
34834
34841
  {
@@ -34844,6 +34851,7 @@ function useVisitorTransactionService() {
34844
34851
  );
34845
34852
  }
34846
34853
  for (const item of preparedPassKeys) {
34854
+ await KeyRepo.checkPassOrKeyAvailability(item.keyId, "Key", session);
34847
34855
  await KeyRepo.updateKeyById(
34848
34856
  item.keyId,
34849
34857
  {
@@ -34886,7 +34894,6 @@ function useVisitorTransactionService() {
34886
34894
  if (found === 1)
34887
34895
  throw new BadRequestError100("This plate number is blocklisted");
34888
34896
  }
34889
- await KeyRepo.checkPassKeyAvailability(value.visitorPass, value.passKeys);
34890
34897
  if (Array.isArray(value.visitorPass)) {
34891
34898
  for (const item of value.visitorPass) {
34892
34899
  item.receivedDate = /* @__PURE__ */ new Date();
@@ -34906,6 +34913,7 @@ function useVisitorTransactionService() {
34906
34913
  const result = await _add(value, session);
34907
34914
  if (Array.isArray(value.visitorPass)) {
34908
34915
  for (const item of value.visitorPass) {
34916
+ await KeyRepo.checkPassOrKeyAvailability(item.keyId, "Pass", session);
34909
34917
  await KeyRepo.updateKeyById(
34910
34918
  item.keyId,
34911
34919
  { status: "In Use" /* IN_USE */, updatedBy: value.createdBy },
@@ -34920,6 +34928,7 @@ function useVisitorTransactionService() {
34920
34928
  }
34921
34929
  if (Array.isArray(value.passKeys)) {
34922
34930
  for (const item of value.passKeys) {
34931
+ await KeyRepo.checkPassOrKeyAvailability(item.keyId, "Key", session);
34923
34932
  await KeyRepo.updateKeyById(
34924
34933
  item.keyId,
34925
34934
  { status: "In Use" /* IN_USE */, updatedBy: value.createdBy },
@@ -35016,6 +35025,12 @@ function useVisitorTransactionService() {
35016
35025
  if (value.site) {
35017
35026
  value.site = typeof value.site === "string" ? new ObjectId63(value.site) : value.site;
35018
35027
  }
35028
+ if (value?.block) {
35029
+ value.block = await convertObjectIdUtil2(value.block, "block Id");
35030
+ }
35031
+ if (value?.level) {
35032
+ value.level = await convertObjectIdUtil2(value.level, "level Id");
35033
+ }
35019
35034
  if (value.unit) {
35020
35035
  value.unit = typeof value.unit === "string" ? new ObjectId63(value.unit) : value.unit;
35021
35036
  const unit = await _getUnitById(value.unit);
@@ -35027,6 +35042,7 @@ function useVisitorTransactionService() {
35027
35042
  if (Array.isArray(value.visitorPass)) {
35028
35043
  for (const item of value.visitorPass) {
35029
35044
  if (item.add) {
35045
+ await KeyRepo.checkPassOrKeyAvailability(item.keyId, "Pass", session);
35030
35046
  await KeyRepo.updateKeyById(
35031
35047
  item.keyId,
35032
35048
  {
@@ -35075,6 +35091,7 @@ function useVisitorTransactionService() {
35075
35091
  if (Array.isArray(value.passKeys)) {
35076
35092
  for (const item of value.passKeys) {
35077
35093
  if (item.add) {
35094
+ await KeyRepo.checkPassOrKeyAvailability(item.keyId, "Key", session);
35078
35095
  await KeyRepo.updateKeyById(
35079
35096
  item.keyId,
35080
35097
  {
@@ -48919,22 +48936,52 @@ function useAccessManagementSvc() {
48919
48936
  }
48920
48937
  };
48921
48938
  const liftAccessLevelsSvc = async (params) => {
48939
+ const { getCache: getCache2, setCache: setCache2 } = useCache48(namespace);
48940
+ const cacheKey = makeCacheKey46(namespace, {
48941
+ user: params.user,
48942
+ resource: "lift-levels"
48943
+ });
48944
+ const cachedData = await getCache2(cacheKey);
48945
+ if (cachedData) {
48946
+ logger125.info(`Cache hit for key: ${cacheKey}`);
48947
+ return cachedData;
48948
+ }
48922
48949
  try {
48923
48950
  const command = readTemplate("lift-levels");
48924
48951
  const response = await sendCommand(command, params.acm_url);
48925
48952
  const res = await parseStringPromise3(response, { explicitArray: false });
48926
48953
  const format2 = await formatLiftAccessLevels(res);
48954
+ setCache2(cacheKey, format2, 60).then(() => {
48955
+ logger125.info(`Cache set for key: ${cacheKey}`);
48956
+ }).catch((err) => {
48957
+ logger125.error(`Failed to set cache for key: ${cacheKey}`, err);
48958
+ });
48927
48959
  return format2;
48928
48960
  } catch (error) {
48929
48961
  throw new Error(error.message);
48930
48962
  }
48931
48963
  };
48932
48964
  const accessGroupsSvc = async (params) => {
48965
+ const { getCache: getCache2, setCache: setCache2 } = useCache48(namespace);
48966
+ const cacheKey = makeCacheKey46(namespace, {
48967
+ user: params.user,
48968
+ resource: "access-groups"
48969
+ });
48970
+ const cachedData = await getCache2(cacheKey);
48971
+ if (cachedData) {
48972
+ logger125.info(`Cache hit for key: ${cacheKey}`);
48973
+ return cachedData;
48974
+ }
48933
48975
  try {
48934
48976
  const command = readTemplate("access-group");
48935
48977
  const response = await sendCommand(command, params.acm_url);
48936
48978
  const res = await parseStringPromise3(response, { explicitArray: false });
48937
48979
  const format2 = await formatAccessGroup(res);
48980
+ setCache2(cacheKey, format2, 60).then(() => {
48981
+ logger125.info(`Cache set for key: ${cacheKey}`);
48982
+ }).catch((err) => {
48983
+ logger125.error(`Failed to set cache for key: ${cacheKey}`, err);
48984
+ });
48938
48985
  return format2;
48939
48986
  } catch (err) {
48940
48987
  throw new Error(err.message);
@@ -52774,6 +52821,7 @@ function useStatementOfAccountService() {
52774
52821
  unit_billings = unit_billings.map((unit) => {
52775
52822
  try {
52776
52823
  unit._id = unit._id.toString();
52824
+ unit.paidBy = unit.paidBy.toString();
52777
52825
  } catch {
52778
52826
  throw new BadRequestError156("Invalid unit id format/type");
52779
52827
  }
@@ -57908,12 +57956,9 @@ function useNewDashboardRepo() {
57908
57956
  function getDateRange(p) {
57909
57957
  const now = moment2().tz("Asia/Singapore");
57910
57958
  if (p === "thisWeek" /* THIS_WEEK */) {
57911
- const rollingStart = now.clone().subtract(6, "days").startOf("day");
57912
- const monthStart = now.clone().startOf("month");
57913
- const start = moment2.max(rollingStart, monthStart);
57914
57959
  return {
57915
- $gte: start.toDate(),
57916
- $lte: now.clone().endOf("day").toDate()
57960
+ $gte: now.clone().startOf("isoWeek").toDate(),
57961
+ $lte: now.clone().endOf("isoWeek").toDate()
57917
57962
  };
57918
57963
  }
57919
57964
  if (p === "thisMonth" /* THIS_MONTH */) {
@@ -57927,6 +57972,12 @@ function useNewDashboardRepo() {
57927
57972
  $lte: now.clone().endOf("day").toDate()
57928
57973
  };
57929
57974
  }
57975
+ function getSiteDayRange(date = moment2.tz("Asia/Singapore")) {
57976
+ return {
57977
+ $gte: date.clone().startOf("day").toDate(),
57978
+ $lte: date.clone().endOf("day").toDate()
57979
+ };
57980
+ }
57930
57981
  const calculatePercentageChange = (currentCount, previousCount) => {
57931
57982
  if (previousCount === 0) {
57932
57983
  return currentCount > 0 ? 100 : 0;
@@ -58353,24 +58404,27 @@ function useNewDashboardRepo() {
58353
58404
  const siteIdObj = toObjectId16(siteId);
58354
58405
  const startOfToday = moment2.tz("Asia/Singapore").startOf("day").toDate();
58355
58406
  const endOfToday = moment2.tz("Asia/Singapore").endOf("day").toDate();
58356
- const localTodayStr = moment2.tz("Asia/Singapore").format("YYYY-MM-DD");
58357
- const facilityTodayStart = moment2.utc(`${localTodayStr}T00:00:00.000Z`).toDate();
58358
- const facilityTodayEnd = moment2.utc(`${localTodayStr}T23:59:59.999Z`).toDate();
58359
- const localYesterdayStr = moment2.tz("Asia/Singapore").subtract(1, "day").format("YYYY-MM-DD");
58360
- const facilityYesterdayStart = moment2.utc(`${localYesterdayStr}T00:00:00.000Z`).toDate();
58361
- const facilityYesterdayEnd = moment2.utc(`${localYesterdayStr}T23:59:59.999Z`).toDate();
58362
- let facilityPeriodRange = { $gte: facilityTodayStart, $lte: facilityTodayEnd };
58407
+ const facilityTodayRange = getSiteDayRange();
58408
+ const facilityYesterdayRange = getSiteDayRange(
58409
+ moment2.tz("Asia/Singapore").subtract(1, "day")
58410
+ );
58411
+ const facilityTodayStart = facilityTodayRange.$gte;
58412
+ const facilityTodayEnd = facilityTodayRange.$lte;
58413
+ const facilityYesterdayStart = facilityYesterdayRange.$gte;
58414
+ const facilityYesterdayEnd = facilityYesterdayRange.$lte;
58415
+ let facilityPeriodRange = {
58416
+ $gte: facilityTodayStart,
58417
+ $lte: facilityTodayEnd
58418
+ };
58363
58419
  if (period === "thisWeek" /* THIS_WEEK */) {
58364
- const startStr = moment2.tz("Asia/Singapore").subtract(7, "days").format("YYYY-MM-DD");
58365
58420
  facilityPeriodRange = {
58366
- $gte: moment2.utc(`${startStr}T00:00:00.000Z`).toDate(),
58367
- $lte: facilityTodayEnd
58421
+ $gte: moment2.tz("Asia/Singapore").startOf("isoWeek").toDate(),
58422
+ $lte: moment2.tz("Asia/Singapore").endOf("isoWeek").toDate()
58368
58423
  };
58369
58424
  } else if (period === "thisMonth" /* THIS_MONTH */) {
58370
- const startStr = moment2.tz("Asia/Singapore").subtract(30, "days").format("YYYY-MM-DD");
58371
58425
  facilityPeriodRange = {
58372
- $gte: moment2.utc(`${startStr}T00:00:00.000Z`).toDate(),
58373
- $lte: facilityTodayEnd
58426
+ $gte: moment2.tz("Asia/Singapore").startOf("month").toDate(),
58427
+ $lte: moment2.tz("Asia/Singapore").endOf("month").toDate()
58374
58428
  };
58375
58429
  }
58376
58430
  const upcomingEvents = await db.collection(events_namespace_collection).find({
@@ -58454,6 +58508,18 @@ function useNewDashboardRepo() {
58454
58508
  const facilityCollection = db.collection(
58455
58509
  facility_bookings_namespace_collection2
58456
58510
  );
58511
+ const facilityBookingStatuses = [
58512
+ "Pending",
58513
+ "Approved",
58514
+ "Ongoing",
58515
+ "For Review",
58516
+ "With Balance",
58517
+ "For Refund",
58518
+ "With Refund",
58519
+ "Completed",
58520
+ "Rejected",
58521
+ "Cancelled"
58522
+ ];
58457
58523
  const [
58458
58524
  workOrderReport,
58459
58525
  yesterdayWorkOrderReport,
@@ -58604,7 +58670,7 @@ function useNewDashboardRepo() {
58604
58670
  }
58605
58671
  }
58606
58672
  ],
58607
- status: { $nin: ["deleted", "Deleted"] }
58673
+ status: { $in: facilityBookingStatuses }
58608
58674
  }
58609
58675
  },
58610
58676
  {
@@ -58629,6 +58695,25 @@ function useNewDashboardRepo() {
58629
58695
  }
58630
58696
  },
58631
58697
  { $count: "count" }
58698
+ ],
58699
+ byStatus: [
58700
+ {
58701
+ $match: {
58702
+ status: { $in: facilityBookingStatuses }
58703
+ }
58704
+ },
58705
+ {
58706
+ $group: {
58707
+ _id: {
58708
+ $cond: [
58709
+ { $eq: ["$status", "For Refund"] },
58710
+ "With Refund",
58711
+ "$status"
58712
+ ]
58713
+ },
58714
+ count: { $sum: 1 }
58715
+ }
58716
+ }
58632
58717
  ]
58633
58718
  }
58634
58719
  }
@@ -58639,7 +58724,12 @@ function useNewDashboardRepo() {
58639
58724
  site: { $in: [siteIdObj, siteId] },
58640
58725
  ...facilityMatchObj,
58641
58726
  $or: [
58642
- { date: { $gte: facilityYesterdayStart, $lte: facilityYesterdayEnd } },
58727
+ {
58728
+ date: {
58729
+ $gte: facilityYesterdayStart,
58730
+ $lte: facilityYesterdayEnd
58731
+ }
58732
+ },
58643
58733
  {
58644
58734
  date: {
58645
58735
  $gte: facilityYesterdayStart.toISOString(),
@@ -58647,7 +58737,7 @@ function useNewDashboardRepo() {
58647
58737
  }
58648
58738
  }
58649
58739
  ],
58650
- status: { $nin: ["deleted", "Deleted"] }
58740
+ status: { $in: facilityBookingStatuses }
58651
58741
  }
58652
58742
  },
58653
58743
  { $count: "count" }
@@ -58666,7 +58756,7 @@ function useNewDashboardRepo() {
58666
58756
  }
58667
58757
  }
58668
58758
  ],
58669
- status: { $nin: ["deleted", "Deleted"] }
58759
+ status: { $in: facilityBookingStatuses }
58670
58760
  }
58671
58761
  },
58672
58762
  { $count: "count" }
@@ -58690,8 +58780,25 @@ function useNewDashboardRepo() {
58690
58780
  const fFacet = facilityReport[0] ?? {
58691
58781
  total: [],
58692
58782
  ongoing: [],
58693
- waitingApproval: []
58783
+ waitingApproval: [],
58784
+ byStatus: []
58694
58785
  };
58786
+ const facilityBookingStatusCounts = {
58787
+ Pending: 0,
58788
+ Approved: 0,
58789
+ Ongoing: 0,
58790
+ "For Review": 0,
58791
+ "With Balance": 0,
58792
+ "With Refund": 0,
58793
+ Completed: 0,
58794
+ Rejected: 0,
58795
+ Cancelled: 0
58796
+ };
58797
+ for (const item of fFacet.byStatus ?? []) {
58798
+ if (typeof item?._id === "string" && item._id in facilityBookingStatusCounts) {
58799
+ facilityBookingStatusCounts[item._id] = item.count ?? 0;
58800
+ }
58801
+ }
58695
58802
  const workOrderStatus = {
58696
58803
  pending: 0,
58697
58804
  inProgress: 0,
@@ -58738,6 +58845,7 @@ function useNewDashboardRepo() {
58738
58845
  count: fFacet.total[0]?.count ?? 0,
58739
58846
  ongoing: fFacet.ongoing[0]?.count ?? 0,
58740
58847
  waitingApproval: fFacet.waitingApproval[0]?.count ?? 0,
58848
+ byStatus: facilityBookingStatusCounts,
58741
58849
  percentage: calculatePercentageChange(
58742
58850
  todayFacilityReport[0]?.count ?? 0,
58743
58851
  yesterdayFacilityReport[0]?.count ?? 0
@@ -63525,9 +63633,12 @@ var useRedDotPaymentRepo = () => {
63525
63633
  }
63526
63634
  const now = /* @__PURE__ */ new Date();
63527
63635
  const unitUpdate = {
63636
+ method: payload.method,
63637
+ message: payload.message,
63528
63638
  updatedAt: now.toISOString(),
63529
63639
  paymentStatus: payload.paymentStatus,
63530
- transaction_id: payload.transaction_id
63640
+ transaction_id: payload.transaction_id,
63641
+ paidBy: paymentInfo.paidBy
63531
63642
  };
63532
63643
  const paymentUpdate = {
63533
63644
  updatedAt: now.toISOString(),
@@ -68433,6 +68544,7 @@ function useBidPrelovedService() {
68433
68544
  const { add: _addBid } = useBidPrelovedRepo();
68434
68545
  const { add: _addChannel, getByParticipants: _getByParticipants } = useChannelPrelovedRepo();
68435
68546
  const { add: _addChat } = useChatPrelovedRepo();
68547
+ const { updateStatus } = usePostPrelovedRepo();
68436
68548
  async function createBid(value) {
68437
68549
  const client = useAtlas129.getClient();
68438
68550
  if (!client)
@@ -68478,6 +68590,9 @@ function useBidPrelovedService() {
68478
68590
  },
68479
68591
  session
68480
68592
  );
68593
+ if (value.type === "reserve") {
68594
+ await updateStatus(postId, "reserved" /* RESERVED */, session);
68595
+ }
68481
68596
  await session.commitTransaction();
68482
68597
  return { bidId };
68483
68598
  } catch (error) {