placementt-core 1.400.689 → 1.400.691

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/lib/hooks.d.ts CHANGED
@@ -164,7 +164,7 @@ export declare function useFilterTablePaginator({ data }: {
164
164
  } | undefined>>;
165
165
  page: number[];
166
166
  };
167
- export declare function useProviderContactPaginator({ data, institute, user, event, view, initialSort, initialSearch, eventId, filters }: {
167
+ export declare function useProviderContactPaginator({ data, institute, user, event, view, initialSort, initialSearch, eventId, filters, sources }: {
168
168
  data: QueryObject[];
169
169
  institute: InstituteData;
170
170
  event?: Partial<ExternalEvent>;
@@ -174,6 +174,7 @@ export declare function useProviderContactPaginator({ data, institute, user, eve
174
174
  filters?: FilterObject;
175
175
  initialSort?: string;
176
176
  initialSearch?: string;
177
+ sources?: ("self" | "trust" | "hub")[];
177
178
  }): {
178
179
  tableData: {
179
180
  [key: string]: {
package/lib/hooks.js CHANGED
@@ -906,7 +906,7 @@ const algoliaProviderContactSearch = async (data, user, query, sort, page, filte
906
906
  }))) : []).filter((e) => e !== undefined);
907
907
  return Object.fromEntries(i);
908
908
  };
909
- function useProviderContactPaginator({ data, institute, user, event, view, initialSort, initialSearch, eventId, filters }) {
909
+ function useProviderContactPaginator({ data, institute, user, event, view, initialSort, initialSearch, eventId, filters, sources = ["self"] }) {
910
910
  const [query, setQuery] = (0, react_1.useState)();
911
911
  const firebaseQuery = new firebaseQuery_1.default();
912
912
  const sorts = {
@@ -999,28 +999,46 @@ function useProviderContactPaginator({ data, institute, user, event, view, initi
999
999
  // }) as QueryObject))
1000
1000
  // return;
1001
1001
  // }
1002
- const constraints = [
1003
- [`savedBy.${user.oId}.exists`, "==", true],
1004
- ];
1005
- // if (event && event.activityId) {
1006
- // constraints.push([`savedBy.${user.oId}.activities`, "array-contains", event.activityId]);
1007
- // }
1008
- if (user.userType === "Students") {
1009
- constraints.push([`savedBy.${user.oId}.cohorts.${user.cohort}.listed`, "==", true]);
1010
- }
1011
- const queries = statuses.map((status) => ({
1012
- path: ["providerContacts"],
1013
- where: [...constraints, [`savedBy.${user.oId}.status`, "==", status]],
1014
- }));
1015
- const links = Object.entries(institute.trustLinks || {});
1016
- if (links.length > 0 && user.userType === "Staff") {
1017
- queries.push(...links.filter(([, link]) => link.status === "approved").map(([linkOId]) => ({
1018
- path: ["providerContacts"],
1019
- where: [[`savedBy.${linkOId}.exists`, "==", true],
1020
- [`savedBy.${linkOId}.status`, "==", "approved"],
1021
- ((event && event.activityId) ? [`savedBy.${linkOId}.activities`, "array-contains", event.activityId] : undefined)]
1022
- .filter((i) => i)
1023
- })));
1002
+ const queries = [];
1003
+ for (const source of sources) {
1004
+ if (source === "self") {
1005
+ const constraints = [
1006
+ [`savedBy.${user.oId}.exists`, "==", true],
1007
+ ];
1008
+ if (user.userType === "Students") {
1009
+ constraints.push([`savedBy.${user.oId}.cohorts.${user.cohort}.listed`, "==", true]);
1010
+ }
1011
+ queries.push(...statuses.map((status) => ({
1012
+ path: ["providerContacts"],
1013
+ where: [...constraints, [`savedBy.${user.oId}.status`, "==", status]],
1014
+ })));
1015
+ }
1016
+ else if (source === "trust") {
1017
+ const approvedTrusts = Object.entries(institute.trustLinks || {}).filter(([, link]) => link.status === "approved");
1018
+ for (const [linkOId] of approvedTrusts) {
1019
+ queries.push({
1020
+ path: ["providerContacts"],
1021
+ where: [
1022
+ [`savedBy.${linkOId}.exists`, "==", true],
1023
+ [`savedBy.${linkOId}.status`, "==", "approved"],
1024
+ ...((event === null || event === void 0 ? void 0 : event.activityId) ? [[`savedBy.${linkOId}.activities`, "array-contains", event.activityId]] : []),
1025
+ ],
1026
+ });
1027
+ }
1028
+ }
1029
+ else if (source === "hub") {
1030
+ const approvedHubs = Object.entries(institute.careersHubLinks || {}).filter(([, link]) => link.status === "approved");
1031
+ for (const [linkOId] of approvedHubs) {
1032
+ queries.push({
1033
+ path: ["providerContacts"],
1034
+ where: [
1035
+ [`savedBy.${linkOId}.exists`, "==", true],
1036
+ [`savedBy.${linkOId}.status`, "==", "approved"],
1037
+ ...((event === null || event === void 0 ? void 0 : event.activityId) ? [[`savedBy.${linkOId}.activities`, "array-contains", event.activityId]] : []),
1038
+ ],
1039
+ });
1040
+ }
1041
+ }
1024
1042
  }
1025
1043
  setQuery(queries);
1026
1044
  }, [user]);