placementt-core 1.400.828 → 1.400.830

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
@@ -1,5 +1,5 @@
1
- import { DocumentData, QueryConstraint, QueryDocumentSnapshot, WhereFilterOp } from "firebase/firestore";
2
- import { AlumniConvoUser, ApplicantStage, Application, ArrowObject, CohortData, CustomFormSchema, ExternalEvent, FileItem, FlagCodes, InstituteData, OnboardingDocs, PlacementListing, Products, ProviderData, QueryObject, QueryObjectConstraint, Sorts, StudentPlacementData, UserData, UserGroupData, WorkflowStage } from "./typeDefinitions";
1
+ import { DocumentData, QueryConstraint, QueryDocumentSnapshot } from "firebase/firestore";
2
+ import { AlumniConvoUser, ApplicantStage, Application, ArrowObject, CohortData, CSVExportResponse, CustomFormSchema, ExternalEvent, FileItem, FilterObject, FlagCodes, InstituteData, OnboardingDocs, PlacementListing, Products, ProviderData, QueryObject, QueryObjectConstraint, Sorts, StudentPlacementData, UserData, UserGroupData, WorkflowStage } from "./typeDefinitions";
3
3
  type StudentPlacementListParams = {
4
4
  user: UserData;
5
5
  student?: UserData;
@@ -133,6 +133,12 @@ export declare function useParentPaginator({ user, filters, view, school, additi
133
133
  };
134
134
  };
135
135
  };
