Skip to content

Commit 65cf7e8

Browse files
authored
Merge pull request #3974 from Northeastern-Electric-Racing/prospective-sponsors
Prospective sponsors
2 parents 2d657fa + 5f9f8cc commit 65cf7e8

48 files changed

Lines changed: 5931 additions & 626 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/backend/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import retrospectiveRouter from './src/routes/retrospective.routes.js';
2626
import partsRouter from './src/routes/parts.routes.js';
2727
import financeRouter from './src/routes/finance.routes.js';
2828
import calendarRouter from './src/routes/calendar.routes.js';
29+
import prospectiveSponsorRouter from './src/routes/prospective-sponsor.routes.js';
2930

3031
const app = express();
3132

@@ -110,6 +111,7 @@ app.use('/retrospective', retrospectiveRouter);
110111
app.use('/parts', partsRouter);
111112
app.use('/finance', financeRouter);
112113
app.use('/calendar', calendarRouter);
114+
app.use('/prospective-sponsors', prospectiveSponsorRouter);
113115
app.use('/', (_req, res) => {
114116
res.status(200).json('Welcome to FinishLine');
115117
});

src/backend/src/controllers/finance.controllers.ts

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,43 @@ export default class FinanceController {
77
const {
88
name,
99
activeStatus,
10+
valueTypes,
1011
sponsorValue,
1112
joinDate,
1213
activeYears,
1314
sponsorTierId,
1415
taxExempt,
15-
sponsorContact,
16+
contactName,
17+
contactEmail,
18+
contactPhone,
19+
contactPosition,
1620
sponsorTasks,
1721
discountCode,
18-
sponsorNotes
22+
sponsorNotes,
23+
stockDescription,
24+
discountDescription
1925
} = req.body;
2026

2127
const sponsor = await FinanceServices.createSponsor(
2228
req.currentUser,
2329
name,
2430
activeStatus,
25-
sponsorValue,
31+
valueTypes,
2632
joinDate,
2733
activeYears,
28-
sponsorTierId,
34+
sponsorTierId || undefined,
2935
taxExempt,
30-
sponsorContact,
36+
contactName,
3137
sponsorTasks,
3238
req.organization,
39+
sponsorValue,
3340
discountCode,
34-
sponsorNotes
41+
sponsorNotes,
42+
contactEmail,
43+
contactPhone,
44+
contactPosition,
45+
stockDescription,
46+
discountDescription
3547
);
3648
res.status(200).json(sponsor);
3749
} catch (error: unknown) {
@@ -73,7 +85,7 @@ export default class FinanceController {
7385
static async editSponsorTask(req: Request, res: Response, next: NextFunction) {
7486
try {
7587
const { sponsorTaskId } = req.params as Record<string, string>;
76-
const { dueDate, notes, notifyDate, assigneeUserId } = req.body;
88+
const { dueDate, notes, notifyDate, assigneeUserId, done } = req.body;
7789

7890
const updatedSponsorTask = await FinanceServices.editSponsorTask(
7991
req.currentUser,
@@ -82,7 +94,8 @@ export default class FinanceController {
8294
dueDate,
8395
notes,
8496
notifyDate,
85-
assigneeUserId
97+
assigneeUserId,
98+
done
8699
);
87100
res.status(200).json(updatedSponsorTask);
88101
} catch (error: unknown) {
@@ -323,15 +336,21 @@ export default class FinanceController {
323336
const {
324337
name,
325338
activeStatus,
339+
valueTypes,
326340
sponsorValue,
327341
joinDate,
328342
activeYears,
329343
sponsorTierId,
330-
sponsorContact,
344+
contactName,
345+
contactEmail,
346+
contactPhone,
347+
contactPosition,
331348
taxExempt,
332349
sponsorTasks,
333350
discountCode,
334-
sponsorNotes
351+
sponsorNotes,
352+
stockDescription,
353+
discountDescription
335354
} = req.body;
336355

337356
const updatedSponsor = await FinanceServices.editSponsor(
@@ -340,15 +359,21 @@ export default class FinanceController {
340359
sponsorId,
341360
name,
342361
activeStatus,
343-
sponsorValue,
362+
valueTypes,
344363
joinDate,
345364
activeYears,
346-
sponsorTierId,
347-
sponsorContact,
365+
sponsorTierId || undefined,
366+
contactName,
348367
taxExempt,
349368
sponsorTasks,
369+
sponsorValue,
350370
discountCode,
351-
sponsorNotes
371+
sponsorNotes,
372+
contactEmail,
373+
contactPhone,
374+
contactPosition,
375+
stockDescription,
376+
discountDescription
352377
);
353378

354379
res.status(200).json(updatedSponsor);
@@ -385,4 +410,14 @@ export default class FinanceController {
385410
next(error);
386411
}
387412
}
413+
414+
static async toggleSponsorTaskDone(req: Request, res: Response, next: NextFunction) {
415+
try {
416+
const { sponsorTaskId } = req.params as Record<string, string>;
417+
const updatedTask = await FinanceServices.toggleSponsorTaskDone(req.currentUser, req.organization, sponsorTaskId);
418+
res.status(200).json(updatedTask);
419+
} catch (error: unknown) {
420+
next(error);
421+
}
422+
}
388423
}
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
import { NextFunction, Request, Response } from 'express';
2+
import ProspectiveSponsorServices from '../services/prospective-sponsor.services.js';
3+
4+
export default class ProspectiveSponsorController {
5+
static async createProspectiveSponsor(req: Request, res: Response, next: NextFunction) {
6+
try {
7+
const {
8+
organizationName,
9+
status,
10+
lastContactDate,
11+
firstContactMethod,
12+
contactName,
13+
contactorUserId,
14+
highlightThresholdDays,
15+
contactEmail,
16+
contactPhone,
17+
contactPosition,
18+
notes,
19+
tasks
20+
} = req.body;
21+
22+
const prospectiveSponsor = await ProspectiveSponsorServices.createProspectiveSponsor(
23+
req.currentUser,
24+
req.organization,
25+
organizationName,
26+
status,
27+
lastContactDate,
28+
firstContactMethod,
29+
contactName,
30+
contactorUserId,
31+
highlightThresholdDays,
32+
contactEmail,
33+
contactPhone,
34+
contactPosition,
35+
notes,
36+
tasks
37+
);
38+
res.status(200).json(prospectiveSponsor);
39+
} catch (error: unknown) {
40+
next(error);
41+
}
42+
}
43+
44+
static async getAllProspectiveSponsors(req: Request, res: Response, next: NextFunction) {
45+
try {
46+
const prospectiveSponsors = await ProspectiveSponsorServices.getAllProspectiveSponsors(req.organization);
47+
res.status(200).json(prospectiveSponsors);
48+
} catch (error: unknown) {
49+
next(error);
50+
}
51+
}
52+
53+
static async editProspectiveSponsor(req: Request, res: Response, next: NextFunction) {
54+
try {
55+
const { prospectiveSponsorId } = req.params as Record<string, string>;
56+
const {
57+
organizationName,
58+
lastContactDate,
59+
status,
60+
firstContactMethod,
61+
contactName,
62+
contactorUserId,
63+
highlightThresholdDays,
64+
contactEmail,
65+
contactPhone,
66+
contactPosition,
67+
notes,
68+
tasks
69+
} = req.body;
70+
71+
const updatedProspectiveSponsor = await ProspectiveSponsorServices.editProspectiveSponsor(
72+
req.currentUser,
73+
req.organization,
74+
prospectiveSponsorId,
75+
organizationName,
76+
status,
77+
lastContactDate,
78+
firstContactMethod,
79+
contactName,
80+
contactorUserId,
81+
highlightThresholdDays,
82+
contactEmail,
83+
contactPhone,
84+
contactPosition,
85+
notes,
86+
tasks
87+
);
88+
res.status(200).json(updatedProspectiveSponsor);
89+
} catch (error: unknown) {
90+
next(error);
91+
}
92+
}
93+
94+
static async deleteProspectiveSponsor(req: Request, res: Response, next: NextFunction) {
95+
try {
96+
const { prospectiveSponsorId } = req.params as Record<string, string>;
97+
const deletedProspectiveSponsor = await ProspectiveSponsorServices.deleteProspectiveSponsor(
98+
prospectiveSponsorId,
99+
req.currentUser,
100+
req.organization
101+
);
102+
res.status(200).json(deletedProspectiveSponsor);
103+
} catch (error: unknown) {
104+
next(error);
105+
}
106+
}
107+
108+
static async getProspectiveSponsorTasks(req: Request, res: Response, next: NextFunction) {
109+
try {
110+
const { prospectiveSponsorId } = req.params as Record<string, string>;
111+
const tasks = await ProspectiveSponsorServices.getProspectiveSponsorTasks(
112+
prospectiveSponsorId,
113+
req.organization.organizationId
114+
);
115+
res.status(200).json(tasks);
116+
} catch (error: unknown) {
117+
next(error);
118+
}
119+
}
120+
121+
static async createProspectiveSponsorTask(req: Request, res: Response, next: NextFunction) {
122+
try {
123+
const { prospectiveSponsorId } = req.params as Record<string, string>;
124+
const { dueDate, notes, notifyDate, assigneeUserId } = req.body;
125+
126+
const task = await ProspectiveSponsorServices.createProspectiveSponsorTask(
127+
req.currentUser,
128+
req.organization,
129+
prospectiveSponsorId,
130+
dueDate,
131+
notes,
132+
notifyDate,
133+
assigneeUserId
134+
);
135+
res.status(200).json(task);
136+
} catch (error: unknown) {
137+
next(error);
138+
}
139+
}
140+
141+
static async acceptProspectiveSponsor(req: Request, res: Response, next: NextFunction) {
142+
try {
143+
const { prospectiveSponsorId } = req.params as Record<string, string>;
144+
const {
145+
sponsorTierId,
146+
valueTypes,
147+
sponsorValue,
148+
joinDate,
149+
activeYears,
150+
taxExempt,
151+
discountCode,
152+
sponsorNotes,
153+
stockDescription,
154+
discountDescription
155+
} = req.body;
156+
157+
const acceptedProspectiveSponsor = await ProspectiveSponsorServices.acceptProspectiveSponsor(
158+
req.currentUser,
159+
req.organization,
160+
prospectiveSponsorId,
161+
sponsorTierId || undefined,
162+
valueTypes,
163+
joinDate,
164+
activeYears,
165+
taxExempt,
166+
sponsorValue,
167+
discountCode,
168+
sponsorNotes,
169+
stockDescription,
170+
discountDescription
171+
);
172+
res.status(200).json(acceptedProspectiveSponsor);
173+
} catch (error: unknown) {
174+
next(error);
175+
}
176+
}
177+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Prisma } from '@prisma/client';
2+
import { getUserQueryArgs } from './user.query-args.js';
3+
import { getSponsorTaskQueryArgs } from './sponsor.query.args.js';
4+
5+
export type ProspectiveSponsorQueryArgs = ReturnType<typeof getProspectiveSponsorQueryArgs>;
6+
7+
export const getProspectiveSponsorQueryArgs = (organizationId: string) =>
8+
Prisma.validator<Prisma.Prospective_SponsorDefaultArgs>()({
9+
include: {
10+
contactor: getUserQueryArgs(organizationId),
11+
tasks: getSponsorTaskQueryArgs(organizationId),
12+
contact: true
13+
}
14+
});

src/backend/src/prisma-query-args/sponsor.query.args.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ export const getSponsorQueryArgs = (organizationId: string) =>
99
Prisma.validator<Prisma.SponsorDefaultArgs>()({
1010
include: {
1111
sponsorTasks: getSponsorTaskQueryArgs(organizationId),
12-
tier: true
12+
tier: true,
13+
contact: true
1314
}
1415
});
1516

0 commit comments

Comments
 (0)