placementt-core 1.400.839 → 1.400.841
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/exportTransformers.d.ts +3 -0
- package/lib/exportTransformers.js +21 -0
- package/lib/exportTransformers.js.map +1 -0
- package/lib/hooks.d.ts +9 -7
- package/lib/hooks.js +42 -5
- package/lib/hooks.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/typeDefinitions.d.ts +1 -0
- package/package.json +1 -1
- package/src/exportTransformers.ts +22 -0
- package/src/hooks.tsx +46 -6
- package/src/index.ts +1 -0
- package/src/typeDefinitions.ts +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exportTransformers = void 0;
|
|
4
|
+
exports.exportTransformers = {
|
|
5
|
+
resolveCohortName: async (fetcher, value) => {
|
|
6
|
+
var _a;
|
|
7
|
+
if (!value)
|
|
8
|
+
return value;
|
|
9
|
+
const cohort = await fetcher.getDocData(["cohorts", value]).catch(() => null);
|
|
10
|
+
return (_a = cohort === null || cohort === void 0 ? void 0 : cohort.name) !== null && _a !== void 0 ? _a : value;
|
|
11
|
+
},
|
|
12
|
+
resolveWorkflowStageName: async (fetcher, value, item) => {
|
|
13
|
+
var _a, _b, _c;
|
|
14
|
+
const cohortId = item.cohort;
|
|
15
|
+
if (!cohortId)
|
|
16
|
+
return value;
|
|
17
|
+
const cohort = await fetcher.getDocData(["cohorts", cohortId]).catch(() => null);
|
|
18
|
+
return (_c = (_b = (_a = cohort === null || cohort === void 0 ? void 0 : cohort.workflow) === null || _a === void 0 ? void 0 : _a.find(s => s.id === value)) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : value;
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=exportTransformers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exportTransformers.js","sourceRoot":"","sources":["../src/exportTransformers.ts"],"names":[],"mappings":";;;AAQa,QAAA,kBAAkB,GAAwC;IACnE,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;;QACxC,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QACzB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,UAAU,CAAa,CAAC,SAAS,EAAE,KAAe,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QACpG,OAAO,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,mCAAI,KAAK,CAAC;IACjC,CAAC;IAED,wBAAwB,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;;QACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAgB,CAAC;QACvC,IAAI,CAAC,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC5B,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,UAAU,CAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QAC7F,OAAO,MAAA,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,0CAAE,IAAI,mCAAI,KAAK,CAAC;IACtE,CAAC;CACJ,CAAC"}
|
package/lib/hooks.d.ts
CHANGED
|
@@ -76,7 +76,7 @@ export declare function useNewInstitutePlacementList({ id, user, oId, uid, filte
|
|
|
76
76
|
value: string;
|
|
77
77
|
direction: "asc" | "desc";
|
|
78
78
|
}] | undefined;
|
|
79
|
-
exportCSV: (userId: string, filename?: string) => Promise<CSVExportResponse
|
|
79
|
+
exportCSV: ((userId: string, filename?: string) => Promise<CSVExportResponse>) | undefined;
|
|
80
80
|
};
|
|
81
81
|
type AlumniPaginatorParams = {
|
|
82
82
|
user?: UserData;
|
|
@@ -105,7 +105,7 @@ export declare function useAlumniPaginator({ user, alumniConvoUser, filters, vie
|
|
|
105
105
|
direction: "asc" | "desc";
|
|
106
106
|
};
|
|
107
107
|
};
|
|
108
|
-
exportCSV: (userId: string, filename?: string) => Promise<CSVExportResponse
|
|
108
|
+
exportCSV: ((userId: string, filename?: string) => Promise<CSVExportResponse>) | undefined;
|
|
109
109
|
};
|
|
110
110
|
type ParentPaginatorParams = {
|
|
111
111
|
user?: UserData;
|
|
@@ -134,7 +134,7 @@ export declare function useParentPaginator({ user, filters, view, school, additi
|
|
|
134
134
|
direction: "asc" | "desc";
|
|
135
135
|
};
|
|
136
136
|
};
|
|
137
|
-
exportCSV: (userId: string, filename?: string) => Promise<CSVExportResponse
|
|
137
|
+
exportCSV: ((userId: string, filename?: string) => Promise<CSVExportResponse>) | undefined;
|
|
138
138
|
};
|
|
139
139
|
export declare const algoliaPlacementSearch: (data: QueryObject | null, user: UserData, query?: string, sort?: [string, {
|
|
140
140
|
value: string;
|
|
@@ -179,7 +179,7 @@ export declare const algoliaProviderContactSearch: (data: QueryObject | null, us
|
|
|
179
179
|
}], page?: number, filters?: FilterObject, limit?: number, cohort?: string, inProgress?: boolean) => Promise<{
|
|
180
180
|
[k: string]: StudentPlacementData;
|
|
181
181
|
}>;
|
|
182
|
-
export declare function useProviderContactPaginator({ data, institute, user, event, view, initialSort, initialSearch, eventId, filters, sources }: {
|
|
182
|
+
export declare function useProviderContactPaginator({ data, institute, user, event, view, initialSort, initialSearch, eventId, filters, sources, csvExport }: {
|
|
183
183
|
data: QueryObject[];
|
|
184
184
|
institute: InstituteData;
|
|
185
185
|
event?: Partial<ExternalEvent>;
|
|
@@ -190,6 +190,7 @@ export declare function useProviderContactPaginator({ data, institute, user, eve
|
|
|
190
190
|
initialSort?: string;
|
|
191
191
|
initialSearch?: string;
|
|
192
192
|
sources?: ("self" | "trust" | "hub")[];
|
|
193
|
+
csvExport?: DataViewerPaginater["csvExport"];
|
|
193
194
|
}): {
|
|
194
195
|
tableData: {
|
|
195
196
|
[key: string]: {
|
|
@@ -214,7 +215,7 @@ export declare function useProviderContactPaginator({ data, institute, user, eve
|
|
|
214
215
|
value: string;
|
|
215
216
|
direction: "asc" | "desc";
|
|
216
217
|
}] | undefined;
|
|
217
|
-
exportCSV: (userId: string, filename?: string) => Promise<CSVExportResponse
|
|
218
|
+
exportCSV: ((userId: string, filename?: string) => Promise<CSVExportResponse>) | undefined;
|
|
218
219
|
};
|
|
219
220
|
type UserPaginatorParams = {
|
|
220
221
|
user: UserData;
|
|
@@ -268,7 +269,7 @@ export declare function useNewCohortUserPaginator({ user, oId, trustSchoolsIDs,
|
|
|
268
269
|
direction: "asc" | "desc";
|
|
269
270
|
}] | undefined;
|
|
270
271
|
search: string | undefined;
|
|
271
|
-
exportCSV: (userId: string, filename?: string) => Promise<CSVExportResponse
|
|
272
|
+
exportCSV: ((userId: string, filename?: string) => Promise<CSVExportResponse>) | undefined;
|
|
272
273
|
};
|
|
273
274
|
export declare function useCohortUserPaginator({ user, cohort, data, search, userType, sort }: UserPaginatorParams): {
|
|
274
275
|
tableData: {
|
|
@@ -849,6 +850,7 @@ export type DataViewerPaginater = {
|
|
|
849
850
|
columns?: {
|
|
850
851
|
field: string;
|
|
851
852
|
header: string;
|
|
853
|
+
transform?: string;
|
|
852
854
|
}[];
|
|
853
855
|
filename?: string;
|
|
854
856
|
};
|
|
@@ -873,6 +875,6 @@ export declare function useDataViewerPaginator({ view: initialView, sorts, query
|
|
|
873
875
|
updateSort: (sortLabel?: string) => void;
|
|
874
876
|
setView: (v: "list" | "table") => void;
|
|
875
877
|
updateSearch: (search: string) => void;
|
|
876
|
-
exportCSV: (userId: string, filename?: string) => Promise<CSVExportResponse
|
|
878
|
+
exportCSV: ((userId: string, filename?: string) => Promise<CSVExportResponse>) | undefined;
|
|
877
879
|
};
|
|
878
880
|
export {};
|
package/lib/hooks.js
CHANGED
|
@@ -298,7 +298,27 @@ function useNewInstitutePlacementList({ id, user, oId, uid, filters, initialSort
|
|
|
298
298
|
}
|
|
299
299
|
return [k, { ...placement, id: k }];
|
|
300
300
|
};
|
|
301
|
-
const
|
|
301
|
+
const exportCols = {
|
|
302
|
+
columns: [
|
|
303
|
+
{ field: "name", header: "Employer Name" },
|
|
304
|
+
{ field: "contactForename", header: "Employer Contact" },
|
|
305
|
+
{ field: "startDate", header: "Start Date" },
|
|
306
|
+
{ field: "endDate", header: "End Date" },
|
|
307
|
+
...(!cohort ? [{ field: "cohort", header: "Cohort", transform: "resolveCohortName" }] : []),
|
|
308
|
+
{ field: "status", header: "Workflow Stage", transform: "resolveWorkflowStageName" },
|
|
309
|
+
{ field: "providerEmail", header: "Employer Email" },
|
|
310
|
+
{ field: "providerPhone", header: "Employer Phone" },
|
|
311
|
+
{ field: "address-line1", header: "Address One" },
|
|
312
|
+
{ field: "address-line2", header: "Address Two" },
|
|
313
|
+
{ field: "locality", header: "City" },
|
|
314
|
+
{ field: "postal_code", header: "Postcode" },
|
|
315
|
+
{ field: "country", header: "Country" },
|
|
316
|
+
{ field: "studentForename", header: "Student Forename" },
|
|
317
|
+
{ field: "studentSurname", header: "Student Surname" },
|
|
318
|
+
{ field: "studentEmail", header: "Student Email" },
|
|
319
|
+
]
|
|
320
|
+
};
|
|
321
|
+
const { tableData, pageUp, pageDown, setFilters, page, setView, loading, updateSearch, updateSort, sort, exportCSV } = 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", csvExport: exportCols });
|
|
302
322
|
(0, react_1.useEffect)(() => {
|
|
303
323
|
var _a;
|
|
304
324
|
console.log("SET QUERY", user, queryConstraints, cohort);
|
|
@@ -909,7 +929,8 @@ const algoliaProviderContactSearch = async (data, user, query, sort, page, filte
|
|
|
909
929
|
return Object.fromEntries(i);
|
|
910
930
|
};
|
|
911
931
|
exports.algoliaProviderContactSearch = algoliaProviderContactSearch;
|
|
912
|
-
function useProviderContactPaginator({ data, institute, user, event, view, initialSort, initialSearch, eventId, filters, sources = ["self"] }) {
|
|
932
|
+
function useProviderContactPaginator({ data, institute, user, event, view, initialSort, initialSearch, eventId, filters, sources = ["self"], csvExport }) {
|
|
933
|
+
var _a;
|
|
913
934
|
const [query, setQuery] = (0, react_1.useState)();
|
|
914
935
|
const firebaseQuery = new firebaseQuery_1.default();
|
|
915
936
|
const sorts = {
|
|
@@ -973,7 +994,23 @@ function useProviderContactPaginator({ data, institute, user, event, view, initi
|
|
|
973
994
|
return [k, v];
|
|
974
995
|
};
|
|
975
996
|
console.log("Query", JSON.stringify(query));
|
|
976
|
-
const
|
|
997
|
+
const defaultExportColumns = [
|
|
998
|
+
{ field: "contactForename", header: "First Name" },
|
|
999
|
+
{ field: "contactSurname", header: "Last Name" },
|
|
1000
|
+
{ field: "name", header: "Employer" },
|
|
1001
|
+
{ field: "providerEmail", header: "Email" },
|
|
1002
|
+
{ field: "providerPhone", header: "Phone" },
|
|
1003
|
+
{ field: "sector", header: "Sector" },
|
|
1004
|
+
{ field: "subsector", header: "Subsector" },
|
|
1005
|
+
{ field: "address-line1", header: "Address line 1" },
|
|
1006
|
+
{ field: "address-line2", header: "Address line 2" },
|
|
1007
|
+
{ field: "locality", header: "City" },
|
|
1008
|
+
{ field: "postal_code", header: "Postcode" },
|
|
1009
|
+
{ field: "country", header: "Country" },
|
|
1010
|
+
{ field: "created", header: "Created" },
|
|
1011
|
+
];
|
|
1012
|
+
const mergedCsvExport = { ...csvExport, columns: (_a = csvExport === null || csvExport === void 0 ? void 0 : csvExport.columns) !== null && _a !== void 0 ? _a : defaultExportColumns };
|
|
1013
|
+
const { tableData, pageUp, pageDown, setFilters, page, setView, loading, updateSearch, updateSort, sort, exportCSV } = 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", csvExport: mergedCsvExport });
|
|
977
1014
|
(0, react_1.useEffect)(() => {
|
|
978
1015
|
if (eventId && (event === null || event === void 0 ? void 0 : event.oId)) {
|
|
979
1016
|
console.log("Setting Query");
|
|
@@ -4019,7 +4056,7 @@ function useDataViewerPaginator({ view: initialView, sorts, queryLimit = 10, add
|
|
|
4019
4056
|
}
|
|
4020
4057
|
reset();
|
|
4021
4058
|
};
|
|
4022
|
-
const exportCSV = async (userId, filename) => {
|
|
4059
|
+
const exportCSV = (csvExportConfig === null || csvExportConfig === void 0 ? void 0 : csvExportConfig.columns) ? async (userId, filename) => {
|
|
4023
4060
|
console.log("Export Data");
|
|
4024
4061
|
if (!fData || !Array.isArray(fData))
|
|
4025
4062
|
throw new Error("CSV export requires QueryObject[] data.");
|
|
@@ -4034,7 +4071,7 @@ function useDataViewerPaginator({ view: initialView, sorts, queryLimit = 10, add
|
|
|
4034
4071
|
filename: filename || (csvExportConfig === null || csvExportConfig === void 0 ? void 0 : csvExportConfig.filename),
|
|
4035
4072
|
});
|
|
4036
4073
|
return res.data;
|
|
4037
|
-
};
|
|
4074
|
+
} : undefined;
|
|
4038
4075
|
return ({ ...{ tableData, pageUp, pageDown, search: searchString, setFilters: updateFilters, page: page[0], sorts, loading, sort, updateSort: updateSort, setView: updateView, updateSearch, exportCSV } });
|
|
4039
4076
|
}
|
|
4040
4077
|
;
|