Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
feb5de7
auto increment when adding an unassigned route delivery to a route, d…
sophearahsp Oct 10, 2023
47b6f78
on increment/decrement, swap route position
sophearahsp Oct 10, 2023
a75be6d
client should not inherit from user
sophearahsp Oct 11, 2023
45894c0
nullable availabilities and availabilities last updated
sophearahsp Oct 11, 2023
490d6e9
fix client seeder now that it doesnt inherit from the User class
sophearahsp Oct 11, 2023
021fb56
soft delete attribute for volunteer + client, filter by soft delete f…
sophearahsp Oct 11, 2023
fd2ce6f
multiselect input for preferred neighborhood in create volunteer moda…
sophearahsp Oct 16, 2023
c4a5d7c
edit preferred neighborhood on edit volunteer modal
sophearahsp Oct 16, 2023
6424db7
sts / map switch match value
sophearahsp Oct 16, 2023
0aab0de
withCredentials is true
sophearahsp Oct 16, 2023
0f5321f
editing client will update the associated route delivery item
sophearahsp Oct 24, 2023
4c283fb
view route data from db, scrappy implementations of dnd-kit + ok one
sophearahsp Feb 26, 2024
b5d9e11
basic style board, card, column
sophearahsp Feb 26, 2024
1f393d0
swap between view / edit mode
sophearahsp Feb 26, 2024
347f44f
setup backend functions for saving route, route page header
sophearahsp Feb 26, 2024
d21096e
rename column/card -> route/stop details
sophearahsp Feb 26, 2024
cc63610
save edited routes, setup board actions
sophearahsp Feb 26, 2024
7a61fdf
refresh data when saving routes
sophearahsp Feb 26, 2024
1bb8bd0
create new route in route editor
sophearahsp Mar 19, 2024
46ba24c
change routedelivery id to be string, save stops dragged to empty routes
sophearahsp Mar 21, 2024
88b9577
drag overlay for stop
sophearahsp Mar 21, 2024
152093e
remove old implementations of route editor that dont work well
sophearahsp Mar 21, 2024
b35bcb1
remove another unnecessary file
sophearahsp Mar 21, 2024
01fa7df
moved common components into respective subcategories
sophearahsp Mar 21, 2024
1c6b9d5
basic stop detail design to be more useful to the user
sophearahsp Mar 21, 2024
49ae0c8
basic modal setup for creating tasks
sophearahsp Mar 21, 2024
268c5b4
temp comment out tests oop
sophearahsp Mar 21, 2024
8632e8c
prettier
sophearahsp Mar 21, 2024
158a2fa
fix bug
sophearahsp Mar 21, 2024
be0575f
separate match control to independent component, create task modal ac…
sophearahsp Mar 22, 2024
c509e87
1) endpoint to get a list of available volunteers/list of routes for …
sophearahsp Mar 22, 2024
eb2e95e
local selection of task matching
sophearahsp Mar 22, 2024
47c7205
endpoint to save tasks, button makes req to save
sophearahsp Mar 22, 2024
124ed0f
volunteer endpoint tests, fe-admin api service class
sophearahsp Mar 31, 2024
9c740a6
volunteer controller as static class
sophearahsp Mar 31, 2024
44cd49b
remove example test files
sophearahsp Mar 31, 2024
30cd693
client endpoint tests, fe-admin api service class
sophearahsp Apr 1, 2024
3eccf5f
setup route delivery test file, fe-admin api service class
sophearahsp Apr 1, 2024
ef33846
setup task test file, fe-admin api service class
sophearahsp Apr 1, 2024
b42a8ae
disable meal delivery tests
sophearahsp Apr 1, 2024
0f308be
prettier format
sophearahsp Apr 1, 2024
2c1035a
auth api service class on fe-admin
sophearahsp Apr 1, 2024
d2e96d5
1) client type definitions, 2) setup meal/program type enums under ty…
sophearahsp May 11, 2024
cd10b3f
1) service method/test createClient(), 2) service method createStopsF…
sophearahsp May 11, 2024
c7c2a4d
1) service method/test updateClient(), 2) service method updateStopsF…
sophearahsp May 13, 2024
6c96524
client controller
sophearahsp May 13, 2024
f6952c9
remove controller tests (too detailed, focus on service level functio…
sophearahsp May 13, 2024
3c5b0c7
1) service method/test getRoutes(), 2) test util for creating routes,…
sophearahsp May 13, 2024
c6a453a
tab prettier config
sophearahsp May 13, 2024
be3747a
1) routedelivery id is number, 2) remove methods to individually set …
sophearahsp May 15, 2024
22262de
1) rename routeDelivery to stop, 2) delete routeDelivery tests, 3) se…
sophearahsp May 15, 2024
db6c07f
1) service/test admin login(), 2) admin utils for testing, 3) admin c…
sophearahsp May 15, 2024
75ba9e7
1) service/test loginVolunteer(), 2) setup volunteer utils createVolu…
sophearahsp May 15, 2024
1b69db3
service/test getActiveVolunteers() and getAllVolunteers()
sophearahsp May 15, 2024
fcf7a29
service/test getVolunteer()
sophearahsp May 15, 2024
ff3bf46
service/test createVolunteer() and updateVolunteer(), drop volunteer …
sophearahsp May 15, 2024
830b59e
1) remove auth route/controller, 2) setup volunteer controller
sophearahsp May 15, 2024
31c498c
1) service createMealsForTask(), 2) service getRouteStops(), 3) servi…
sophearahsp May 16, 2024
37acd59
remove task test files that arent used
sophearahsp May 16, 2024
4dad19f
remove unnecessary prop for test task util
sophearahsp May 18, 2024
c348502
1) service/test updateMeal(), 2) service updateMealInTask(), 3) meal …
sophearahsp May 18, 2024
edd3ff9
remove old meal delivery tests
sophearahsp May 18, 2024
e6b3ece
1) get rid of meal delivery controller/router, 2) setup task controll…
sophearahsp May 18, 2024
8554897
controllers use static methods
sophearahsp May 18, 2024
821b3e0
add await to the controller functions bc forgot
sophearahsp May 20, 2024
617de8d
rewrite seed scripts using services, hide env file
sophearahsp May 20, 2024
6650dbf
gitignore update to hide .env file
sophearahsp May 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules/
.DS_Store
*.lock
backend/build/
frontend/build/
frontend/build/
**/.env
7 changes: 0 additions & 7 deletions backend/.env

