placementt-core 1.400.1113 → 1.400.1115

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
@@ -245,7 +245,7 @@ type NewUserPaginatorParams = {
245
245
  view: "list" | "table";
246
246
  filters?: FilterObject;
247
247
  institute: InstituteData;
248
- userType: "Staff" | "Students";
248
+ userType: "Staff" | "Students" | "Leavers";
249
249
  initialSort?: string;
250
250
  trustSchoolsIDs?: string[];
251
251
  };
package/lib/hooks.js CHANGED
@@ -2235,7 +2235,10 @@ function useUserUploadHandler({ product, oId, event, eventId, userType, user, on
2235
2235
  const [emptyCellsWarning, setEmptyCellsWarning] = (0, react_1.useState)(false);
2236
2236
  const [alert, setAlert] = (0, react_1.useState)();
2237
2237
  const { execute } = (0, firebase_1.useExecuteCallableJob)({ user: user });
2238
- const requiredFields = ["forename", "surname", "email"];
2238
+ // Students also need a year group: Destinations, Development and the careers
2239
+ // calendar are all set up per year group, and a CSV is the only way a school
2240
+ // without Wonde gets one onto its students.
2241
+ const requiredFields = ["forename", "surname", "email", ...(userType === "Students" ? [constants_1.STUDENT_YEAR_FIELD] : [])];
2239
2242
  const checkData = (userData) => {
2240
2243
  setAlert(undefined);
2241
2244
  userData = userData.filter((u) => Object.entries(u).some(([, v]) => v));
@@ -2268,15 +2271,14 @@ function useUserUploadHandler({ product, oId, event, eventId, userType, user, on
2268
2271
  setAlert({ msg: "Data cannot be uploaded in unnamed columns.", severity: "error" });
2269
2272
  return false;
2270
2273
  }
2271
- for (const field in user) {
2272
- if (!user[field]) {
2273
- if (requiredFields.includes(field)) {
2274
- setAlert({ msg: "All users must contain " + requiredFields.join(", "), severity: "error" });
2275
- emptyRequiredCell = true;
2276
- }
2277
- emptyOptionalCell = true;
2278
- }
2274
+ // Checked against the list rather than the row's keys, so a required
2275
+ // column missing from the upload altogether fails too.
2276
+ if (requiredFields.some((field) => !user[field])) {
2277
+ setAlert({ msg: "All users must contain " + requiredFields.map((f) => f === constants_1.STUDENT_YEAR_FIELD ? "year group" : f).join(", "), severity: "error" });
2278
+ emptyRequiredCell = true;
2279
2279
  }
2280
+ if (Object.values(user).some((v) => !v))
2281
+ emptyOptionalCell = true;
2280
2282
  // Add more test cases
2281
2283
  }
2282
2284
  if (emptyRequiredCell) {