@7365admin1/core 3.34.4-staging.21 → 3.34.4-staging.22

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 CHANGED
@@ -2809,8 +2809,8 @@ type visitorPersonService = {
2809
2809
  nric: string;
2810
2810
  name: string;
2811
2811
  contact: string;
2812
- plateNumber: string;
2813
- email: string;
2812
+ plateNumber?: string;
2813
+ email?: string;
2814
2814
  type: visitorType;
2815
2815
  site: string | ObjectId;
2816
2816
  company?: string;
@@ -2821,7 +2821,7 @@ type visitorPersonRepo = {
2821
2821
  name: string;
2822
2822
  contacts: string[];
2823
2823
  plateNumbers: string[];
2824
- email: string;
2824
+ email?: string;
2825
2825
  type: visitorType;
2826
2826
  site: string | ObjectId;
2827
2827
  companyName: string[];
package/dist/index.js CHANGED
@@ -34292,8 +34292,20 @@ function usePersonService() {
34292
34292
  const email = value.email?.trim();
34293
34293
  const type = value.type?.trim();
34294
34294
  const company = value.company?.trim();
34295
+ const nricQuery = nric ? { nric: { $regex: `^${escapeRegex(nric)}$`, $options: "i" } } : null;
34296
+ const nameQuery = name ? { name: { $regex: `^${escapeRegex(name)}$`, $options: "i" } } : null;
34297
+ let nricCondition = null;
34298
+ if (nric) {
34299
+ if (nric.length < 9) {
34300
+ if (nameQuery) {
34301
+ nricCondition = { $and: [nricQuery, nameQuery] };
34302
+ }
34303
+ } else {
34304
+ nricCondition = nricQuery;
34305
+ }
34306
+ }
34295
34307
  const orConditions = [
34296
- ...nric ? [{ nric: { $regex: `^${escapeRegex(nric)}$`, $options: "i" } }] : [],
34308
+ ...nricCondition ? [nricCondition] : [],
34297
34309
  ...contact ? [{ contacts: { $regex: `^\\+?${cleanPhone(escapeRegex(contact))}$`, $options: "i" } }] : [],
34298
34310
  ...plateNumber ? [{ plateNumbers: { $regex: `^${escapeRegex(plateNumber)}$`, $options: "i" } }] : []
34299
34311
  ];
@@ -35687,7 +35699,6 @@ function useVisitorTransactionService() {
35687
35699
  value.unitName = unit?.name;
35688
35700
  }
35689
35701
  const { nric = "", name = "", contact = "", plateNumber = "", email = "", site = "", type = "guest", company, createdBy } = value;
35690
- console.log("type", type);
35691
35702
  if (/^(guest|walk-in|contractor|delivery)$/.test(type)) {
35692
35703
  await addUpdateFromVisitor({
35693
35704
  nric,
@@ -35699,7 +35710,7 @@ function useVisitorTransactionService() {
35699
35710
  site,
35700
35711
  company,
35701
35712
  updatedBy: createdBy
35702
- });
35713
+ }, session);
35703
35714
  }
35704
35715
  if (Array.isArray(value.members) && value.members.length > 0) {
35705
35716
  const chunkSize = 10;
@@ -35720,7 +35731,18 @@ function useVisitorTransactionService() {
35720
35731
  await Promise.all(
35721
35732
  chunk.map(async (member) => {
35722
35733
  const clonedMember = structuredClone(member);
35723
- const { visitorPass, passKeys } = clonedMember;
35734
+ const { visitorPass, passKeys, nric: nric2, name: name2, contact: contact2 } = clonedMember;
35735
+ if (/^(guest|walk-in|contractor|delivery)$/.test(type2 ?? "invalid") && site2) {
35736
+ await addUpdateFromVisitor({
35737
+ nric: nric2,
35738
+ name: name2,
35739
+ contact: contact2,
35740
+ type: type2,
35741
+ site: site2,
35742
+ company: company2,
35743
+ updatedBy: createdBy
35744
+ }, session);
35745
+ }
35724
35746
  const preparedVisitorPass = Array.isArray(visitorPass) ? visitorPass.map((item) => ({
35725
35747
  ...item,
35726
35748
  receivedDate: /* @__PURE__ */ new Date(),
@@ -35907,16 +35929,30 @@ function useVisitorTransactionService() {
35907
35929
  const parsed = new Date(value.checkIn);
35908
35930
  value.checkIn = isNaN(parsed.getTime()) ? null : parsed;
35909
35931
  }
35932
+ const { nric = "", name = "", contact = "", plateNumber = "", email = "", site = "", type = "guest", company, createdBy } = value;
35933
+ if (/^(guest|walk-in|contractor|delivery)$/.test(type)) {
35934
+ await addUpdateFromVisitor({
35935
+ nric,
35936
+ name,
35937
+ contact,
35938
+ plateNumber,
35939
+ email,
35940
+ type,
35941
+ site,
35942
+ company,
35943
+ updatedBy: createdBy
35944
+ }, session);
35945
+ }
35910
35946
  if (value.isMembersAdded != true && Array.isArray(value.members) && value.members.length > 0) {
35911
35947
  const chunkSize = 10;
35912
35948
  const {
35913
35949
  block,
35914
35950
  level,
35915
35951
  unit,
35916
- site,
35952
+ site: site2,
35917
35953
  org,
35918
- type,
35919
- company,
35954
+ type: type2,
35955
+ company: company2,
35920
35956
  remarks,
35921
35957
  contractorType,
35922
35958
  unitName
@@ -35926,7 +35962,18 @@ function useVisitorTransactionService() {
35926
35962
  await Promise.all(
35927
35963
  chunk.map(async (member) => {
35928
35964
  const clonedMember = structuredClone(member);
35929
- const { visitorPass, passKeys } = clonedMember;
35965
+ const { visitorPass, passKeys, nric: nric2, name: name2, contact: contact2 } = clonedMember;
35966
+ if (/^(guest|walk-in|contractor|delivery)$/.test(type2 ?? "invalid") && site2) {
35967
+ await addUpdateFromVisitor({
35968
+ nric: nric2,
35969
+ name: name2,
35970
+ contact: contact2,
35971
+ type: type2,
35972
+ site: site2,
35973
+ company: company2,
35974
+ updatedBy: createdBy
35975
+ }, session);
35976
+ }
35930
35977
  const preparedVisitorPass = Array.isArray(visitorPass) ? visitorPass.map((item) => ({
35931
35978
  ...item,
35932
35979
  receivedDate: /* @__PURE__ */ new Date(),
@@ -35948,10 +35995,10 @@ function useVisitorTransactionService() {
35948
35995
  level,
35949
35996
  unit,
35950
35997
  unitName,
35951
- site,
35998
+ site: site2,
35952
35999
  org,
35953
- type,
35954
- company,
36000
+ type: type2,
36001
+ company: company2,
35955
36002
  remarks,
35956
36003
  contractorType,
35957
36004
  checkIn: value.checkIn,