This file was deleted.

1 change: 1 addition & 0 deletions backend/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"tabWidth": 4,
"semi": true,
"trailingComma": "none",
"singleQuote": true,
Expand Down
10 changes: 10 additions & 0 deletions backend/example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
TOKEN_KEY=
JWT_PRIVATE_KEY=

# SEED OPTIONS
SEED_DEFAULT_ADMIN_EMAIL=admin@example.com
SEED_DEFAULT_ADMIN_PASSWORD=pw
SEED_DEFAULT_VOLUNTEER_EMAIL=volunteer@example.com
SEED_DEFAULT_VOLUNTEER_PASSWORD=pw
SEED_NUM_CLIENTS=10
SEED_NUM_VOLUNTEERS=10
12 changes: 6 additions & 6 deletions backend/src/ExampleEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
// Entity is a class that maps to a database table : https://orkhan.gitbook.io/typeorm/docs/entities
@Entity()
export class ExampleEntity {
@PrimaryGeneratedColumn()
id: number;
@PrimaryGeneratedColumn()
id: number;

@Column()
stringColumn: string;
@Column()
stringColumn: string;

@Column()
boolColumn: boolean;
@Column()
boolColumn: boolean;
}
7 changes: 6 additions & 1 deletion backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ const app = express();

// Using third party middleware
app.use(bodyParser.json()); // body-parser is which allows express to read the body and then parse that into a Json object that we can understand.
app.use(cors()); //
app.use(
cors({
credentials: true,
origin: ['http://localhost:5173']
})
);

// Routes go here
// Creating route : https://expressjs.com/en/guide/routing.html
Expand Down
60 changes: 26 additions & 34 deletions backend/src/controllers/admin.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,34 @@
import { Request, Response } from 'express';
import { AppDataSource } from '../data-source';
import { AdminEntity } from '../entities/AdminEntity';
import { StatusCode } from './statusCode';
import * as bcrypt from 'bcryptjs';
import * as jwt from 'jsonwebtoken';

require('dotenv').config();
const TOKEN_KEY = process.env.TOKEN_KEY;
import AdminService from '../services/admin';

