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 +2 -1
- package/lib/hooks.js +41 -23
- package/lib/hooks.js.map +1 -1
- package/lib/util.js +0 -1
- package/lib/util.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks.tsx +39 -26
- package/src/util.ts +0 -1
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
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
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]);
|