136
+ export declare const algoliaPlacementSearch: (data: QueryObject | null, user: UserData, query?: string, sort?: [string, {
137
+ value: string;
138
+ direction: "asc" | "desc";
139
+ }], page?: number, filters?: FilterObject, limit?: number, cohort?: string, inProgress?: boolean) => Promise<{
140
+ [k: string]: StudentPlacementData;
141
+ }>;
136
142
  export declare function useVeryOldInstitutePlacementList({ user, cohort, queryConstraint, ql }: InstitutePlacementParams): {
137
143
  placements: {
138
144
  [key: string]: StudentPlacementData & {
@@ -164,6 +170,12 @@ export declare function useFilterTablePaginator({ data }: {
164
170
  } | undefined>>;
165
171
  page: number[];
166
172
  };
173
+ export declare const algoliaProviderContactSearch: (data: QueryObject | null, user: UserData, query?: string, sort?: [string, {
174
+ value: string;
175
+ direction: "asc" | "desc";
176
+ }], page?: number, filters?: FilterObject, limit?: number, cohort?: string, inProgress?: boolean) => Promise<{
177
+ [k: string]: StudentPlacementData;
178
+ }>;
167
179
  export declare function useProviderContactPaginator({ data, institute, user, event, view, initialSort, initialSearch, eventId, filters, sources }: {
168
180
  data: QueryObject[];
169
181
  institute: InstituteData;
@@ -208,6 +220,12 @@ type UserPaginatorParams = {
208
220
  userType: "Staff" | "Students";
209
221
  sort?: string;
210
222
  };
223
+ export declare const algoliaUsersSearch: (data: QueryObject | null, user: UserData, query?: string, sort?: [string, {
224
+ value: string;
225
+ direction: "asc" | "desc";
226
+ }], page?: number, filters?: FilterObject, limit?: number, cohort?: string, userType?: string) => Promise<{
227
+ [k: string]: UserData;
228
+ }>;
211
229
  type NewUserPaginatorParams = {
212
230
  user: UserData;
213
231
  cohort?: string;
@@ -794,23 +812,6 @@ export declare function useLoadApplications({ user, applicationType, listingId,
794
812
  loading: boolean;
795
813
  changeQueryConstraints: (e: QueryConstraint[]) => void;
796
814
  };
797
- export type FilterObject = {
798
- [key: string]: {
799
- label: string;
800
- value?: unknown;
801
- values?: {
802
- [key: string | number]: string | {
803
- label: string;
804
- test: {
805
- k: string;
806
- e?: WhereFilterOp;
807
- v: unknown;
808
- };
809
- };
810
- };
811
- type: "dropdown" | "string" | "number";
812
- };
813
- };
814
815
  export type DataViewerPaginater = {
815
816
  view: "list" | "table";
816
817
  queryLimit?: number;
@@ -829,6 +830,7 @@ export type DataViewerPaginater = {
829
830
  }], queryObject?: QueryObject, algoliaPage?: number, filters?: FilterObject, limit?: number) => Promise<{
830
831
  [key: string]: any;
831
832
  }>);
833
+ algoliaIndex?: string;
832
834
  data?: {
833
835
  [key: string]: {
834
836
  [key: string]: unknown;
@@ -838,8 +840,15 @@ export type DataViewerPaginater = {
838
840
  sorts?: Sorts;
839
841
  initialSort?: string;
840
842
  initialSearch?: string;
843
+ csvExport?: {
844
+ columns?: {
845
+ field: string;
846
+ header: string;
847
+ }[];
848
+ filename?: string;
849
+ };
841
850
  };
842
- export declare function useDataViewerPaginator({ view: initialView, sorts, queryLimit, additionalEntryProcessing, formatItems, snapshot, filters: initialFilters, initialSort, initialSearch, onSearch, data }: DataViewerPaginater): {
851
+ export declare function useDataViewerPaginator({ view: initialView, sorts, queryLimit, additionalEntryProcessing, formatItems, snapshot, filters: initialFilters, initialSort, initialSearch, onSearch, algoliaIndex, data, csvExport: csvExportConfig }: DataViewerPaginater): {
843
852
  tableData: {
844
853
  [key: string]: {
845
854
  [key: string]: unknown;
@@ -859,5 +868,6 @@ export declare function useDataViewerPaginator({ view: initialView, sorts, query
859
868
  updateSort: (sortLabel?: string) => void;
860
869
  setView: (v: "list" | "table") => void;
861
870
  updateSearch: (search: string) => void;
871
+ exportCSV: (userId: string) => Promise<CSVExportResponse>;
862
872
  };
863
873
  export {};
package/lib/hooks.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.useRefDimensions = void 0;
6
+ exports.useRefDimensions = exports.algoliaUsersSearch = exports.algoliaProviderContactSearch = exports.algoliaPlacementSearch = void 0;
7
7
  exports.useStudentPlacementList = useStudentPlacementList;
8
8
  exports.useOldInstitutePlacementList = useOldInstitutePlacementList;
9
9
  exports.useNewInstitutePlacementList = useNewInstitutePlacementList;
@@ -298,7 +298,7 @@ function useNewInstitutePlacementList({ id, user, oId, uid, filters, initialSort
298
298
  }
299
299
  return [k, { ...placement, id: k }];
300
300
  };
301
- const { tableData, pageUp, pageDown, setFilters, page, setView, loading, updateSearch, updateSort, sort } = useDataViewerPaginator({ view, filters, sorts, queryLimit: ql, initialSort, initialSearch, data: query, additionalEntryProcessing: additionalProcessing, onSearch: async (s, sort, data, page, filters, limit) => await algoliaPlacementSearch(data || null, user, s, sort, page, filters, limit, cohort, inProgress) });
301
+ const { tableData, pageUp, pageDown, setFilters, page, setView, loading, updateSearch, updateSort, sort } = useDataViewerPaginator({ view, filters, sorts, queryLimit: ql, initialSort, initialSearch, data: query, additionalEntryProcessing: additionalProcessing, onSearch: async (s, sort, data, page, filters, limit) => await (0, exports.algoliaPlacementSearch)(data || null, user, s, sort, page, filters, limit, cohort, inProgress), algoliaIndex: "placements" });
302
302
  (0, react_1.useEffect)(() => {
303
303
  var _a;
304
304
  console.log("SET QUERY", user, queryConstraints, cohort);
@@ -510,6 +510,7 @@ const algoliaPlacementSearch = async (data, user, query, sort, page, filters, li
510
510
  }))) : []).filter((e) => e !== undefined);
511
511
  return Object.fromEntries(i);
512
512
  };
513
+ exports.algoliaPlacementSearch = algoliaPlacementSearch;
513
514
  function useVeryOldInstitutePlacementList({ user, cohort, queryConstraint, ql = DEFAULTQUERYLIMIT }) {
514
515
  const [loadMoreIcon, setLoadMoreIcon] = (0, react_1.useState)(true);
515
516
  const [query, setQuery] = (0, react_1.useState)("");
@@ -907,6 +908,7 @@ const algoliaProviderContactSearch = async (data, user, query, sort, page, filte
907
908
  }))) : []).filter((e) => e !== undefined);
908
909
  return Object.fromEntries(i);
909
910
  };
911
+ exports.algoliaProviderContactSearch = algoliaProviderContactSearch;
910
912
  function useProviderContactPaginator({ data, institute, user, event, view, initialSort, initialSearch, eventId, filters, sources = ["self"] }) {
911
913
  const [query, setQuery] = (0, react_1.useState)();
912
914
  const firebaseQuery = new firebaseQuery_1.default();
@@ -971,7 +973,7 @@ function useProviderContactPaginator({ data, institute, user, event, view, initi
971
973
  return [k, v];
972
974
  };
973
975
  console.log("Query", JSON.stringify(query));
974
- const { tableData, pageUp, pageDown, setFilters, page, setView, loading, updateSearch, updateSort, sort } = useDataViewerPaginator({ view, filters, sorts, queryLimit: 10, data: query, initialSearch, initialSort, additionalEntryProcessing: getAdditionalData, onSearch: async (s, sort, data, page, filters, limit) => await algoliaProviderContactSearch(data !== null && data !== void 0 ? data : null, user, s, sort, page, filters, limit) });
976
+ const { tableData, pageUp, pageDown, setFilters, page, setView, loading, updateSearch, updateSort, sort } = useDataViewerPaginator({ view, filters, sorts, queryLimit: 10, data: query, initialSearch, initialSort, additionalEntryProcessing: getAdditionalData, onSearch: async (s, sort, data, page, filters, limit) => await (0, exports.algoliaProviderContactSearch)(data !== null && data !== void 0 ? data : null, user, s, sort, page, filters, limit), algoliaIndex: "providerContacts" });
975
977
  (0, react_1.useEffect)(() => {
976
978
  if (eventId && (event === null || event === void 0 ? void 0 : event.oId)) {
977
979
  console.log("Setting Query");
@@ -1094,6 +1096,7 @@ const algoliaUsersSearch = async (data, user, query, sort, page, filters, limit,
1094
1096
  }))) : []).filter((e) => e !== undefined);
1095
1097
  return Object.fromEntries(i);
1096
1098
  };
1099
+ exports.algoliaUsersSearch = algoliaUsersSearch;
1097
1100
  function useNewCohortUserPaginator({ user, oId, trustSchoolsIDs, institute, initialSort, filters, view, cohort, queryConstraints, ql = DEFAULTQUERYLIMIT, userType }) {
1098
1101
  const [query, setQuery] = (0, react_1.useState)();
1099
1102
  const firebaseQuery = new firebaseQuery_1.default();
@@ -1241,7 +1244,7 @@ function useNewCohortUserPaginator({ user, oId, trustSchoolsIDs, institute, init
1241
1244
  getAccess();
1242
1245
  }, [user, queryConstraints, cohort]);
1243
1246
  console.log("Query", query);
1244
- const { tableData, pageUp, pageDown, setFilters, page, setView, loading, updateSearch, updateSort, search, sort } = useDataViewerPaginator({ view, filters, initialSort, sorts, queryLimit: ql, data: query, onSearch: async (s, sort, data, page, filters, limit) => await algoliaUsersSearch(data !== null && data !== void 0 ? data : null, user, s, sort, page, filters, limit, cohort, userType) });
1247
+ const { tableData, pageUp, pageDown, setFilters, page, setView, loading, updateSearch, updateSort, search, sort } = useDataViewerPaginator({ view, filters, initialSort, sorts, queryLimit: ql, data: query, onSearch: async (s, sort, data, page, filters, limit) => await (0, exports.algoliaUsersSearch)(data !== null && data !== void 0 ? data : null, user, s, sort, page, filters, limit, cohort, userType), algoliaIndex: "users" });
1245
1248
  return { tableData, page, loading, updateSearch, setFilters, setView, pageUp, pageDown, sorts, updateSort, sort, search };
1246
1249
  }
1247
1250
  function useCohortUserPaginator({ user, cohort, data, search, userType, sort }) {
@@ -3642,7 +3645,7 @@ function useLoadApplications({ user, applicationType, listingId, queryConstraint
3642
3645
  };
3643
3646
  return { applications, type, setType, onScrollBottom, loading, changeQueryConstraints };
3644
3647
  }
3645
- function useDataViewerPaginator({ view: initialView, sorts, queryLimit = 10, additionalEntryProcessing, formatItems, snapshot, filters: initialFilters, initialSort, initialSearch, onSearch, data }) {
3648
+ function useDataViewerPaginator({ view: initialView, sorts, queryLimit = 10, additionalEntryProcessing, formatItems, snapshot, filters: initialFilters, initialSort, initialSearch, onSearch, algoliaIndex, data, csvExport: csvExportConfig }) {
3646
3649
  const [tableData, setTableData] = (0, react_1.useState)(data ? Array.isArray(data) ? {} : Object.fromEntries(Object.entries(data).slice(0, queryLimit)) : undefined);
3647
3650
  const [page, setPage] = (0, react_1.useState)([1, 0]);
3648
3651
  const [view, setView] = (0, react_1.useState)(initialView);
@@ -4016,7 +4019,22 @@ function useDataViewerPaginator({ view: initialView, sorts, queryLimit = 10, add
4016
4019
  }
4017
4020
  reset();
4018
4021
  };
4019
- return ({ ...{ tableData, pageUp, pageDown, search: searchString, setFilters: updateFilters, page: page[0], sorts, loading, sort, updateSort: updateSort, setView: updateView, updateSearch } });
4022
+ const exportCSV = async (userId) => {
4023
+ if (!fData || !Array.isArray(fData))
4024
+ throw new Error("CSV export requires QueryObject[] data.");
4025
+ const res = await (0, firebase_1.executeCallable)("exportData", {
4026
+ userId,
4027
+ queries: fData,
4028
+ filters,
4029
+ sort,
4030
+ searchString,
4031
+ algoliaIndex,
4032
+ columns: csvExportConfig === null || csvExportConfig === void 0 ? void 0 : csvExportConfig.columns,
4033
+ filename: csvExportConfig === null || csvExportConfig === void 0 ? void 0 : csvExportConfig.filename,
4034
+ });
4035
+ return res.data;
4036
+ };
4037
+ return ({ ...{ tableData, pageUp, pageDown, search: searchString, setFilters: updateFilters, page: page[0], sorts, loading, sort, updateSort: updateSort, setView: updateView, updateSearch, exportCSV } });
4020
4038
  }
4021
4039
  ;
4022
4040
  //# sourceMappingURL=hooks.js.map