export default class AdminController {
private AdminRepository = AppDataSource.getRepository(AdminEntity);

login = async (request: Request, response: Response) => {
console.log(request);
const { email, password } = request.body;
if (!(email && password)) {
console.log('missing params');
}
static login = async (request: Request, response: Response) => {
const { email, password } = request.body;

const adminUser = await this.AdminRepository.findOne({ where: { email } });
if (!(email && password)) {
response
.status(StatusCode.BAD_REQUEST)
.json({ message: 'No email or password' });
}

// User not found
if (!adminUser)
return response
.status(StatusCode.NOT_FOUND)
.json({ message: 'User not found' });
try {
await AdminService.getAdminByEmail(email)
} catch {
response
.status(StatusCode.NOT_FOUND)
.json({ message: 'User not found' });
}

if (await bcrypt.compare(password, adminUser.password)) {
const token = jwt.sign({ email: email }, TOKEN_KEY, {
expiresIn: '2h'
});
// Login successful
return response.status(StatusCode.OK).json({ token: token });
} else {
// Wrong password
return response
.status(StatusCode.UNAUTHORIZED)
.json({ message: 'Invalid Credentials' });
}
};
try {
const token = await AdminService.login(email, password)
response
.status(StatusCode.OK)
.json({ token: token});
} catch {
response
.status(StatusCode.UNAUTHORIZED)
.json({ message: 'Invalid credentials' });
}
};
}
26 changes: 0 additions & 26 deletions backend/src/controllers/authentication.ts

This file was deleted.

108 changes: 35 additions & 73 deletions backend/src/controllers/clients.ts
Original file line number Diff line number Diff line change
@@ -1,78 +1,40 @@
import { Request, Response } from 'express';
import { AppDataSource } from '../data-source';
import { ClientEntity } from '../entities/ClientEntity';
// import { TaskEntity } from '../entities/TaskEntity';
import { RouteDeliveryEntity } from '../entities/RouteDeliveryEntity';
import { StatusCode } from './statusCode';
import { ProgramType, MealType } from '../entities/types';
import ClientService from '../services/clients';
import { Client, CreateClientProps, UpdateClientProps } from '../types/clients';

export default class ClientController {
private ClientRepository = AppDataSource.getRepository(ClientEntity);
private RouteDeliveryRepository =
AppDataSource.getRepository(RouteDeliveryEntity);

getClients = async (request: Request, response: Response) => {
const clients = await this.ClientRepository.find();
response.status(StatusCode.OK).json({ clients: clients });
};

createClient = async (request: Request, response: Response) => {
const client = await this.ClientRepository.create({
name: request.body.name,
email: request.body.email,
phoneNumber: request.body.phoneNumber,
address: request.body.address,
mealType: request.body.mealType,
sts: request.body.sts,
map: request.body.map
});
const savedClient = await this.ClientRepository.save(client);

if (client.sts) {
const stsRouteDelivery = new RouteDeliveryEntity();
stsRouteDelivery.client = savedClient;
stsRouteDelivery.routeNumber = 0;
stsRouteDelivery.routePosition = 0;
stsRouteDelivery.mealType = savedClient.mealType;
stsRouteDelivery.program = ProgramType.STS;

await this.RouteDeliveryRepository.save(stsRouteDelivery);
}

if (client.map) {
const mapRouteDelivery = new RouteDeliveryEntity();
mapRouteDelivery.client = savedClient;
mapRouteDelivery.routeNumber = 0;
mapRouteDelivery.routePosition = 0;
mapRouteDelivery.mealType = savedClient.mealType;
mapRouteDelivery.program = ProgramType.MAP;

await this.RouteDeliveryRepository.save(mapRouteDelivery);
}

response.status(StatusCode.OK).json({ client });
};

getClient = async (request: Request, response: Response) => {
const client = await this.ClientRepository.findOne({
where: { id: parseInt(request.params.id) }
});
response.status(StatusCode.OK).json({ client: client });
};

editClient = async (request: Request, response: Response) => {
const client = await this.ClientRepository.update(
{ id: parseInt(request.params.id) },
{
name: request.body.name,
email: request.body.email,
phoneNumber: request.body.phoneNumber,
address: request.body.address,
mealType: request.body.mealType,
sts: request.body.sts,
map: request.body.map
}
);
response.status(StatusCode.OK).json({ client });
};
static getClients = async (request: Request, response: Response) => {
const clients = await ClientService.getAllClients();
response.status(StatusCode.OK).json({ clients: clients });
};

static createClient = async (request: Request, response: Response) => {
const props: CreateClientProps = request.body;
const client = await ClientService.createClient(props);
response.status(StatusCode.OK).json({ client: client });
};

static getClient = async (request: Request, response: Response) => {
const id = parseInt(request.params.id);
const client = await ClientService.getClient(id);

if (client == null) {
response.status(StatusCode.NOT_FOUND);
} else {
response.status(StatusCode.OK).json({ client: client });
}
};

static updateClient = async (request: Request, response: Response) => {
const id = parseInt(request.params.id);
const props: UpdateClientProps = request.body;
const client = await ClientService.updateClient(id, props);

if (client == null) {
response.status(StatusCode.NOT_FOUND);
} else {
response.status(StatusCode.OK).json({ client: client });
}
};
}
101 changes: 0 additions & 101 deletions backend/src/controllers/mealDelivery.ts

This file was deleted.

Loading