Skip to content

Commit fe6546b

Browse files
committed
Fix problem with adding students
1 parent e95e92a commit fe6546b

26 files changed

Lines changed: 11559 additions & 8073 deletions

frontend/src/components/EmployeeModal/EmployeeModal.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ type EmployeeEntity = {
3939
};
4040

4141
// both for formatting to current api data expectations
42-
function extractAdminData(employeeData: EmployeeEntity): Omit<EmployeeType, 'id'> {
42+
function extractAdminData(
43+
employeeData: EmployeeEntity
44+
): Omit<EmployeeType, 'id'> {
4345
return {
4446
firstName: employeeData.firstName,
4547
lastName: employeeData.lastName,
@@ -53,7 +55,9 @@ function extractAdminData(employeeData: EmployeeEntity): Omit<EmployeeType, 'id'
5355
};
5456
}
5557

56-
function extractDriverData(employeeData: EmployeeEntity): Partial<EmployeeType> {
58+
function extractDriverData(
59+
employeeData: EmployeeEntity
60+
): Partial<EmployeeType> {
5761
return {
5862
firstName: employeeData.firstName,
5963
lastName: employeeData.lastName,
@@ -95,8 +99,7 @@ const EmployeeModal = ({
9599
React.useEffect(() => {
96100
if (existingEmployee && isOpen) {
97101
// Initialize roles, normalizing Prisma enum values (SDS_ADMIN → sds-admin)
98-
const normalizeRole = (r: string) =>
99-
r.toLowerCase().replace(/_/g, '-');
102+
const normalizeRole = (r: string) => r.toLowerCase().replace(/_/g, '-');
100103
const roles: string[] = [];
101104
if (existingEmployee.admin?.adminRoles) {
102105
roles.push(...existingEmployee.admin.adminRoles.map(normalizeRole));
@@ -179,7 +182,9 @@ const EmployeeModal = ({
179182
switch (endpoint) {
180183
case '/api/drivers':
181184
// Use optimistic create from context
182-
await createDriver(extractDriverData(employeeData) as Omit<EmployeeType, 'id'>);
185+
await createDriver(
186+
extractDriverData(employeeData) as Omit<EmployeeType, 'id'>
187+
);
183188
res = employeeData; // The context will handle server response and ID assignment
184189
break;
185190
case '/api/admins':

frontend/src/components/UserDetail/UserInfoCard.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ const UserInfoCard: React.FC<UserInfoCardProps> = ({ user, userType }) => {
3030
const getEmployeeRole = (employee: Employee) => {
3131
const roles: string[] = [];
3232
if (employee.isDriver) roles.push('driver');
33-
if (employee.isAdmin) roles.push(...(employee.adminRoles.length > 0 ? employee.adminRoles.map((r) => r.toLowerCase().replace('_', '-')) : ['admin']));
33+
if (employee.isAdmin)
34+
roles.push(
35+
...(employee.adminRoles.length > 0
36+
? employee.adminRoles.map((r) => r.toLowerCase().replace('_', '-'))
37+
: ['admin'])
38+
);
3439
return roles.length > 0 ? roles.join(' • ') : 'N/A';
3540
};
3641

frontend/src/context/EmployeesContext.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@ type employeesState = {
88
loading: boolean;
99
refreshDrivers: () => Promise<void>;
1010
refreshAdmins: () => Promise<void>;
11-
updateDriverInfo: (driverId: string, updates: Partial<EmployeeType>) => Promise<void>;
11+
updateDriverInfo: (
12+
driverId: string,
13+
updates: Partial<EmployeeType>
14+
) => Promise<void>;
1215
createDriver: (driver: Omit<EmployeeType, 'id'>) => Promise<void>;
1316
deleteDriver: (driverId: string) => Promise<void>;
14-
updateAdminInfo: (adminId: string, updates: Partial<EmployeeType>) => Promise<void>;
17+
updateAdminInfo: (
18+
adminId: string,
19+
updates: Partial<EmployeeType>
20+
) => Promise<void>;
1521
createAdmin: (admin: Omit<EmployeeType, 'id'>) => Promise<void>;
1622
deleteAdmin: (adminId: string) => Promise<void>;
1723
getDriverById: (driverId: string) => EmployeeType | undefined;

frontend/src/pages/Admin/Employees.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,20 @@ import buttonStyles from '../../styles/button.module.css';
1313
const Employees = () => {
1414
const { admins, drivers } = useEmployees();
1515
const [isOpen, setIsOpen] = useState(false);
16-
const [filteredEmployees, setFilteredEmployees] = useState<EmployeeType[]>([]);
16+
const [filteredEmployees, setFilteredEmployees] = useState<EmployeeType[]>(
17+
[]
18+
);
1719
const [selectedEmployee] = useState<EmployeeType | null>(null);
1820

1921
const [page, setPage] = useState(1);
2022
const pageSize = 8;
2123

2224
// Deduplicate by id — a person who is both admin and driver appears in both lists
2325
const displayEmployees = useMemo(() => {
24-
const employeeMap = new Map<string, EmployeeType & { roleType: string[] }>();
26+
const employeeMap = new Map<
27+
string,
28+
EmployeeType & { roleType: string[] }
29+
>();
2530

2631
admins.forEach((admin) => {
2732
const roleType = admin.isDriver ? ['admin', 'driver'] : ['admin'];

server/generated/prisma/browser.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,53 @@
1-
21
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
32
/* eslint-disable */
43
// biome-ignore-all lint: generated file
5-
// @ts-nocheck
4+
// @ts-nocheck
65
/*
7-
* This file should be your main import to use Prisma-related types and utilities in a browser.
6+
* This file should be your main import to use Prisma-related types and utilities in a browser.
87
* Use it to get access to models, enums, and input types.
9-
*
8+
*
109
* This file does not contain a `PrismaClient` class, nor several other helpers that are intended as server-side only.
1110
* See `client.ts` for the standard, server-side entry point.
1211
*
1312
* 🟢 You can import this file directly.
1413
*/
1514

16-
import * as Prisma from './internal/prismaNamespaceBrowser.js'
17-
export { Prisma }
18-
export * as $Enums from './enums.js'
15+
import * as Prisma from './internal/prismaNamespaceBrowser.js';
16+
export { Prisma };
17+
export * as $Enums from './enums.js';
1918
export * from './enums.js';
2019
/**
2120
* Model Location
2221
* A named pickup or drop-off point used in rides
2322
*/
24-
export type Location = Prisma.LocationModel
23+
export type Location = Prisma.LocationModel;
2524
/**
2625
* Model Employee
2726
* A platform employee who may be an admin, a driver, or both
2827
*/
29-
export type Employee = Prisma.EmployeeModel
28+
export type Employee = Prisma.EmployeeModel;
3029
/**
3130
* Model Rider
3231
* A rider who requests and takes rides
3332
*/
34-
export type Rider = Prisma.RiderModel
33+
export type Rider = Prisma.RiderModel;
3534
/**
3635
* Model Ride
3736
* A scheduled trip from a start location to an end location
3837
*/
39-
export type Ride = Prisma.RideModel
38+
export type Ride = Prisma.RideModel;
4039
/**
4140
* Model Favorite
4241
* Tracks which riders have favorited which rides
4342
*/
44-
export type Favorite = Prisma.FavoriteModel
43+
export type Favorite = Prisma.FavoriteModel;
4544
/**
4645
* Model Stats
4746
* Aggregated daily ride statistics -- year and day of year
4847
*/
49-
export type Stats = Prisma.StatsModel
48+
export type Stats = Prisma.StatsModel;
5049
/**
5150
* Model Notification
5251
* A push notification sent to a user about a ride status change
5352
*/
54-
export type Notification = Prisma.NotificationModel
53+
export type Notification = Prisma.NotificationModel;

server/generated/prisma/client.ts

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
1-
21
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
32
/* eslint-disable */
43
// biome-ignore-all lint: generated file
5-
// @ts-nocheck
4+
// @ts-nocheck
65
/*
76
* This file should be your main import to use Prisma. Through it you get access to all the models, enums, and input types.
87
* If you're looking for something you can import in the client-side of your application, please refer to the `browser.ts` file instead.
98
*
109
* 🟢 You can import this file directly.
1110
*/
1211

13-
import * as process from 'node:process'
14-
import * as path from 'node:path'
15-
import { fileURLToPath } from 'node:url'
16-
globalThis['__dirname'] = path.dirname(fileURLToPath(import.meta.url))
12+
import * as process from 'node:process';
13+
import * as path from 'node:path';
14+
import { fileURLToPath } from 'node:url';
15+
globalThis['__dirname'] = path.dirname(fileURLToPath(import.meta.url));
1716

18-
import * as runtime from "@prisma/client/runtime/client"
19-
import * as $Enums from "./enums.js"
20-
import * as $Class from "./internal/class.js"
21-
import * as Prisma from "./internal/prismaNamespace.js"
17+
import * as runtime from '@prisma/client/runtime/client';
18+
import * as $Enums from './enums.js';
19+
import * as $Class from './internal/class.js';
20+
import * as Prisma from './internal/prismaNamespace.js';
2221

23-
export * as $Enums from './enums.js'
24-
export * from "./enums.js"
22+
export * as $Enums from './enums.js';
23+
export * from './enums.js';
2524
/**
2625
* ## Prisma Client
27-
*
26+
*
2827
* Type-safe database client for TypeScript
2928
* @example
3029
* ```
@@ -34,45 +33,49 @@ export * from "./enums.js"
3433
* // Fetch zero or more Locations
3534
* const locations = await prisma.location.findMany()
3635
* ```
37-
*
36+
*
3837
* Read more in our [docs](https://pris.ly/d/client).
3938
*/
40-
export const PrismaClient = $Class.getPrismaClientClass()
41-
export type PrismaClient<LogOpts extends Prisma.LogLevel = never, OmitOpts extends Prisma.PrismaClientOptions["omit"] = Prisma.PrismaClientOptions["omit"], ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = $Class.PrismaClient<LogOpts, OmitOpts, ExtArgs>
42-
export { Prisma }
39+
export const PrismaClient = $Class.getPrismaClientClass();
40+
export type PrismaClient<
41+
LogOpts extends Prisma.LogLevel = never,
42+
OmitOpts extends Prisma.PrismaClientOptions['omit'] = Prisma.PrismaClientOptions['omit'],
43+
ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
44+
> = $Class.PrismaClient<LogOpts, OmitOpts, ExtArgs>;
45+
export { Prisma };
4346

4447
/**
4548
* Model Location
4649
* A named pickup or drop-off point used in rides
4750
*/
48-
export type Location = Prisma.LocationModel
51+
export type Location = Prisma.LocationModel;
4952
/**
5053
* Model Employee
5154
* A platform employee who may be an admin, a driver, or both
5255
*/
53-
export type Employee = Prisma.EmployeeModel
56+
export type Employee = Prisma.EmployeeModel;
5457
/**
5558
* Model Rider
5659
* A rider who requests and takes rides
5760
*/
58-
export type Rider = Prisma.RiderModel
61+
export type Rider = Prisma.RiderModel;
5962
/**
6063
* Model Ride
6164
* A scheduled trip from a start location to an end location
6265
*/
63-
export type Ride = Prisma.RideModel
66+
export type Ride = Prisma.RideModel;
6467
/**
6568
* Model Favorite
6669
* Tracks which riders have favorited which rides
6770
*/
68-
export type Favorite = Prisma.FavoriteModel
71+
export type Favorite = Prisma.FavoriteModel;
6972
/**
7073
* Model Stats
7174
* Aggregated daily ride statistics -- year and day of year
7275
*/
73-
export type Stats = Prisma.StatsModel
76+
export type Stats = Prisma.StatsModel;
7477
/**
7578
* Model Notification
7679
* A push notification sent to a user about a ride status change
7780
*/
78-
export type Notification = Prisma.NotificationModel
81+
export type Notification = Prisma.NotificationModel;

0 commit comments

Comments
 (0)